/* Celvo — design tokens, the website's copy of assets/brand/tokens.css (keep the two in step). */
/* ════════════════════════════════════════════════════════════════════════════
   Celvo — design tokens (one file for celvo-tech.com and the app)

   Three layers, read top to bottom:
     1. Primitives  — raw values. Never used by components directly.
     2. Semantic    — what a value is FOR (surface, text, line, accent, status).
                      Components use only these. Light and dark both define them.
     3. Motion, type, space, shape — shared by both themes.

   Themes: light is the default (the app). The website sets data-theme="dark" on
   <html>. Any element can carry data-theme to flip a section (a dark hero on a light
   page, a light document preview inside a dark site).

   Direction: every component uses logical properties (inline-start, not left), so
   Arabic (dir="rtl") and English (dir="ltr") share the same rules.

   Contrast (WCAG 2.2, measured): text-1 16.8:1, text-2 6.5:1, text-3 4.6:1 on
   surface-1 (light); accent-solid with white text 6.3:1; every status ink ≥ 5.7:1.
   ════════════════════════════════════════════════════════════════════════════ */

:root, [data-theme="light"] {
  /* ── 1. Primitives ───────────────────────────────────────────────────────── */

  /* Stone: warm neutrals. Grey with a little clay in it, never blue-grey. */
  --stone-0:   #FCFBF8;  /* card paper */
  --stone-50:  #F6F5F1;  /* page paper (the tactile off-white) */
  --stone-100: #EEECE6;
  --stone-150: #E7E4DD;
  --stone-200: #E2DFD7;
  --stone-300: #CBC7BC;
  --stone-400: #A39E92;
  --stone-500: #8A857A;
  --stone-600: #736E64;
  --stone-650: #5C5850;
  --stone-700: #44413B;
  --stone-800: #2B2925;
  --stone-850: #221F1C;
  --stone-900: #1C1A17;  /* rich graphite */
  --stone-950: #12110F;  /* warm obsidian */
  --stone-1000:#0B0A09;

  /* Clay: the one accent. Fired brick, terracotta, the colour of a site at dusk. */
  --clay-50:  #FBF1EC;
  --clay-100: #F5DDD1;
  --clay-200: #EBBBA3;
  --clay-300: #DE936F;
  --clay-400: #CF6F44;
  --clay-500: #B9572C;
  --clay-600: #9E4521;
  --clay-700: #7F371B;
  --clay-800: #5F2A16;
  --clay-900: #3F1D10;

  /* Status inks. Functional only: never decoration, never a gradient. Each status
     also has its own shape (see .tag), so colour is never the only signal. */
  --olive-ink: #4F6B2F;  --olive-dot: #6B8E3D;  --olive-ink-d: #9DB872;
  --ochre-ink: #8A5A00;  --ochre-dot: #C48A1A;  --ochre-ink-d: #E0B04A;
  --wine-ink:  #9B1C31;  --wine-dot:  #C0334D;  --wine-ink-d:  #F07A8E;
  --steel-ink: #3E5C76;  --steel-dot: #5B7C99;  --steel-ink-d: #8FB3D1;

  /* ── 2. Semantic, light (default) ────────────────────────────────────────── */

  /* Surfaces, back to front. A tier is one step lighter (light) or one step brighter
     (dark) than the one behind it, plus a 1px line. No heavy drop shadows. */
  --surface-0: var(--stone-50);   /* page */
  --surface-1: var(--stone-0);    /* cards, tables, panels */
  --surface-2: #FFFFFF;           /* popovers, menus, the raised row */
  --surface-sunken: var(--stone-100); /* wells: inputs, code, the table header */
  --surface-inverse: var(--stone-900);

  /* Lines: hairlines in the ink colour at low alpha, so they sit right on any tier. */
  --line-1: rgb(28 26 23 / .06);  /* inside a card: row dividers */
  --line-2: rgb(28 26 23 / .10);  /* card and panel edges */
  --line-3: rgb(28 26 23 / .18);  /* inputs, secondary buttons */
  --line-strong: rgb(28 26 23 / .32);

  /* The specular top edge: light catching the top of a card. Replaces drop shadows. */
  --highlight: inset 0 1px 0 rgb(255 255 255 / .75);
  --highlight-press: inset 0 1px 1px rgb(28 26 23 / .10);

  /* Text, by contrast level. */
  --text-1: var(--stone-900);  /* headings, values, the thing you read */
  --text-2: var(--stone-650);  /* labels, secondary copy */
  --text-3: var(--stone-600);  /* hints, timestamps, placeholders (4.6:1) */
  --text-disabled: var(--stone-400);
  --text-on-accent: #FFFFFF;
  --text-on-inverse: var(--stone-50);

  /* The accent. One colour, used for: the primary action, focus, selection, the
     current place in a flow. Nothing else. */
  --accent-solid: var(--clay-600);
  --accent-solid-hover: var(--clay-700);
  --accent-solid-press: var(--clay-800);
  --accent-ink: var(--clay-700);        /* accent as text and links */
  --accent-tint: rgb(158 69 33 / .08);  /* selected row, active chip */
  --accent-tint-2: rgb(158 69 33 / .14);
  --accent-line: rgb(158 69 33 / .40);

  /* Interactive state layers, laid over any surface. */
  --state-hover: rgb(28 26 23 / .045);
  --state-press: rgb(28 26 23 / .08);
  --state-selected: var(--accent-tint);
  --focus-ring: 0 0 0 2px var(--surface-1), 0 0 0 4px var(--clay-500);

  /* Status, semantic. */
  --ok-ink: var(--olive-ink);   --ok-dot: var(--olive-dot);   --ok-tint: rgb(79 107 47 / .10);
  --warn-ink: var(--ochre-ink); --warn-dot: var(--ochre-dot); --warn-tint: rgb(196 138 26 / .13);
  --bad-ink: var(--wine-ink);   --bad-dot: var(--wine-dot);   --bad-tint: rgb(155 28 49 / .09);
  --info-ink: var(--steel-ink); --info-dot: var(--steel-dot); --info-tint: rgb(62 92 118 / .10);
  --idle-ink: var(--stone-650); --idle-dot: var(--stone-400); --idle-tint: rgb(28 26 23 / .06);

  /* Elevation: only for things that float above the page (menus, dialogs, toasts). */
  --elev-1: var(--highlight), 0 0 0 1px var(--line-2);
  --elev-2: var(--highlight), 0 0 0 1px var(--line-2), 0 1px 2px rgb(18 17 15 / .05), 0 10px 24px -12px rgb(18 17 15 / .20);
  --elev-3: var(--highlight), 0 0 0 1px var(--line-2), 0 2px 4px rgb(18 17 15 / .06), 0 24px 48px -16px rgb(18 17 15 / .28);

  /* Schematic drawing inks (graphics only, see docs/design-system.md §6). */
  --draw-ink: rgb(28 26 23 / .62);
  --draw-faint: rgb(28 26 23 / .20);
  --draw-grid: rgb(28 26 23 / .07);
  --draw-accent: var(--clay-500);

  /* ── 3. Type ─────────────────────────────────────────────────────────────── */

  /* Display: IBM Plex Sans + its Arabic twin. An engineer's typeface, drawn as one
     family for both scripts, so a mixed headline keeps one voice.
     Text: Readex Pro (Arabic + Latin), the face the app already reads best in.
     Figures: IBM Plex Mono for codes, quantities and money, always tabular. */
  --font-display: 'IBM Plex Sans', 'IBM Plex Sans Arabic', system-ui, sans-serif;
  --font-text: 'Readex Pro', 'IBM Plex Sans Arabic', 'IBM Plex Sans', system-ui, sans-serif;
  --font-mono: 'IBM Plex Mono', ui-monospace, 'SFMono-Regular', Menlo, monospace;

  /* One scale (1.2 minor third, rounded to whole pixels), shared by site and app.
     The app lives on 12–22; the site uses the full range. */
  --text-2xs: .75rem;    /* 12  labels in caps, axis ticks */
  --text-xs:  .8125rem;  /* 13  table meta, hints */
  --text-sm:  .875rem;   /* 14  app body, table cells */
  --text-md:  1rem;      /* 16  site body, app emphasis */
  --text-lg:  1.125rem;  /* 18  lead copy, card titles */
  --text-xl:  1.375rem;  /* 22  app page titles */
  --text-2xl: 1.75rem;   /* 28  site section titles */
  --text-3xl: 2.25rem;   /* 36  */
  --text-4xl: 3rem;      /* 48  hero, tablet */
  --text-5xl: 4rem;      /* 64  hero, desktop */

  --leading-tight: 1.1;   /* display, Latin */
  --leading-snug: 1.3;
  --leading-body: 1.55;
  --tracking-display: -0.022em;  /* Latin display only. Arabic is always 0: see :lang(ar) */
  --tracking-caps: 0.06em;

  --weight-regular: 400;
  --weight-medium: 500;
  --weight-semibold: 600;

  /* ── 4. Space, shape, size ───────────────────────────────────────────────── */

  --space-0: 0;
  --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; --space-24: 96px; --space-32: 128px;

  --radius-xs: 4px;    /* tags, checkboxes */
  --radius-sm: 6px;    /* inputs, buttons */
  --radius-md: 10px;   /* cards, tables */
  --radius-lg: 14px;   /* panels, the hero frame */
  --radius-full: 999px;/* status dots, the sound switch */

  --control-sm: 28px;  /* dense table toolbars */
  --control-md: 36px;  /* the app's default */
  --control-lg: 44px;  /* site CTAs, touch */
  --row-compact: 36px;
  --row-comfy: 52px;

  --stroke-hair: .75px; /* schematic secondary lines */
  --stroke-line: 1px;   /* schematic primary lines, every UI border */

  /* ── 5. Motion ───────────────────────────────────────────────────────────── */

  /* One friction curve for things arriving, a firmer one for presses. */
  --ease-out: cubic-bezier(.16, 1, .3, 1);
  --ease-press: cubic-bezier(.32, .72, 0, 1);
  --ease-in-out: cubic-bezier(.65, 0, .35, 1);

  --dur-press: 120ms;   /* scale-down on press */
  --dur-fast: 150ms;    /* hover, colour, focus */
  --dur-base: 180ms;    /* toggles, chips, checkboxes */
  --dur-view: 220ms;    /* panels, tabs, the batch bar, view changes */
  --dur-hero: 420ms;    /* marketing only: the hero's stage changes */

  --press-scale: .98;
  --press-shift: 1px;

  color-scheme: light;
}

