/* AskWingman tokens — every colour literal of the web app lives in this file
   (UI overhaul, docs/spec-ui-overhaul.md §4.3; enforced by
   scripts/test_ui_tokens.py, contrast checked by scripts/test_ui_contrast.py).

   Values: the prototype's tokens (docs/ui-overhaul/prototype/src/css/tokens.css)
   plus, under "legacy", the names today's page still uses, each with a dark
   and a light value, until its last user is rebuilt.

   Theme: dark-first (the brand look), following the device unless the user
   chose. An explicit choice is data-theme="light|dark" on <html> (absent =
   System), set before first paint by the head script in static/index.html
   from localStorage['aw.theme']. The light palette is written twice, between
   @light-begin/@light-end and @light-copy-begin/@light-copy-end; the two
   copies must stay identical (the token test checks).

   Referenced as /static/ui/tokens.css?v=<CACHE_VERSION number>: any change to
   this file bumps CACHE_VERSION in static/service-worker.js and the ?v= token
   in static/index.html (scripts/test_ui_assets.py checks). */

:root,
:root[data-theme="dark"] {
  color-scheme: dark;

  /* surfaces */
  --bg: #0a0c0f;
  --surface: #111418;
  --raised: #171c23;
  --field: #0a0c0f;
  --hover: rgba(255, 255, 255, 0.06);
  --selected: #1e2530;
  --scrim: rgba(0, 0, 0, 0.6);
  --viewer: #1b1f26;
  --seg-on: #1e2530;
  --avatar: #2a3545;
  /* the strip under the phone/tablet status bar (body::before on the app
     page and on the admin console; zero high where there is none): in the
     dark theme the page's dark, a shade darker than the top bar; in the
     light theme the light surface, as the top bar and the console's header
     (the founder's decision of 2026-11-15: the top of the app light in the
     light theme, docs/ui-overhaul/r3-notes/sitting-fx-topbar.md; dark in
     both themes until then). The installed iPad and iPhone apps run without
     viewport-fit=cover (the head script in static/index.html, spec §7.1)
     and, since 2026-11-15, with the system's default status bar: there the
     page starts below the bar and the strip is zero high */
  --statusbar: #0a0c0f;
  /* the theme-color metas: the top bar's colour (--surface) in each theme,
     so wherever a system colours its bar from them (the default status bar
     of the installed app since 2026-11-15, Android's) the light app gets a
     light bar and the dark app a dark one; AW.theme (core.js) writes the
     shown theme's value into both. The manifest's theme_color is this dark
     value (a manifest has one) */
  --theme-color: #111418;

  /* lines */
  --border: #1e2530;
  --border-hi: #2a3545;

  /* text */
  --text-hi: #f8fafc;
  --text: #e3e9f1;
  --text-dim: #c0cad5;
  --muted: #8f9bab;
  --disabled: #6b7686;
  --disabled-shade: #4a5462;

  /* amber - the brand */
  --amber: #e8a020;
  --amber-edge: #e8a020;
  --on-amber: #1a1206;
  --on-amber-shade: #553805;
  --amber-text: #e8a020;
  --amber-tint: rgba(232, 160, 32, 0.12);
  --amber-line: #7a5010;
  --logo-shade: #7a5010;
  --wordmark: #e8a020;
  --dot: #e8a020;
  --focus: #e8a020;

  /* semantic */
  --warn-bg: rgba(232, 160, 32, 0.07);
  --warn-line: #7a5010;
  --warn-chip: transparent;
  --gk: #a884e8;
  --gk-bg: rgba(168, 132, 232, 0.08);
  --gk-line: #4b3a78;
  --red: #f0685a;
  --red-bg: rgba(240, 104, 90, 0.1);
  --red-line: #7a2e27;
  --green: #2ecc71;
  --green-bg: rgba(46, 204, 113, 0.1);
  --green-line: #1a6640;
  --blue: #4aa3e0;
  --blue-bg: rgba(52, 152, 219, 0.1);
  --blue-line: #1f4e75;

  /* elevation */
  --shadow-pop: 0 12px 40px rgba(0, 0, 0, 0.55);
  --shadow-card: none;
  --shadow-seg: none;

  /* legacy - today's page (static/index.html); replaced as screens are rebuilt */
  --amber-wash: rgba(232, 160, 32, 0.07);
  --warn-bg-lo: rgba(232, 160, 32, 0.05);
  --warn-glow: rgba(232, 160, 32, 0.35);
  --weak-bg: rgba(255, 255, 255, 0.03);
  --fix-bg: rgba(46, 204, 113, 0.07);
  --fix-glow: rgba(46, 204, 113, 0.35);
  --stripe: rgba(255, 255, 255, 0.025);
  --code-bg: rgba(255, 255, 255, 0.05);
  --pre-bg: rgba(0, 0, 0, 0.3);
}

