/*
 * internal-quoting design tokens and self-hosted fonts.
 * Dark is the default theme: :root carries the dark palette and
 * [data-theme="light"] is the remap. Components consume semantic tokens only.
 */

/* ---------- Fonts (self-hosted; no CDN) ---------- */

@font-face {
  font-family: "Montserrat";
  src: url("../fonts/montserrat-latin.woff2") format("woff2");
  font-weight: 400 800;
  font-style: normal;
  font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA,
    U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193,
    U+2212, U+2215, U+FEFF, U+FFFD;
}

/* ---------- Tokens: dark base ---------- */

:root {
  color-scheme: dark;

  /* Foundation */
  --color-canvas: #101216;
  --color-surface: #181b20;
  --color-surface-subtle: #1d2026;
  --color-surface-sunken: #23262c;
  --color-border: #2a2e36;
  --color-border-strong: #6b7280;
  --color-text: #eceef2;
  --color-text-secondary: #c6cbd3;
  --color-text-muted: #9aa1ac;
  --color-text-disabled: #6b7280;
  --color-text-inverse: #ffffff;
  --color-chrome: #0c0e11;
  --color-chrome-surface: #1a1d22;
  --color-chrome-border: #33373f;
  --color-chrome-text: #c8cdd5;
  --color-chrome-muted: #9aa1ac;

  /* Interaction: TransLoop blue */
  --color-action: #339aff;
  /* The brand blue is a fill and an accent; as small text on a light surface it
     does not reach 4.5:1, so text takes its own step of the same ramp. Dark
     needs no separate value, verified in ui/contrast_test.go. */
  --color-action-text: #339aff;
  --color-action-hover: #66b3ff;
  --color-action-active: #0080ff;
  --color-action-subtle: rgba(0, 128, 255, 0.16);
  --color-action-subtle-hover: rgba(0, 128, 255, 0.26);
  --color-on-action: #071521;
  --color-focus: #7cb8ff;
  --color-focus-on-chrome: #ffffff;

  /* Brand identity: fixed across themes (not a light-mode text remap) */
  --color-brand: #0080ff;
  --color-on-brand: #ffffff;
  --color-brand-glow: rgba(0, 128, 255, 0.28);

  /* Semantic state */
  --color-success-text: #57d98a;
  --color-success-bg: rgba(22, 163, 74, 0.14);
  --color-success-border: rgba(22, 163, 74, 0.35);
  --color-warning-text: #f5b04c;
  --color-warning-bg: rgba(217, 119, 6, 0.14);
  --color-warning-border: rgba(217, 119, 6, 0.35);
  --color-danger-text: #f87171;
  --color-danger-bg: rgba(220, 38, 38, 0.14);
  --color-danger-border: rgba(220, 38, 38, 0.4);

  /* MCI gauge bands (cool → hot; decorative fill, not text) */
  --color-mci-1: #1e3a8a;
  --color-mci-2: #2563eb;
  --color-mci-3: #60a5fa;
  --color-mci-4: #fde68a;
  --color-mci-5: #fb923c;
  --color-mci-6: #ea580c;
  --color-mci-7: #dc2626;

  /* Rate visuals: chart + L/T bar */
  --color-chart-series: #eab308;
  --color-chart-now: #f5b04c;
  --color-lt-loads: #64748b;
  --color-lt-trucks: #94a3b8;

  /* Elevation */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.25);
  --shadow-md: 0 4px 14px rgba(0, 0, 0, 0.4), 0 1px 3px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.5), 0 2px 6px rgba(0, 0, 0, 0.35);
  --shadow-inset: inset 0 1px 2px rgba(0, 0, 0, 0.18);
  --overlay-scrim: rgba(0, 0, 0, 0.6);

  /* Typography: Montserrat only */
  --font: "Montserrat";
  --text-xs: 0.6875rem;
  --text-sm: 0.75rem;
  --text-label: 0.8125rem;
  --text-base: 0.875rem;
  --text-md: 1rem;
  --text-lg: 1.25rem;
  --text-mobile-title: 1.5rem;
  --text-xl: 1.875rem;

  /* Spacing (4px ramp): remapped by density, see the bottom of this file */
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.25rem;
  --space-6: 1.5rem;
  --space-8: 2rem;
  --space-10: 2.5rem;

  /* Geometry */
  --radius-sm: 4px;
  --radius-md: 6px;
  --radius-lg: 8px;
  --border-width: 1px;
  --focus-width: 2px;

  /* Component metrics */
  --topbar-height: 3rem;
  --sidebar-width: 15rem;
  --sidebar-width-collapsed: 4rem;
  --control-height-md: 2.25rem;
  --touch-target-min: 2.75rem;
  --icon-sm: 1rem;
  --icon-md: 1.25rem;
  --icon-lg: 1.75rem;

  /* Z ladder */
  --z-sticky: 100;
  --z-nav: 200;
  --z-dropdown: 300;
  --z-overlay: 400;
  --z-drawer: 500;

  /* Motion */
  --duration-fast: 120ms;
  --duration-base: 160ms;
  --duration-slow: 200ms;
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
}

