/* Euler Hall /next — design tokens. THE SOVEREIGN ACADEMY SYSTEM.

   Lane BRAND-SOVEREIGN-ACADEMY, 29 Nov 2026. The founder locked the visual system
   as **Sovereign Academy**: midnight navy, antique gold and luminous ivory, on an
   archival warm parchment for light mode. The values below are that palette and
   nothing else; every other stylesheet may use only the custom properties defined
   here, so a colour is decided once.

   Light is the default and is the ARCHIVAL PARCHMENT page — the ground a reader
   spends the longest time on, tuned so black-navy ink on warm paper is calmer than
   ink on a pure white screen. Dark is the SIGNATURE surface: the same navy the app
   icon, the banner and the social card are drawn on, so an installed app, a shared
   link and the page a learner opens are one object.

   CONTRAST IS A CONTRACT, NOT AN AESTHETIC.
   Text tokens (--fg, --muted, --faint, --ok, --bad) stay at least 4.5:1 on --bg,
   --surface AND --surface-2; --line is the control border and stays at least 3:1 on
   those same three grounds. Measured on this file (WCAG 2.1 relative luminance):

                       on --bg   on --surface   on --surface-2
     light  --fg        15.44        16.97           13.88
            --muted      6.73         7.40            6.05
            --faint      5.69         6.26            5.11
            --ok         5.77         6.34            5.19
            --bad        6.61         7.26            5.94
            --line       4.11         4.52            3.69   (border: needs 3)
     dark   --fg        13.50        12.18           10.36
            --muted      9.22         8.32            7.07
            --faint      7.02         6.33            5.38
            --ok         9.90         8.94            7.60
            --bad        6.24         5.63            4.79
            --line       4.94         4.46            3.79   (border: needs 3)

   `tests/check_a11y.mjs` re-measures all of that in a real browser, in both themes,
   on desktop and on a phone. Do not lighten a token to get a softer hairline: the
   hairline has its own token (--hair) precisely so a divider never borrows the
   weight of a control border.

   WHAT CHANGED IN THIS PASS, AND WHY
   ----------------------------------
   * The whole ramp is new. The previous system was a neutral grey/ink ramp with no
     accent at all; the founder's chosen identity carries three brand inks (navy,
     gold, ivory) and one meaningful accent (gold = progress and emphasis). Colour is
     still reserved for MEANING: a right answer, a wrong one, and progress. There is
     no decorative colour anywhere.
   * `--gold` is the ACCENT (rules, the pediment, a meter's fill, a chip's edge) and
     `--gold-ink` is the same accent used as TEXT. They differ in light mode for one
     measurable reason: #8a652e reaches 4.72:1 on the parchment and 5.19:1 on the
     ivory card, but only 4.24:1 on the tinted --surface-2, which is below AA for
     body-size text. Text therefore uses the slightly deeper #7f5c28, which clears
     4.5:1 on all three grounds. Dark mode uses one value for both, because there is
     no surface in that ramp where the antique gold falls short (lowest 6.78:1).
   * `--brand-navy` / `--brand-gold` / `--brand-ivory` do NOT flip with the theme.
     They are the identity's constants — the colours the icon, the banner and the
     exported share card are drawn in — and a component that means "the brand ground"
     must not silently become ivory because the reader chose light mode.
   * `--btn-primary-*` are new. The primary button is the one control that carries the
     identity, and it inverts by theme: navy ground with ivory ink on paper, antique
     gold ground with navy ink on the dark surface (10.58:1). Naming the three values
     keeps that decision in this file instead of in a `[data-theme]` selector inside
     components.css.
   * `--surface-3` (the hover/active wash) and `--step--2` / `--radius-sm` / `--mono`
     / `--ink` / `--paper` all stay: several stylesheets already reference them, and
     two of them once silently fell back to an inherited value because the token
     did not exist.
   * `--hair` is still THE hairline: a divider, not a border. It is mixed from --fg so
     it inherits the theme's ink and cannot drift from the text it separates.
   * Dark mode's --line is 4.9:1 on the navy: visible as a control edge, still quieter
     than the ivory text inside it. */

