/* ENKI-DESIGN-TOKENS-20261106 (DESIGN-SYSTEM-A1, quality-bar track A).
 * The SEMANTIC layer: --ds-* names that components and migrated modules use. It sits on top of enki-tokens.css
 * (the primitives, loaded first) and aliases its live values, so dark is pixel-identical to today; light is new
 * and only applies under <html data-theme="light"> (nothing sets that yet, so this file changes no live pixel).
 *   Types   two families, six sizes, 11px floor        Space   4/8-pt scale
 *   Colour  dark + light, accent family, status        Elev    three levels (border + fill first, shadow last)
 *   Motion  150 / 250 / 400 ms + ONE spring            State   hover / focus / active / disabled
 *   Phone   density rules under max-width:560px or a coarse pointer
 * Reference: DESIGN-SYSTEM.md. Acceptance surface: (ENKI gallery, not shipped here).
 * Undo: delete the two registry rows 'design-tokens' + 'components' in enki-module-gate.js.
 */
:root {
  /* ---- TYPE · two families, six sizes ------------------------------------------------ */
  --ds-ff-sans: var(--font-sans, system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif);
  --ds-ff-mono: var(--font-mono, ui-monospace, "SF Mono", Menlo, Consolas, monospace);
  --ds-t1: 11px;   /* label / caption   (mono, uppercase, tracked) */
  --ds-t2: 12.5px; /* secondary / dense table body */
  --ds-t3: 14px;   /* body */
  --ds-t4: 18px;   /* section title */
  --ds-t5: 22px;   /* page title */
  --ds-t6: 28px;   /* display / big number */
  --ds-lh-tight: 1.25;
  --ds-lh-body: 1.55;
  --ds-ls-label: .12em;
  --ds-w-reg: 400; --ds-w-med: 600; --ds-w-bold: 700;

  /* ---- SPACE · 4/8-pt ---------------------------------------------------------------- */
  --ds-sp-1: 4px;  --ds-sp-2: 8px;  --ds-sp-3: 12px; --ds-sp-4: 16px;
  --ds-sp-5: 24px; --ds-sp-6: 32px; --ds-sp-7: 48px; --ds-sp-8: 64px;

  /* ---- RADII ------------------------------------------------------------------------- */
  --ds-r-sm: 6px; --ds-r-md: 10px; --ds-r-lg: 14px; --ds-r-pill: 999px;

  /* ---- COLOUR · dark (default). Aliases of the live palette, so nothing shifts ------------ */
  --ds-bg:        var(--bg, #04090f);
  --ds-surface-1: var(--panel, rgba(8, 20, 30, .42));      /* cards, rows */
  --ds-surface-2: var(--panel-2, rgba(10, 26, 38, .60));   /* hover, raised */
  --ds-surface-3: var(--panel2, rgba(8, 32, 46, .78));     /* drawer, modal, toast */
  --ds-overlay:   rgba(1, 7, 13, .62);
  --ds-line:      var(--line, rgba(120, 200, 210, .17));
  --ds-line-hi:   var(--line-hi, rgba(120, 200, 210, .36));
  --ds-text:      var(--text, #d8eef2);
  --ds-text-dim:  var(--dim, #7fb2ba);
  --ds-text-faint:var(--faint, #6d939b);
  --ds-on-accent: #031318;
  /* accent family: primary cyan, teal for "live/ok-ish", soft for secondary emphasis */
  --ds-accent:      var(--acc, #4be8ff);   --ds-accent-rgb: var(--acc-rgb, 75, 232, 255);
  --ds-accent-2:    var(--acc2, #0fd9b4);
  --ds-accent-soft: var(--acc-soft, #8fd3ff);
  --ds-accent-bg:   rgba(var(--ds-accent-rgb), .12);
  --ds-gold:        var(--gold, #d9b45b);  /* RESERVED: money / approval / reaches Sir */
  --ds-ok:   var(--ok, #3ddc97);   --ds-warn: var(--warn, #ffc857);   --ds-bad: var(--bad, #ff5d5d);
  --ds-info: var(--acc-soft, #8fd3ff);

  /* ---- ELEVATION · 3 levels ---------------------------------------------------------- */
  --ds-elev-1: 0 0 0 1px var(--ds-line);                                              /* flat: border only */
  --ds-elev-2: 0 0 0 1px var(--ds-line-hi), 0 3px 14px rgba(0, 0, 0, .38);            /* raised: drawer, menu */
  --ds-elev-3: 0 0 0 1px var(--ds-line-hi), 0 14px 40px rgba(1, 8, 14, .62);          /* overlay: modal, toast */

  /* ---- MOTION · 150 / 250 / 400 and one spring ------------------------------------------ */
  --ds-m1: 150ms; --ds-m2: 250ms; --ds-m3: 400ms;
  --ds-ease: cubic-bezier(.2, .7, .3, 1);
  --ds-spring: cubic-bezier(.34, 1.45, .64, 1);   /* the one spring: overshoots ~4%, used for drawer/modal/toast entry only */

  /* ---- STATE · how a control looks, once, for everyone -------------------------------- */
  --ds-hover-bg:    rgba(var(--ds-accent-rgb), .08);
  --ds-active-bg:   rgba(var(--ds-accent-rgb), .16);
  --ds-selected-bg: rgba(var(--ds-accent-rgb), .12);
  --ds-disabled-op: .45;
  --ds-focus-ring:  0 0 0 2px var(--ds-bg), 0 0 0 4px var(--ds-accent);

  /* ---- CONTROL SIZE ------------------------------------------------------------------ */
  --ds-ctl:   36px;    /* desktop control height */
  --ds-touch: 44px;    /* the floor under any finger */
  --ds-pad-card: var(--ds-sp-4);
  --ds-gap: var(--ds-sp-3);
}

/* ---- LIGHT · opt-in via <html data-theme="light">. Accent family re-derived for 4.5:1 on white surfaces,
   never the dark accent reused (a brand's state colour is not a free light variant of itself). ---------- */
html[data-theme="light"] {
  color-scheme: light;
  --ds-bg:        #f4f8fa;
  --ds-surface-1: #ffffff;
  --ds-surface-2: #eef4f7;
  --ds-surface-3: #ffffff;
  --ds-overlay:   rgba(10, 30, 40, .42);
  --ds-line:      rgba(10, 60, 80, .16);
  --ds-line-hi:   rgba(10, 60, 80, .34);
  --ds-text:      #0b2530;
  --ds-text-dim:  #3d5e6b;
  --ds-text-faint:#56747f;
  --ds-on-accent: #ffffff;
  --ds-accent:      #006f87;   --ds-accent-rgb: 0, 111, 135;
  --ds-accent-2:    #00796b;
  --ds-accent-soft: #1565a8;
  --ds-gold:        #8a6500;
  --ds-ok:   #12754a;   --ds-warn: #8a5a00;   --ds-bad: #b3261e;
  --ds-info: #1565a8;
  --ds-elev-2: 0 0 0 1px var(--ds-line-hi), 0 3px 14px rgba(10, 40, 55, .14);
  --ds-elev-3: 0 0 0 1px var(--ds-line-hi), 0 14px 40px rgba(10, 40, 55, .24);
}

/* ---- PHONE DENSITY · one rule set: touch floor, tighter cards, one-column grids ---------------- */
@media (max-width: 560px), (pointer: coarse) {
  :root {
    --ds-ctl: var(--ds-touch);
    --ds-pad-card: var(--ds-sp-3);
    --ds-gap: var(--ds-sp-2);
  }
}

/* ---- MOTION BUDGET · same switches as enki-tokens.css: LIGHT perf mode and reduced motion run instantly ---- */
html[data-perf="light"], html[data-perf-rm="1"] { --ds-m1: 0ms; --ds-m2: 0ms; --ds-m3: 0ms; }
@media (prefers-reduced-motion: reduce) { :root { --ds-m1: 0ms; --ds-m2: 0ms; --ds-m3: 0ms; } }
@media (prefers-contrast: more) {
  :root { --ds-line: rgba(150, 220, 230, .38); --ds-line-hi: rgba(150, 220, 230, .6); --ds-text-dim: #b9dde4; }
  html[data-theme="light"] { --ds-line: rgba(0, 40, 60, .5); --ds-line-hi: rgba(0, 40, 60, .75); --ds-text-dim: #1d3f4c; }
}
