/*
 * HxCore design tokens - HexaMain colour scheme (binding, replaces the former lime "Signal" accent).
 * HxContrastIT reads this file: every text/ground pair must reach WCAG AA, so values must not drift.
 *
 * Dark is the default and, for now, the only active theme. The light variant below is built but
 * switched off: it applies only where an element carries data-theme="light", which the shell sets
 * only with `hxcore.ui.light-theme-enabled=true`. prefers-color-scheme is ignored.
 *
 * Brand values (never altered): cyan #21C2F8 (primary, interactive only) - navy #141325 (background)
 *   - surface #1D1C34 - border #2E2D4A / strong #46456A - text #FFFFFF / secondary #B9BCD2
 *   - orange #FF5733 (highlight, sparingly) - status error #FF4D6D, success #3DDC97, info #8B9CFF,
 *   warning #FFC23D with their tints. Text on cyan, orange or a solid status fill is always #141325.
 *
 * Derived values (no new hues, see docs/design/PATTERNS.md section 3):
 *   - dark surface-2/-hover/-active/-sunken, border-subtle/-stronger, text-subtle/-faint: navy tints.
 *   - light surfaces and text: navy-tinted whites and the navy itself; --accent stays #21C2F8 as a fill
 *     (dark text on it); links/icons/focus use --accent-text #056F92 = #21C2F8 at the same hue (195 deg)
 *     and saturation with lightness 55 % -> 30 % (5.68:1 on white, 4.58:1 on --surface-active).
 *   - light status text: the same hues darkened to >= 4.5:1 on white and their tints
 *     (error #CF0025, success #15754B, info #3250FF, warning #895E00, orange text #C92400).
 *   - --purple is an alias of --info (no extra hue); --text-faint and --border-* are decorative only.
 */

/* Cascade layers of the design CSS, lowest first (base.css, components.css + shell.css). */
@layer base, components;

