/*
 * kwp design — layers 1 and 2. The parent identity.
 *
 * Ported unchanged from kwpledger-site/src/styles/tokens.css on 2026-08-14.
 * Values are byte-identical to the shipping site; this file is a relocation,
 * not a redesign. It is the known-good baseline every other file builds on.
 *
 * Contains ONLY tokens. No reset, no element styles, no utilities — those are
 * each consuming property's business, not a shared concern. @font-face lives
 * in fonts.css so a consumer can take the tokens without the files.
 *
 * Deliberately not derived from either YouTube channel's brand. The portal
 * needs an identity both channels can sit inside without either dominating.
 *
 * THREE LAYERS, AND THE RULE THAT MAKES THEM WORTH HAVING:
 *
 *   1. Palette — raw values, named for what they are (--teal-700). Here.
 *   2. Semantic — roles components consume (--accent, --surface, --fg). Here.
 *   3. Domain — app-specific meanings (--meal-breakfast, --macro-carbs).
 *      IN THE CONSUMING REPO, NEVER HERE.
 *
 * **Consumers reference layer 2 only. Each layer may reach exactly one layer
 * down.** A domain token maps onto a semantic or categorical token, never
 * past it to a raw palette value. The moment an app writes
 * `--meal-breakfast: var(--teal-700)`, the abstraction is dead and
 * re-theming means editing every consumer.
 *
 * That is what lets a future section drop in with its own colors by
 * remapping the semantic layer on one wrapper, without touching a component.
 *
 * NOTATION IS MIXED, ON PURPOSE. This file is hex; categorical.css is oklch().
 * The brand palette below was contrast-validated as hex and converting it
 * would carry rounding risk for no benefit. See docs/SPEC.md, "Notation".
 *
 * All text pairs below meet WCAG AA at their intended sizes. Verified by
 * `npm run verify`.
 */

:root {
  color-scheme: light dark;

  /* ---- 1. Palette — raw values. Do not use these in components. ---- */

  /* Warm neutrals — the light surface family */
  --paper-0: #ffffff;
  --paper-50: #fbfaf8;
  --sand-200: #e3e0da;
  --ink-900: #1a1917;
  --ink-500: #5c5a57;

  /* Teal — the thread. Both channels accent in teal (KPLS #4aa3ac,
     MPSAS #2f8079); the portal sits in the same family without copying
     either, which is what makes it read as the parent rather than a third
     sibling. OKLCH hue ~188; --teal-300 at chroma 0.091 is the most
     saturated color in the system and sets the ceiling everything else
     stays under. See docs/SPEC.md, "Stately, not neon". */
  --teal-800: #0a4a47;
  --teal-700: #0d5c58;
  --teal-300: #5fbdb4;
  --teal-200: #8ad8d0;

  /* Navy-slate — the dark surface family, hue ~206 */
  --navy-900: #0a1420;
  --navy-800: #10202f;
  --navy-600: #1e3245;
  --navy-200: #9aabbb;
  --navy-50: #e6ecf2;

  /* ---- 2. Semantic — what components use. Light is the default. ---- */
  --surface: var(--paper-50);
  --surface-card: var(--paper-0);
  --fg: var(--ink-900);
  --fg-muted: var(--ink-500);
  --accent: var(--teal-700);
  --accent-hover: var(--teal-800);
  --border: var(--sand-200);

  /* Type */
  /* Lora is variable, 400–700; --fw-display is the default heading weight. See fonts.css. */
  --font-display: 'Lora', Georgia, 'Iowan Old Style', 'Palatino Linotype', Palatino, serif;
  --font-body: 'Hanken Grotesk', system-ui, -apple-system, 'Segoe UI', Roboto, Helvetica, Arial,
    sans-serif;
  /* IBM Plex Mono is static Regular 400 only: set mono text at 400. See fonts.css. */
  --font-mono: 'IBM Plex Mono', ui-monospace, 'SF Mono', Menlo, Consolas, 'Liberation Mono',
    monospace;
  /* Kevin's handwriting. Rare on purpose: arrows and annotations, never running text.
     Static 400 and 700 only. See fonts.css and docs/handwriting-font.md. */
  --font-hand: 'kwp Handwriting', 'Segoe Print', 'Bradley Hand', cursive;
  --fw-display: 600;

  --step--1: clamp(0.83rem, 0.79rem + 0.19vw, 0.94rem);
  --step-0: clamp(1rem, 0.95rem + 0.24vw, 1.13rem);
  --step-1: clamp(1.2rem, 1.13rem + 0.36vw, 1.42rem);
  --step-2: clamp(1.44rem, 1.33rem + 0.55vw, 1.8rem);
  --step-3: clamp(1.73rem, 1.56rem + 0.83vw, 2.27rem);
  --step-4: clamp(2.07rem, 1.83rem + 1.22vw, 2.86rem);

  /* Spacing — a 4px-derived scale */
  --space-2xs: 0.5rem;
  --space-xs: 0.75rem;
  --space-s: 1rem;
  --space-m: 1.5rem;
  --space-l: 2.5rem;
  --space-xl: 4rem;
  --space-2xl: 6rem;

  --measure: 34rem;
  --page: 68rem;
}