/* ── Dark theme: the website's default, and any data-theme="dark" section ──── */
[data-theme="dark"] {
  --surface-0: var(--stone-950);
  --surface-1: var(--stone-900);
  --surface-2: var(--stone-850);
  --surface-sunken: var(--stone-1000);
  --surface-inverse: var(--stone-50);

  --line-1: rgb(255 250 240 / .05);
  --line-2: rgb(255 250 240 / .08);
  --line-3: rgb(255 250 240 / .14);
  --line-strong: rgb(255 250 240 / .26);

  --highlight: inset 0 1px 0 rgb(255 250 240 / .06);
  --highlight-press: inset 0 1px 1px rgb(0 0 0 / .35);

  --text-1: #ECE8DF;
  --text-2: var(--stone-400);
  --text-3: var(--stone-500);
  --text-disabled: var(--stone-650);
  --text-on-accent: var(--stone-950);
  --text-on-inverse: var(--stone-900);

  --accent-solid: var(--clay-400);
  --accent-solid-hover: var(--clay-300);
  --accent-solid-press: var(--clay-500);
  --accent-ink: var(--clay-300);
  --accent-tint: rgb(207 111 68 / .12);
  --accent-tint-2: rgb(207 111 68 / .20);
  --accent-line: rgb(207 111 68 / .45);

  --state-hover: rgb(255 250 240 / .04);
  --state-press: rgb(255 250 240 / .07);
  --focus-ring: 0 0 0 2px var(--surface-1), 0 0 0 4px var(--clay-300);

  --ok-ink: var(--olive-ink-d);   --ok-tint: rgb(157 184 114 / .12);
  --warn-ink: var(--ochre-ink-d); --warn-tint: rgb(224 176 74 / .12);
  --bad-ink: var(--wine-ink-d);   --bad-tint: rgb(240 122 142 / .12);
  --info-ink: var(--steel-ink-d); --info-tint: rgb(143 179 209 / .12);
  --idle-ink: var(--stone-400);   --idle-dot: var(--stone-500); --idle-tint: rgb(255 250 240 / .06);

  --elev-1: var(--highlight), 0 0 0 1px var(--line-2);
  --elev-2: var(--highlight), 0 0 0 1px var(--line-2), 0 12px 32px -12px rgb(0 0 0 / .6);
  --elev-3: var(--highlight), 0 0 0 1px var(--line-3), 0 32px 64px -24px rgb(0 0 0 / .7);

  --draw-ink: rgb(236 232 223 / .58);
  --draw-faint: rgb(236 232 223 / .18);
  --draw-grid: rgb(236 232 223 / .05);
  --draw-accent: var(--clay-400);

  color-scheme: dark;
}

/* ── Arabic: never track, give the script more room ──────────────────────────
   Letter-spacing breaks Arabic joining, and Arabic needs taller lines for its
   ascenders, descenders and dots. These override the Latin values wherever the
   content is Arabic, whatever the page direction. */
:lang(ar) {
  --tracking-display: 0;
  --tracking-caps: 0;
  --leading-tight: 1.3;
  --leading-snug: 1.45;
  --leading-body: 1.75;
}

/* ── Reduced motion: keep feedback, drop travel ──────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  :root {
    --dur-press: 0ms; --dur-view: 0ms; --dur-hero: 0ms;
    --press-scale: 1; --press-shift: 0px;
  }
}
