/* ==========================================================================
   Nexteryale — design tokens (the contract between design and front-end).

   Source of the values: the sider.ai production tokens (`--sds-*`) recorded
   in docs/research/sider-ai.md §4 — surfaces, single violet accent, black
   pill CTA, text and lines as ALPHA of a blue-grey, near-zero shadows.
   Where a Sider value fails WCAG AA it is darkened/lightened and the
   deviation is written next to the token ("AA:" comments).

   Theme model
   -----------
   Every colour is declared ONCE with light-dark(<light>, <dark>). The active
   branch is picked by `color-scheme`:
     - default            → `light dark`  → follows prefers-color-scheme
     - [data-theme=light] → forced light
     - [data-theme=dark]  → forced dark
   Why light-dark() rather than a duplicated dark block: a single source per
   token means light and dark can never drift apart (Chrome 123+, Firefox 120+,
   Safari 17.5+ — acceptable for a demo; see docs/design/README.md).

   Contrast (WCAG 2.x): python docs/design/tools/contrast.py — alpha tokens
   are composited on each background before measuring; 0 failing pair.

   Font: DM Sans (Sider's face), ONE self-hosted file — latin subset,
   variable weight 400-600, opsz pinned at 14: 20.5 KB woff2, font-display
   swap, system-ui underneath so first paint never waits for it.
   ========================================================================== */

@font-face {
  font-family: "DM Sans";
  font-style: normal;
  font-weight: 400 600;
  font-display: swap;
  src: url("fonts/dm-sans-latin.woff2") format("woff2");
  unicode-range: U+0020-007E, U+00A0-00FF, U+0152-0153, U+2013-2014, U+2018-201E,
                 U+2022, U+2026, U+202F, U+20AC, U+2122, U+2190-2193, U+21B5;
}

:root {
  color-scheme: light dark;
}
:root[data-theme="light"] { color-scheme: light; }
:root[data-theme="dark"]  { color-scheme: dark; }

