/*
 * SCL UI — design tokens. ONE source of truth for every SCL internal tool.
 *
 * Primitives are OKLCH-generated scales anchored on the logo: navy-900 is the
 * logo navy #002B49, gold-500 the logo gold #AC8C2E. Every text/background
 * pairing below is checked for WCAG AA (docs/design-system.md, palette.py).
 * Components use SEMANTIC tokens only (--color-*), never primitives, so the
 * dark theme is a token swap, not a second stylesheet.
 *
 * Layer order is declared in every SCL UI file; unlayered app CSS always wins,
 * so an existing app can adopt this without breaking.
 */
@layer scl.reset, scl.tokens, scl.base, scl.layout, scl.components, scl.utilities;

@layer scl.tokens {
  :root {
    /* ---- primitives ---------------------------------------------------- */
    --navy-50: #f1f8fe;
    --navy-100: #deeffe;
    --navy-200: #beddfa;
    --navy-300: #95c3ec;
    --navy-400: #6aa5d7;
    --navy-500: #4586bb;
    --navy-600: #2b6b9d;
    --navy-700: #18517b;
    --navy-800: #0f3b5b;
    --navy-900: #002b49;
    --navy-950: #0b1722;
    --gold-50: #fcf6e8;
    --gold-100: #f6ecd2;
    --gold-200: #ead8a9;
    --gold-300: #d6bb75;
    --gold-400: #bc9a3b;
    --gold-500: #ac8c2e;
    --gold-600: #7d6204;
    --gold-700: #5f4a01;
    --gold-800: #463602;
    --gold-900: #312501;
    --gold-950: #1c1504;
    --slate-50: #f2f7fc;
    --slate-100: #e7eef4;
    --slate-200: #d2dae2;
    --slate-300: #b5bfc9;
    --slate-400: #94a0ab;
    --slate-500: #76828d;
    --slate-600: #5c6872;
    --slate-700: #444e57;
    --slate-800: #313940;
    --slate-900: #21272d;
    --slate-950: #12171a;
    --green-50: #ecfcf0;
    --green-100: #d8f6e1;
    --green-200: #b3e8c4;
    --green-300: #82d39f;
    --green-400: #4ab778;
    --green-500: #049957;
    --green-600: #057a45;
    --green-700: #035d33;
    --green-800: #004424;
    --green-900: #002f17;
    --green-950: #051b0e;
    --amber-50: #fff5ea;
    --amber-100: #ffe9d0;
    --amber-200: #fbd1a1;
    --amber-300: #eeb066;
    --amber-400: #d78c17;
    --amber-500: #b07002;
    --amber-600: #8d5900;
    --amber-700: #6b4303;
    --amber-800: #4f3001;
    --amber-900: #382101;
    --amber-950: #221201;
    --red-50: #fff4f3;
    --red-100: #ffe6e4;
    --red-200: #fecbc5;
    --red-300: #ffa098;
    --red-400: #f86b65;
    --red-500: #da4242;
    --red-600: #b92229;
    --red-700: #920817;
    --red-800: #6d040e;
    --red-900: #4b090b;
    --red-950: #280b0a;
    --blue-50: #f1f8fe;
    --blue-100: #e0efff;
    --blue-200: #bdddff;
    --blue-300: #89c3fe;
    --blue-400: #46a3fa;
    --blue-500: #0183e0;
    --blue-600: #0168b4;
    --blue-700: #024f8a;
    --blue-800: #003967;
    --blue-900: #00274a;
    --blue-950: #051729;
    --white: #ffffff;

    /* ---- type ---------------------------------------------------------- */
    --font-sans: "Instrument Sans", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
    --font-mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
    --text-xs: 0.75rem;     /* 12 */
    --text-sm: 0.8125rem;   /* 13 */
    --text-base: 0.9375rem; /* 15 */
    --text-md: 1.0625rem;   /* 17 */
    --text-lg: 1.25rem;     /* 20 */
    --text-xl: 1.5rem;      /* 24 */
    --text-2xl: 1.875rem;   /* 30 */
    --text-3xl: clamp(1.875rem, 1.4rem + 1.6vw, 2.5rem); /* 30-40 */
    --leading-tight: 1.15;
    --leading-snug: 1.3;
    --leading-body: 1.55;
    --tracking-tight: -0.022em;
    --tracking-snug: -0.012em;
    --weight-regular: 420;
    --weight-medium: 520;
    --weight-semibold: 620;
    --weight-bold: 700;

    /* ---- space (4px grid) ------------------------------------------------ */
    --space-0-5: 2px; --space-1: 4px; --space-1-5: 6px; --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;

    /* ---- shape: radius rises with the size of the thing ------------------ */
    --radius-xs: 4px;   /* badges, chips */
    --radius-sm: 6px;   /* small controls */
    --radius-md: 8px;   /* buttons, inputs */
    --radius-lg: 12px;  /* panels */
    --radius-xl: 16px;  /* page-level feature blocks */
    --radius-full: 999px;

    /* ---- elevation (navy-tinted, never neutral grey) --------------------- */
    --shadow-xs: 0 1px 2px rgb(0 43 73 / 0.06);
    --shadow-sm: 0 1px 3px rgb(0 43 73 / 0.08), 0 1px 2px rgb(0 43 73 / 0.04);
    --shadow-md: 0 6px 16px -4px rgb(0 43 73 / 0.12), 0 2px 4px rgb(0 43 73 / 0.05);
    --shadow-lg: 0 20px 44px -12px rgb(0 43 73 / 0.24);

    /* ---- motion ---------------------------------------------------------- */
    --ease-out: cubic-bezier(0.2, 0.8, 0.2, 1);
    --ease-in-out: cubic-bezier(0.65, 0, 0.35, 1);
    --duration-fast: 120ms;
    --duration-base: 200ms;
    --duration-slow: 320ms;

    /* ---- layout ---------------------------------------------------------- */
    --sidebar-width: 252px;
    --topbar-height: 56px;
    --content-max: 1240px;
    --control-height: 40px;
    --control-height-sm: 32px;
    --control-height-lg: 48px;
    --z-sticky: 20; --z-drawer: 40; --z-overlay: 50; --z-toast: 60;

    /* ---- semantic colour -------------------------------------------------
       Each token states its LIGHT and DARK value side by side with
       light-dark(), so the themes can't drift apart. Theme follows the
       system unless <html data-theme="light|dark"> forces one.
       Light: navy rail, navy primary actions, gold accents.
       Dark (chosen 1 Dec): calm neutral greys, charcoal rail, gold primary
       actions. Every pair AA-checked — see docs/design-system.md. */
    color-scheme: light dark;
    --color-canvas:         light-dark(var(--slate-50), var(--slate-950));
    --color-surface:        light-dark(var(--white), var(--slate-900));
    --color-surface-sunken: light-dark(var(--slate-100), #0d1114);
    --color-surface-raised: light-dark(var(--slate-100), var(--slate-800));
    --color-surface-hover:  light-dark(var(--slate-50), #2a3138);
    --color-text:           light-dark(var(--slate-900), var(--slate-50));
    --color-text-muted:     light-dark(var(--slate-600), #a3aeb9);
    --color-text-subtle:    light-dark(var(--slate-500), var(--slate-500));
    --color-text-inverse:   light-dark(var(--white), var(--navy-950));
    --color-border:         light-dark(var(--slate-200), var(--slate-800));
    --color-border-strong:  light-dark(#828e99, #6b7781); /* control edges: ≥ 3:1 on surface and canvas (WCAG 1.4.11) */

    --color-brand:          light-dark(var(--navy-900), var(--gold-400));   /* primary actions */
    --color-brand-hover:    light-dark(var(--navy-800), var(--gold-300));
    --color-on-brand:       light-dark(var(--white), var(--navy-950));
    --color-brand-text:     light-dark(var(--navy-700), var(--navy-300));   /* links */
    --color-brand-soft:     light-dark(var(--navy-50), color-mix(in srgb, var(--navy-500) 18%, var(--slate-900)));
    --color-brand-border:   light-dark(var(--navy-200), var(--navy-800));

    /* emphasis: selected states and your own messages — never gold, so gold
       stays reserved for primary buttons and small accents */
    --color-emphasis:       light-dark(var(--navy-900), #3a4d63);
    --color-on-emphasis:    var(--white);

    --color-accent:         light-dark(var(--gold-500), var(--gold-400));   /* decoration, never small text */
    --color-accent-text:    light-dark(var(--gold-700), var(--gold-300));
    --color-accent-soft:    light-dark(var(--gold-50), color-mix(in srgb, var(--gold-500) 16%, var(--slate-900)));
    --color-accent-border:  light-dark(var(--gold-200), var(--gold-800));

    --color-focus:          light-dark(var(--navy-500), var(--gold-400));

    --color-success-text:   light-dark(var(--green-700), var(--green-300));
    --color-success-soft:   light-dark(var(--green-50), color-mix(in srgb, var(--green-500) 16%, var(--slate-900)));
    --color-success-border: light-dark(var(--green-200), var(--green-800));
    --color-success-solid:  light-dark(var(--green-600), var(--green-400));
    --color-warning-text:   light-dark(var(--amber-700), var(--amber-300));
    --color-warning-soft:   light-dark(var(--amber-50), color-mix(in srgb, var(--amber-500) 16%, var(--slate-900)));
    --color-warning-border: light-dark(var(--amber-200), var(--amber-800));
    --color-warning-solid:  light-dark(var(--amber-500), var(--amber-400));
    --color-danger-text:    light-dark(var(--red-700), var(--red-300));
    --color-danger-soft:    light-dark(var(--red-50), color-mix(in srgb, var(--red-500) 16%, var(--slate-900)));
    --color-danger-border:  light-dark(var(--red-200), var(--red-800));
    --color-danger-solid:   light-dark(var(--red-600), var(--red-400));
    --color-info-text:      light-dark(var(--blue-700), var(--blue-300));
    --color-info-soft:      light-dark(var(--blue-50), color-mix(in srgb, var(--blue-500) 16%, var(--slate-900)));
    --color-info-border:    light-dark(var(--blue-200), var(--blue-800));
    --color-info-solid:     light-dark(var(--blue-600), var(--blue-400));

    /* navigation rail — brand navy in light, charcoal (same family as the
       page) in dark */
    --nav-bg:          light-dark(var(--navy-900), #0d1114);
    --nav-text:        light-dark(var(--navy-200), var(--slate-300));
    --nav-text-subtle: light-dark(var(--navy-300), var(--slate-500));
    --nav-text-strong: var(--white);
    --nav-hover-bg:    rgb(255 255 255 / 0.06);
    --nav-active-bg:   light-dark(var(--navy-800), var(--slate-800));
    --nav-indicator:   var(--gold-400);
    --nav-border:      light-dark(rgb(255 255 255 / 0.08), var(--slate-800));
  }

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

  /* Shadows aren't colours, so light-dark() can't switch them: dark needs
     deeper, navy-black shadows to read at all. */
  @media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) { --shadow-xs: 0 1px 2px rgb(0 0 0 / 0.4); --shadow-sm: 0 1px 3px rgb(0 0 0 / 0.45); --shadow-md: 0 8px 20px -6px rgb(0 0 0 / 0.55); --shadow-lg: 0 24px 48px -12px rgb(0 0 0 / 0.65); }
  }
  :root[data-theme="dark"] { --shadow-xs: 0 1px 2px rgb(0 0 0 / 0.4); --shadow-sm: 0 1px 3px rgb(0 0 0 / 0.45); --shadow-md: 0 8px 20px -6px rgb(0 0 0 / 0.55); --shadow-lg: 0 24px 48px -12px rgb(0 0 0 / 0.65); }
}
