/* Owner: P8a (UI shell and design system). Keep this Owner line.
   Brief: OWNERSHIP.md / DESIGN.md section 4 (P8a); contracts: docs/ARCHITECTURE.md.

   Design tokens of the Essence Hosting panel (DESIGN 2). This file is the only place with raw values.
   base.css, shell.css, components.css and every css/pages/<name>.css use var(--token) and nothing else.
   Page CSS must be scoped under .page-<name> (the shell puts "page page-<name>" on the outlet).

   Contrast (WCAG 2.2 AA, checked by panel/static/js/tests/core.test.mjs):
   text pairs >= 4.5:1, chart / border / focus colours >= 3:1.

   Breakpoints are literals in the media queries (custom properties cannot be used there):
   1200 (sidebar -> icon rail), 800 (rail -> bottom bar), 480 (compact phone). */

/* Acherus Feral: UI text (Light 400, Bold 700). Copied from the live panel. */
@font-face {
  font-family: "Acherus Feral";
  src: url("/static/fonts/AcherusFeral-Light.otf") format("opentype");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Acherus Feral";
  src: url("/static/fonts/AcherusFeral-Bold.otf") format("opentype");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

/* AtGambit: display face (H1/H2, KPI numbers). Waits for decision D17 (licence for web use); the lead
   adds the files to static/fonts/ and a second src line here:
     src: local("AtGambit"), url("/static/fonts/AtGambit-Regular.woff2") format("woff2");
   Until then local() only: the stack below falls back to Acherus Feral Bold, then Georgia. */
@font-face {
  font-family: "AtGambit";
  src: local("AtGambit"), local("At Gambit");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

:root {
  color-scheme: light;

  /* Brand palette (DESIGN 2) */
  --navy: #003459;
  --navy-900: #00243e;
  --navy-700: #0b4a73;
  --navy-100: #dfe8ef;
  --navy-50: #eef3f7;
  --navy-950: #0f1b33;        /* chrome: sidebar, bottom bar, welcome panel */
  --navy-850: #16264a;
  --teal: #1c7783;
  --teal-700: #155d66;
  --teal-100: #dcedef;
  --peach: #f0b482;
  --peach-200: #f8dcc3;
  --peach-100: #fcefe2;
  --peach-50: #fdf7f1;
  --peach-ink: #8f4a1c;        /* peach-family text on light surfaces (AA) */
  --cream: #f0e1db;
  --ink: #0f2236;
  --canvas: #f6f4ef;
  --surface: #ffffff;
  --surface-2: #faf8f4;

  /* Text and lines */
  --muted: #566174;
  --muted-2: #6b7587;
  --line: #e3ded3;
  --line-strong: #cfc8b9;
  --border-input: #8a93a3;

  /* Status colours: text colour on its own tint */
  --success: #17694a;
  --success-bg: #e3f3ea;
  --warning: #8a5200;
  --warning-bg: #fdefd5;
  --danger: #a3262b;
  --danger-bg: #fcebea;
  --unknown: #556070;
  --unknown-bg: #e9ebef;
  --info: #175d68;
  --info-bg: #e0f0f2;

  /* Aliases kept for the legacy v1 panel vocabulary (research/panel-src) so ported page CSS keeps working */
  --accent: var(--cream);
  --bg: var(--canvas);
  --card: var(--surface);
  --text: var(--ink);
  --primary: var(--teal);
  --good: var(--success);
  --good-bg: var(--success-bg);
  --warn: var(--warning);
  --warn-bg: var(--warning-bg);
  --bad: var(--danger);
  --bad-bg: var(--danger-bg);
  --ok: var(--success);
  --ok-bg: var(--success-bg);
  --grey: var(--unknown);
  --grey-bg: var(--unknown-bg);

  /* Data visualisation: >= 3:1 on white; series are also told apart by dash pattern (svgchart.js) */
  --chart-1: #003459;
  --chart-2: #1c7783;
  --chart-3: #c2631d;
  --chart-4: #6b4c9a;
  --chart-5: #6a7a1f;
  --chart-6: #7b8794;
  --chart-grid: #e6e1d6;
  --chart-axis: #566174;
  --chart-stale: #a8b0bc;

  /* Typography */
  --font-ui: "Acherus Feral", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-display: "AtGambit", "Acherus Feral", Georgia, "Times New Roman", serif;
  --font-mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --fs-xs: 0.75rem;
  --fs-sm: 0.875rem;
  --fs-md: 1rem;
  --fs-lg: 1.125rem;
  --fs-xl: 1.375rem;
  --fs-2xl: 1.75rem;
  --fs-3xl: 2.25rem;
  --fs-kpi: 2.75rem;
  --lh-tight: 1.2;
  --lh-snug: 1.35;
  --lh-body: 1.5;
  --tracking-display: -0.015em;
  --tracking-eyebrow: 0.14em;
  --tracking-tight: -0.02em;
  --fs-2xs: 0.6875rem;
  --fw-regular: 400;
  --fw-bold: 700;

  /* Spacing (4 px grid) and legacy --sN names */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;
  --space-10: 40px;
  --space-12: 48px;
  --space-16: 64px;
  --s1: var(--space-1);
  --s2: var(--space-2);
  --s3: var(--space-3);
  --s4: var(--space-4);
  --s6: var(--space-6);
  --s8: var(--space-8);
  --s12: var(--space-12);

  /* Shapes */
  --radius-card: 20px;
  --radius-ctl: 12px;
  --radius-sm: 8px;
  --radius-pill: 999px;
  --radius-lg: 24px;
  --radius-xs: 6px;
  --radius: var(--radius-card);
  --hit: 44px;
  --brand-wordmark-w: 108px;
  --brand-welcome-wordmark-w: 216px;
  --border: 1px solid var(--line);

  /* Elevation: navy-tinted, layered (contact + ambient) */
  --shadow-0: 0 1px 2px rgba(15, 27, 51, 0.05);
  --shadow-1: 0 1px 2px rgba(15, 27, 51, 0.04), 0 4px 12px -2px rgba(15, 27, 51, 0.06), 0 12px 28px -18px rgba(15, 27, 51, 0.16);
  --shadow-2: 0 2px 6px rgba(15, 27, 51, 0.06), 0 22px 44px -18px rgba(15, 27, 51, 0.26);
  --shadow-3: 0 4px 10px rgba(15, 27, 51, 0.07), 0 30px 60px -22px rgba(15, 27, 51, 0.32);
  --shadow-chrome: 4px 0 24px -12px rgba(15, 27, 51, 0.45);
  --shadow-inset: inset 0 1px 2px rgba(15, 27, 51, 0.06);
  --highlight-top: inset 0 1px 0 rgba(255, 255, 255, 0.7);
  --scrim: rgba(11, 21, 42, 0.58);

  /* Surfaces with depth */
  --grad-chrome: linear-gradient(180deg, #172a52 0%, #0f1b33 46%, #0b1529 100%);
  --grad-welcome: radial-gradient(120% 90% at 100% 0%, rgba(240, 180, 130, 0.22) 0%, rgba(240, 180, 130, 0) 55%), linear-gradient(160deg, #172a52 0%, #0f1b33 60%, #0b1529 100%);
  --grad-canvas: radial-gradient(1200px 420px at 85% -120px, rgba(240, 180, 130, 0.16), rgba(240, 180, 130, 0) 70%);
  --grad-card-accent: linear-gradient(90deg, var(--peach) 0%, var(--peach-200) 100%);
  --grad-state: radial-gradient(80% 120% at 50% 0%, var(--peach-50) 0%, var(--surface) 70%);
  --topbar-glass: rgba(246, 244, 239, 0.86);
  --skeleton-base: #ece7dd;
  --skeleton-shine: #f8f6f1;

  /* On navy (sidebar, bottom bar, welcome panel) */
  --on-navy: var(--cream);
  --on-navy-strong: #ffffff;
  --navy-hover: rgba(255, 255, 255, 0.08);
  --navy-active: rgba(240, 180, 130, 0.14);
  --navy-line: rgba(240, 225, 219, 0.18);

  /* Focus */
  --focus: var(--teal);
  --focus-on-dark: var(--peach);
  --focus-width: 3px;
  --focus-offset: 2px;
  --ring: 0 0 0 4px rgba(28, 119, 131, 0.22);

  /* Motion */
  --dur-fast: 120ms;
  --dur: 180ms;
  --ease: cubic-bezier(0.2, 0, 0, 1);
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --dur-slow: 280ms;
  --lift: translateY(-2px);

  /* Semantic layer (dark-mode ready: :root[data-theme="dark"] below redefines the raw values;
     new CSS should prefer these names) */
  --bg-app: var(--canvas);
  --bg-surface: var(--surface);
  --bg-subtle: var(--surface-2);
  --bg-chrome: var(--navy-950);
  --text-1: var(--ink);
  --text-2: var(--muted);
  --text-3: var(--muted-2);
  --text-brand: var(--navy);
  --text-accent: var(--peach-ink);
  --border-1: var(--line);
  --border-2: var(--line-strong);
  --interactive: var(--teal);
  --interactive-strong: var(--teal-700);
  --delta-up: var(--success);
  --delta-up-bg: var(--success-bg);
  --delta-down: var(--danger);
  --delta-down-bg: var(--danger-bg);
  --delta-flat: var(--unknown);
  --delta-flat-bg: var(--unknown-bg);

  /* Layout */
  --sidebar-w: 248px;
  --rail-w: 76px;
  --topbar-h: 64px;
  --bottombar-h: 64px;
  --content-max: 1280px;
  --gutter: 24px;
  --dialog-w: 520px;
  --drawer-w: 480px;

  /* Stacking */
  --z-sticky: 20;
  --z-popover: 40;
  --z-dialog: 50;
  --z-toast: 60;
}

/* Dark theme, ready but not enabled: set <html data-theme="dark"> to use it. Only raw values change; every
   component reads tokens, so no component CSS needs a dark variant. Not part of the AA audit in
   core.test.mjs (that audits :root); audit it before turning it on. */
:root[data-theme="dark"] {
  color-scheme: dark;
  --canvas: #0b1426;
  --surface: #12203a;
  --surface-2: #172846;
  --ink: #e8eef7;
  --muted: #a7b3c7;
  --muted-2: #8f9bb1;
  --line: #22355a;
  --line-strong: #30487a;
  --border-input: #6a7da3;
  --navy: #9fc3e6;
  --navy-700: #b9d4ee;
  --navy-100: #1b2f55;
  --navy-50: #152646;
  --teal: #4fb3bf;
  --teal-700: #7cc9d2;
  --teal-100: #123a40;
  --peach-100: #2b2320;
  --peach-50: #221d1c;
  --peach-200: #4a3426;
  --peach-ink: #f3c39a;
  --cream: #f0e1db;
  --success: #6fd3a3;
  --success-bg: #12362a;
  --warning: #f2be6b;
  --warning-bg: #3a2c12;
  --danger: #ff9a9e;
  --danger-bg: #3d1a1f;
  --unknown: #b4bfd0;
  --unknown-bg: #222f47;
  --info: #7cc9d2;
  --info-bg: #123a40;
  --chart-1: #9fc3e6;
  --chart-2: #4fb3bf;
  --chart-3: #f0a46a;
  --chart-4: #b79be0;
  --chart-5: #b9c862;
  --chart-6: #a7b3c7;
  --chart-grid: #22355a;
  --chart-axis: #a7b3c7;
  --chart-stale: #4d5d7c;
  --shadow-1: 0 1px 2px rgba(0, 0, 0, 0.35), 0 10px 24px -14px rgba(0, 0, 0, 0.6);
  --shadow-2: 0 2px 6px rgba(0, 0, 0, 0.4), 0 22px 44px -18px rgba(0, 0, 0, 0.7);
  --shadow-3: 0 4px 10px rgba(0, 0, 0, 0.45), 0 30px 60px -22px rgba(0, 0, 0, 0.75);
  --highlight-top: inset 0 1px 0 rgba(255, 255, 255, 0.04);
  --grad-canvas: radial-gradient(1200px 420px at 85% -120px, rgba(240, 180, 130, 0.08), rgba(240, 180, 130, 0) 70%);
  --grad-state: radial-gradient(80% 120% at 50% 0%, var(--peach-50) 0%, var(--surface) 70%);
  --topbar-glass: rgba(11, 20, 38, 0.84);
  --skeleton-base: #1b2c4c;
  --skeleton-shine: #24395f;
  --focus: #7cc9d2;
  --ring: 0 0 0 4px rgba(124, 201, 210, 0.25);
}

@media (max-width: 800px) {
  :root {
    --gutter: 16px;
    --fs-kpi: 2.25rem;
  }
}

@media (max-width: 480px) {
  :root {
    --fs-3xl: 1.875rem;
    --fs-2xl: 1.5rem;
    --fs-kpi: 2rem;
  }
}
