/*
 * antihinged design tokens: the single source.
 *
 * Read top to bottom:
 *   Seeds    the only raw values in the system
 *   Papers   brick adjusted for use as a page background
 *   Roles    which colour plays which part; the ONLY thing a theme changes
 *   Derived  everything the site stylesheet is allowed to use
 *
 * site.css takes its colours, type sizes and spacing from here.
 * The /tokens/ page is generated by parsing this file.
 */
:root {
  /* @group Seeds | Four colours, plus one number each for type, space, corner and line. */
  --seed-char: oklch(0.25 0.006 270);
  --seed-mint: oklch(0.915 0.018 165);
  --seed-brick: oklch(0.52 0.16 32);
  --seed-butter: oklch(0.925 0.06 100);
  --seed-size: 1rem;
  --seed-ratio: 1.25;
  --seed-space: 0.25rem;
  --seed-radius: 0.25rem;
  --seed-line: 1px;

  /* @group Papers | Brick as a page background: the same hue, darkened a little so butter text passes contrast. */
  --paper-brick: color-mix(in oklab, var(--seed-brick) 90%, black);

  /* @group Roles | Themes reassign these and nothing else. */
  --paper: var(--seed-mint);
  --ink: var(--seed-char);
  --accent: var(--seed-brick);
  --second: var(--seed-butter);
  --second-ink: var(--seed-char);

  /* @group Colour | Mixed from the roles, so every theme gets its own set for free. Mixed in oklab so hues never drift. */
  --bg: var(--paper);
  --fg: var(--ink);
  --fg-muted: color-mix(in oklab, var(--ink) 78%, var(--paper));
  --rule: color-mix(in oklab, var(--ink) 26%, var(--paper));
  --rule-strong: var(--ink);

  /* @group Status | Project status markers. They keep their colour on every theme. */
  --status-active: var(--seed-brick);
  --status-simmering: var(--seed-butter);
  --status-dormant: var(--seed-mint);
  --status-shelved: var(--seed-char);

  /* @group Type | One size and one ratio; each step multiplies the one before. */
  --font-display: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --font-text: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --step--1: calc(var(--seed-size) / var(--seed-ratio));
  --step-0: var(--seed-size);
  --step-half: calc(var(--step-0) * sqrt(var(--seed-ratio)));
  --step-1: calc(var(--step-0) * var(--seed-ratio));
  --step-2: calc(var(--step-1) * var(--seed-ratio));
  --step-3: calc(var(--step-2) * var(--seed-ratio));
  --leading-tight: 1.05;
  --leading-text: 1.55;
  --tracking-caps: 0.05em;

  /* @group Space | Multiples of one unit. */
  --space-1: var(--seed-space);
  --space-2: calc(var(--seed-space) * 2);
  --space-3: calc(var(--seed-space) * 3);
  --space-4: calc(var(--seed-space) * 4);
  --space-5: calc(var(--seed-space) * 6);
  --space-6: calc(var(--seed-space) * 8);
  --space-7: calc(var(--seed-space) * 12);
  --space-8: calc(var(--seed-space) * 16);

  /* @group Shape | Corners, lines and widths. */
  --line: var(--seed-line);
  --line-heavy: calc(var(--seed-line) * 2);
  --radius: var(--seed-radius);
  --gutter: var(--space-4);
  --measure: 34rem;
  --column: 44rem;
  --page: 80rem;
}

/* Auto: mint in light, charcoal in dark. Stated twice so both the system setting and an explicit choice work. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: var(--seed-char);
    --ink: var(--seed-mint);
    --accent: color-mix(in oklab, var(--seed-brick) 58%, var(--seed-butter));
  }
}
:root[data-theme="dark"] {
  --paper: var(--seed-char);
  --ink: var(--seed-mint);
  --accent: color-mix(in oklab, var(--seed-brick) 58%, var(--seed-butter));
}

/* Explicit theme choices. Later than the above, so they win. The pages ship with data-paper="brick". */
:root[data-paper="mint"] {
  --paper: var(--seed-mint);
  --ink: var(--seed-char);
  --accent: var(--seed-brick);
}
:root[data-paper="char"] {
  --paper: var(--seed-char);
  --ink: var(--seed-mint);
  --accent: color-mix(in oklab, var(--seed-brick) 58%, var(--seed-butter));
}
:root[data-paper="brick"] {
  --paper: var(--paper-brick);
  --ink: var(--seed-butter);
  --accent: var(--seed-mint);
  --fg-muted: color-mix(in oklab, var(--ink) 88%, var(--paper));
  --rule: color-mix(in oklab, var(--ink) 40%, var(--paper));
}
:root[data-paper="butter"] {
  --paper: var(--seed-butter);
  --ink: var(--seed-char);
  --accent: var(--seed-brick);
  --second: var(--seed-mint);
}
