/* ==========================================================
   FelixChess Game Analyzer AI — component styles
   ==========================================================
   This file covers only the Game Analyzer-specific elements.
   The games table, profile card (stats), W/D/B bar, Elo bands,
   and timeline chart all reuse .fc-oe__ classes from
   opening-explorer.css — no duplication needed.
   ========================================================== */

/* ── Root container ──────────────────────────────────────── */

/*
 * PERMANENT FIX (narrowed): Only .fc-ga__loading and .fc-ga__statusBar
 * use display:flex, which can override the UA stylesheet's
 * [hidden]{display:none} and keep them visible after JS sets hidden=true.
 * We override ONLY those two elements — NOT the broad .fc-ga [hidden]
 * selector — so that boardWrap is governed by the UA stylesheet alone
 * (no !important). This matters because FelixChessBoardController calls
 * isVisible() → clientWidth > 0 immediately after boardWrap is unhidden;
 * if !important is in play the browser defers the reflow and clientWidth
 * stays 0, silently preventing the board from ever being created.
 */
.fc-ga__loading[hidden],
.fc-ga__statusBar[hidden] { display: none !important; }

.fc-ga {
    width: 100%;
    --fc-ga-right-column-width: 560px;
    /* Dark theme — matches the shared page canvas treatment.
       Semi-transparent colors used throughout the component
       (rgba(255,255,255,0.04) for cards, rgba(0,0,0,0.20) for inputs, etc.)
       are designed to work against a dark surface.
       Setting background + color here ensures the Game Analyzer looks
       consistent regardless of which page template
       it is placed on. */
    background: #202020;
    color: #e8e8e8;
    border-top: 1px solid rgba(255, 255, 255, 0.12);
    border-bottom: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 0;
    min-height: 645.8px;
    padding: 20px 24px;
    box-sizing: border-box;
}

.fc-ga__inner {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

/* ── Search row ──────────────────────────────────────────── */
.fc-ga__searchRow {
    display: grid;
    grid-template-columns: 1fr 1.2fr;
    gap: 14px;
    align-items: start;
}

.fc-ga__searchLabel {
    padding-top: 6px;
}

.fc-ga__searchTitle {
    font-size: 18px;
    font-weight: 800;
    line-height: 1.2;
}

.fc-ga__searchHint {
    margin-top: 6px;
    color: rgba(232, 232, 232, 0.62);
    font-size: 13px;
    line-height: 1.35;
}

.fc-ga__searchControls {
    display: flex;
    align-items: flex-start;
    flex-wrap: nowrap;
    gap: 10px;
    min-width: 0;
}

@media (max-width: 900px) {
    .fc-ga__searchRow {
        grid-template-columns: 1fr;
    }
}

.fc-ga__inputWrap {
    position: relative;
    flex: 1;
    min-width: 0;
}

.fc-ga__input {
    width: 100%;
    box-sizing: border-box;
    border-radius: 14px;
    border: 1px solid rgba(255, 255, 255, 0.14);
    background: rgba(0, 0, 0, 0.20);
    color: inherit;
    padding: 10px 16px;
    font-size: 14px;
    outline: none;
    transition: border-color .2s, box-shadow .2s;
}

.fc-ga__input:focus {
    border-color: rgba(185,255,59,0.55);
    box-shadow: 0 0 0 3px rgba(185,255,59,0.14);
}

.fc-ga__input::placeholder { opacity: .55; }

/* Opening Explorer-style icon controls */
.fc-ga .fc-mtsearch__iconBtn,
.fc-ga .fc-oe__clearBtn {
    flex: 0 0 46px;
    width: 46px;
    height: 44px;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.14);
    background: rgba(255, 255, 255, 0.06);
    color: #e8e8e8;
    cursor: pointer;
    display: grid;
    place-items: center;
    padding: 0;
    transition: background 140ms ease, transform 140ms ease, border-color 140ms ease, color 140ms ease;
}

.fc-ga .fc-mtsearch__iconBtn svg,
.fc-ga .fc-oe__clearBtn svg {
    width: 22px;
    height: 22px;
    fill: currentColor;
    opacity: 0.9;
}

.fc-ga .fc-mtsearch__iconBtn:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.10);
    transform: translateY(-1px);
}

.fc-ga .fc-mtsearch__iconBtn:disabled {
    opacity: 0.35;
    cursor: not-allowed;
    transform: none;
}

