/* ═══════════════════════════════════════════════════════════════════════════
   DSOC Situational Awareness — Design tokens
   ───────────────────────────────────────────────────────────────────────────
   TWO COLOR SYSTEMS, DELIBERATELY SEPARATE:

   1. CHROME (this file) — panel surfaces, text, borders, HUD, modal frames.
      Flips with the active theme.

   2. METEOROLOGICAL ENCODINGS (js/map/spc.js, js/map/alerts.js,
      js/map/stations.js) — SPC categorical/probability fills, NWS alert
      polygon colors, WBGT/temperature scales. These are STANDARDIZED PRODUCTS
      and are identical in both themes. Never tokenize them; recoloring them
      for light mode makes the map read wrong.

   Theme resolution order (see js/theme.js):
      :root                        -> complete LIGHT palette (the base)
      prefers-color-scheme: dark   -> dark, only when no explicit choice
      [data-theme="dark"|"light"]  -> explicit toggle, wins in both directions

   Every token has its value defined on bare :root. Nothing is defined ONLY
   inside a media query or attribute block.
   ═══════════════════════════════════════════════════════════════════════════ */

:root {
  color-scheme: light;

  /* ── Type ────────────────────────────────────────────────────────────────
     Verbatim from people.wku.edu/joshua.durkee/dsoc/sitedev/css/style.css.
     That site loads no webfont — it expects Neue Haas Grotesk to be installed
     and otherwise falls back to Helvetica — so this dashboard does the same
     rather than pulling a different face off a CDN. --font-mono is the display
     face there too, not a true monospace; numeric columns here get
     font-variant-numeric: tabular-nums instead, which keeps digits aligned
     without introducing a typeface the brand does not use. */
  --font-display: "Neue Haas Grotesk Display Pro", "neue-haas-grotesk-display", "Helvetica Neue", Helvetica, Arial, sans-serif;
  --font-body:    "Neue Haas Grotesk Text Pro", "neue-haas-grotesk-text", "Helvetica Neue", Helvetica, Arial, sans-serif;
  --font-mono:    "Neue Haas Grotesk Display Pro", "neue-haas-grotesk-display", "Helvetica Neue", Helvetica, Arial, sans-serif;

  /* ── Brand greys (color-branding.txt / DSOC site :root) ──────────────── */
  --brand-red:   #be141b;
  --brand-black: #000000;
  --ink:         #222222;
  --carbon:      #333333;
  --gray-mid:    #555555;
  --gray-muted:  #777777;
  --gray-line:   #cccccc;
  --gray-bg:     #efefef;
  --brand-white: #ffffff;

  /* ── Surfaces ── */
  --bg:             #efefef;   /* gray-bg */
  --surface:        #ffffff;
  --raised:         #ffffff;
  --sunken:         rgba(0, 0, 0, 0.05);
  --map-bg:         #efefef;

  /* ── Glassy floating overlays (HUD, legend, time panel, carousels) ── */
  --overlay:        rgba(255, 255, 255, 0.90);
  --overlay-strong: rgba(255, 255, 255, 0.95);
  --overlay-shadow: 0 8px 32px rgba(0, 0, 0, 0.16);
  --scrim:          rgba(0, 0, 0, 0.45);

  /* ── Lines ── */
  --border:         rgba(15, 23, 42, 0.10);
  --border-strong:  rgba(15, 23, 42, 0.18);
  --accent-line:    rgba(190, 20, 27, 0.28);  /* sidebar edge, section rules */

  /* ── Type ── */
  --text:           #222222;   /* ink */
  --muted:          #777777;   /* gray-muted */
  --muted2:         #555555;   /* gray-mid */
  --faint:          rgba(34, 34, 34, 0.62);
  --on-accent:      #ffffff;   /* text sitting on an accent fill */

  /* ── Brand + status ── */
  --accent:         #be141b;   /* DSOC red */
  --accent-hover:   #9a1016;
  --accent-soft:    rgba(190, 20, 27, 0.10);
  --accent-glow:    rgba(190, 20, 27, 0.18);
  --amber:          #b45309;
  --blue:           #1d4ed8;
  --cyan:           #0e7490;
  --green:          #15803d;

  /* ── Focus ── */
  --focus:          #1d4ed8;
  --focus-ring:     0 0 0 2px var(--surface), 0 0 0 4px var(--focus);

  /* ── Metrics ── */
  --sidebar-w:      340px;

  /* Legacy aliases — kept so any stray rule still resolves.
     Prefer the names above in new code. */
  --bg2:            var(--surface);
  --bg3:            var(--raised);
  --border2:        var(--border-strong);
  --red:            var(--accent);
  --red2:           var(--accent);
}

