/* ==========================================================================
   Smmize — canonical colour tokens (single source of truth)
   Loaded first on every surface: landing, catalog, blog, FAQ, auth, dashboard,
   admin. Nothing else may define these variables; everything reads them.
   One palette: navy chrome, white canvas, one blue signal. Every text pair is
   measured — body >= 9:1, secondary >= 4.5:1, accent text >= 6:1, white on the
   signal fill 5.17:1.
   ========================================================================== */

:root {
  /* ---- surfaces (light) ---- */
  --smm-paper: #F4F7FB;          /* page */
  --smm-paper-deep: #E9EFF7;     /* stripe / inset */
  --smm-surface: #FFFFFF;        /* cards, inputs */
  --smm-surface-raise: #FFFFFF;  /* cards on cards */

  /* ---- text ---- */
  --smm-ink: #0D1B2E;            /* 16.1:1 on paper */
  --smm-ink-soft: #33445C;       /* 9.2:1 — body copy */
  --smm-ink-faint: #5D6E85;      /* 4.8:1 — labels, meta */

  /* ---- hairlines ---- */
  --smm-line: #E2E8F0;
  --smm-line-strong: #C9D5E3;

  /* ---- one signal blue ---- */
  --smm-signal: #2563EB;
  --smm-signal-deep: #1D4ED8;    /* 6.2:1 — links and small accent text */
  /* Text placed on a solid signal fill. White measures 5.17:1 on it. */
  --smm-on-accent: #FFFFFF;
  --smm-signal-ink: var(--smm-on-accent);
  /* Accent colour for TEXT: the deeper blue, so words never sit at 3.6:1. */
  --smm-accent: #1D4ED8;

  /* ---- state ---- */
  --smm-ok: #0B7A53;
  --smm-warn: #A25A00;
  --smm-bad: #B42318;
  --smm-info: #1D4ED8;

  /* ---- chrome ---- */
  --smm-ground: #0D1B2E;         /* always-dark surface: footer, readouts */
  --smm-bar: #0D1B2E;
  --smm-bar-text: #F4F7FB;
  --smm-shadow: 0 1px 2px rgba(13, 27, 46, 0.05), 0 4px 14px rgba(13, 27, 46, 0.07);
  --smm-shadow-lift: 0 2px 4px rgba(13, 27, 46, 0.06), 0 10px 26px rgba(13, 27, 46, 0.10);

  /* ---- geometry + type (unchanged, kept here with the palette) ---- */
  --smm-radius: 10px;
  --smm-radius-sm: 6px;
  --smm-font-display: 'Bricolage Grotesque', 'Archivo', sans-serif;
  --smm-font-body: 'Archivo', system-ui, sans-serif;
  --smm-font-mono: 'Martian Mono', ui-monospace, monospace;

  /* ---- legacy aliases: the landing stylesheet's older namespace ---- */
  --paper: var(--smm-paper);
  --paper-2: var(--smm-paper-deep);
  --ink: var(--smm-ink);
  --ink-2: var(--smm-ink-soft);
  --muted: var(--smm-ink-faint);
  --line: var(--smm-line);
  --line-strong: var(--smm-line-strong);
  --signal: var(--smm-signal);
  --signal-ink: var(--smm-on-accent);
  --signal-text: var(--smm-signal-deep);
  --ok: var(--smm-ok);
  --surface: var(--smm-surface);
  --ink-soft: var(--smm-ink-soft);
  --ink-faint: var(--smm-ink-faint);
  --warn: var(--smm-warn);
  --bad: var(--smm-bad);

  /* ---- inverse surfaces ----
     Some blocks are painted WITH the ink colour (key strips, code blocks,
     footers). Those keep the same look in both themes, so text on them must
     never use --smm-ink: that token flips to near-white in dark mode and the
     block turns into a white-on-white smear. These stay fixed. */
  --smm-inverse-bg: #0D1B2E;
  --smm-inverse-bg-raise: #16243A;
  --smm-inverse-ink: #EAF1FA;        /* 15.2:1 on the strip */
  --smm-inverse-ink-soft: #B9C7DA;   /* 10.1:1 */
  --smm-inverse-ink-faint: #8598B0;  /* 5.9:1  — labels, meta */
  --smm-inverse-accent: #93C5FD;     /* 9.6:1  — accent TEXT on the strip */
  --smm-inverse-line: #2E435F;
}

/* Night mode: the customer dashboard's one toggle. Deep navy ground, never
   pure #000; accents brighten because they now sit on dark ground. */
body.theme-dark {
  --smm-paper: #0B1220;
  --smm-paper-deep: #080E18;
  --smm-surface: #111C2E;
  --smm-surface-raise: #16243A;

  --smm-ink: #EAF1FA;            /* 16.5:1 on the dark page */
  --smm-ink-soft: #B9C7DA;       /* 10.9:1 */
  --smm-ink-faint: #8598B0;      /* 6.3:1 */

  --smm-line: #1E2E45;
  --smm-line-strong: #2E435F;

  --smm-signal: #3B82F6;
  --smm-signal-deep: #93C5FD;    /* 10.4:1 */
  --smm-on-accent: #08111F;      /* dark text on the bright fill, 5.14:1 */
  --smm-signal-ink: var(--smm-on-accent);
  --smm-accent: #93C5FD;         /* 10.4:1 on the dark page */

  --smm-ok: #3DD68C;
  --smm-warn: #F2B44C;
  --smm-bad: #F87171;
  --smm-info: #93C5FD;

  --smm-ground: #060B14;
  --smm-bar: #060B14;
  --smm-bar-text: #EAF1FA;
  --smm-shadow: 0 1px 2px rgba(0, 0, 0, 0.35), 0 6px 18px rgba(0, 0, 0, 0.4);
  --smm-shadow-lift: 0 2px 6px rgba(0, 0, 0, 0.45), 0 14px 32px rgba(0, 0, 0, 0.5);

  /* Legacy aliases, re-declared.
     `--ink: var(--smm-ink)` in :root substitutes the LIGHT value there and the
     result inherits down the tree as a plain colour, so a child that overrides
     --smm-ink cannot reach it. That froze every --paper/--ink consumer (all of
     landing-modern.css and the API docs) to the light palette while the page
     behind them went dark: 1.08:1 headings, 1.89:1 body copy. Redeclaring the
     whole alias block here makes each one re-resolve against the dark values. */
  --paper: var(--smm-paper);
  --paper-2: var(--smm-paper-deep);
  --ink: var(--smm-ink);
  --ink-2: var(--smm-ink-soft);
  --ink-soft: var(--smm-ink-soft);
  --ink-faint: var(--smm-ink-faint);
  --muted: var(--smm-ink-faint);
  --line: var(--smm-line);
  --line-strong: var(--smm-line-strong);
  --signal: var(--smm-signal);
  --signal-ink: var(--smm-on-accent);
  --signal-text: var(--smm-signal-deep);
  --surface: var(--smm-surface);
  --ok: var(--smm-ok);
  --warn: var(--smm-warn);
  --bad: var(--smm-bad);
}

/* Native controls + selection follow the palette instead of the browser default. */
:root { color-scheme: light; }
body.theme-dark { color-scheme: dark; }
::selection { background: rgba(37, 99, 235, 0.24); }