.fc-ga .fc-mtsearch__boardBtn.is-active {
    background: rgba(185, 255, 59, 0.14);
    border-color: rgba(185, 255, 59, 0.55);
    color: #b9ff3b;
    box-shadow: 0 0 0 2px rgba(185, 255, 59, 0.12) inset;
}

.fc-ga .fc-mtsearch__boardSquare--dark {
    fill: #69864A;
}

.fc-ga .fc-mtsearch__boardSquare--light {
    fill: #DACAA7;
}

.fc-ga .fc-oe__clearBtn:hover {
    background: rgba(220, 60, 60, 0.18);
    border-color: rgba(220, 60, 60, 0.45);
    color: #ff7070;
    transform: translateY(-1px);
}

.fc-ga .fc-oe__clearBtn[hidden] {
    display: none !important;
}

/* Speech / microphone button */
.fc-ga__micBtn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 46px;
    height: 44px;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.14);
    background: rgba(0, 0, 0, 0.20);
    color: #d8d8d8;
    cursor: pointer;
    flex-shrink: 0;
    transition: background .2s, border-color .2s, color .2s, box-shadow .2s;
}

.fc-ga__micBtn:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.24);
    color: #fff;
}

.fc-ga__micBtn:disabled {
    opacity: .45;
    cursor: not-allowed;
}

.fc-ga__micBtn.is-recording {
    background: rgba(200, 40, 40, 0.18);
    border-color: rgba(255, 80, 80, 0.50);
    color: #ff8a8a;
    box-shadow: 0 0 0 4px rgba(200, 40, 40, 0.16);
}

.fc-ga__micBtn {
    position: relative;
    overflow: hidden;
}

.fc-ga__micIcon,
.fc-ga__micWave {
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.fc-ga__micIcon {
    transition: opacity .18s ease, transform .18s ease;
}

.fc-ga__micWave {
    position: absolute;
    inset: 0;
    gap: 2px;
    opacity: 0;
    pointer-events: none;
    transition: opacity .18s ease;
}

.fc-ga__micBtn.is-recording .fc-ga__micIcon {
    opacity: 0;
    transform: scale(.9);
}

.fc-ga__micBtn.is-recording .fc-ga__micWave {
    opacity: 1;
}

.fc-ga__micBar {
    width: 3px;
    height: 10px;
    border-radius: 999px;
    background: currentColor;
    opacity: .9;
    transform-origin: center;
    animation: fc-ga-wave 1s ease-in-out infinite;
}

.fc-ga__micBar:nth-child(1) { animation-delay: 0s; }
.fc-ga__micBar:nth-child(2) { animation-delay: .12s; }
.fc-ga__micBar:nth-child(3) { animation-delay: .24s; }
.fc-ga__micBar:nth-child(4) { animation-delay: .36s; }

@keyframes fc-ga-wave {
    0%, 100% { transform: scaleY(.45); opacity: .55; }
    50%      { transform: scaleY(1.35); opacity: 1; }
}

/* ── Candidates dropdown (player disambiguation) ──────────── */
.fc-ga__candidates {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    right: 0;
    z-index: 200;
    background: #1e1e1e;
    border: 1px solid rgba(255, 255, 255, 0.14);
    border-radius: 14px;
    overflow: hidden;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.55);
}