/*
 * Dark mode remaps the semantic layer only — the palette above is unchanged.
 * Deep navy-slate rather than neutral black, from an analogous family around
 * hue 206 (#072A46), accent at the teal end of that family (#084541,
 * lightened to clear AA here). The source swatches were all ~15% lightness,
 * which makes them surfaces rather than accents: side by side they read as
 * four near-identical dark blues.
 *
 * This switch is USER PREFERENCE, and it is deliberately not the same switch
 * as brand identity. A future channel- or section-scoped block sets its own
 * fixed colors and must NOT invert with this — dark mode should never make
 * the portal silently wear KPLS's uniform, and light mode should never put
 * MPSAS cream on a page that isn't MPSAS.
 */
/*
 * ---- The toggle contract (v0.6.0) ----
 *
 * The dark register is authored TWICE, on purpose, and the two copies must
 * stay byte-identical in value. A media query answers to the operating system
 * and a button cannot override it, so a consumer with its own theme toggle
 * needs a selector to drive. A rule inside a media query and a rule outside
 * one cannot be the same rule, so there is no way to express this once.
 *
 *   :root:not([data-theme="light"])  inside the query — system preference,
 *                                    unless the page has explicitly opted out
 *   :root[data-theme="dark"]         outside it — the explicit choice
 *
 * A consumer that never sets data-theme is COMPLETELY UNAFFECTED: the media
 * query still governs and the :not() guard only matters once an explicit
 * light override exists.
 *
 * `npm run verify` gates the two copies against each other — same tokens, same
 * values — so drift is a build failure rather than a silent defect. That gate
 * is the reason this shape is safe to author. See SPEC.md §7.4 and §9.1.
 */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --surface: var(--navy-900);
    --surface-card: var(--navy-800);
    --fg: var(--navy-50);
    --fg-muted: var(--navy-200);
    --accent: var(--teal-300);
    --accent-hover: var(--teal-200);
    --border: var(--navy-600);
  }
}

/* The same register, reachable by an explicit choice. Identical by rule. */
:root[data-theme="dark"] {
  --surface: var(--navy-900);
  --surface-card: var(--navy-800);
  --fg: var(--navy-50);
  --fg-muted: var(--navy-200);
  --accent: var(--teal-300);
  --accent-hover: var(--teal-200);
  --border: var(--navy-600);
}

/*
 * `color-scheme: light dark` above tells the UA this page renders both, so it
 * picks form controls, scrollbars and the canvas from the SYSTEM preference.
 * An explicit choice has to pin it too, or a page toggled to dark on a light
 * OS gets dark tokens with light scrollbars and light date pickers.
 *
 * Separate from the token blocks above deliberately: this is a UA rendering
 * hint rather than a token, it is not part of the duplicated register, and
 * keeping it out of those blocks is what lets them stay identical.
 */
:root[data-theme="light"] {
  color-scheme: light;
}

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