@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
/* @light-copy-begin */
  color-scheme: light;

  /* surfaces */
  --bg: #f4f6f8;
  --surface: #ffffff;
  --raised: #eceff3;
  --field: #f4f6f8;
  --hover: rgba(13, 17, 23, 0.05);
  --selected: #e3e8ee;
  --scrim: rgba(13, 17, 23, 0.45);
  --viewer: #d5dae1;
  --seg-on: #ffffff;
  --avatar: #dde2e8;
  --statusbar: #ffffff;
  --theme-color: #ffffff;

  /* lines */
  --border: #dde2e8;
  --border-hi: #c5ccd6;

  /* text */
  --text-hi: #0d1117;
  --text: #1c232c;
  --text-dim: #3d4753;
  --muted: #5b6675;
  --disabled: #8a94a1;
  --disabled-shade: #b3bcc7;

  /* amber - the brand: the same fill, darker where it is text */
  --amber: #e8a020;
  --amber-edge: #c9860f;
  --on-amber: #1a1206;
  --on-amber-shade: #553805;
  --amber-text: #7a4a00;
  --amber-tint: #fdf1dc;
  --amber-line: #e3b566;
  --logo-shade: #9a6508;
  --wordmark: #c47f08;
  --dot: #b8760a;
  --focus: #8a5a00;

  /* semantic */
  --warn-bg: #fff7e6;
  --warn-line: #e3b566;
  --warn-chip: #ffffff;
  --gk: #5b34b0;
  --gk-bg: #f3eefc;
  --gk-line: #cdbdf0;
  --red: #b42318;
  --red-bg: #fdecea;
  --red-line: #f0b4ad;
  --green: #157347;
  --green-bg: #e7f5ec;
  --green-line: #a9d8bc;
  --blue: #1a5fb4;
  --blue-bg: #e8f0fb;
  --blue-line: #b3cdf0;

  /* elevation */
  --shadow-pop: 0 12px 40px rgba(13, 17, 23, 0.16);
  --shadow-card: 0 1px 3px rgba(13, 17, 23, 0.06);
  --shadow-seg: 0 1px 2px rgba(13, 17, 23, 0.08);

  /* legacy */
  --amber-wash: #fff7e6;
  --warn-bg-lo: #fffaf0;
  --warn-glow: rgba(201, 134, 15, 0.35);
  --weak-bg: rgba(13, 17, 23, 0.03);
  --fix-bg: #e7f5ec;
  --fix-glow: rgba(21, 115, 71, 0.3);
  --stripe: rgba(13, 17, 23, 0.03);
  --code-bg: rgba(13, 17, 23, 0.05);
  --pre-bg: #eceff3;
/* @light-copy-end */
  }
}

:root[data-theme="light"] {
/* @light-begin */
  color-scheme: light;

  /* surfaces */
  --bg: #f4f6f8;
  --surface: #ffffff;
  --raised: #eceff3;
  --field: #f4f6f8;
  --hover: rgba(13, 17, 23, 0.05);
  --selected: #e3e8ee;
  --scrim: rgba(13, 17, 23, 0.45);
  --viewer: #d5dae1;
  --seg-on: #ffffff;
  --avatar: #dde2e8;
  --statusbar: #ffffff;
  --theme-color: #ffffff;

  /* lines */
  --border: #dde2e8;
  --border-hi: #c5ccd6;

  /* text */
  --text-hi: #0d1117;
  --text: #1c232c;
  --text-dim: #3d4753;
  --muted: #5b6675;
  --disabled: #8a94a1;
  --disabled-shade: #b3bcc7;

  /* amber - the brand: the same fill, darker where it is text */
  --amber: #e8a020;
  --amber-edge: #c9860f;
  --on-amber: #1a1206;
  --on-amber-shade: #553805;
  --amber-text: #7a4a00;
  --amber-tint: #fdf1dc;
  --amber-line: #e3b566;
  --logo-shade: #9a6508;
  --wordmark: #c47f08;
  --dot: #b8760a;
  --focus: #8a5a00;

  /* semantic */
  --warn-bg: #fff7e6;
  --warn-line: #e3b566;
  --warn-chip: #ffffff;
  --gk: #5b34b0;
  --gk-bg: #f3eefc;
  --gk-line: #cdbdf0;
  --red: #b42318;
  --red-bg: #fdecea;
  --red-line: #f0b4ad;
  --green: #157347;
  --green-bg: #e7f5ec;
  --green-line: #a9d8bc;
  --blue: #1a5fb4;
  --blue-bg: #e8f0fb;
  --blue-line: #b3cdf0;

  /* elevation */
  --shadow-pop: 0 12px 40px rgba(13, 17, 23, 0.16);
  --shadow-card: 0 1px 3px rgba(13, 17, 23, 0.06);
  --shadow-seg: 0 1px 2px rgba(13, 17, 23, 0.08);

  /* legacy */
  --amber-wash: #fff7e6;
  --warn-bg-lo: #fffaf0;
  --warn-glow: rgba(201, 134, 15, 0.35);
  --weak-bg: rgba(13, 17, 23, 0.03);
  --fix-bg: #e7f5ec;
  --fix-glow: rgba(21, 115, 71, 0.3);
  --stripe: rgba(13, 17, 23, 0.03);
  --code-bg: rgba(13, 17, 23, 0.05);
  --pre-bg: #eceff3;
/* @light-end */
}