:root {
  color-scheme: light;

  /* -- the identity, fixed across both themes ----------------------------- */
  --brand-navy: #111b2c;
  --brand-gold: #dfc89b;
  --brand-ivory: #f0e2c9;
  --brand-parchment: #f6f2e8;

  /* -- the page (archival parchment) -------------------------------------- */
  --bg: #f6f2e8;
  --fg: #111b2c;
  --muted: #4a5568;
  --faint: #556072;
  --line: #6b7688;
  --surface: #fffdf8;
  --surface-2: #ede6d6;
  --surface-3: #e3d9c3;

  /* -- the accent --------------------------------------------------------- */
  --gold: #8a652e;
  --gold-ink: #7f5c28;
  --gold-wash: #f1e8d2;
  --gold-rule: color-mix(in srgb, var(--gold) 46%, transparent);

  --ok: #146c43;
  --bad: #9c2e2e;
  --focus: #111b2c;

  /* -- the primary control, which inverts by theme ------------------------ */
  --btn-primary-bg: #111b2c;
  --btn-primary-fg: #f0e2c9;
  --btn-primary-bg-hover: #1a2842;
  --btn-primary-edge: #111b2c;

  /* The hairline: a divider, not a border. 12% ink is visible on parchment at 1px
     and disappears at 1px on a projector — which is the right weight for a rule
     between two blocks of text. */
  --hair: color-mix(in srgb, var(--fg) 12%, transparent);
  --hair-strong: color-mix(in srgb, var(--fg) 20%, transparent);
  /* THE CARD EDGE is a warm hairline rather than an ink one. A card is a sheet of
     paper on the page, and under this identity paper has an edge with a little gold
     in it — visible at 1px on parchment, quiet enough that a stack of cards is not a
     stack of boxes. It is NOT `--gold`: at full strength a card's border competes with
     the primary button inside it (the same mistake the old `--line` card border made,
     in the other direction). */
  --card-edge: color-mix(in srgb, var(--gold) 26%, transparent);

  --font-text: "Iowan Old Style", "Palatino Linotype", Palatino, "Noto Serif", "Liberation Serif", Georgia, serif;
  --font-ui: Inter, "Source Sans 3", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-mono: "JetBrains Mono", "Cascadia Mono", ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  /* Aliases for the names older stylesheets reached for. See the header. */
  --mono: var(--font-mono);
  --ink: var(--fg);
  --paper: var(--bg);

  --step--2: 0.75rem;
  --step--1: 0.8125rem;
  --step-0: 1rem;
  --step-1: 1.125rem;
  --step-2: 1.625rem;
  --step-3: 2.25rem;

  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.5rem;
  --space-6: 2rem;
  --space-7: 3rem;
  --space-8: 4.5rem;

  /* Vertical rhythm: the gaps the flow rules in base.css use between blocks of
     text. A container can retune them locally (`.card` tightens the heading gap). */
  --flow: var(--space-4);
  --flow-heading: var(--space-6);
  --flow-under-h1: var(--space-5);
  --flow-under-heading: var(--space-4);
  --flow-under-minor: var(--space-2);
  --flow-item: var(--space-2);
  /* NO GAP: a label and the heading it names are one thought, so the flow rule that
     spaces siblings contributes nothing between them. Named because the rhythm gate
     requires every flow gap to be a `--flow*` token rather than a bare `0`. */
  --flow-none: 0px;
  /* A sub-head (h3/h4) is closer to its own text than to what came before: the space
     above it is a section head's, the space under it is the tightest in the scale.
     Named rather than written as `var(--space-5)` at the call site because
     `tests/check_rhythm.py` holds every flow gap to a `--flow*` TOKEN — the rule that
     keeps long-form spacing in one place — and a literal there, even a token alias,
     is a gap the next container cannot retune. */
  --flow-subhead: var(--space-5);

  --radius: 4px;
  --radius-sm: 3px;
  --measure: 68ch;
  --tap: 44px;
}

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

    --bg: #111b2c;
    --fg: #f0e2c9;
    --muted: #b5bece;
    --faint: #9aa6ba;
    --line: #7a8aa6;
    --surface: #182438;
    --surface-2: #21304a;
    --surface-3: #2a3c5c;

    /* The signature antique gold, and it is legible on every surface here: 10.58:1
       on the navy ground, 9.55:1 on a card, 8.11:1 on the inset, 6.78:1 on the
       hover wash. One value serves both the accent and the text. */
    --gold: #dfc89b;
    --gold-ink: #dfc89b;
    --gold-wash: #26344c;
    --gold-rule: color-mix(in srgb, var(--gold) 40%, transparent);

    --ok: #4ade80;
    --bad: #f87171;
    --focus: #dfc89b;

    --btn-primary-bg: #dfc89b;
    --btn-primary-fg: #111b2c;
    --btn-primary-bg-hover: #e9d5ae;
    --btn-primary-edge: #dfc89b;
  }
}

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

  --bg: #111b2c;
  --fg: #f0e2c9;
  --muted: #b5bece;
  --faint: #9aa6ba;
  --line: #7a8aa6;
  --surface: #182438;
  --surface-2: #21304a;
  --surface-3: #2a3c5c;

  --gold: #dfc89b;
  --gold-ink: #dfc89b;
  --gold-wash: #26344c;
  --gold-rule: color-mix(in srgb, var(--gold) 40%, transparent);

  --ok: #4ade80;
  --bad: #f87171;
  --focus: #dfc89b;

  --btn-primary-bg: #dfc89b;
  --btn-primary-fg: #111b2c;
  --btn-primary-bg-hover: #e9d5ae;
  --btn-primary-edge: #dfc89b;
}

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

  --bg: #f6f2e8;
  --fg: #111b2c;
  --muted: #4a5568;
  --faint: #556072;
  --line: #6b7688;
  --surface: #fffdf8;
  --surface-2: #ede6d6;
  --surface-3: #e3d9c3;

  --gold: #8a652e;
  --gold-ink: #7f5c28;
  --gold-wash: #f1e8d2;
  --gold-rule: color-mix(in srgb, var(--gold) 46%, transparent);

  --ok: #146c43;
  --bad: #9c2e2e;
  --focus: #111b2c;

  --btn-primary-bg: #111b2c;
  --btn-primary-fg: #f0e2c9;
  --btn-primary-bg-hover: #1a2842;
  --btn-primary-edge: #111b2c;
}

/* An h1 on a wide screen. The step is a ratio, not a fixed size, so the largest
   text setting still scales it. */
@media (min-width: 900px) {
  :root { --step-3: 2.5rem; }
}
