/* ahi-theme.css — ONE shared visual theme for every AHI Platform portal.
 *
 * The palette + typography of the public /crs estimator (Apple system look),
 * expressed as tokens so every page reads the SAME colours and type while keeping
 * its own content and structure. Link this FIRST in <head> (before a page's own
 * <style>), so page-specific rules can still override layout.
 *
 * Themes: light is the default (/crs). Dark is served three ways so it resolves in
 * every state — system dark (guarded so an explicit light choice wins), and both
 * data-theme="light"/"dark" for a hard toggle. The OPERATOR DESK opts into dark by
 * setting <html data-theme="dark"> (or <body data-theme="dark">) — same tokens as
 * public-dark, so the whole site stays one system while the desk stays a dark console.
 *
 * Token superset (so no page references a vanished name):
 *   core   — --bg --ink --ink2 --hair --card --accent --on-accent --good --bad --warn
 *   alias  — --muted (=ink2), --line (=hair)   [legal pages]
 *   desk   — --panel --sunk --dim --faint       [admin / genesis / review]
 */

/* ── light (default: the /crs palette) ─────────────────────────────────── */
:root{
  --bg:#fbfbfd; --ink:#1d1d1f; --ink2:#6e6e73; --hair:#d2d2d7; --card:#ffffff;
  --accent:#0071e3; --on-accent:#ffffff; --good:#1d7a3e; --bad:#c22e3a; --warn:#b25000;
  --muted:#6e6e73; --line:#d2d2d7;                       /* legal-page aliases */
  --panel:#ffffff; --sunk:#f5f5f7; --dim:#6e6e73; --faint:#86868b;   /* desk tokens (light) */
  color-scheme:light dark;
}
/* ── dark: system default (an explicit light choice still wins) ────────── */
@media (prefers-color-scheme:dark){
  :root:not([data-theme="light"]){
    --bg:#000000; --ink:#f5f5f7; --ink2:#86868b; --hair:#2c2c2e; --card:#1c1c1e;
    --accent:#2997ff; --on-accent:#ffffff; --good:#4cd07a; --bad:#ff6369; --warn:#ffb340;
    --muted:#86868b; --line:#2c2c2e;
    --panel:#1c1c1e; --sunk:#000000; --dim:#86868b; --faint:#6e6e73;
  }
}
/* ── explicit toggles win in both directions ───────────────────────────── */
:root[data-theme="light"]{
  --bg:#fbfbfd; --ink:#1d1d1f; --ink2:#6e6e73; --hair:#d2d2d7; --card:#ffffff;
  --accent:#0071e3; --on-accent:#ffffff; --good:#1d7a3e; --bad:#c22e3a; --warn:#b25000;
  --muted:#6e6e73; --line:#d2d2d7;
  --panel:#ffffff; --sunk:#f5f5f7; --dim:#6e6e73; --faint:#86868b;
}
:root[data-theme="dark"]{
  --bg:#000000; --ink:#f5f5f7; --ink2:#86868b; --hair:#2c2c2e; --card:#1c1c1e;
  --accent:#2997ff; --on-accent:#ffffff; --good:#4cd07a; --bad:#ff6369; --warn:#ffb340;
  --muted:#86868b; --line:#2c2c2e;
  --panel:#1c1c1e; --sunk:#000000; --dim:#86868b; --faint:#6e6e73;
}

/* ── base ──────────────────────────────────────────────────────────────── */
*{ box-sizing:border-box; }
@media (prefers-reduced-motion:reduce){ *{ animation:none!important; transition:none!important; } }
html{ -webkit-text-size-adjust:100%; }
body{
  margin:0;
  font-family:-apple-system,BlinkMacSystemFont,"SF Pro Display","SF Pro Text","Helvetica Neue",Helvetica,Arial,sans-serif;
  background:var(--bg); color:var(--ink);
  -webkit-font-smoothing:antialiased; -moz-osx-font-smoothing:grayscale;
  line-height:1.5;
}
/* every link uses the theme accent (WCAG AA in both themes) — never the browser default */
a{ color:var(--accent); }
:where(h1,h2,h3){ letter-spacing:-.02em; line-height:1.15; }
:where(img,svg,video){ max-width:100%; }
::selection{ background:color-mix(in srgb, var(--accent) 24%, transparent); }
:where(input,select,textarea,button){ font-family:inherit; }
:focus-visible{ outline:2px solid var(--accent); outline-offset:2px; }
