/* Frostpeak Panel — design tokens.
   Dark console theme (default, docs/design/DESIGN.md), light theme (:root[data-theme="light"]) and
   large text (:root[data-text-size="large"]). js/prefs.js sets both attributes before the first paint.
   Typography is in rem so that the "large text" setting scales every text of the interface. */

@font-face {
  font-family: "Source Sans 3";
  font-style: normal;
  font-display: swap;
  font-weight: 200 900;
  src: url("../fonts/source-sans-3-latin-wght-normal.woff2") format("woff2-variations"),
       url("../fonts/source-sans-3-latin-wght-normal.woff2") format("woff2");
}

@font-face {
  font-family: "Source Sans 3";
  font-style: italic;
  font-display: swap;
  font-weight: 200 900;
  src: url("../fonts/source-sans-3-latin-wght-italic.woff2") format("woff2-variations"),
       url("../fonts/source-sans-3-latin-wght-italic.woff2") format("woff2");
}

@font-face {
  font-family: "JetBrains Mono";
  font-style: normal;
  font-display: swap;
  font-weight: 400;
  src: url("../fonts/jetbrains-mono-latin-400-normal.woff2") format("woff2");
}

@font-face {
  font-family: "JetBrains Mono";
  font-style: normal;
  font-display: swap;
  font-weight: 600;
  src: url("../fonts/jetbrains-mono-latin-600-normal.woff2") format("woff2");
}

/* ---------------------------------------------------------------------------
   Colours — dark theme (default).
   The same block is re-declared on "dark islands": surfaces that stay dark in the light theme
   (demo banner, dashboard hero, console logs, job output). .surface-dark is the generic hook.
   --------------------------------------------------------------------------- */