/* Theme-independent scales */
:root {
  --font-display: 'Bricolage Grotesque Variable', 'Bricolage Grotesque', system-ui, sans-serif;
  --font-sans: 'IBM Plex Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, 'SFMono-Regular', Menlo, monospace;

  --text-display: 800 2.5rem/1.05 var(--font-display); /* 40px, Cockpit greeting */
  --text-h1: 700 1.375rem/1.2 var(--font-display); /* 22px, section title */
  --text-h2: 700 1.125rem/1.25 var(--font-display); /* 18px, panel title */
  --text-body: 400 0.875rem/1.5 var(--font-sans); /* 14px */
  --text-small: 400 0.75rem/1.4 var(--font-sans); /* 12px */
  --text-mono: 400 0.8125rem/1.4 var(--font-mono); /* 13px */
  --size-display: 2.5rem;
  --size-kpi: 4rem;
  --size-h1: 1.375rem;
  --size-h2: 1.125rem;
  --size-body: 0.875rem;
  --size-small: 0.75rem;
  --size-label: 0.6875rem;
  --size-mono: 0.8125rem;
  /* DS3-6 (review M-1): the remaining fixed sizes of the components as tokens
     (were arbitrary rem values in the templates). */
  --size-control: 0.8125rem; /* 13px: button, label, hint and search text */
  --size-h3: 1rem; /* 16px: h3, empty-state title */
  --size-brand: 1.25rem; /* 20px: the "H" of the rail */
  --size-kpi-md: 2.125rem; /* 34px: HxKpi size="md" (tiles) */
  --size-kpi-fluid: clamp(2.5rem, 5vw, var(--size-kpi)); /* HxKpi size="lg" */
  --tracking-display: -0.035em;
  --tracking-label: 0.1em;
  --tracking-heading: -0.02em; /* h1–h4, sidebar title */
  --tracking-title: -0.01em; /* panel title */
  --tracking-kpi: -0.04em; /* HxKpi lg */
  --tracking-kpi-md: -0.03em; /* HxKpi md */

  /* 4px spacing scale */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-7: 28px;
  --space-8: 32px;
  --space-10: 40px;
  --space-12: 48px;

  --radius-xs: 5px;
  --radius-sm: 6px;
  --radius-md: 10px; /* buttons, inputs (HexaMain: 10-12 px) */
  --radius-lg: 12px;
  --radius-xl: 20px; /* cards, panels (HexaMain: 18-28 px) */
  --radius-2xl: 24px;
  --radius-full: 999px;
  --radius-control: var(--radius-md);
  --radius-card: var(--radius-xl);

  --rail-width: 64px;
  --rail-width-touch: 84px; /* mobile menu: label under each area icon */
  --sidebar-width: 260px;
  --header-height: 60px;
  --control-height: 38px;
  --control-height-sm: 30px;
  --control-height-lg: 40px;

  --transition-fast: 120ms ease;
  --tooltip-delay: 400ms;

  /* M5: sizes the Tailwind spacing steps expressed inline in the Vue components
     (now plain CSS needs them as named tokens). */
  --space-0-5: 2px;
  --space-1-5: 6px;
  --space-2-5: 10px;
  --space-3-5: 14px;
  --space-4-5: 18px;
  --space-5-5: 22px;
  --size-icon-sm: 14px;
  --size-icon: 16px;
  --size-icon-md: 20px;
  --size-icon-lg: 22px;
  --size-hairline: 1px;
  --size-bar: 3px;
  --size-dot: 6px;
  --size-rail-item: 44px;
  --size-brand-box: 36px;
  --size-avatar: 34px;
  --size-tab: 26px;
  --width-search: min(440px, 40vw);
  --width-menu: 200px;
  --width-dialog-sm: min(420px, calc(100vw - 32px));
  --width-dialog-md: min(560px, calc(100vw - 32px));
  --width-dialog-lg: min(760px, calc(100vw - 32px));
  --width-chat: 380px;
  --min-kpi-tile: 224px;
  --min-meta: 176px;
  --min-form-field: 192px;
  --min-pair: 320px;
  --min-side: 280px;
  --min-check: 256px;
  --max-prose: 44ch;
  --height-pick: 288px;
  --height-palette: min(420px, 55vh);
  --height-chart: 280px;
  --z-rail: 30;
  --z-sidebar: 25;
  --z-topbar: 20;
  --z-scrim: 15;
  --z-menu: 40;
  --z-skip: 100;

  /* Status icons as CSS masks (alerts, toasts): shape only, the colour comes from the status token. */
  --icon-info: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='9'/%3E%3Cpath d='M12 11v6M12 7.5v.01'/%3E%3C/svg%3E");
  --icon-warning: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 3 2 20h20z'/%3E%3Cpath d='M12 10v4M12 17v.01'/%3E%3C/svg%3E");
  --icon-danger: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='9'/%3E%3Cpath d='m9 9 6 6M15 9l-6 6'/%3E%3C/svg%3E");
  --icon-success: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='9'/%3E%3Cpath d='m8 12.5 3 3 5-6'/%3E%3C/svg%3E");
  --icon-star: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m12 3 2.7 5.6 6.1.9-4.4 4.3 1 6.1L12 17l-5.4 2.9 1-6.1-4.4-4.3 6.1-.9z'/%3E%3C/svg%3E");
}

/* Light (derived, only with hxcore.ui.light-theme-enabled=true) */
[data-theme='light'] {
  color-scheme: light;

  /* Surfaces */
  --bg: #f4f5fa;
  --surface: #ffffff;
  --surface-2: #f9f9fc;
  --surface-hover: #ecedf4;
  --surface-active: #e5e6f0;
  --surface-sunken: #eeeff6;
  --border: #dcdde8;
  --border-subtle: #e8e9f1;
  --border-strong: #c5c6d8;
  --border-stronger: #a3a4be;

  /* Text */
  --text: #141325;
  --text-muted: #46456a;
  --text-subtle: #5c5b7e;
  --text-faint: #8a8aa6;
  --text-strong: #0d0c1c;

  /* Primary = HexaMain cyan: interactive only (buttons, links, icons, active, focus). Historic name --accent. */
  --accent: #21c2f8;
  --on-accent: #141325;
  --accent-text: #056f92;
  --primary: #21c2f8;
  --on-primary: #141325;
  --primary-text: #056f92;
  --link: #056f92;
  --focus-color: #056f92;

  /* Highlight = HexaMain orange: sparingly (Neu, eyebrow, one highlighted card). Never a status, never alternating with cyan. */
  --highlight: #ff5733;
  --on-highlight: #141325;
  --highlight-text: #c92400;
  --highlight-bg: #ffeeeb;

  /* Status (system messages only): fg on its tint, surface and bg >= 4.5:1; solid fills carry --on-tone. */
  --info: #3250ff;
  --info-bg: #eceeff;
  --warning: #895e00;
  --warning-bg: #fff5dc;
  --danger: #cf0025;
  --danger-bg: #ffe9ed;
  --success: #15754b;
  --success-bg: #e3f8ef;
  --purple: #3250ff;
  --purple-bg: #eceeff;
  --neutral: #5c5b7e;
  --neutral-bg: #ecedf4;
  --on-tone: #141325;
  /* Solid status fills (badges, scan flash, done marks): the brand status colours in both themes, text --on-tone. */
  --info-fill: #8b9cff;
  --success-fill: #3ddc97;
  --warning-fill: #ffc23d;
  --danger-fill: #ff4d6d;
  --neutral-fill: #b9bcd2;

  /* Charts: cyan first, then neutral tints and cyan shades - no extra hues. */
  --chart-1: #056f92;
  --chart-2: #46456a;
  --chart-3: #0b8fc2;
  --chart-4: #8a8aa6;
  --chart-5: #0b4e66;
  --chart-6: #c5c6d8;
  --chart-bar: #dcdde8;
  --chart-bar-recent: #8a8aa6;

  /* Shadows */
  --shadow-sm: 0 1px 2px rgba(20, 19, 37, 0.06);
  --shadow-md: 0 8px 24px rgba(20, 19, 37, 0.08);
  --shadow-lg: 0 20px 40px rgba(20, 19, 37, 0.12);
  --scrim: rgba(20, 19, 37, 0.32);
}