.fc-ga__candidatesHeader {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.fc-ga__candidatesTitle {
    font-size: 13px;
    font-weight: 600;
    opacity: .85;
}

.fc-ga__candidatesNote {
    font-size: 11px;
    font-weight: 400;
    opacity: .5;
    margin-left: 4px;
}

.fc-ga__candidatesClose {
    appearance: none;
    border: 0;
    background: transparent;
    color: inherit;
    cursor: pointer;
    opacity: .6;
    font-size: 14px;
    padding: 2px 6px;
    border-radius: 6px;
    transition: opacity .15s, background .15s;
}
.fc-ga__candidatesClose:hover { opacity: 1; background: rgba(255,255,255,.08); }

.fc-ga__candidatesBody {
    max-height: 320px;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: #444 transparent;
    padding: 6px 0;
}

/* Individual candidate row */
.fc-ga__candidate {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 10px 14px;
    cursor: pointer;
    transition: background .12s;
    outline: none;
}
.fc-ga__candidate:hover,
.fc-ga__candidate:focus {
    background: rgba(110, 143, 45, 0.14);
}

.fc-ga__candidateName {
    font-size: 14px;
    font-weight: 600;
    color: #e8e8e8;
    display: flex;
    align-items: baseline;
    gap: 5px;
}

.fc-ga__candidateRating {
    font-size: 12px;
    font-weight: 400;
    color: #999;
}

.fc-ga__candidateMeta {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.fc-ga__candidateTag {
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.07);
    color: #aaa;
    white-space: nowrap;
}

.fc-ga__candidateTitle  { color: #c8ff60; background: rgba(100, 180, 0, 0.12); }
.fc-ga__candidateFed    { color: #88ccff; background: rgba(50, 120, 200, 0.14); }
.fc-ga__candidateGames  { color: #888; }

/* ── Candidates footer: "Showing 20 of 47 · Show all 47" ─── */
.fc-ga__candidatesFooter {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 14px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    margin-top: 4px;
}

.fc-ga__candidatesCount {
    font-size: 12px;
    color: #666;
}

.fc-ga__showAllBtn {
    appearance: none;
    border: 0;
    background: transparent;
    color: #6aaa20;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    padding: 0;
    transition: opacity .15s;
}
.fc-ga__showAllBtn:hover { opacity: .75; }

/* ── Loading indicator ────────────────────────────────────── */
.fc-ga__loading {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 13px;
    opacity: .8;
}

@keyframes fc-ga-spin { to { transform: rotate(360deg); } }

.fc-ga__spinner {
    width: 16px;
    height: 16px;
    border: 2px solid rgba(110, 143, 45, 0.30);
    border-top-color: #6aaa20;
    border-radius: 50%;
    flex-shrink: 0;
    animation: fc-ga-spin .7s linear infinite;
}

/* ── Error bar ────────────────────────────────────────────── */
.fc-ga__error {
    padding: 10px 14px;
    border-radius: 10px;
    background: rgba(200, 40, 40, 0.15);
    border: 1px solid rgba(200, 40, 40, 0.30);
    color: #ff9090;
    font-size: 13px;
    line-height: 1.4;
}

/* ── Status bar ───────────────────────────────────────────── */
.fc-ga__statusBar {
    display: flex;
    align-items: baseline;
    gap: 12px;
    font-size: 13px;
}

.fc-ga__statusText {
    opacity: .75;
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Shared "link-style" button (Clear, etc.) */
.fc-ga__linkBtn {
    appearance: none;
    border: 0;
    background: transparent;
    color: #6aaa20;
    font-size: 13px;
    cursor: pointer;
    padding: 0;
    white-space: nowrap;
    transition: opacity .15s;
    flex-shrink: 0;
}
.fc-ga__linkBtn:hover { opacity: .75; }

/* ── Game result cell colouring ───────────────────────────── */
.fc-ga__result--white { color: #c9c6b8; font-weight: 700; }
.fc-ga__result--black { color: #999;    font-weight: 700; }
.fc-ga__result--draw  { color: #777;    font-weight: 700; }

/* ── Game row hover ───────────────────────────────────────── */
.fc-ga__gameRow:hover {
    background: rgba(255, 255, 255, 0.06) !important;
}

/* ── Board viewer overrides ───────────────────────────────── */
.fc-ga .fc-boardViewer__boardPane {
    position: relative;
}

.fc-ga .fc-boardViewer__boardPane [data-role="playerWhite"] {
    grid-column: 1 / -1;
    margin-top: 8px;
}

.fc-ga .fc-boardViewer__boardPane [data-role="playerWhite"] .fc-boardViewer__clock {
    margin-inline-start: auto;
}

.fc-ga .fc-boardViewer__boardPane [data-role="playerWhite"] .fc-boardViewer__clock--active {
    background: rgba(120, 170, 70, 0.25);
    border: 1px solid rgba(150, 210, 80, 0.45);
    color: #c9ff6a;
    outline: none;
}

.fc-ga .fc-boardViewer__boardPane [data-role="playerWhite"] .fc-boardViewer__clock--inactive {
    background: transparent;
    border: 0;
    box-shadow: none;
    color: rgba(201, 255, 106, 0.62);
    outline: none;
}

.fc-ga .fc-boardViewer__gameType {
    text-transform: uppercase;
}

/* ── Dark-context overrides for inherited .fc-oe__ classes ── */
/*
 * The opening-explorer.css uses rgba(255,255,255,…) transparencies
 * throughout, relying on a dark page background to work correctly.
 * These overrides are scoped to .fc-ga so they never affect the
 * actual Opening Explorer.
 */

/* Profile card and games panel backgrounds */
.fc-ga .fc-oe__card,
.fc-ga .fc-oe__gamesPanel {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.10);
    border-radius: 14px;
    padding: 12px;
}

/* Match title-to-box spacing between the Games and Search results columns. */
.fc-ga .fc-oe__main,
.fc-ga .fc-oe__side {
    gap: 12px;
}

/* Section / layout titles */
.fc-ga .fc-oe__mainTitle,
.fc-ga .fc-oe__sideTitle {
    color: #e8e8e8;
    margin-bottom: 0;
}

/* Placeholder text */
.fc-ga .fc-oe__placeholder {
    color: rgba(255, 255, 255, 0.55);
}

/* Sort buttons in table headers */
.fc-ga .fc-oe__thBtn {
    color: #ccc;
}

/* Table row backgrounds */
.fc-ga .fc-oe__gamesTable tbody tr {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.08);
    color: #e8e8e8;
}

.fc-ga .fc-oe__gamesTable tbody tr.is-selected {
    outline: 1px solid rgba(140, 190, 70, 0.9);
    background: rgba(140, 190, 70, 0.14);
}

/* Stats card text colors */
.fc-ga .fc-oe__pcTitle  { color: #e0e0e0; }
.fc-ga .fc-oe__pcStatV  { color: #c8ff60; }
.fc-ga .fc-oe__pcStatL  { color: #666; }
.fc-ga .fc-oe__pcSectionLabel { color: #555; }
.fc-ga .fc-oe__bandLabel,
.fc-ga .fc-oe__bandCount { color: #777; }
.fc-ga .fc-oe__wdbLW { color: #b8b5a8; }
.fc-ga .fc-oe__wdbLD { color: #777; }
.fc-ga .fc-oe__wdbLB { color: #888; }
/* ── Analyzer layout ──────────────────────────────────────── */
.fc-ga .fc-oe__layout {
    display: grid;
    grid-template-columns: minmax(520px, 1fr) minmax(500px, var(--fc-ga-right-column-width));
    gap: 20px;
    align-items: start;
    transition: grid-template-columns 280ms ease;
}

.fc-ga .fc-ga__rightColumn {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 18px;
    min-width: 0;
    width: 100%;
    align-items: stretch;
}

.fc-ga .fc-ga__searchResultsPanel,
.fc-ga .fc-ga__selectedGamePanel {
    width: 100%;
    max-width: none;
    min-width: 0;
    box-sizing: border-box;
    align-self: stretch;
}

.fc-ga .fc-ga__selectedGamePanel.fc-oe__boardWrap,
.fc-ga .fc-ga__selectedGamePanel .fc-boardViewer {
    width: 100%;
    max-width: none;
    min-width: 0;
    box-sizing: border-box;
}

.fc-ga .fc-ga__selectedGamePanel.fc-oe__boardWrap {
    border-radius: 14px;
}

.fc-ga .fc-boardViewer:focus,
.fc-ga .fc-boardViewer:focus-visible,
.fc-boardViewer[data-board-context="game-analyzer"]:focus,
.fc-boardViewer[data-board-context="game-analyzer"]:focus-visible {
    outline: none;
}

.fc-ga--game-selected .fc-oe__layout {
    grid-template-columns: minmax(520px, 1fr) minmax(500px, var(--fc-ga-right-column-width));
}

.fc-ga.is-resizing-right-column .fc-oe__layout {
    transition: none;
}

.fc-ga__rightResizeHandle {
    position: absolute;
    left: -10px;
    top: 0;
    width: 12px;
    height: 100%;
    cursor: ew-resize;
    z-index: 20;
}

.fc-ga__rightResizeHandle::after {
    content: "";
    position: absolute;
    left: 5px;
    top: 120px;
    width: 2px;
    height: 80px;
    border-radius: 2px;
    background: rgba(255, 255, 255, 0.18);
    opacity: 0;
    transition: background .15s ease, opacity .15s ease;
}

.fc-ga__rightResizeHandle:hover::after,
.fc-ga__rightResizeHandle.is-dragging::after,
.fc-ga.is-resizing-right-column .fc-ga__rightResizeHandle::after {
    background: rgba(141, 198, 63, 0.8);
    opacity: 1;
}

/* Narrow screens: collapse to 1 column (matches opening-explorer.css breakpoint) */
@media (max-width: 1100px) {
    .fc-ga .fc-oe__layout,
    .fc-ga--game-selected .fc-oe__layout,
    .fc-ga--game-selected.fc-ga--board-full .fc-oe__layout {
        grid-template-columns: 1fr;
    }

    .fc-ga__rightResizeHandle {
        display: none;
    }
}

.fc-ga--game-selected .fc-ga__selectedGamePanel .fc-boardViewer__boardPane,
.fc-ga--game-selected .fc-ga__selectedGamePanel .fc-boardViewer__nav,
.fc-ga--game-selected .fc-ga__selectedGamePanel .fc-boardViewer__analyzer {
    max-width: min(620px, calc(100vh - 260px));
}

/* ── Stats card collapse when game is open ───────────────── */
/*
 * The full profile card (W/D/B bar, Elo bands, timeline chart) is replaced
 * by a compact one-line summary via JS when a game is selected.
 * The card background is kept so the right panel doesn't look empty.
 */
.fc-ga__statsCompact {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 2px 0;
}

.fc-ga__statsCompactTitle {
    font-size: 13px;
    font-weight: 700;
    color: #e0e0e0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.fc-ga__statsCompactMeta {
    font-size: 12px;
    color: #777;
}

/* ── Board size toggle button ─────────────────────────────── */
/*
 * Small ⤢/⤡ button in the top-right corner of the board wrap.
 * Positioned absolute so it floats over the board wrap border
 * without affecting the board's own layout.
 */
.fc-ga .fc-oe__boardWrap {
    position: relative;  /* anchor for the toggle button */
}

.fc-ga__boardToggle {
    position: absolute;
    top: 8px;
    right: 8px;
    z-index: 10;
    appearance: none;
    border: 1px solid rgba(255, 255, 255, 0.18);
    background: rgba(30, 30, 30, 0.85);
    color: #aaa;
    font-size: 14px;
    line-height: 1;
    width: 26px;
    height: 26px;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background .15s, color .15s;
    backdrop-filter: blur(4px);
}

.fc-ga__boardToggle:hover {
    background: rgba(50, 50, 50, 0.95);
    color: #e8e8e8;
}

/* ─────────────────────────────────────────────────────────────────────────────
   WS Curated Prompt Row
   Mirrors the Opening Explorer WS pattern. Replaces the NL search row for
   anonymous (webservice) visitors. Reuses fc-oe__wsNotice from
   opening-explorer.css — no duplicate rules needed for the notice bar.
   ───────────────────────────────────────────────────────────────────────────── */

/* Prompt row layout — same flex structure as fc-ga__searchRow */
.fc-ga__promptRow {
    align-items: center;
}

/* Wrapper provides relative positioning for any future tooltip anchoring */
.fc-ga__promptWrap {
    flex: 1 1 auto;
    min-width: 0;
    position: relative;
}

/* The <select> — styled to match the fc-ga__input field */
.fc-ga__promptSelect {
    width: 100%;
    height: 44px;
    padding: 0 40px 0 14px;
    background-color: var(--fc-surface, #1a1e1a);
    color: var(--fc-text, #e8ede8);
    border: 1px solid var(--fc-accent, #aaff00);
    border-radius: 8px;
    font-family: inherit;
    font-size: 14px;
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;

    /* Lime glow on page load — signals "start here" without user interaction */
    box-shadow: 0 0 0 2px color-mix(in srgb, var(--fc-accent, #aaff00) 20%, transparent);

    /* Chevron arrow — inline SVG as background image */
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath fill='%23888' d='M4 6l4 4 4-4'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 16px 16px;

    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.fc-ga__promptSelect:focus {
    outline: none;
    border-color: var(--fc-accent, #aaff00);
    box-shadow: 0 0 0 2px color-mix(in srgb, var(--fc-accent, #aaff00) 20%, transparent);
}

.fc-ga__promptSelect:hover:not(:disabled) {
    border-color: var(--fc-border-hover, #4a564a);
}

.fc-ga__promptSelect:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* Style the placeholder option differently (dimmed) */
.fc-ga__promptSelect option[value=""] {
    color: var(--fc-muted, #666);
}

/* Option items inherit the dark background in most browsers */
.fc-ga__promptSelect option {
    background-color: var(--fc-surface, #1a1e1a);
    color: var(--fc-text, #e8ede8);
    padding: 6px 10px;
}

/* Subscription link in the WS search hint */
.fc-ga__wsLink {
    color: var(--fc-accent, #aaff00);
    text-decoration: none;
    font-weight: 500;
}

.fc-ga__wsLink:hover {
    text-decoration: underline;
}