:root,
.surface-dark,
.demo-banner,
.pg-hero,
.pg-log,
.pg-log__jump,
.pg-job__output {
  color-scheme: dark;

  /* Surfaces */
  --background: #020308;
  --card: #0b0d17;
  --border: #1d2031;
  --muted: #171a28;
  --nav-hover-bg: #171a28;
  --nav-selected-bg: #1d2031;
  --input-background: #10121d;
  --popover: #10121d;
  --input: #61667d;
  --input-hover: #7a7f96;
  --secondary: #2b2f42;
  --secondary-hover: #363b52;

  /* Text */
  --foreground: #ffffff;
  --nav-foreground: #c3c7d6;
  --nav-hover-foreground: #d5d8e4;
  --nav-selected-foreground: #e6e8f0;
  /* Secondary text: lighter than DESIGN's #a7abbb for readability (>= 9:1 on every surface). */
  --muted-foreground: #bcc0cf;

  /* Accents */
  --primary: #157eea;
  --primary-hover: #0050d7;
  /* Button fill: #157eea darkened just enough for white 14px text to reach WCAG AA (4.9:1). */
  --primary-button: #0f6fd6;
  --primary-foreground: #ffffff;
  /* Links: brand glow blue, AA (>= 4.5:1) on every dark surface including --muted. */
  --link: #3d8bff;
  --link-hover: #7ab6f8;
  --ring: #157eea;
  --focus-ring: #4bb2f6;
  --info: #4bb2f6;
  --glow: #3d8bff;

  /* Status */
  --success: #10b981;
  --success-strong: #a7f3d0;
  --warning: #f59e0b;
  --warning-strong: #fde68a;
  --danger: #bf0020;
  --danger-hover: #9a001a;
  --danger-light: #e67386;
  --danger-pale: #ffccd9;
  --info-strong: #bae6fd;

  --success-bg: color-mix(in srgb, var(--success) 12%, var(--card));
  --success-border: color-mix(in srgb, var(--success) 38%, var(--border));
  --warning-bg: color-mix(in srgb, var(--warning) 12%, var(--card));
  --warning-border: color-mix(in srgb, var(--warning) 38%, var(--border));
  --danger-bg: color-mix(in srgb, var(--danger) 16%, var(--card));
  --danger-border: color-mix(in srgb, var(--danger-light) 38%, var(--border));
  --info-bg: color-mix(in srgb, var(--info) 12%, var(--card));
  --info-border: color-mix(in srgb, var(--info) 38%, var(--border));

  --neutral-badge-bg: #1a1a1a;
  --neutral-badge-border: #808080;
  --neutral-badge-fg: #cccccc;

  /* Misc surfaces */
  --scrollbar-thumb: #2b2f42;
  --scrollbar-thumb-hover: #3a3f57;
  --skeleton-highlight: #22263a;
  --backdrop: rgba(2, 3, 8, 0.75);
  --selection: color-mix(in srgb, #157eea 55%, transparent);
  --select-chevron: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23bcc0cf' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");

  /* Effects */
  --shadow-popover: 0 12px 32px rgba(0, 0, 0, 0.55), 0 0 0 1px var(--border);
  --shadow-modal: 0 24px 64px rgba(0, 0, 0, 0.7);
  --shadow-card: 0 0 0 1px rgba(61, 139, 255, 0.06), 0 24px 64px rgba(0, 0, 0, 0.5);
  --gradient-brand: linear-gradient(135deg, #157eea 0%, #3d8bff 55%, #4bb2f6 100%);
  --gradient-name: linear-gradient(90deg, #ffffff 0%, #b9dcfb 45%, #4bb2f6 100%);
  --auth-glow: rgba(21, 126, 234, 0.22);
  --auth-grid: rgba(61, 139, 255, 0.06);
}

/* Dark islands keep their own text colour (zero specificity: page styles still win). */
:where(.surface-dark, .demo-banner, .pg-hero, .pg-log, .pg-log__jump, .pg-job__output) {
  color: var(--foreground);
}

/* ---------------------------------------------------------------------------
   Colours — light theme. Every colour token is redefined; contrasts are WCAG AA
   (text >= 4.5:1, large text / icons / control borders >= 3:1), checked by
   tests/test_shell_frontend.py. The status backgrounds/borders above are derived from
   these values automatically (var() inside color-mix).
   --------------------------------------------------------------------------- */
:root[data-theme="light"] {
  color-scheme: light;

  --background: #f4f6fb;
  --card: #ffffff;
  --border: #d5d9e5;
  --muted: #eceff6;
  --nav-hover-bg: #eceff6;
  --nav-selected-bg: #dfe4f0;
  --input-background: #ffffff;
  --popover: #ffffff;
  --input: #767b91;
  --input-hover: #545970;
  --secondary: #e2e6ef;
  --secondary-hover: #d3d8e4;

  --foreground: #0b0d17;
  --nav-foreground: #343a52;
  --nav-hover-foreground: #1d2031;
  --nav-selected-foreground: #0b0d17;
  --muted-foreground: #4b5066;

  --primary: #0f6fd6;
  --primary-hover: #0a56ad;
  --primary-button: #0f6fd6;
  --primary-foreground: #ffffff;
  --link: #0b5cc0;
  --link-hover: #083f86;
  --ring: #0f6fd6;
  --focus-ring: #0b5cc0;
  --info: #0369a1;
  --glow: #2f74e0;

  --success: #047857;
  --success-strong: #064e3b;
  --warning: #b45309;
  --warning-strong: #713f12;
  --danger: #bf0020;
  --danger-hover: #9a001a;
  --danger-light: #b4001e;
  --danger-pale: #7a0014;
  --info-strong: #0c4a6e;

  --neutral-badge-bg: #eef0f5;
  --neutral-badge-border: #7d8296;
  --neutral-badge-fg: #2f3346;

  --scrollbar-thumb: #b9bfce;
  --scrollbar-thumb-hover: #9aa1b4;
  --skeleton-highlight: #dde2ec;
  --backdrop: rgba(11, 13, 23, 0.45);
  --selection: color-mix(in srgb, #0f6fd6 30%, transparent);
  --select-chevron: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%234b5066' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");

  --shadow-popover: 0 12px 32px rgba(17, 24, 39, 0.16), 0 0 0 1px var(--border);
  --shadow-modal: 0 24px 64px rgba(17, 24, 39, 0.24);
  --shadow-card: 0 0 0 1px rgba(15, 111, 214, 0.06), 0 16px 48px rgba(17, 24, 39, 0.12);
  --gradient-brand: linear-gradient(135deg, #0f6fd6 0%, #2f74e0 55%, #0369a1 100%);
  --gradient-name: linear-gradient(90deg, #0b0d17 0%, #1d4f9c 45%, #0f6fd6 100%);
  --auth-glow: rgba(15, 111, 214, 0.14);
  --auth-grid: rgba(15, 111, 214, 0.07);
}

/* ---------------------------------------------------------------------------
   Typography, spacing, layout (theme independent)
   --------------------------------------------------------------------------- */
:root {
  /* Radii */
  --radius: 0.625rem;
  --radius-card: 14px;
  --radius-control: 8px;
  --radius-sm: 6px;
  --radius-pill: 999px;

  /* Typography (rem: follows the "large text" setting). 14px is the smallest interface text;
     --text-xs is kept as an alias of 14px for existing callers, only badges and counters use
     --text-counter. */
  --font-sans: "Source Sans 3", sans-serif, -apple-system, "Segoe UI", Roboto, Arial;
  --font-mono: "JetBrains Mono", ui-monospace, Menlo, Consolas, monospace;
  --text-counter: 0.75rem;
  --text-xs: 0.875rem;
  --text-sm: 0.875rem;
  --text-md: 1rem;
  --text-lg: 1.125rem;
  --text-xl: 1.5rem;
  --text-2xl: 1.875rem;
  --text-3xl: 2.25rem;
  --leading-counter: 1rem;
  --leading-xs: 1.25rem;
  --leading-sm: 1.25rem;
  --leading-md: 1.5rem;
  --leading-lg: 1.75rem;
  --tracking-tight: -0.025em;

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

  /* Layout */
  --topbar-height: 56px;
  --sidebar-width: 256px;
  --sidebar-collapsed-width: 64px;
  --content-max: 1400px;

  /* Motion & stacking */
  --transition-fast: 120ms ease;
  --z-sidebar: 40;
  --z-topbar: 50;
  --z-popover: 60;
  --z-modal: 80;
  --z-toast: 90;
}

/* Large text: body 18px, every rem-based size scales by 112.5 %. */
:root[data-text-size="large"] {
  font-size: 112.5%;
}

@media (prefers-reduced-motion: reduce) {
  :root {
    --transition-fast: 0ms;
  }
}
