/* The one palette for every AIGate browser surface.
 *
 * Extracted from portal/index.html's inline <style> in sub-project 5 so the
 * admin UI could read the same values at runtime instead of copying them.
 * control-plane/portal/index.html, control-plane/admin-ui/index.html and
 * control-plane/chat-ui/index.html all link this file;
 * ci/test_checks.py::TestSharedTokens enforces that, enforces that none of
 * them redeclares a token locally, and enforces that the dark block below
 * covers every token the light one defines.
 *
 * Served by the control plane's existing /portal StaticFiles mount, so the
 * admin UI's and chat UI's Vite dev servers proxy /portal as well as /v1.
 *
 * Tokens only -- no selectors other than :root. The components built from
 * these (button, input, card, pill, banner, table, the app header and the
 * sign-in card) live in base.css beside this file, which all three surfaces
 * also link. A component rule here would apply to every surface with no
 * stylesheet of its own to say so.
 *
 * WHY THERE ARE LINE AND ON-ACCENT TOKENS. Dark mode is what forced them.
 * `.banner.bad` used to hardcode `#fef2f2`/`#fecaca`, `.banner.warn` and
 * `.banner.ok` hardcoded their borders, and three places wrote `color:#fff`
 * for text on an accent or ink background. Every one of those is correct in
 * light mode and wrong in dark -- a near-white banner does not stop being
 * near-white because the page went dark. So the palette now names them, and
 * ci/test_checks.py::TestNoHardcodedColours keeps them from creeping back.
 *
 * The light values below are EXACTLY the values those hardcoded rules used,
 * so adding dark mode changed nothing about how any surface renders in
 * light mode. Keep that property: if a light value here needs to change,
 * change it because the design changed, not as a side effect of tuning dark.
 */
:root {
  --bg: #f6f7f9;
  --card: #fff;
  --ink: #1a1d21;
  --mut: #6b7280;
  /* Hairlines: card edges, table rules, dividers. Decorative, so 1.24:1 on
     --card is fine for them -- but NOT for a control's edge (below). */
  --line: #e5e7eb;
  /* The border of an input, select or secondary button. WCAG 1.4.11 wants
     3:1 for the boundary that tells you a control is there, and a white
     button on a white card has no other boundary. #868c96 is 3.38:1 on
     --card and 3.16:1 on --bg; --line was 1.24:1. */
  --control-line: #868c96;
  --acc: #2563eb;
  --acc-bg: #eff6ff;
  /* Text ON an --acc background (a primary button). Never plain #fff: in
     dark mode --acc is a light blue, and white on light blue fails. */
  --acc-ink: #fff;
  --ok: #047857;
  --ok-bg: #ecfdf5;
  --ok-line: #a7f3d0;
  --warn: #b45309;
  --warn-bg: #fffbeb;
  --warn-line: #fde68a;
  --bad: #b91c1c;
  --bad-bg: #fef2f2;
  --bad-line: #fecaca;

  /* Syntax colours for the chat's highlighted code (sub-project A, D5).
     Read on a --bg code block. Never a bundled highlight.js theme: that
     would be a second palette that cannot follow prefers-color-scheme. */
  --syn-kw: #6f42c1;
  --syn-str: #0a7b3e;
  --syn-num: #b45309;
  --syn-cmt: #6b7280;
  --syn-fn: #1d4ed8;
  --syn-type: #0f766e;
  --syn-attr: #9d174d;
  --syn-punct: #4b5563;

  /* A member's personal quota once spend crosses quota_warn_ratio. One
     token so the portal's bar and the chat's footer line cannot disagree
     again: the portal painted it amber, the chat red, for the same fact
     (2026-10-14 UX review). Warn, not bad -- nothing has been refused yet. */
  --quota-warn: var(--warn);

  /* ---- Scale. Not colours, so the dark block below does not repeat them. */
  --font: system-ui, "Segoe UI", Roboto, sans-serif;
  --font-mono: ui-monospace, Consolas, monospace;
  --lh: 1.6;
  /* Three sizes cover every surface: secondary text and pills, body, and
     the one heading size each card and the app header use. */
  --fs-sm: 13px;
  --fs-md: 15px;
  --fs-lg: 17px;
  --sp-1: 4px;
  --sp-2: 8px;
  --sp-3: 12px;
  --sp-4: 16px;
  --sp-5: 24px;
  --sp-6: 32px;
  /* sm: chips and inline code; md: controls and banners; lg: cards. */
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 10px;
  /* An outline, not a box-shadow: forced-colors mode keeps outlines and
     drops shadows. --acc is 4.8:1 on --bg and 5.2:1 on --card in light,
     6.8:1 / 7.4:1 in dark, so the ring itself clears 3:1 everywhere. */
  --focus-ring: 2px solid var(--acc);
  --focus-offset: 2px;
}

/* Follows the operating system. There is deliberately no in-app toggle: a
   toggle needs somewhere to persist a choice, and these three surfaces
   share no storage -- the chat and admin apps keep nothing in web storage
   at all, by design (see admin-ui's own note on tokens in browser storage).
   `prefers-color-scheme` needs no persistence and is already the user's
   stated preference. */
@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;

    --bg: #0f1216;
    --card: #171b21;
    --ink: #e7e9ec;
    --mut: #9aa3ad;
    --line: #2a3038;
    /* 3.43:1 on --card, 3.73:1 on --bg (--line is 1.30:1). */
    --control-line: #66707c;

    /* Lightened so it carries text on a dark card (#60a5fa on #171b21 is
       ~7:1), which the light-mode #2563eb does not. */
    --acc: #60a5fa;
    /* A tint, not a wash: this backs the chat's own turns and the portal's
       pills, so it has to stay clearly darker than --card. */
    --acc-bg: #1b2a4a;
    --acc-ink: #0b1220;

    --ok: #34d399;
    --ok-bg: #06281f;
    --ok-line: #14532d;
    --warn: #fbbf24;
    --warn-bg: #2a1f06;
    --warn-line: #713f12;
    --bad: #f87171;
    --bad-bg: #2a1113;
    --bad-line: #7f1d1d;

    --syn-kw: #c4b5fd;
    --syn-str: #86efac;
    --syn-num: #fcd34d;
    --syn-cmt: #9aa3ad;
    --syn-fn: #93c5fd;
    --syn-type: #5eead4;
    --syn-attr: #f9a8d4;
    --syn-punct: #9aa3ad;
  }
}
