/* Themes. Every colour, font family, radius and glow the reader uses is a token here,
   and app.css only ever reads them - a literal in app.css is the one thing a theme
   cannot reach (tests/test_themes.py holds it to that).

   The beta service serves this same file at /themes.css for beta.css, read from this
   package rather than copied: two copies of a palette are two palettes.

   The design, shared with Compendium, is compendium/PLAN_THEMES.md.

   System, light and dark are one declaration per token: `light-dark()` picks by the
   resolved `color-scheme`, so the system setting decides with no script at all, and an
   explicit choice wins simply by pinning `color-scheme`. The other themes are blocks
   that restate the colour tokens outright.

   Every text pair is held to WCAG AA in every theme by the tests, measured rather than
   judged. Muted text on --hl is the exception that is not drawn: secondary text on a
   highlighted row takes --text instead (app.css), because no muted step reads on a
   highlight in every theme. */
:root {
  color-scheme: light dark;
  --bg:     light-dark(#faf8f4, #1b1a18);
  --panel:  light-dark(#f1ede5, #232220);
  --text:   light-dark(#26231f, #e6e1d8);
  /* Was #756e64, which is 4.31:1 on the sidebar - under AA, and found by the test. */
  --muted:  light-dark(#6e675d, #9a9286);
  --line:   light-dark(#e0d9cc, #34312d);
  --accent: light-dark(#8a5a2b, #d9a46a);
  --hl:     light-dark(#f6e3b4, #5a4a22);
  --warn:   light-dark(#a14a2a, #e08a68);
  --backdrop: rgb(0 0 0 / .45);
  --shadow: rgb(0 0 0 / .25);

  --font-ui: system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-prose: Georgia, "Iowan Old Style", "Palatino Linotype", serif;
  --font-display: Georgia, serif;
  --font-mono: ui-monospace, "Cascadia Mono", Consolas, "SF Mono", Menlo, monospace;

  --radius-sm: 2px;
  --radius: 6px;
  --radius-lg: 10px;
  --radius-pill: 999px;

  /* A phosphor halo on controls, in the one theme that has one. Never on prose: it
     softens every glyph edge, which costs nothing on a button and adds up over a
     chapter. */
  --glow: none;
}

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

/* Near-black and off-white, no hue; colour only where it means something. Not #000 on
   #fff - pure white on pure black blooms over a long read. */
:root[data-theme="classic"] {
  color-scheme: dark;
  --bg:     oklch(15% 0 0);
  --panel:  oklch(19% 0 0);
  --text:   oklch(94% 0 0);
  --muted:  oklch(70% 0 0);
  --line:   oklch(32% 0 0);
  --accent: oklch(72% 0.14 250);
  --hl:     oklch(32% 0.06 250);
  --warn:   oklch(72% 0.15 25);
}

/* Green phosphor on black, monospace throughout - the novel too - and square corners.
   Errors stay red: an error the same green as everything else is not an error. Every
   value is inside sRGB; at this lightness green runs out of gamut quickly, and an
   out-of-gamut accent is clipped by the browser into something nobody chose. */
:root[data-theme="terminal"] {
  color-scheme: dark;
  --bg:     oklch(13% 0.02 145);
  --panel:  oklch(16% 0.03 145);
  --text:   oklch(86% 0.19 145);
  --muted:  oklch(68% 0.15 145);
  --line:   oklch(33% 0.06 145);
  --accent: oklch(92% 0.14 145);
  --hl:     oklch(35% 0.09 145);
  --warn:   oklch(72% 0.16 30);

  --font-ui: var(--font-mono);
  --font-prose: var(--font-mono);
  --font-display: var(--font-mono);

  --radius-sm: 0;
  --radius: 0;
  --radius-lg: 0;
  --radius-pill: 0;

  --glow: 0 0 4px oklch(86% 0.19 145 / .45);
}

/* Somebody who asked for more contrast gets crisp edges whatever the theme. As specific
   as a theme block and later, so it wins. */
@media (prefers-contrast: more) {
  :root, :root[data-theme] { --glow: none; }
}
