/* Smart Pacts design tokens — the COMPLETE token layer (A7 design system).
 * This file is the single source of truth for every visual primitive on the
 * site: color, type, spacing, radii, borders, shadows, z-layers, motion and
 * container widths. Components (site.css) and pages consume ONLY the semantic
 * tokens — change a value here and the whole site follows.
 * Consumers: import this file plus /fonts/fonts.css (public/fonts/).
 *
 * TWO SCHEMES, ONE FILE. Dark is the brand default (founder decision
 * 2026-07-12) and is what :root declares. Light (founder requirement
 * 2026-09-22) is the [data-theme="light"] override block at the bottom of
 * this file — it re-maps ONLY the semantic layer, never the raws, and it is
 * the only place a light value may live. The visitor picks the scheme with
 * the header toggle; /theme.js applies the choice before first paint.
 * prefers-color-scheme is deliberately NOT consulted: dark is served to
 * everyone until they choose otherwise. */

:root {
  /* ── raw palette — always reference through the semantic tokens below ── */
  --sp-black: #0b0d10;         /* deepest — terminal / sunken islands */
  --sp-ink-deep: #101216;      /* page base */
  --sp-ink: #16181d;           /* cards / panels / chrome */
  --sp-ink-2: #1f232b;         /* raised rows, code, disclaimers */
  --sp-ink-3: #282d37;         /* borders on ink */
  --sp-white: #ffffff;         /* light scheme: cards over paper */
  --sp-paper: #faf9f6;
  --sp-paper-dim: #f0eee9;
  --sp-mist: #e3e1db;
  --sp-slate: #5b6472;
  --sp-slate-bright: #949ca9;  /* secondary text — 7.0:1 on ink */
  --sp-violet: #6d28d9;        /* accent (light contexts) — 6.75:1 on paper */
  --sp-violet-deep: #5b21b6;
  --sp-violet-bright: #a78bfa; /* THE accent — 6.53:1 on ink */
  --sp-violet-glow: #c4b5fd;   /* accent hover */
  --sp-teal: #0e7569;          /* legacy accent, retained for reference */
  --sp-teal-bright: #2bb3a0;
  --sp-error: #b3261e;
  --sp-error-bright: #ea5c61;  /* 4.65:1 on ink-2 — #e5484d measured 4.02:1 on raised rows
                                  (found by check-theme.mjs, 2026-09-22) */
  --sp-amber: #7d4e00;         /* attention, light scheme: GitHub Primer's yellow-6 (its attention.fg #9a6700 measured
                                  4.20:1 on paper-dim raised rows — check-theme.mjs, 2026-11-08) */
  --sp-amber-bright: #d29922;  /* attention, dark scheme: GitHub Primer's attention.fg (dark). Both Primer values are
                                  recalled, not re-read from Primer's source [UNVERIFIED]; the contrast is measured */

  /* ── semantic color — dark, layered ink ladder ── */
  --color-text: var(--sp-paper);
  --color-text-secondary: var(--sp-slate-bright);
  --color-page: var(--sp-ink-deep);           /* body base under the washes */
  --color-surface: var(--sp-ink);             /* cards, panels, chrome */
  --color-surface-raised: var(--sp-ink-2);    /* kv rows, code, disclaimers */
  --color-surface-sunken: var(--sp-black);    /* terminal/code islands */
  --color-on-sunken: var(--sp-paper);
  --color-on-sunken-dim: var(--sp-slate-bright);
  --color-border: var(--sp-ink-3);
  --color-border-strong: var(--sp-slate);
  --color-accent: var(--sp-violet-bright);
  --color-accent-hover: var(--sp-violet-glow);
  --color-accent-soft: color-mix(in srgb, var(--sp-violet-bright) 12%, transparent);
  --color-on-accent: var(--sp-ink);
  --color-error: var(--sp-error-bright);
  --color-attention: var(--sp-amber-bright);  /* a caution that is not an error (badge.attention) */
  --color-ask: var(--sp-error-bright);        /* order book: offers to sell (asks) */
  --color-bid: var(--sp-teal-bright);         /* order book: offers to buy (bids) */
  --color-focus: var(--sp-violet-bright);
  --color-footer: var(--sp-black);            /* the global footer band; its text stays the
                                                 page's text tokens, so the light scheme gives
                                                 it a light band rather than an ink one */

  /* page background — the AURORA field (founder-picked, 2026-07-12):
     three violet aurora washes over deep ink, with a film-grain noise layer
     on top to kill gradient banding. All one token; body consumes it. */
  /* NOTE: these decorative SVGs are same-origin FILES (public/assets/), not
     data: URIs — the CSP's img-src allows 'self' but not data:. */
  --bg-noise: url('/assets/noise.svg');
  --bg-page:
    var(--bg-noise),
    radial-gradient(64rem 38rem at 80% -14rem,
      color-mix(in srgb, var(--sp-violet) 42%, transparent), transparent 60%),
    radial-gradient(46rem 32rem at -10rem 16rem,
      color-mix(in srgb, #4c1d95 38%, transparent), transparent 58%),
    radial-gradient(50rem 34rem at 55% 120rem,
      color-mix(in srgb, var(--sp-violet-bright) 10%, transparent), transparent 60%),
    var(--color-page);

  /* blueprint detail ink (corner ticks, annotations) */
  --tick-ink: color-mix(in srgb, var(--sp-violet-bright) 55%, transparent);
  /* single strand divider (braid language at rest) — sine strand + node */
  --strand-rule: url('/assets/strand.svg');
  /* hero braid (canvas #braid-hero, drawn by site-ui.ts, which reads these at
     draw time). Plain colors on purpose: canvas parses no var()/color-mix(). */
  --braid-strand-1: #6d28d9;
  --braid-strand-2: #a78bfa;
  --braid-strand-3: #c4b5fd;
  --braid-gap: #101216;             /* the under-pass stroke = the page base */
  --braid-glow: rgba(167, 139, 250, 0.5);
  --braid-node: #faf9f6;
  --braid-node-glow: rgba(196, 181, 253, 0.8);
  /* the ONE glass surface (homepage verify terminal): translucent ink fill + gradient ring */
  --glass-fill: color-mix(in srgb, var(--sp-black) 72%, transparent);
  --glass-ring: linear-gradient(160deg,
    color-mix(in srgb, var(--sp-violet-glow) 55%, transparent),
    color-mix(in srgb, var(--sp-violet) 16%, transparent) 45%,
    color-mix(in srgb, var(--sp-violet-glow) 32%, transparent));

  /* ── typography ── */
  --font-sans: "IBM Plex Sans", -apple-system, "Segoe UI", Roboto,
    "Helvetica Neue", Arial, sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, Consolas,
    "Liberation Mono", monospace;
  --weight-regular: 400;
  --weight-medium: 500;
  --weight-semibold: 600; /* heaviest weight in the kit — no 700 */

  /* type scale (px equivalents: 13 / 16 / 20 / 25 / 31 / 39 / 49) */
  --text-sm: 0.8125rem;
  --text-base: 1rem;
  --text-lg: 1.25rem;
  --text-xl: 1.5625rem;
  --text-2xl: 1.9375rem;
  --text-3xl: 2.4375rem;
  --text-4xl: 3.0625rem;       /* display — hero only */
  --leading-body: 1.6;
  --leading-heading: 1.25;
  --leading-tight: 1.1;        /* display headlines */
  --tracking-wide: 0.015em;    /* wordmark-style letter-space for labels/nav brand */
  --tracking-caps: 0.08em;     /* uppercase eyebrows / badges */

  /* ── spacing scale ── */
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.5rem;
  --space-6: 2rem;
  --space-7: 2.5rem;
  --space-8: 3rem;
  --space-9: 4rem;
  --space-10: 5rem;
  --space-11: 6rem;
  /* smallest height of a control that acts — connect, buy, send, vote, claim (DESIGN.md "Reach") */
  --tap-min: 2.75rem;
  --tap-min-small: 2rem;

  /* ── radii ── */
  --radius-sm: 4px;
  --radius-md: 6px;
  --radius-lg: 8px;
  --radius-xl: 12px;
  --radius-pill: 999px;

  /* ── borders ── */
  --border-w: 1px;
  --border-w-accent: 3px;      /* disclaimer / log left rails */

  /* ── shadows (lift on hover pairs with translateY) ── */
  --shadow-sm: 0 1px 2px rgb(0 0 0 / 0.4);
  --shadow-md: 0 2px 8px rgb(0 0 0 / 0.45);
  --shadow-lg: 0 10px 28px rgb(0 0 0 / 0.5);
  --shadow-glow: 0 0 32px color-mix(in srgb, var(--sp-violet-bright) 14%, transparent);

  /* ── z-layers ── */
  --z-banner: 30;
  --z-dock: 35;   /* docked activity log — above the banner, below nothing else */
  --z-nav: 20;
  --z-menu: 25;

  /* ── motion ── */
  --dur-fast: 150ms;
  --dur-base: 250ms;
  --dur-slow: 450ms;
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-in-out: cubic-bezier(0.45, 0, 0.25, 1);

  /* ── container widths ── */
  --container-sm: 46rem;       /* reading pages (event, guides, legal) */
  --container-md: 52rem;       /* app pages (gallery, portal) */
  --container-lg: 64rem;       /* homepage */
  --gutter: 1.25rem;
}

/* ── LIGHT SCHEME — the only override block, applied by /theme.js ──
 * Re-maps the semantic layer onto the light raws. Same ladder, inverted:
 * paper page, white cards, paper-dim raised rows. The SUNKEN surface stays
 * ink on purpose — terminal and code islands keep the brand's violet-on-ink
 * in both schemes. Contrast pairs are measured by scripts/check-theme.mjs
 * on every build (WCAG AA, 4.5:1 for text). */
:root[data-theme="light"] {
  --color-text: var(--sp-ink-deep);
  --color-text-secondary: var(--sp-slate);
  --color-page: var(--sp-paper);
  --color-surface: var(--sp-white);
  --color-surface-raised: var(--sp-paper-dim);
  --color-surface-sunken: var(--sp-black);
  --color-on-sunken: var(--sp-paper);
  --color-on-sunken-dim: var(--sp-slate-bright);
  --color-border: var(--sp-mist);
  --color-border-strong: var(--sp-slate);
  --color-accent: var(--sp-violet);
  --color-accent-hover: var(--sp-violet-deep);
  --color-accent-soft: color-mix(in srgb, var(--sp-violet) 10%, transparent);
  --color-on-accent: var(--sp-paper);
  --color-error: var(--sp-error);
  --color-attention: var(--sp-amber);
  --color-ask: var(--sp-error);
  --color-bid: var(--sp-teal);
  --color-focus: var(--sp-violet);
  --color-footer: var(--sp-mist);             /* 4.57:1 for secondary text, measured */

  /* aurora on paper: the same three washes, much fainter — lavender light
     over paper instead of violet glow over ink; the grain layer stays. */
  --bg-page:
    var(--bg-noise),
    radial-gradient(64rem 38rem at 80% -14rem,
      color-mix(in srgb, var(--sp-violet) 14%, transparent), transparent 60%),
    radial-gradient(46rem 32rem at -10rem 16rem,
      color-mix(in srgb, #4c1d95 10%, transparent), transparent 58%),
    radial-gradient(50rem 34rem at 55% 120rem,
      color-mix(in srgb, var(--sp-violet-bright) 12%, transparent), transparent 60%),
    var(--color-page);

  --tick-ink: color-mix(in srgb, var(--sp-violet) 45%, transparent);
  --strand-rule: url('/assets/strand-light.svg');
  --braid-strand-1: #4c1d95;
  --braid-strand-2: #6d28d9;
  --braid-strand-3: #a78bfa;
  --braid-gap: #faf9f6;
  --braid-glow: rgba(109, 40, 217, 0.25);
  --braid-node: #4c1d95;
  --braid-node-glow: rgba(167, 139, 250, 0.7);
  --glass-fill: color-mix(in srgb, var(--sp-black) 92%, transparent); /* 72% reads grey on paper */
  --glass-ring: linear-gradient(160deg,
    color-mix(in srgb, var(--sp-violet) 60%, transparent),
    color-mix(in srgb, var(--sp-violet-deep) 20%, transparent) 45%,
    color-mix(in srgb, var(--sp-violet) 35%, transparent));

  --shadow-sm: 0 1px 2px rgb(16 18 22 / 0.08);
  --shadow-md: 0 2px 8px rgb(16 18 22 / 0.10);
  --shadow-lg: 0 10px 28px rgb(16 18 22 / 0.14);
  --shadow-glow: 0 0 32px color-mix(in srgb, var(--sp-violet) 12%, transparent);
}
