/* tokens.css — the platform token set.
 *
 * PLATFORM_STYLING_GUIDE.md sections 3.1-3.3 are the contract; this file is that contract and
 * nothing else. No component rules, no type rules, no layout: a surface adopts the system by
 * loading this file and DELETING its own `:root` block, not by copying a palette into itself.
 *
 * Section 3.1/3.2 come from Appendix A verbatim (the block `app/static/training.css:1-72`
 * carried until the training module was retired 2026-09-19). The six status-fill tokens in
 * each block come from section 3.3 and were ruled by Rick on 2026-08-20: the light six are
 * what all seven console surfaces already carry, and the dark six were derived from the dark
 * hues for the matrix pilot and have been live on the box since 2026-08-15.
 *
 * CONSUMED, since 2026-09-20, by admin.html, profile.html, editor.html and index.html. It
 * landed alone the same day (guide section 9, "a reasonable first commit") and that sentence
 * stood here until the first surface converted hours later; it is corrected rather than
 * deleted because the reason it landed alone is still the reason every surface commit is a
 * DELETION of a local :root block rather than a copy of a palette.
 *
 * The dark values appear TWICE, and both copies must stay in step: `html[data-theme="dark"]`
 * is the explicit choice, and the `@media` block is the same palette for someone whose
 * preference is `system` and whose OS is dark. theme.js stamps both attributes.
 *
 * Families and --max-width do not change between themes; only colour and shadow do.
 */

:root {
  --paper: #f3efe6;
  --paper-2: #ece6d9;
  --card: #faf7f0;
  --card-2: #f4efe4;

  --ink: #0e0b08;
  --ink-2: #1e1b16;
  --ink-soft: #4d443b;
  --line: #dcd4c4;
  --line-2: #cabfa8;

  --accent: #b1442a;
  --accent-soft: #d99d8a;

  /* --accent-fill, ADDED 2026-09-20 (Rick ruled it the same day the theme rollout deployed).
   * MEASURED, not eyeballed: white on the dark --accent #d06a4b is 3.59:1, under the 4.5 floor
   * section 11.1 sets, and the .btn.primary label is 600 14px so the AA-large 3.0 allowance does
   * not apply. Section 11.1 had measured --warn on --paper and ramp C's --ink-soft; it never
   * measured white on a filled accent, which is how 28 rules across all eight surfaces shipped
   * with it. Dark only became reachable with the 2026-09-20 deploy, so this was never live before.
   *
   * WHY A SECOND TOKEN RATHER THAN A DEEPER --accent. --accent does two jobs: it is a FILL under
   * white text, and it is TEXT on --paper/--card. Deepening --accent itself to clear white would
   * have dropped accent-as-text from 4.74 to 3.76 on --card and 5.14 to 4.07 on --paper - one
   * violation traded for two. Splitting the fill off fixes the button and leaves every
   * accent-as-text use untouched. Rick's constraint was that the label stay WHITE, which rules
   * out the other candidate fix (a per-theme on-accent ink).
   *
   * Hue and saturation are held exactly from --accent; only lightness moves, which is what 11.1
   * prescribes and what keeps this clear of 11.4's ban on reaching for saturation.
   *
   * LIGHT IS UNCHANGED BY CONSTRUCTION: #b1442a already gives 5.63:1 with white, so the light
   * value is --accent's own. This is a dark-only correction, and the token exists in both blocks
   * only so a rule can name one thing.
   *
   * USE IT ONLY AS A FILL UNDER WHITE TEXT. It is not a darker accent for general use: as TEXT
   * on a dark ground it measures 3.78, which fails. Accent text stays --accent. */
  --accent-fill: #b1442a;  /* = --accent; white on it is 5.63:1 */
  --pass: #5b6c3f;
  /* --warn DEEPENED 2026-09-20, #a9792a -> #7b571b. NOT a new colour: guide 11.1 already
   * derived this exact value for the matrix pilot, and #view-matrix .pill.caution has carried
   * `color:#7b571b` since. This promotes it from that one section to the token.
   *
   * #a9792a was failing in EVERY role it has, which is why one value fixes five pairs:
   *   as TEXT   on --paper  3.35 -> 5.68   (the failure 11.1 itself recorded and never fixed
   *             on --card   3.60 -> 6.09    platform-wide - it only fixed it inside the matrix)
   *             on --card-2 3.36 -> 5.69
   *             on --warn-bg over paper 2.99 -> 5.07, over card 3.19 -> 5.40
   *   as a FILL under --paper 3.35 -> 5.68, under white 3.85 -> 6.52
   * Hue moves 0.2 degrees and saturation 2.9 points: a lightness move, per 11.1, not 11.4's
   * saturation bump. (11.1 quotes 4.72 for this value on "its own tinted ground"; that is the
   * matrix's row ground, not --warn-bg, so the numbers above differ and both pass.)
   *
   * --warn-bg AND --warn-line ARE DELIBERATELY NOT RE-DERIVED. They stay on the #a9792a hue so
   * the tint remains LIGHTER than the ink that sits on it - re-deriving them from the deeper
   * value would darken the tint and close the gap this change just opened. A status tint being
   * a lighter relative of its ink is the intended relationship, not drift.
   *
   * DARK --warn #d0a156 is unchanged and needs no change: 7.84 as text on --paper, 7.23 on
   * --card, 7.84 as a fill under --paper. The problem was only ever the light value.
   *
   * The 11.2 FROZEN COMPOSITES in admin.html are solid hexes, not tokens, so they are immune
   * to this and must stay that way. */
  --warn: #7b571b;
  --fail: #9c2b1a;

  /* Section 3.3. These are what the status pills and the In-flight drain chips are drawn
   * with, so changing a value here restyles those screens too — the coupling is the reason
   * the matrix pilot scoped its own pill work instead of raising the tokens. */
  --pass-bg: rgba(91, 108, 63, 0.10);
  --pass-line: rgba(91, 108, 63, 0.45);
  --warn-bg: rgba(169, 121, 42, 0.11);
  --warn-line: rgba(169, 121, 42, 0.45);
  --fail-bg: rgba(156, 43, 26, 0.07);
  --fail-line: rgba(156, 43, 26, 0.40);

  /* AMENDED 2026-09-20, the day this file landed, on measurement rather than taste.
   * Appendix A's fallbacks were Georgia / Arial / Consolas, and they came in with the
   * appendix unexamined - §5 rules the type ROLE and SCALE, never the fallback chains.
   * Measured across the served surfaces: SEVEN of the eight (admin, index, profile,
   * reviewer_console, session, session_delivery, session_qc) already carried the richer
   * chains below; only editor.html, the newest console, carried Appendix A's. Since
   * Appendix A is retired training.css, keeping its chains would have encoded the minority
   * stack and silently downgraded seven surfaces from San Francisco to Arial as each one
   * converted - a regression nobody sees until a webfont fails to load, on a macOS target.
   * Promoting the majority chain makes the conversion a real DELETION for those seven. */
  --serif: "Newsreader", Georgia, "Times New Roman", serif;
  --sans: "IBM Plex Sans", -apple-system, BlinkMacSystemFont, sans-serif;
  --mono: "JetBrains Mono", "SF Mono", ui-monospace, Menlo, monospace;

  /* Section 8.3, THE ONE LITERAL EVERY SURFACE SHARES. rgba(243,239,230,0.86) appears
   * exactly once in all seven surfaces: the frosted topbar, hardcoded to the LIGHT --paper,
   * so under a dark theme every topbar on the platform stayed cream. Ruled 2026-08-20 that
   * the topbar follows; Rick chose a dedicated token over color-mix() on 2026-09-20.
   * The value is --paper at 86% alpha and the ALPHA IS THE POINT - it sits under
   * backdrop-filter: blur(14px), and a flat var(--paper) would lose the frost entirely. */
  --topbar-bg: rgba(243, 239, 230, 0.86);

  /* No console defines these three today. --focus arrives to replace the per-file hardcoded
   * focus ring (guide section 11.3). */
  --shadow: 0 18px 32px rgba(33, 22, 10, 0.08);
  --focus: 0 0 0 3px rgba(177, 68, 42, 0.28);
  --max-width: 1200px;
}

