/* ============================================================================
   Two-group (bipartite) matches scope

   Three pieces: the single/double toggle, the author/title transfer list,
   and the genre two-box selector. Group 1 is amber, group 2 is deep
   olive — consistent across all three.
   ============================================================================ */

:root {
    --group1-color: var(--color-primary, #b8742a);
    /* Deep olive — WCAG AA in the default Manuscript theme both as a fill
       under inverse (white) text (5.95:1) and as text on the light page
       surfaces (>=5.48:1). The old sand #9A8466 failed AA in both roles
       (~3.6:1 fill, ~3.4:1 text). Distinct in hue from group-1's saddle brown. */
    --group2-color: #556B2F;
}

/* Night Scholar flips inverse text to charcoal and the surfaces to near-black,
   so group-2 must be a LIGHT olive there to stay AA as both fill (5.8:1 under
   the theme's dark inverse text) and text (6.1:1 on the #111 surface) — mirroring
   the way group-1 already tracks --color-primary per theme. */
[data-theme="night-scholar"] {
    --group2-color: #8B9A50;
}

/* ---- single / double toggle ---- */

.group-mode-toggle {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 24px;
    background: var(--color-sand-light, #f5f0e8);
    border-bottom: 1px solid var(--color-border-subtle, #e0e0e0);
}

.group-mode-toggle__label {
    font-family: var(--font-primary);
    font-size: 0.9rem;
    color: var(--color-text-secondary);
}

.group-mode-toggle__seg {
    display: inline-flex;
    border: 1px solid var(--color-primary);
    border-radius: var(--radius-md);
    overflow: hidden;
}

.gmt-btn {
    padding: 6px 16px;
    border: none;
    background: var(--color-white);
    color: var(--color-text-primary);
    font-family: var(--font-primary);
    font-size: 0.9rem;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease;
}

.gmt-btn + .gmt-btn {
    border-inline-start: 1px solid var(--color-primary);
}

.gmt-btn.active {
    background: var(--color-primary);
    color: var(--color-white);
    font-weight: 600;
}

.group-mode-toggle__hint {
    font-size: 0.8rem;
    color: var(--color-text-muted);
}

/* Greyed نطاق المطابقات in double mode. */
.scope-mode-filter.scope-greyed {
    opacity: 0.5;
    pointer-events: none;
}

/* Greyed two-group toggle when the current viz mode (network ego / sankey
   single-center document) has no bipartite meaning. The buttons carry the
   `disabled` attribute, so only the dimmed look is needed here. */
.group-mode-toggle.scope-greyed {
    opacity: 0.55;
}

.gmt-btn:disabled {
    cursor: not-allowed;
}

.scope-greyed-note {
    font-size: 0.85rem;
    color: var(--color-text-secondary);
    margin: 0 0 8px;
}

/* ============================================================================
   Author / title transfer list
   ============================================================================ */

.two-group-transfer {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    direction: rtl;
    min-height: 340px;
}

.tg-left {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.tg-window {
    display: flex;
    flex-direction: column;
    flex: 1 1 0;
    min-height: 0;
    border: 2px solid var(--color-border-primary, #d4c4a8);
    border-radius: var(--radius-md);
    overflow: hidden;
}

.tg-window--g1 { border-color: var(--group1-color); }
.tg-window--g2 { border-color: var(--group2-color); }

.tg-window__head {
    padding: 6px 10px;
    font-family: var(--font-primary);
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--color-white);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.tg-window--g1 .tg-window__head { background: var(--group1-color); }
.tg-window--g2 .tg-window__head { background: var(--group2-color); }

.tg-window__count { font-weight: 400; opacity: 0.9; }

.tg-window__list {
    list-style: none;
    margin: 0;
    padding: 4px;
    overflow-y: auto;
    flex: 1 1 0;
}

.tg-item {
    display: flex;
    align-items: baseline;
    gap: 6px;
    padding: 5px 8px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 0.85rem;
}

.tg-item:hover { background: var(--color-sand-light, #f5f0e8); }

.tg-item.focused {
    background: var(--color-primary-light, #f0e0c8);
    outline: 1px solid var(--color-primary);
}

.tg-item__label { color: var(--color-text-primary); }
.tg-item__sub { color: var(--color-text-muted); font-size: 0.75rem; }

/* Move controls between the two windows. */
.tg-controls {
    display: flex;
    justify-content: center;
    gap: 8px;
    padding: 2px 0;
}

.tg-ctl {
    width: 34px;
    height: 28px;
    border: 1px solid var(--color-border-primary);
    border-radius: var(--radius-sm);
    background: var(--color-white);
    color: var(--color-text-primary);
    cursor: pointer;
    font-size: 0.9rem;
    line-height: 1;
    transition: background 0.15s ease, border-color 0.15s ease;
}

.tg-ctl:hover:not(:disabled) {
    background: var(--color-sand-light);
    border-color: var(--color-primary);
}

.tg-ctl--del:hover:not(:disabled) {
    color: var(--color-error, #b91c1c);
    border-color: var(--color-error, #b91c1c);
}

.tg-ctl:disabled { opacity: 0.4; cursor: not-allowed; }

/* Available pool on the right. */
.tg-right {
    display: flex;
    flex-direction: column;
    gap: 6px;
    border: 1px solid var(--color-border-primary);
    border-radius: var(--radius-md);
    padding: 8px;
    min-height: 0;
}

.tg-search {
    padding: 6px 10px;
    border: 1px solid var(--color-border-primary);
    border-radius: var(--radius-sm);
    font-family: var(--font-primary);
    font-size: 0.85rem;
    direction: rtl;
}

.tg-pool {
    list-style: none;
    margin: 0;
    padding: 0;
    overflow-y: auto;
    flex: 1 1 0;
}

.tg-pool__item {
    display: flex;
    align-items: baseline;
    gap: 8px;
    padding: 4px 6px;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
}

.tg-pool__item:hover { background: var(--color-sand-light); }

.tg-pool__add {
    width: 22px;
    height: 22px;
    flex: 0 0 auto;
    border: 1px solid var(--group1-color);
    border-radius: var(--radius-full);
    background: transparent;
    color: var(--group1-color);
    cursor: pointer;
    font-size: 0.9rem;
    line-height: 1;
}

.tg-pool__add:hover { background: var(--group1-color); color: var(--color-white); }
.tg-pool__label { color: var(--color-text-primary); }
.tg-pool__sub { color: var(--color-text-muted); font-size: 0.75rem; }

/* ============================================================================
   Genre two-box
   ============================================================================ */

.g2b-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 6px;
}

.g2b-row--child { padding-inline-start: 22px; }

.g2b-name { flex: 1 1 auto; font-family: var(--font-primary); font-size: 0.9rem; }
.g2b-count { color: var(--color-text-muted); font-size: 0.75rem; }

.g2b-boxes { display: inline-flex; gap: 6px; }

.g2b-box {
    width: 24px;
    height: 24px;
    border-radius: var(--radius-sm);
    background: var(--color-white);
    cursor: pointer;
    font-size: 0.8rem;
    line-height: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    transition: background 0.12s ease;
}

/* Distinct colored borders per the spec. */
.g2b-box--g1 { border: 2px solid var(--group1-color); color: var(--group1-color); }
.g2b-box--g2 { border: 2px solid var(--group2-color); color: var(--group2-color); }

.g2b-box--g1.on { background: var(--group1-color); color: var(--color-white); }
.g2b-box--g2.on { background: var(--group2-color); color: var(--color-white); }