:root {
  /* ---- Surfaces (Sider layer1/2/3) ----------------------------------- */
  --color-bg:             light-dark(#ffffff, #0c0d19); /* chat thread (light: layer2 white, dark: layer1) */
  --color-surface:        light-dark(#f6f6f8, #141522); /* sidebar, panels (light: layer1) */
  --color-surface-2:      light-dark(#ededf1, #262735); /* hover rows, chips, user bubble (grey-fill) */
  --color-surface-raised: light-dark(#ffffff, #1e1f2b); /* composer, cards (layer2) */
  --color-surface-overlay:light-dark(#ffffff, #2e2f3c); /* menus, popovers (layer3) */
  --color-overlay:        light-dark(rgb(12 13 25 / 0.32), rgb(0 0 0 / 0.60)); /* modal scrim */

  /* ---- Lines (alpha of 114,118,139 — Sider line1/line2) -------------- */
  --color-border:         light-dark(rgb(114 118 139 / 0.16), rgb(114 118 139 / 0.24)); /* hairlines */
  --color-border-strong:  light-dark(rgb(114 118 139 / 0.28), rgb(114 118 139 / 0.40)); /* hover cards, dashed */
  /* Boundary of a control whose outline is its only cue (checkbox, toggle
     track, bare text field) — ≥ 3:1 per WCAG 1.4.11. The composer does NOT
     need it: placeholder + raised fill identify it. */
  --color-border-control: light-dark(#8a8ca0, #7c7e96);

  /* ---- Text (alpha of 10,13,51 light / 220,223,249 dark) ------------- */
  --color-text:           light-dark(rgb(6 8 31 / 0.88), rgb(220 223 249 / 0.92));
  --color-text-strong:    light-dark(rgb(0 0 0 / 0.96), #ffffff);       /* titles */
  --color-text-muted:     light-dark(rgb(10 13 51 / 0.66), rgb(214 218 255 / 0.64)); /* Sider -3 (.60/.56) nudged for AA on fills */
  --color-text-subtle:    light-dark(rgb(10 13 51 / 0.60), rgb(214 218 255 / 0.58)); /* AA: Sider -4 is .45/.40 — raised */

  /* ---- Accent: ONE violet ------------------------------------------- */
  --color-accent:          light-dark(#6128ff, #7f60ff); /* fills, active states; as TEXT only on --color-bg (else --color-link) */
  --color-accent-hover:    light-dark(#6a3fff, #937dff);
  --color-accent-pressed:  light-dark(#561bef, #896fff);
  --color-accent-contrast: light-dark(#ffffff, #0c0d19); /* AA: white on #7f60ff is 4.0 → dark ink in dark mode */
  --color-accent-soft:     light-dark(#f2eeff, #241f4a); /* = rgba(122,89,255,.08/.24) flattened: selected row */
  --color-accent-soft-text:light-dark(#561bef, #c4b8ff);
  --color-link:            light-dark(#6128ff, #a593ff); /* accent as text on ANY surface (raised included) */

  /* ---- Primary CTA: black pill (Sider advanced-fill) ----------------- */
  --color-cta:          light-dark(#0c0d19, #7f60ff);
  --color-cta-hover:    light-dark(#2a2b3a, #937dff);
  --color-cta-contrast: light-dark(#ffffff, #0c0d19);

  /* ---- Status (Sider hues, darkened where text needs AA) ------------- */
  --color-danger:       light-dark(#c9362a, #f57365); /* AA: Sider #e55649 is 3.6 on white */
  --color-danger-soft:  light-dark(#fff0ee, #390001);
  --color-success:      light-dark(#10785a, #3fcf9c); /* AA: Sider #20b082 is 2.9 on white */
  --color-success-soft: light-dark(#f0f9f1, #001c12);
  --color-warning:      light-dark(#8a5800, #e4d200);
  --color-warning-soft: light-dark(#fdf6dc, #2a2600);
  --color-info:         light-dark(#1065d6, #6aa6ff);
  --color-info-soft:    light-dark(#f1f3ff, #00163a);

  /* ---- Focus --------------------------------------------------------- */
  /* Solid 2px ring (AA 1.4.11) + Sider's soft violet halo around it. */
  --color-focus-ring: light-dark(#6128ff, #937dff);
  --shadow-focus: 0 0 0 4px light-dark(rgb(122 89 255 / 0.16), rgb(122 89 255 / 0.32));

  /* ---- Code ---------------------------------------------------------- */
  /* Code blocks follow the theme (no black slab in light mode); the header
     bar, not a contrasting fill, is what gives a block its identity. */
  --color-code-bg:        light-dark(#f6f6f8, #141522);
  --color-code-header-bg: light-dark(#ededf1, #1e1f2b);
  --color-code-text:      light-dark(#1c1e33, #e3e5f8);
  --color-code-inline-bg: light-dark(#ededf1, #262735);
  /* Syntax palette — each ≥ 4.5:1 on --color-code-bg. */
  --syntax-comment:  light-dark(#62647a, #8e90a8);
  --syntax-keyword:  light-dark(#5a1fe6, #b4a4ff);
  --syntax-string:   light-dark(#10785a, #6fdcb2);
  --syntax-number:   light-dark(#a44a00, #ffb072);
  --syntax-function: light-dark(#1060c8, #7fb2ff);
  --syntax-type:     light-dark(#b0177a, #ff8fd0);
  --syntax-punct:    light-dark(#4a4c62, #b4b6cc);

  /* ---- Typography ---------------------------------------------------- */
  --font-sans: "DM Sans", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue",
               Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji";
  --font-mono: ui-monospace, "Cascadia Code", "SF Mono", Menlo, Consolas,
               "Liberation Mono", monospace;

  --text-xs:  0.75rem;   /* 12 — badges, meta, rail labels */
  --text-sm:  0.875rem;  /* 14 — sidebar rows, buttons, code */
  --text-md:  1rem;      /* 16 — message body (Sider body size) */
  --text-lg:  1.125rem;  /* 18 — section titles */
  --text-xl:  1.5rem;    /* 24 — card / page titles */
  --text-2xl: 2.25rem;   /* 36 — empty-state greeting */

  --leading-tight: 1.25;
  --leading-normal: 1.5;
  --leading-relaxed: 1.65; /* long assistant answers */

  --weight-regular: 400;
  --weight-medium: 500;
  --weight-semibold: 600;

  /* ---- Spacing (4px grid) ------------------------------------------- */
  --space-1: 0.25rem; /*  4 */
  --space-2: 0.5rem;  /*  8 */
  --space-3: 0.75rem; /* 12 */
  --space-4: 1rem;    /* 16 */
  --space-5: 1.25rem; /* 20 */
  --space-6: 1.5rem;  /* 24 */
  --space-7: 2rem;    /* 32 */
  --space-8: 3rem;    /* 48 */

  /* ---- Radii (Sider: 8 · 12 · 16 · 24 · pill) ------------------------ */
  --radius-xs: 4px;    /* inline code, kbd */
  --radius-sm: 8px;    /* chips, small buttons, thumbnails */
  --radius-md: 12px;   /* buttons, inputs, menu items */
  --radius-lg: 16px;   /* cards, code blocks, bubbles, panels */
  --radius-xl: 24px;   /* composer, hero cards */
  --radius-full: 9999px;

  /* ---- Elevation ----------------------------------------------------- */
  /* Sider separates by lines and grey fills, almost never by shadow; only
     floating layers (menus, dialogs) cast one. Dark mode: elevation = the
     lighter layer tone, shadows only deepen. */
  --shadow-color: light-dark(rgb(12 13 25 / 0.06), rgb(0 0 0 / 0.50));
  --shadow-sm: 0 1px 2px var(--shadow-color);
  --shadow-md: 0 2px 8px var(--shadow-color);
  --shadow-lg: 0 4px 12px var(--shadow-color), 0 16px 40px var(--shadow-color);

  /* ---- Layout -------------------------------------------------------- */
  --sidebar-width: 264px;
  --sidebar-width-collapsed: 64px;
  --chat-max-width: 760px;     /* reading column of the thread + composer */
  --artifact-width: min(46vw, 720px);
  --pane-min-width: 340px;     /* multipane column floor */
  --topbar-height: 56px;
  --hit-target: 36px;          /* min height of icon buttons (pointer UI) */

  /* ---- Layering ------------------------------------------------------ */
  --z-sticky: 10;
  --z-popover: 100;
  --z-modal: 200;
  --z-toast: 300;

  /* ---- Motion -------------------------------------------------------- */
  --duration-fast: 120ms;   /* hover, press */
  --duration-base: 200ms;   /* menus, toggles */
  --duration-slow: 320ms;   /* panels sliding in */
  --ease-standard: cubic-bezier(0.2, 0, 0, 1);
  --ease-emphasized: cubic-bezier(0.3, 0, 0, 1.15); /* slight overshoot, entering panels */
  --ease-exit: cubic-bezier(0.3, 0, 1, 1);
  --duration-enter: 260ms;  /* a message / menu appearing */
  --ease-spring: cubic-bezier(0.34, 1.4, 0.64, 1); /* small press/pop feedback */

  /* ---- Beautify layer (m0-beautify) ---------------------------------- */
  /* QUOI : depth and accent "volume" on top of Sider's flat language.
     POURQUOI : Alexi asked for more visual volume without leaving Sider —
     so the accent stays ONE violet, gradients only go violet → lighter violet,
     and shadows stay soft (tinted by the accent, never grey slabs).
     COMMENT : every gradient end-stop used under text is listed in
     contrast.py (accent-2 on bg ≥ 4.5). */
  --color-accent-2: light-dark(#7b3cf5, #a593ff);   /* gradient end-stop (AA on bg) */
  --gradient-accent: linear-gradient(135deg, var(--color-accent) 0%, var(--color-accent-2) 100%);
  /* Soft violet glow behind empty states / hero — a light, not a fill. */
  --gradient-glow: radial-gradient(closest-side, light-dark(rgb(122 89 255 / 0.14), rgb(122 89 255 / 0.22)), transparent);
  /* Hairline that fades out at both ends (topbar, separators). */
  --gradient-hairline: linear-gradient(90deg, transparent, var(--color-border-strong) 20%, var(--color-border-strong) 80%, transparent);
  /* Glass surface: bar over scrolling content. */
  --color-glass: light-dark(rgb(255 255 255 / 0.72), rgb(12 13 25 / 0.70));
  --blur-glass: saturate(1.6) blur(14px);

  /* Raised card (composer): a contact shadow + a long, accent-tinted drop. */
  --shadow-raised: 0 1px 2px var(--shadow-color),
                   0 12px 32px -12px light-dark(rgb(97 40 255 / 0.16), rgb(0 0 0 / 0.70));
  /* Accent glow for the primary violet elements (brand mark, active send). */
  --shadow-accent: 0 6px 18px -6px light-dark(rgb(97 40 255 / 0.45), rgb(127 96 255 / 0.55));
  /* Inner top highlight that makes a fill read as a lit surface. */
  --shadow-inset-highlight: inset 0 1px 0 light-dark(rgb(255 255 255 / 0.9), rgb(255 255 255 / 0.06));
}

/* Touch screens: targets grow to 48px (WCAG 2.5.5 / Material touch floor). */
@media (pointer: coarse) {
  :root { --hit-target: 48px; }
}
