/* =====================================================================
   Design tokens — Option 2 UI.
   Every colour, size, radius and shadow used by the app lives here.
   Other CSS/JS files must only reference these variables.
   Theme: light by default; dark via the OS setting, or forced with
   <html data-theme="light|dark"> (set by the top-bar toggle).
   ===================================================================== */

:root {
  color-scheme: light;

  /* ---- Typography ---- */
  --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;

  --fs-display: 30px;   --fw-display: 700; --lh-display: 1.15; --ls-display: -0.03em;
  --fs-h1: 24px;        --fw-h1: 700;      --lh-h1: 1.20;      --ls-h1: -0.02em;
  --fs-h2: 18px;        --fw-h2: 600;      --lh-h2: 1.30;      --ls-h2: -0.015em;
  --fs-h3: 15px;        --fw-h3: 600;      --lh-h3: 1.35;      --ls-h3: -0.01em;
  --fs-body: 14px;      --fw-body: 400;    --lh-body: 1.50;    --ls-body: 0;
  --fs-button: 14px;    --fw-button: 600;  --lh-button: 1.20;  --ls-button: 0.005em;
  --fs-caption: 12px;   --fw-caption: 500; --lh-caption: 1.40; --ls-caption: 0.01em;
  --fs-micro: 11px;     --fw-micro: 600;   --lh-micro: 1.30;   --ls-micro: 0.06em;
  --fs-input: 16px;     /* 16px keeps phones from zooming into form fields */
  --fs-count-hero: 56px; /* damage count number */

  /* ---- Geometry ---- */
  --pad-screen: 16px;
  --pad-card: 16px;
  --gap-card: 12px;
  --gap-section: 28px;
  --r-card: 16px;
  --r-control: 12px;
  --r-icon: 10px;
  --r-pill: 9999px;
  --tap: 48px;
  --nav-h: 64px;
  --topbar-h: 60px;
  --sidebar-w: 240px;
  --content-max: 1120px;
  --hairline: 1px;

  /* ---- Surfaces & text (light) ---- */
  --bg: #F4F6F8;
  --surface: #FFFFFF;
  --surface-2: #EDF1F5;
  --border: #E2E8F0;
  --input-border: #CBD5E1;
  --focus: #1D4ED8;
  --text: #111827;
  --text-2: #4B5563;
  --text-3: #9CA3AF;

  /* ---- Brand ---- */
  --brand: #1D4ED8;
  --brand-hover: #1E40AF;
  --accent-tint: #EFF6FF;
  --accent-border: #BFDBFE;
  --on-brand: #FFFFFF;
  /* brand split by use, so both stay readable (WCAG AA 4.5:1) in each theme */
  --brand-fill: #1D4ED8;        /* solid backgrounds carrying white text */
  --brand-fill-hover: #1E40AF;
  --brand-text: #1D4ED8;        /* blue text, badges, links */

  /* ---- Status (text / tint) ---- */
  --success: #047857;  --success-bg: #ECFDF5;
  --warning: #B45309;  --warning-bg: #FFFBEB;
  --error: #B91C1C;    --error-bg: #FEF2F2;

  /* ---- Elevation ---- */
  --shadow-card: 0 1px 2px rgba(17, 24, 39, 0.04), 0 4px 12px rgba(17, 24, 39, 0.03);
  --shadow-float: 0 4px 16px rgba(17, 24, 39, 0.12);

  /* ---- Overlays ---- */
  --toast-bg: #111827;
  --toast-text: #FFFFFF;
  --scrim-hover: rgba(17, 24, 39, 0.04);

  /* ---- Charts ---- */
  --chart-1: var(--brand);       /* main series */
  --chart-1-hover: var(--brand-hover);
  --chart-2: #94A3B8;            /* secondary series / de-emphasised bars */
  --chart-3: #CBD5E1;
  --chart-area: rgba(29, 78, 216, 0.08);
  --chart-text: var(--text-2);
  --chart-grid: var(--border);
  --chart-tooltip-bg: #111827;
  --chart-tooltip-text: #FFFFFF;
}

/* ---- Dark palette (shared by the OS-preference and forced-dark blocks) ---- */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0D1117;
    --surface: #161B22;
    --surface-2: #21262D;
    --border: #30363D;
    --input-border: #30363D;
    --focus: #3B82F6;
    --text: #F3F4F6;
    --text-2: #9CA3AF;
    --text-3: #6B7280;
    --brand: #3B82F6;
    --brand-hover: #2563EB;
    --brand-fill: #2563EB;        /* white text on it: 5.2:1 */
    --brand-fill-hover: #1D4ED8;
    --brand-text: #60A5FA;        /* on dark surfaces and blue tints: 6-7:1 */
    --accent-tint: rgba(59, 130, 246, 0.14);
    --accent-border: rgba(59, 130, 246, 0.30);
    --on-brand: #FFFFFF;
    --success: #34D399;  --success-bg: rgba(52, 211, 153, 0.14);
    --warning: #FBBF24;  --warning-bg: rgba(251, 191, 36, 0.14);
    --error: #F87171;    --error-bg: rgba(248, 113, 113, 0.14);
    --shadow-card: none;
    --shadow-float: 0 4px 16px rgba(0, 0, 0, 0.5);
    --toast-bg: #F3F4F6;
    --toast-text: #0D1117;
    --scrim-hover: rgba(255, 255, 255, 0.04);
    --chart-2: #6B7280;
    --chart-3: #3A424D;
    --chart-area: rgba(59, 130, 246, 0.14);
    --chart-tooltip-bg: #F3F4F6;
    --chart-tooltip-text: #0D1117;
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0D1117;
  --surface: #161B22;
  --surface-2: #21262D;
  --border: #30363D;
  --input-border: #30363D;
  --focus: #3B82F6;
  --text: #F3F4F6;
  --text-2: #9CA3AF;
  --text-3: #6B7280;
  --brand: #3B82F6;
  --brand-hover: #2563EB;
  --brand-fill: #2563EB;
  --brand-fill-hover: #1D4ED8;
  --brand-text: #60A5FA;
  --accent-tint: rgba(59, 130, 246, 0.14);
  --accent-border: rgba(59, 130, 246, 0.30);
  --on-brand: #FFFFFF;
  --success: #34D399;  --success-bg: rgba(52, 211, 153, 0.14);
  --warning: #FBBF24;  --warning-bg: rgba(251, 191, 36, 0.14);
  --error: #F87171;    --error-bg: rgba(248, 113, 113, 0.14);
  --shadow-card: none;
  --shadow-float: 0 4px 16px rgba(0, 0, 0, 0.5);
  --toast-bg: #F3F4F6;
  --toast-text: #0D1117;
  --scrim-hover: rgba(255, 255, 255, 0.04);
  --chart-2: #6B7280;
  --chart-3: #3A424D;
  --chart-area: rgba(59, 130, 246, 0.14);
  --chart-tooltip-bg: #F3F4F6;
  --chart-tooltip-text: #0D1117;
}

@media (min-width: 600px) {
  :root { --pad-screen: 20px; }
}
