/* FireBuddy Night — default tokens and the fallback forever.
   Load order: tokens.css -> components.css -> /theme.css (district primitives) -> page extra_head.
   /theme.css only rewrites the PRIMITIVES below; aliases follow via var(). */
:root {
  color-scheme: dark;

  /* Primitives (written per district by palette.to_css) */
  --fb-canvas: #121417;
  --fb-chrome: #2B2E33;
  --fb-ink: #F4EDE4;
  --fb-muted: #9CA3AF;
  --fb-live: #C23B22;
  --fb-live-hot: #E85D04;
  --fb-live-hover: #E85D04;
  --fb-ready: #C9A227;
  --fb-print: #F4EDE4;
  --fb-on-primary: #121417;
  --fb-on-live: #FFFFFF;

  /* Bottom nav — FIXED. Never written by /theme.css; one definition, here only. */
  --fb-nav-home: #C9A227;
  --fb-nav-ops: #E85D04;
  --fb-nav-ops-text: #F98A4B; /* readable label on --fb-nav-chrome (>= 4.5:1) */
  --fb-nav-res: #F5A524;
  --fb-nav-tasks: #22D3EE;
  --fb-nav-more: #A78BFA;
  /* Home KPI tile accents (vault-era red/yellow/green/orange cards). Numbers sit on --fb-surface;
     each passes WCAG AA (4.5:1) there. */
  --fb-kpi-stations: #F87171;
  --fb-kpi-apparatus: #FBBF24;  /* v0.2 amber-400 */
  --fb-kpi-personnel: #34D399;  /* v0.2 emerald-400 */
  --fb-kpi-incidents: #FB923C;
  --fb-kpi-burns: #FDBA74;      /* v0.2 orange-300 */
  /* Map pin fills: saturated, same in light and dark (pins sit on the basemap, not the page). */
  --fb-pin-call: #FBBF24;
  --fb-pin-call-ink: #111418;
  --fb-nav-base: #121417;   /* well tint base (fixed, not --fb-canvas) */
  --fb-nav-edge: #1a1c20;   /* face border mix */
  --fb-nav-black: #000;     /* well border mix */
  --fb-nav-chrome: #2B2E33; /* v0.2 restore C: nav face (fixed, never district-themed) */

  /* Legacy module accent (unconverted pages) */
  --module-accent: var(--fb-live);
  --module-accent-hover: var(--fb-live-hot);

  /* Semantic aliases — components read only these */
  --fb-bg: var(--fb-canvas);
  /* v0.2 restore: cards sit darker than the chrome, like v0.2's zinc-900 (#18181B) on #121417. */
  --fb-surface: color-mix(in srgb, var(--fb-chrome) 35%, var(--fb-canvas));
  /* surface-2/-3 kept dark enough that muted text on them stays >= 4.5:1 (WCAG AA) on every preset */
  --fb-surface-2: color-mix(in srgb, var(--fb-chrome) 94%, var(--fb-ink));
  --fb-surface-3: color-mix(in srgb, var(--fb-chrome) 88%, var(--fb-ink));
  --fb-text: var(--fb-ink);
  --fb-text-muted: color-mix(in srgb, var(--fb-muted) 85%, var(--fb-ink));
  --fb-primary: var(--fb-live-hot);
  --fb-secondary: var(--fb-chrome);
  --fb-accent: #14B8A6;
  --fb-focus: var(--fb-accent);
  --fb-border: color-mix(in srgb, var(--fb-ink) 18%, transparent);
  --fb-danger: #FCA5A5;
  --fb-warning: #FBBF24;
  --fb-success: #4ADE80;
  --fb-info: #7DD3FC;
  /* District color used as TEXT (links, headings on legacy pages): lifted toward ink so it reads on dark and light */
  --fb-accent-text: color-mix(in srgb, var(--module-accent) 45%, var(--fb-ink));
  --fb-on-module: var(--fb-on-live);
  /* Filled status buttons carry white text: both >= 4.5:1 with #FFFFFF */
  --fb-success-fill: #15803D;
  --fb-info-fill: #1D4ED8;
  --fb-overlay: rgb(0 0 0 / 0.6);

  /* Shape */
  --fb-radius: 16px;
  --fb-tap-min: 48px;          /* v0.2 restore: back to the 48px floor (still >= WCAG 2.5.5 44px) */

  /* Spacing */
  --fb-space-1: 4px;
  --fb-space-2: 8px;
  --fb-space-3: 12px;
  --fb-space-4: 16px;
  --fb-space-5: 24px;
  --fb-space-6: 32px;
  --fb-space-7: 40px;
  --fb-space-8: 48px;

  /* Type — v0.2 restore: rem is 16px again (was 19px), body 17px like v0.2. */
  --fb-font-body: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --fb-font-heading: var(--fb-font-body);
  --fb-text-base-px: 16px;
  --fb-text-body-px: 17px;
  --fb-text-xs: 0.8rem;
  --fb-text-sm: 0.9rem;
  --fb-text-md: 1rem;
  --fb-text-lg: 1.3rem;
  --fb-text-xl: 1.75rem;
  --fb-text-2xl: 2.25rem;
}

html, body {
  background: var(--fb-canvas);
  color: var(--fb-ink);
}

.fb-wordmark { color: var(--fb-ready); }
.fb-live { color: var(--fb-live); }
.fb-ready { color: var(--fb-ready); }
.fb-chrome { background: var(--fb-chrome); }

/* v0.2 restore E: dark only — the light theme was removed. */
[data-theme="high-contrast"] {
  --fb-border: #FFFFFF;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}