/* ---------- Tokens: light remap ---------- */

html[data-theme="light"] {
  color-scheme: light;

  --color-canvas: #f4f5f7;
  --color-surface: #ffffff;
  --color-surface-subtle: #fafbfc;
  --color-surface-sunken: #edeff2;
  --color-border: #e2e5ea;
  --color-border-strong: #878c95;
  --color-text: #14161a;
  --color-text-secondary: #3b3f46;
  --color-text-muted: #62676f;
  --color-text-disabled: #9aa1ac;
  --color-chrome: #14161a;
  --color-chrome-surface: #23262c;
  --color-chrome-border: #3b3f46;

  --color-action: #0080ff;
  --color-action-text: #0067cf;
  --color-action-hover: #0066cc;
  --color-action-active: #0052a3;
  --color-action-subtle: #e6f2ff;
  --color-action-subtle-hover: #cce6ff;
  --color-on-action: #ffffff;
  --color-focus: #0066cc;

  --color-success-text: #15803d;
  --color-success-bg: #effaf3;
  --color-success-border: #d7f2e1;
  --color-warning-text: #b45309;
  --color-warning-bg: #fef7ec;
  --color-warning-border: #fcebcf;
  --color-danger-text: #b91c1c;
  --color-danger-bg: #fef1f1;
  --color-danger-border: #fddcdc;

  --color-mci-1: #1e40af;
  --color-mci-2: #2563eb;
  --color-mci-3: #93c5fd;
  --color-mci-4: #fde047;
  --color-mci-5: #fb923c;
  --color-mci-6: #ea580c;
  --color-mci-7: #b91c1c;

  --color-chart-series: #ca8a04;
  --color-chart-now: #b45309;
  --color-lt-loads: #475569;
  --color-lt-trucks: #94a3b8;

  --shadow-sm: 0 1px 2px rgba(20, 22, 26, 0.06);
  --shadow-md: 0 4px 12px rgba(20, 22, 26, 0.1), 0 1px 3px rgba(20, 22, 26, 0.06);
  --shadow-lg: 0 8px 24px rgba(20, 22, 26, 0.14), 0 2px 6px rgba(20, 22, 26, 0.08);
  --shadow-inset: inset 0 1px 2px rgba(20, 22, 26, 0.06);
  --overlay-scrim: rgba(8, 15, 28, 0.4);
}

/* ---------- Density ----------
 *
 * Spacing, not zoom: type never changes size, so a compact table is still the
 * same table, just closer together. Like the theme, this is a token remap and
 * no component rule is written twice. Absence of the attribute is Default,
 * which is unchanged from what shipped before the preference existed.
 * The coarse-pointer floors in components.css still win over Compact. */

html[data-density="compact"] {
  --space-2: 0.375rem;
  --space-3: 0.5rem;
  --space-4: 0.75rem;
  --space-5: 0.875rem;
  --space-6: 1rem;
  --space-8: 1.5rem;
  --space-10: 1.75rem;
  --control-height-md: 2rem;
}