html[data-theme="dark"] {
  --paper: #171310;
  --paper-2: #1d1813;
  --card: #211b16;
  --card-2: #2a231c;

  --ink: #f8f2e7;
  --ink-2: #eee5d7;
  --ink-soft: #c1b5a2;
  --line: #43382c;
  --line-2: #5a4c3d;

  --accent: #d06a4b;
  --accent-soft: #f1b5a3;
  --accent-fill: #b65d42;  /* white on it is 4.53:1; as TEXT it is 3.78 and must not be used so */
  --pass: #8ea56f;
  --warn: #d0a156;
  --fail: #d87b67;

  /* Section 3.3, dark. Higher alpha than the light six because the dark grounds would
   * otherwise swallow them. */
  --pass-bg: rgba(142, 165, 111, 0.14);
  --pass-line: rgba(142, 165, 111, 0.45);
  --warn-bg: rgba(208, 161, 86, 0.14);
  --warn-line: rgba(208, 161, 86, 0.45);
  --fail-bg: rgba(216, 123, 103, 0.12);
  --fail-line: rgba(216, 123, 103, 0.45);

  /* Dark --paper (#171310) at the same 86%. */
  --topbar-bg: rgba(23, 19, 16, 0.86);

  --shadow: 0 22px 42px rgba(0, 0, 0, 0.4);
  --focus: 0 0 0 3px rgba(240, 181, 163, 0.35);
}

@media (prefers-color-scheme: dark) {
  html[data-theme-preference="system"] {
    --paper: #171310;
    --paper-2: #1d1813;
    --card: #211b16;
    --card-2: #2a231c;

    --ink: #f8f2e7;
    --ink-2: #eee5d7;
    --ink-soft: #c1b5a2;
    --line: #43382c;
    --line-2: #5a4c3d;

    --accent: #d06a4b;
    --accent-soft: #f1b5a3;
    --accent-fill: #b65d42;
    --pass: #8ea56f;
    --warn: #d0a156;
    --fail: #d87b67;

    --pass-bg: rgba(142, 165, 111, 0.14);
    --pass-line: rgba(142, 165, 111, 0.45);
    --warn-bg: rgba(208, 161, 86, 0.14);
    --warn-line: rgba(208, 161, 86, 0.45);
    --fail-bg: rgba(216, 123, 103, 0.12);
    --fail-line: rgba(216, 123, 103, 0.45);

    --topbar-bg: rgba(23, 19, 16, 0.86);

    --shadow: 0 22px 42px rgba(0, 0, 0, 0.4);
    --focus: 0 0 0 3px rgba(240, 181, 163, 0.35);
  }
}
