/* =============================================================
   FelixChess — Tree Navigator
   Requires: movetree-search.css (defines --fc-* custom properties)
   ============================================================= */

/* ── Trigger button (inside .fc-mtsearch__treeToolbar) ──────── */

.fc-mtsearch__treeToolbar {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 12px;
    position: absolute;
    top: 14px;
    right: 14px;
    z-index: 4;
    margin-bottom: 0;
}

/* Inherit treeTitle styles that existed on the element directly */
.fc-mtsearch__treeToolbar .fc-mtsearch__treeTitle {
    margin-bottom: 0; /* reset any prior margin; toolbar handles spacing */
}

.fc-mtsearch__navigatorBtn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px 6px 10px;
    border-radius: 999px;
    border: 1px solid rgba(0, 0, 0, 0.22);
    background: rgba(0, 0, 0, 0.06);
    color: #111111;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.3px;
    cursor: pointer;
    transition: background 140ms ease, transform 140ms ease, border-color 140ms ease;
    white-space: nowrap;
    line-height: 1;
}

.fc-mtsearch__navigatorBtn svg {
    width: 14px;
    height: 14px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
    flex-shrink: 0;
}

.fc-mtsearch__navigatorBtn:hover {
    background: rgba(0, 0, 0, 0.11);
    border-color: rgba(0, 0, 0, 0.40);
    transform: translateY(-1px);
}

.fc-mtsearch__navigatorBtn[hidden] {
    display: none;
}

@media (max-width: 900px) {
    .fc-mtsearch__treeToolbar {
        position: static;
        margin-bottom: 6px;
    }
}


/* ── Overlay backdrop (full-screen, fixed) ───────────────────── */

.fc-mtsearch__navOverlay {
    position: fixed;
    inset: 0;
    z-index: 1100;
    background: rgba(0, 0, 0, 0.60);
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: 28px 16px 28px;
    /* CSS vars inherited from .fc-mtsearch parent */
}

.fc-mtsearch__navOverlay[hidden] {
    display: none;
}


/* ── Modal shell ─────────────────────────────────────────────── */

