/* Shared design tokens — single source of truth for the warm paper/ink
   palette and type stack used across the public landing page
   (css/styles.css), the gated admin/access/projects pages
   (server/views.js), and the CV variants (resume_plain/*.html).
   Served as a static file by nginx from every surface, gated or not,
   since CSS itself isn't sensitive (see nginx.conf's static-asset location).

   Previously these values were hand-copied into three places and drifted —
   a WCAG AA contrast fix to --muted-2 landed in styles.css but not the other
   two, which is why this file exists. Change a color here, once.

   --fill/--on-fill are a separate pair for solid UI fills (chips, buttons,
   the thick header rule), kept apart from --ink (strong text). Naively
   reusing --ink as a fill meant dark mode's inverted --ink turned every
   fill into a glaring near-white slab. In light mode --fill equals the old
   --ink value, so light mode is unchanged; in dark mode --fill is a quiet
   elevated warm gray instead of near-white. Consumers should reference
   fills as var(--fill, var(--ink)) / var(--on-fill, var(--on-ink)) so
   pages that predate this pair (or the CV documents, which override :root
   without defining --fill) still render correctly via the fallback. */
:root {
  --paper: #f0eee9;
  --surface: #f9f8f4;
  --ink: #211f1c;
  --heading: #1a1a18;
  --body: #33312d;
  --muted: #6b675f;
  --muted-2: #6e6a61; /* darkened from #8a867d — that failed WCAG AA (~3.4:1) on small text */
  --on-ink: #f4f1ea;
  --fill: #211f1c; /* = --ink in light mode: chip/button/rule fill color */
  --on-fill: #f4f1ea; /* = --on-ink in light mode: text/icon color on --fill */
  --rule: #d6d2c8;
  --rule-2: #e0dcd2;
  --accent: #c92a2a;

  --font-mono: 'IBM Plex Mono', ui-monospace, 'SF Mono', Menlo, monospace;
  --font-sans: 'Helvetica Neue', Helvetica, Arial, sans-serif;
}

/* Dark variant — a designed dark theme, not a naive inversion. --paper and
   --surface are lifted apart (not just relabeled) so cards read as
   elevated, not flat; --fill is a quiet elevated warm gray "pill" for
   chips/buttons/rules rather than the near-white slab a straight --ink
   inversion produces (that glare was the original bug — see --fill's
   definition above). --accent is a less saturated, slightly deeper red
   than the earlier #ff6b5b so it doesn't compete as a UI-chrome color;
   it's meant for links/hover and the single primary CTA per view, not
   for large fills.

   All text-bearing pairs verified >=4.5:1 (WCAG AA, small text) against
   both --paper and --surface: --muted/--muted-2 6.2–7.0:1, --body
   9.9–11.2:1, --accent 5.5–6.2:1, --heading 14.6–16.5:1, --ink 14.8:1.
   --on-fill on --fill: 11.1:1. */
@media (prefers-color-scheme: dark) {
  :root {
    --paper: #14130f;
    --surface: #221f19;
    --ink: #e8e5dd;
    --heading: #f4f1ea;
    --body: #cdc9bf;
    --muted: #a49f93;
    --muted-2: #a49f93;
    --on-ink: #1a1a18;
    --fill: #35322b;
    --on-fill: #f2efe8;
    --rule: #38352d;
    --rule-2: #2a2822;
    --accent: #f5675a;
  }
}

/* Manual theme override via the header toggle (persisted in localStorage,
   applied to <html data-theme> pre-paint by js/theme-init.js — js/theme-toggle.js
   just handles the click). These win over the prefers-color-scheme block above
   by specificity (0,2,0 vs 0,1,0) without raising the *unqualified* :root's
   specificity — important because the CV documents (resume_plain/*.html) link
   this file and then override :root themselves to force a light print palette
   regardless of OS theme. They never set data-theme, so neither block below
   ever matches a CV. Do not rewrite the media query above as
   :root:not([data-theme="light"]) — that would raise its specificity above the
   CV's plain :root and break that override.
   --data-theme="light" re-asserts light so it can beat the media query on a
   dark-OS machine. Values mirror the base :root and the dark block above; keep
   all three in sync. */
:root[data-theme="dark"] {
  --paper: #14130f;
  --surface: #221f19;
  --ink: #e8e5dd;
  --heading: #f4f1ea;
  --body: #cdc9bf;
  --muted: #a49f93;
  --muted-2: #a49f93;
  --on-ink: #1a1a18;
  --fill: #35322b;
  --on-fill: #f2efe8;
  --rule: #38352d;
  --rule-2: #2a2822;
  --accent: #f5675a;
}

:root[data-theme="light"] {
  --paper: #f0eee9;
  --surface: #f9f8f4;
  --ink: #211f1c;
  --heading: #1a1a18;
  --body: #33312d;
  --muted: #6b675f;
  --muted-2: #6e6a61;
  --on-ink: #f4f1ea;
  --fill: #211f1c;
  --on-fill: #f4f1ea;
  --rule: #d6d2c8;
  --rule-2: #e0dcd2;
  --accent: #c92a2a;
}