/* Legacy names that equal a token above in both themes (aliases). */
:root {
  --cite: var(--amber-text);
  --cite-bg: var(--amber-tint);
  --cite-border: var(--amber-line);
  --weak: var(--text-dim);
  --weak-border: var(--border-hi);
  --fix: var(--green);
  --fix-border: var(--green-line);
}

/* The top bar re-declares no token: it follows the theme, in the admin
   console's header tokens (the founder's decision of 2026-11-15; until then a
   band here held it dark in both themes, founder decision 8, spec §4.3). */

/* Print: the answer sheet prints black on white whatever the theme
   (the @media print block in static/index.html uses these only). */
:root {
  --print-paper: #fff;
  --print-ink: #000;
  --print-wash: #fafafa;
  --print-band: #f4f4f4;
  --print-chip: #f0f0f0;
  --print-rule: #ccc;
  --print-edge: #999;
  --print-muted: #555;
  --print-dim: #444;
  --print-amber: #e8a020;
  --print-amber-text: #7a4a00;                  /* amber words on paper: the light theme's --amber-text, 6.9:1 (founder 2026-11-19); --print-amber stays for the printed logo */
  --print-fix-text: #157347;                    /* green words on paper: the light theme's --green, 5.4:1 (founder 2026-11-19) */
  --print-amber-shade: #7a5010;

  /* Today's printed colours for answer-card rules the print block pins
     (audit F1): without the pin they followed the theme in force, and
     Chromium prints System as light. The values are what v0.71.0 printed
     (its dark palette). */
  --print-table-rule: #1e2530;                  /* today's --border */
  --print-table-edge: #2a3545;                  /* --border-hi */
  --print-table-head-rule: #7a5010;             /* --amber-dim */
  --print-table-head: rgba(232, 160, 32, 0.07); /* --amber-wash */
  --print-stripe: #fafafa;                      /* light grey on paper (founder 2026-11-19, D12; was the dark screen's --stripe, invisible) */
  --print-code-bg: #f0f0f0;                     /* D12 (was --code-bg, invisible on paper) */
  --print-pre-bg: #f4f4f4;                      /* D12 (was --pre-bg, dark grey on paper) */
  --print-gk-rule: #999;                        /* D12 (was --text-hi, invisible on paper) */
  --print-note-bg: rgba(232, 160, 32, 0.1);     /* the storage-full note (0.1 in v0.71.0) */
  --print-jump-bg: rgba(232, 160, 32, 0.05);    /* --warn-bg-lo: the "See verification warning" chip */
  --print-fix-edge: #1a6640;                    /* --fix-border */
  --print-fix-bg: rgba(46, 204, 113, 0.07);     /* --fix-bg: that chip, a corrected table row's cells */
}

/* Not colours: type and safe areas. The type stacks are today's; the
   prototype's take over as screens are rebuilt. */
:root {
  --mono: 'JetBrains Mono', monospace;
  --sans: 'Barlow', sans-serif;
  /* the wordmark "AskWingman" only (the logo's text), design reference D8 */
  --font-wordmark: 'Orbitron', sans-serif;

  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
}