/* Dark (default, HexaMain) - also every nested [data-theme='dark'] block */
:root:not([data-theme='light']),
[data-theme='dark'] {
  color-scheme: dark;

  /* Surfaces */
  --bg: #141325;
  --surface: #1d1c34;
  --surface-2: #191830;
  --surface-hover: #25243f;
  --surface-active: #2a2948;
  --surface-sunken: #100f1e;
  --border: #2e2d4a;
  --border-subtle: #262540;
  --border-strong: #46456a;
  --border-stronger: #5a5980;

  /* Text */
  --text: #ffffff;
  --text-muted: #b9bcd2;
  --text-subtle: #9496b0;
  --text-faint: #6e7090;
  --text-strong: #ffffff;

  /* Primary = HexaMain cyan: interactive only (buttons, links, icons, active, focus). Historic name --accent. */
  --accent: #21c2f8;
  --on-accent: #141325;
  --accent-text: #21c2f8;
  --primary: #21c2f8;
  --on-primary: #141325;
  --primary-text: #21c2f8;
  --link: #21c2f8;
  --focus-color: #21c2f8;

  /* Highlight = HexaMain orange: sparingly (Neu, eyebrow, one highlighted card). Never a status, never alternating with cyan. */
  --highlight: #ff5733;
  --on-highlight: #141325;
  --highlight-text: #ff5733;
  --highlight-bg: #351d27;

  /* Status (system messages only): fg on its tint, surface and bg >= 4.5:1; solid fills carry --on-tone. */
  --info: #8b9cff;
  --info-bg: #252644;
  --warning: #ffc23d;
  --warning-bg: #352c28;
  --danger: #ff4d6d;
  --danger-bg: #351b2f;
  --success: #3ddc97;
  --success-bg: #1a2f35;
  --purple: #8b9cff;
  --purple-bg: #252644;
  --neutral: #b9bcd2;
  --neutral-bg: #25243f;
  --on-tone: #141325;
  /* Solid status fills (badges, scan flash, done marks): the brand status colours in both themes, text --on-tone. */
  --info-fill: #8b9cff;
  --success-fill: #3ddc97;
  --warning-fill: #ffc23d;
  --danger-fill: #ff4d6d;
  --neutral-fill: #b9bcd2;

  /* Charts: cyan first, then neutral tints and cyan shades - no extra hues. */
  --chart-1: #21c2f8;
  --chart-2: #b9bcd2;
  --chart-3: #127699;
  --chart-4: #7c7e9c;
  --chart-5: #90e0fb;
  --chart-6: #5a5980;
  --chart-bar: #2e2d4a;
  --chart-bar-recent: #5a5980;

  /* Shadows */
  --shadow-sm: 0 1px 2px rgba(5, 4, 15, 0.45);
  --shadow-md: 0 10px 30px rgba(5, 4, 15, 0.5);
  --shadow-lg: 0 20px 40px rgba(5, 4, 15, 0.55);
  --scrim: rgba(8, 7, 20, 0.66);
}

/* A nested theme block (styleguide) repaints itself with its own tokens. */
[data-theme] {
  background-color: var(--bg);
  color: var(--text);
}
