/* ── UI themes — single source of truth for colors ───────────────────────────
   Dark is the bare :root because every screen was designed on it; its values
   are byte-identical to the :root blocks that used to live inline in each
   template, so nothing changes visually until a user picks another theme.

   Each [data-theme] block redefines TOKENS ONLY — never selectors — so the
   component CSS in templates/*.html stays untouched. <html data-theme> is
   always a concrete theme ("light" / "contrast" / absent = dark); the
   "system" preference is resolved to one of those by static/theme.js.

   Custom theme packs (data/themes/<id>.json) are applied on top of the dark
   base as inline style.setProperty() calls — see /api/themes/<id>. */
:root {
    color-scheme: dark;          /* native scrollbars, <select> popups, form controls */
    --bg:        #0B0E14;
    --bg2:       #10141C;
    --surface:   #131822;
    --surface2:  #1A2029;
    --border:    #232A37;
    --border2:   #2E3644;
    --text:      #E7EAF0;
    --dim:       #838EA1;
    --dim2:      #5B6576;
    --accent:    #E0A83E;
    --accent2:   #F0C878;
    --accent-dim:rgba(224,168,62,.16);
    --green:     #16C784;
    --green-dim: rgba(22,199,132,.12);
    --red:       #F6465D;
    --red-dim:   rgba(246,70,93,.12);
    --amber:     #F0B90B;
    --amber-dim: rgba(240,185,11,.12);
    /* Added with theming — these replaced literal colors in the templates */
    --accent-rgb:     224,168,62;   /* for rgba(var(--accent-rgb), a) glows/shadows */
    --sidebar-end:    #0D111A;      /* bottom of the sidebar gradient */
    --logo-text:      #FFFFFF;      /* "Trade Box" wordmark */
    --heading-hi:     #FFFFFF;      /* light end of the heading text gradient */
    --text-on-accent: #1A1305;      /* text on the gold primary button */
    --row-stripe:     rgba(255,255,255,.012);
    --grid-line:      rgba(255,255,255,.025);
}

:root[data-theme="light"] {
    color-scheme: light;
    --bg:        #F5F3EE;
    --bg2:       #EEEBE4;
    --surface:   #FFFFFF;
    --surface2:  #F8F6F1;
    --border:    #E2DED4;
    --border2:   #CFC9BC;
    --text:      #171A20;
    --dim:       #5E6675;
    --dim2:      #8A92A0;
    --accent:    #B07A12;           /* 4.6:1 on white */
    --accent2:   #8C5F0A;           /* darker than --accent on purpose: gradients still read on white */
    --accent-dim:rgba(176,122,18,.12);
    --green:     #0B8A55;           /* 4.6:1 on white */
    --green-dim: rgba(11,138,85,.12);
    --red:       #D9304A;           /* 4.6:1 on white */
    --red-dim:   rgba(217,48,74,.10);
    --amber:     #A67C00;
    --amber-dim: rgba(166,124,0,.12);
    --accent-rgb:     176,122,18;
    --sidebar-end:    #E7E3DA;
    --logo-text:      #171A20;
    --heading-hi:     #171A20;
    --text-on-accent: #FFFFFF;
    --row-stripe:     rgba(23,26,32,.025);
    --grid-line:      rgba(23,26,32,.05);
}

:root[data-theme="contrast"] {
    color-scheme: dark;
    --bg:        #000000;
    --bg2:       #000000;
    --surface:   #000000;
    --surface2:  #0A0A0A;
    --border:    #FFFFFF;
    --border2:   #FFFFFF;
    --text:      #FFFFFF;
    --dim:       #D0D0D0;
    --dim2:      #A0A0A0;
    --accent:    #FFD966;
    --accent2:   #FFE699;
    --accent-dim:rgba(255,217,102,.25);
    --green:     #3FF23F;
    --green-dim: rgba(63,242,63,.2);
    --red:       #FF5C5C;
    --red-dim:   rgba(255,92,92,.2);
    --amber:     #FFD700;
    --amber-dim: rgba(255,215,0,.2);
    --accent-rgb:     255,217,102;
    --sidebar-end:    #000000;
    --logo-text:      #FFFFFF;
    --heading-hi:     #FFFFFF;
    --text-on-accent: #000000;
    --row-stripe:     rgba(255,255,255,.06);
    --grid-line:      rgba(255,255,255,.08);
}

/* Cross-fade on switch. Scoped to the big surfaces only and enabled just for
   the ~250ms around a switch (html.theme-anim, set by theme.js) so the
   thousands of screener rows never carry a transition on every price tick. */
@media (prefers-reduced-motion: no-preference) {
    html.theme-anim body,
    html.theme-anim .app-shell,
    html.theme-anim .sidebar,
    html.theme-anim .masthead {
        transition: background-color 160ms ease, color 160ms ease;
    }
}