.fc-mtsearch__navModal {
    background: var(--fc-bg, #2f2f2f);
    border: 1px solid var(--fc-border-strong, rgba(255,255,255,0.20));
    border-radius: 16px;
    width: 100%;
    max-width: 740px;
    max-height: calc(100dvh - 56px);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    color: var(--fc-text, #f3f3f3);
    font-size: 13px;
}


/* ── Modal header ────────────────────────────────────────────── */

.fc-nav__hd {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 11px 14px;
    border-bottom: 1px solid var(--fc-border, rgba(255,255,255,0.12));
    background: rgba(0,0,0,0.12);
    flex-shrink: 0;
}

.fc-nav__title {
    font-size: 14px;
    font-weight: 800;
    letter-spacing: 0.3px;
    flex: 1;
    min-width: 0;
}

.fc-nav__mode-badge {
    font-size: 11px;
    font-weight: 700;
    padding: 3px 9px;
    border-radius: 999px;
    border: 1px solid var(--fc-border-strong, rgba(255,255,255,0.20));
    color: var(--fc-muted, #b7b7b7);
    white-space: nowrap;
    background: rgba(255,255,255,0.05);
}

/* View toggle (tree / column icons) */
.fc-nav__vtoggle {
    display: flex;
    gap: 2px;
    background: rgba(0,0,0,0.18);
    border-radius: 8px;
    padding: 2px;
    border: 1px solid var(--fc-border, rgba(255,255,255,0.12));
}

.fc-nav__vbtn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 26px;
    border-radius: 6px;
    border: none;
    background: transparent;
    color: var(--fc-muted, #b7b7b7);
    cursor: pointer;
    transition: background 120ms ease, color 120ms ease;
}

.fc-nav__vbtn svg {
    width: 14px;
    height: 14px;
}

.fc-nav__vbtn:hover {
    background: rgba(255,255,255,0.08);
    color: var(--fc-text, #f3f3f3);
}

.fc-nav__vbtn.is-active {
    background: rgba(185, 255, 59, 0.14);
    color: var(--fc-accent, #b9ff3b);
}

/* Close button */
.fc-nav__close {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    border-radius: 8px;
    border: 1px solid var(--fc-border, rgba(255,255,255,0.12));
    background: rgba(255,255,255,0.05);
    color: var(--fc-muted, #b7b7b7);
    cursor: pointer;
    transition: background 120ms ease, color 120ms ease;
    flex-shrink: 0;
}

.fc-nav__close svg {
    width: 14px;
    height: 14px;
}

.fc-nav__close:hover {
    background: rgba(255,255,255,0.10);
    color: var(--fc-text, #f3f3f3);
}


/* ── Modal body (scrollable area) ────────────────────────────── */

.fc-nav__body {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    min-height: 0;
}


/* ── Loading / message states ────────────────────────────────── */

.fc-nav__loading,
.fc-nav__msg {
    padding: 32px 20px;
    text-align: center;
    color: var(--fc-muted, #b7b7b7);
    font-size: 13px;
}


/* ── Modal footer (breadcrumb) ───────────────────────────────── */

.fc-nav__ft {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    border-top: 1px solid var(--fc-border, rgba(255,255,255,0.12));
    background: rgba(0,0,0,0.12);
    flex-shrink: 0;
    min-height: 38px;
}

.fc-nav__bc {
    display: flex;
    align-items: center;
    gap: 2px;
    flex: 1;
    min-width: 0;
    flex-wrap: wrap;
}

.fc-nav__bc-btn {
    font-family: var(--fc-mono, monospace);
    font-size: 11px;
    padding: 3px 7px;
    border-radius: 5px;
    border: none;
    background: transparent;
    color: var(--fc-muted, #b7b7b7);
    cursor: pointer;
    white-space: nowrap;
    max-width: 140px;
    overflow: hidden;
    text-overflow: ellipsis;
    transition: background 120ms ease, color 120ms ease;
}

.fc-nav__bc-btn:hover {
    background: rgba(255,255,255,0.08);
    color: var(--fc-text, #f3f3f3);
}

.fc-nav__bc-btn.is-cur {
    color: var(--fc-text, #f3f3f3);
    font-weight: 700;
    background: rgba(255,255,255,0.07);
}

.fc-nav__bc-sep {
    font-size: 10px;
    color: rgba(255,255,255,0.25);
    flex-shrink: 0;
    padding: 0 1px;
}

.fc-nav__ft-hint {
    font-size: 11px;
    color: rgba(255,255,255,0.25);
    white-space: nowrap;
    flex-shrink: 0;
}


/* ── TREE VIEW ───────────────────────────────────────────────── */

.fc-nav__tree-view {
    display: flex;
    flex-direction: column;
}

/* Context chain */
.fc-nav__ctx-pane {
    padding: 14px 14px 12px;
    border-bottom: 1px solid var(--fc-border, rgba(255,255,255,0.12));
}

.fc-nav__ctx-label {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    color: rgba(255,255,255,0.30);
    margin-bottom: 10px;
}

.fc-nav__ctx-chain {
    display: flex;
    flex-direction: column;
    gap: 0;
}

.fc-nav__ctx-row {
    display: flex;
    flex-direction: column;
}

.fc-nav__ctx-row-inner {
    display: flex;
    align-items: center;
    gap: 10px;
}

.fc-nav__ctx-tick {
    width: 1px;
    height: 10px;
    background: rgba(255,255,255,0.18);
    margin-left: 16px;
    margin-bottom: 1px;
}

.fc-nav__ctx-chip {
    font-family: var(--fc-mono, monospace);
    font-size: 13px;
    font-weight: 700;
    padding: 5px 13px;
    border-radius: 8px;
    background: rgba(255,255,255,0.07);
    border: 1px solid rgba(255,255,255,0.12);
    color: var(--fc-text, #f3f3f3);
    white-space: nowrap;
}

/* Highlight the last (current) move in the chain */
.fc-nav__ctx-chip.is-last {
    background: rgba(11, 107, 43, 0.45);
    border-color: rgba(11, 107, 43, 0.80);
    color: #c8f5c8;
}

.fc-nav__ctx-games {
    font-size: 11px;
    color: var(--fc-muted, #b7b7b7);
    white-space: nowrap;
}

/* Selection info row: name + PGN on one line */
.fc-nav__sel-row {
    display: flex;
    align-items: baseline;
    gap: 8px;
    flex-wrap: wrap;
    margin-top: 6px;
    margin-left: 2px;
}

.fc-nav__sel-name {
    font-size: 12px;
    color: var(--fc-muted, #b7b7b7);
    line-height: 1.3;
    white-space: nowrap;
}

.fc-nav__sel-pgn {
    font-family: var(--fc-mono, monospace);
    font-size: 12px;
    color: rgba(255,255,255,0.40);
    line-height: 1.3;
}

/* Per-ply breadcrumb token */
.fc-nav__bc-move {
    font-family: var(--fc-mono, monospace);
    font-size: 11px;
    padding: 2px 5px;
    border-radius: 4px;
    border: none;
    background: transparent;
    color: rgba(255,255,255,0.32);
    white-space: nowrap;
    cursor: default;
    line-height: 1;
}

/* Clickable breadcrumb token (link) */
button.fc-nav__bc-move {
    cursor: pointer;
    color: rgba(255,255,255,0.55);
    transition: background 110ms ease, color 110ms ease;
}

button.fc-nav__bc-move:hover {
    background: rgba(185, 255, 59, 0.12);
    color: var(--fc-accent, #b9ff3b);
}

/* Current (last) token — highlighted */
.fc-nav__bc-move.is-cur {
    color: var(--fc-text, #f3f3f3);
    font-weight: 700;
}

/* Branch scroll area */
.fc-nav__branch-pane {
    padding: 12px 14px 4px;
}

.fc-nav__branch-label {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 10px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: rgba(255,255,255,0.30);
}

.fc-nav__scroll-hint {
    font-weight: 400;
    text-transform: none;
    letter-spacing: 0;
    opacity: 0.6;
}

.fc-nav__branch-scroll {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding-bottom: 12px;
    scroll-snap-type: x mandatory;
    /* custom scrollbar */
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,0.15) transparent;
}

.fc-nav__branch-scroll::-webkit-scrollbar {
    height: 3px;
}

.fc-nav__branch-scroll::-webkit-scrollbar-track {
    background: transparent;
}

.fc-nav__branch-scroll::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.15);
    border-radius: 2px;
}

/* Branch card */
.fc-nav__bcard {
    flex-shrink: 0;
    min-width: 136px;
    max-width: 136px;
    padding: 9px 11px;
    border-radius: 10px;
    border: 1px solid rgba(255,255,255,0.10);
    background: rgba(255,255,255,0.04);
    cursor: pointer;
    scroll-snap-align: start;
    transition: border-color 130ms ease, background 130ms ease;
}

.fc-nav__bcard:hover {
    border-color: rgba(185, 255, 59, 0.45);
    background: rgba(185, 255, 59, 0.07);
}

.fc-nav__bc-top {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    margin-bottom: 6px;
}

.fc-nav__bc-san {
    font-family: var(--fc-mono, monospace);
    font-size: 15px;
    font-weight: 800;
    color: var(--fc-text, #f3f3f3);
    line-height: 1;
}

.fc-nav__bcard:hover .fc-nav__bc-san {
    color: var(--fc-accent, #b9ff3b);
}

.fc-nav__bc-pct {
    font-size: 11px;
    color: var(--fc-muted, #b7b7b7);
    white-space: nowrap;
}

.fc-nav__bcard:hover .fc-nav__bc-pct {
    color: rgba(185, 255, 59, 0.75);
}

/* Frequency bar */
.fc-nav__freq-bar {
    height: 2px;
    background: rgba(255,255,255,0.10);
    border-radius: 1px;
    margin-bottom: 6px;
    overflow: hidden;
}

.fc-nav__freq-fill {
    height: 100%;
    background: rgba(185, 255, 59, 0.50);
    border-radius: 1px;
    transition: background 130ms ease;
}

.fc-nav__bcard:hover .fc-nav__freq-fill {
    background: var(--fc-accent, #b9ff3b);
}

.fc-nav__bc-games {
    font-size: 11px;
    color: var(--fc-muted, #b7b7b7);
    margin-bottom: 6px;
}

/* Score bar (W/D/B) */
.fc-nav__score-bar {
    display: flex;
    height: 4px;
    border-radius: 2px;
    overflow: hidden;
    gap: 1px;
    margin-bottom: 4px;
}

.fc-nav__sb-w {
    background: #c8c4b0;
    border-radius: 2px 0 0 2px;
}

.fc-nav__sb-d {
    background: #787570;
}

.fc-nav__sb-b {
    background: #3a3a38;
    border-radius: 0 2px 2px 0;
}

.fc-nav__bc-wdl {
    display: flex;
    justify-content: space-between;
    font-size: 10px;
    color: rgba(255,255,255,0.30);
}

.fc-nav__bcard:hover .fc-nav__bc-wdl {
    color: rgba(185, 255, 59, 0.50);
}

/* Tree view footer note */
.fc-nav__tree-foot {
    padding: 6px 14px 10px;
    font-size: 11px;
    color: rgba(255,255,255,0.20);
    border-top: 1px solid var(--fc-border, rgba(255,255,255,0.12));
}


/* ── COLUMN VIEW ─────────────────────────────────────────────── */

.fc-nav__col-view {
    display: flex;
    overflow-x: auto;
    max-height: 360px;
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,0.15) transparent;
}

.fc-nav__col-view::-webkit-scrollbar {
    height: 4px;
}

.fc-nav__col-view::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.15);
    border-radius: 2px;
}

.fc-nav__col {
    min-width: 170px;
    border-right: 1px solid var(--fc-border, rgba(255,255,255,0.12));
    flex-shrink: 0;
    overflow-y: auto;
}

.fc-nav__col:last-child {
    border-right: none;
}

.fc-nav__col-hd {
    position: sticky;
    top: 0;
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    background: rgba(0,0,0,0.22);
    border-bottom: 1px solid var(--fc-border, rgba(255,255,255,0.12));
    z-index: 1;
}

.fc-nav__turn-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
    border: 1px solid rgba(255,255,255,0.20);
}

.fc-nav__turn-dot.dot-w {
    background: #ede9da;
    border-color: rgba(255,255,255,0.35);
}

.fc-nav__turn-dot.dot-b {
    background: #3a3835;
    border-color: rgba(0,0,0,0.55);
}

.fc-nav__col-hd-txt {
    font-size: 10px;
    font-weight: 700;
    color: rgba(255,255,255,0.35);
    text-transform: uppercase;
    letter-spacing: 0.4px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Column move row */
.fc-nav__col-mv {
    padding: 6px 10px 5px;
    border-bottom: 1px solid rgba(255,255,255,0.05);
    cursor: pointer;
    transition: background 110ms ease;
}

.fc-nav__col-mv:hover,
.fc-nav__col-mv.is-sel {
    background: rgba(185, 255, 59, 0.09);
}

.fc-nav__col-mv-row {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: 4px;
}

.fc-nav__col-san {
    font-family: var(--fc-mono, monospace);
    font-size: 13px;
    font-weight: 700;
    color: var(--fc-text, #f3f3f3);
}

.fc-nav__col-mv:hover .fc-nav__col-san,
.fc-nav__col-mv.is-sel .fc-nav__col-san {
    color: var(--fc-accent, #b9ff3b);
}

.fc-nav__col-ct {
    font-size: 11px;
    color: var(--fc-muted, #b7b7b7);
}

.fc-nav__col-mv:hover .fc-nav__col-ct,
.fc-nav__col-mv.is-sel .fc-nav__col-ct {
    color: rgba(185, 255, 59, 0.65);
}

.fc-nav__col-bar-bg {
    height: 2px;
    background: rgba(255,255,255,0.08);
    border-radius: 1px;
    overflow: hidden;
}

.fc-nav__col-bar {
    height: 100%;
    background: rgba(185, 255, 59, 0.40);
    border-radius: 1px;
    transition: background 110ms ease;
}

.fc-nav__col-mv:hover .fc-nav__col-bar,
.fc-nav__col-mv.is-sel .fc-nav__col-bar {
    background: var(--fc-accent, #b9ff3b);
}
/* ── D3 tree node click links ─────────────────────────────────────────────── */

/* Clickable move nodes in the D3 tree */
.fc-mt-nodeText--link {
    cursor: pointer;
    text-decoration: underline;
    text-decoration-color: rgba(0,0,0,0.25);
    text-decoration-thickness: 1px;
    text-underline-offset: 2px;
    transition: fill 120ms ease;
}

.fc-mt-nodeText--link:hover {
    fill: #0b6b2b;
}
