/* Design tokens. Every color, size, spacing and radius used in the UI is defined here. */

@font-face {
  font-family: "Inter Variable";
  font-style: normal;
  font-display: swap;
  font-weight: 100 900;
  src: url("../fonts/inter-latin-wght-normal.woff2") format("woff2-variations");
  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;
}

@font-face {
  font-family: "Inter Variable";
  font-style: normal;
  font-display: swap;
  font-weight: 100 900;
  src: url("../fonts/inter-latin-ext-wght-normal.woff2") format("woff2-variations");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF,
    U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020,
    U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

/* Light and dark theme: every color is light-dark(light, dark). Without a choice
   the system setting decides; the toggle (theme.js) sets data-theme on <html>,
   which the server renders from the "theme" cookie. */
:root {
  color-scheme: light dark;
}

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

:root[data-theme="dark"] {
  color-scheme: dark;
}

:root {
  /* Neutral palette */
  --color-bg: light-dark(#ffffff, #23272f);
  --color-bg-subtle: light-dark(#f7f8fa, #282d36);
  --color-bg-muted: light-dark(#eef0f3, #313742);
  --color-surface: light-dark(#ffffff, #2a2f38);
  --color-surface-translucent: light-dark(rgb(255 255 255 / 0.92), rgb(35 39 47 / 0.9));
  --color-border: light-dark(#e3e6eb, #3b414c);
  --color-border-strong: light-dark(#cdd2da, #4c5361);
  --color-text: light-dark(#161a21, #e4e7ed);
  --color-text-muted: light-dark(#545c6b, #b3bac6);
  --color-text-subtle: light-dark(#7d8594, #9199a6);
  /* On --color-text and --color-accent backgrounds. */
  --color-text-inverse: light-dark(#ffffff, #23272f);

  /* Single accent */
  --color-accent: light-dark(#1f4bb8, #86a8f8);
  --color-accent-hover: light-dark(#193d96, #a2bcfa);
  --color-accent-active: light-dark(#142f74, #bccffc);
  --color-accent-subtle: light-dark(#eef2fb, #2c3756);
  --color-accent-border: light-dark(#c8d4f1, #43578a);

  /* Status colors (used sparingly, text always meets 4.5:1 on its background) */
  --color-success: light-dark(#17693f, #6fd09a);
  --color-success-bg: light-dark(#edf6f0, #203429);
  --color-success-border: light-dark(#bfdcca, #375c44);
  --color-warning: light-dark(#8a4f00, #ebb563);
  --color-warning-bg: light-dark(#fdf5e6, #382f1e);
  --color-warning-border: light-dark(#f0d5a6, #665230);
  --color-danger: light-dark(#b42318, #f4877f);
  --color-danger-hover: light-dark(#93190f, #f7a59f);
  --color-danger-bg: light-dark(#fdf0ef, #3c2626);
  --color-danger-border: light-dark(#f2c4bf, #6d3935);
  --color-danger-ring: light-dark(rgb(180 35 24 / 0.2), rgb(244 135 127 / 0.3));
  --color-info: var(--color-accent);
  --color-info-bg: var(--color-accent-subtle);
  --color-info-border: var(--color-accent-border);

  /* Court badges: one tone per court level */
  --color-court-constitutional: light-dark(#5b2a86, #c9a6ec);
  --color-court-constitutional-bg: light-dark(#f5f0fa, #342b40);
  --color-court-constitutional-border: light-dark(#ddd0ec, #58456c);
  --color-court-fiscal: light-dark(#2f5d62, #7fc4ca);
  --color-court-fiscal-bg: light-dark(#eef5f5, #233539);
  --color-court-fiscal-border: light-dark(#cbe0e1, #385c61);
  --color-court-european: light-dark(#7a4a12, #e2b27a);
  --color-court-european-bg: light-dark(#fbf4ea, #382e21);
  --color-court-european-border: light-dark(#ecd8bd, #634c30);

  --color-highlight: light-dark(#fff1b8, #6b5b20);
  --color-overlay: light-dark(rgb(16 20 27 / 0.45), rgb(0 0 0 / 0.6));
  --color-focus: light-dark(#2f62e0, #86a8f8);

  /* Typography */
  --font-sans: "Inter Variable", system-ui, -apple-system, "Segoe UI", Roboto,
    "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, "SF Mono", "Cascadia Mono", Consolas, monospace;

  --text-xs: 0.75rem;
  --text-sm: 0.875rem;
  --text-base: 1rem;
  --text-lg: 1.125rem;
  --text-xl: 1.25rem;
  --text-2xl: 1.5rem;
  --text-3xl: 1.875rem;
  --text-4xl: 2.5rem;

  --leading-tight: 1.25;
  --leading-snug: 1.4;
  --leading-normal: 1.6;
  --leading-relaxed: 1.75;

  --weight-regular: 400;
  --weight-medium: 500;
  --weight-semibold: 600;
  --weight-bold: 700;

  --tracking-tight: -0.015em;

  /* Spacing scale (4px base) */
  --space-0: 0;
  --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;
  --space-12: 3rem;
  --space-16: 4rem;
  --space-20: 5rem;
  --space-24: 6rem;

  /* Radii */
  --radius-sm: 4px;
  --radius-md: 6px;
  --radius-lg: 10px;
  --radius-xl: 14px;
  --radius-full: 999px;

  /* Borders and elevation (borders first, shadows only for overlays) */
  --border-width: 1px;
  --border: var(--border-width) solid var(--color-border);
  --shadow-sm: 0 1px 2px light-dark(rgb(16 20 27 / 0.04), rgb(0 0 0 / 0.3));
  --shadow-overlay: 0 12px 32px light-dark(rgb(16 20 27 / 0.12), rgb(0 0 0 / 0.5)),
    0 2px 6px light-dark(rgb(16 20 27 / 0.06), rgb(0 0 0 / 0.3));

  /* Layout */
  --container-max: 72rem;
  --container-narrow: 30rem;
  --container-medium: 48rem;
  --measure: 68ch;
  --navbar-height: 3.75rem;
  /* Space the navbar takes at the top; 0 while it is hidden (navbar.js). */
  --navbar-offset: var(--navbar-height);
  --sidebar-width: 17rem;
  --gutter: var(--space-6);

  /* Controls */
  --control-height: 2.5rem;
  --control-height-sm: 2rem;
  --control-height-lg: 3rem;
  --focus-ring: 0 0 0 3px light-dark(rgb(47 98 224 / 0.35), rgb(134 168 248 / 0.4));

  /* Motion */
  --duration-fast: 120ms;
  --duration-base: 200ms;
  --duration-slow: 360ms;
  --ease-out: cubic-bezier(0.2, 0.8, 0.2, 1);
  --ease-in: cubic-bezier(0.4, 0, 1, 1);
  --ease-spring: cubic-bezier(0.34, 1.45, 0.64, 1);
  --stagger: 60ms;

  /* Hover elevation (interactive surfaces only) */
  --shadow-raised: 0 6px 16px light-dark(rgb(16 20 27 / 0.08), rgb(0 0 0 / 0.4)),
    0 1px 3px light-dark(rgb(16 20 27 / 0.06), rgb(0 0 0 / 0.3));
  --shadow-accent: 0 4px 14px light-dark(rgb(31 75 184 / 0.28), rgb(134 168 248 / 0.25));
  --shadow-danger: 0 4px 14px light-dark(rgb(180 35 24 / 0.25), rgb(244 135 127 / 0.2));
  --color-ripple: light-dark(rgb(255 255 255 / 0.35), rgb(35 39 47 / 0.25));
  --color-ripple-dark: light-dark(rgb(31 75 184 / 0.14), rgb(134 168 248 / 0.18));
  --color-glow: light-dark(rgb(31 75 184 / 0.5), rgb(134 168 248 / 0.5));
  --color-pulse: light-dark(rgb(31 75 184 / 0.35), rgb(134 168 248 / 0.35));
  --color-pulse-danger: light-dark(rgb(180 35 24 / 0.35), rgb(244 135 127 / 0.35));
  --color-pulse-warning: light-dark(rgb(138 79 0 / 0.3), rgb(235 181 99 / 0.3));

  /* Stacking */
  --z-navbar: 50;
  --z-dropdown: 60;
  --z-overlay: 100;
  --z-toast: 200;
}

@media (max-width: 40rem) {
  :root {
    --gutter: var(--space-4);
    --text-4xl: 2rem;
    --text-3xl: 1.625rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  :root {
    --duration-fast: 0ms;
    --duration-base: 0ms;
    --duration-slow: 0ms;
    --stagger: 0ms;
  }
}