/* ── DARK ─────────────────────────────────────────────────────────────────
   Applies when the OS asks for dark AND the user has not chosen light. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;

    --bg:             #000000;   /* brand black, as the site header */
    --surface:        #111111;
    --raised:         #222222;   /* ink */
    --sunken:         rgba(0, 0, 0, 0.35);
    --map-bg:         #000000;

    --overlay:        rgba(0, 0, 0, 0.88);
    --overlay-strong: rgba(0, 0, 0, 0.94);
    --overlay-shadow: 0 8px 32px rgba(0, 0, 0, 0.60);
    --scrim:          rgba(0, 0, 0, 0.62);

    --border:         rgba(255, 255, 255, 0.10);
    --border-strong:  #333333;   /* carbon */
    --accent-line:    rgba(190, 20, 27, 0.35);

    --text:           #efefef;   /* gray-bg, inverted */
    --muted:          #777777;   /* gray-muted holds in both themes */
    --muted2:         #cccccc;   /* gray-line */
    --faint:          rgba(239, 239, 239, 0.70);
    --on-accent:      #ffffff;

    --accent:         #be141b;
    --accent-hover:   #d9242c;
    --accent-soft:    rgba(190, 20, 27, 0.15);
    --accent-glow:    rgba(220, 38, 38, 0.10);
    --amber:          #f59e0b;
    --blue:           #3b82f6;
    --cyan:           #06b6d4;
    --green:          #39ff14;

    --focus:          #60a5fa;
  }
}

/* ── Explicit DARK (toggle beats the OS) ── */
:root[data-theme="dark"] {
  color-scheme: dark;

    --bg:             #000000;   /* brand black, as the site header */
  --surface:        #111111;
  --raised:         #222222;   /* ink */
  --sunken:         rgba(0, 0, 0, 0.35);
  --map-bg:         #000000;

  --overlay:        rgba(0, 0, 0, 0.88);
  --overlay-strong: rgba(0, 0, 0, 0.94);
  --overlay-shadow: 0 8px 32px rgba(0, 0, 0, 0.60);
  --scrim:          rgba(0, 0, 0, 0.62);

  --border:         rgba(255, 255, 255, 0.10);
  --border-strong:  #333333;   /* carbon */
  --accent-line:    rgba(190, 20, 27, 0.35);

  --text:           #efefef;   /* gray-bg, inverted */
  --muted:          #777777;   /* gray-muted holds in both themes */
  --muted2:         #cccccc;   /* gray-line */
  --faint:          rgba(239, 239, 239, 0.70);
  --on-accent:      #ffffff;

  --accent:         #be141b;
  --accent-hover:   #d9242c;
  --accent-soft:    rgba(190, 20, 27, 0.15);
  --accent-glow:    rgba(220, 38, 38, 0.10);
  --amber:          #f59e0b;
  --blue:           #3b82f6;
  --cyan:           #06b6d4;
  --green:          #39ff14;

  --focus:          #60a5fa;
}

/* ── Explicit LIGHT (toggle beats the OS) ──
   Same values as bare :root; present so light wins under a dark OS. */
:root[data-theme="light"] {
  color-scheme: light;

  --bg:             #eef1f6;
  --surface:        #f8fafc;
  --raised:         #ffffff;
  --sunken:         rgba(15, 23, 42, 0.05);
  --map-bg:         #e8ecf2;

  --overlay:        rgba(255, 255, 255, 0.90);
  --overlay-strong: rgba(255, 255, 255, 0.95);
  --overlay-shadow: 0 8px 32px rgba(0, 0, 0, 0.16);
  --scrim:          rgba(0, 0, 0, 0.45);

  --border:         rgba(15, 23, 42, 0.10);
  --border-strong:  rgba(15, 23, 42, 0.18);
  --accent-line:    rgba(190, 20, 27, 0.28);

  --text:           #222222;   /* ink */
  --muted:          #777777;   /* gray-muted */
  --muted2:         #555555;   /* gray-mid */
  --faint:          rgba(34, 34, 34, 0.62);
  --on-accent:      #ffffff;

  --accent:         #be141b;
  --accent-hover:   #9a1016;
  --accent-soft:    rgba(190, 20, 27, 0.10);
  --accent-glow:    rgba(190, 20, 27, 0.18);
  --amber:          #b45309;
  --blue:           #1d4ed8;
  --cyan:           #0e7490;
  --green:          #15803d;

  --focus:          #1d4ed8;
}
