/* ============================================================================
   RedAI Studios — design tokens v1.0
   Source of truth: Brand Handoff v1.0 §04 (colour) + §06 (type),
   extended by the Product Design Language for product-only concerns.

   Two consumers:
     • ReDeal CRM (Tailwind v3) — reads the `--brand-*` channel triplets that
       tailwind.config.js already maps to `rgb(var(--brand-500) / <alpha-value>)`.
       This file is a superset of the ramp currently in src/frontend/index.css.
     • Static sites / anything not on Tailwind — read the `--c-*` hex tokens.

   Channel triplets (no commas) exist so Tailwind can apply alpha. Hex tokens
   exist so plain CSS can use them directly. They describe the same colours.

   RULE: no colour literal anywhere in a component. If you need a colour that
   isn't here, add it here first, with a one-line note on when to use it.
   ========================================================================== */

:root {
  /* ---- Brand core (Handoff §04) ------------------------------------------ */
  --c-signal-red: #ff5964; /* interactive accent: primary fill, links, focus, selection */
  --c-brand-red:  #d42438; /* large fills, primary hover, knockout panels */
  --c-deep-red:   #c31832; /* pressed state, semantic danger, print-safe */
  --c-ink:        #0b0d11; /* text + dark surfaces. never #000 */
  --c-paper:      #f7f8fa; /* light surfaces. never #fff for page background */

  /* Brand ramp as rgb channels. 500/600/700 are the three named brand reds
     verbatim; the lighter steps are Signal Red mixed toward white on the same
     curve BrandingContext.applyAccent() uses, so a customer's generated ramp
     and ours behave identically. */
  --brand-50:  255 240 242;
  --brand-100: 255 228 231;
  --brand-200: 255 197 201;
  --brand-300: 255 155 162;
  --brand-400: 255 114 123;
  --brand-500: 255  89 100; /* Signal Red  #FF5964 */
  --brand-600: 212  36  56; /* Brand Red   #D42438 */
  --brand-700: 195  24  50; /* Deep Red    #C31832 */
  --brand-800: 158  19  40;
  --brand-900: 125  15  32;

  /* ---- Surfaces ---------------------------------------------------------- */
  /* A faint cool tint rather than flat grey, so white cards lift off the page. */
  --surface:        248 249 252;
  --surface-raised: 255 255 255;
  --surface-sunken: 241 243 247; /* table headers, inset wells */

  /* ---- Structure (the 30% in the 60/30/10 allocation) ----------------------
     The PDL names "slate borders, dividers, muted text" but no token carried them, so every
     product was picking its own slate. Measured against Paper #F7F8FA before being written here.

     --c-border is DECORATIVE ONLY: 1.23:1 on white, which is correct for a card edge or a
     divider and is NOT sufficient for anything WCAG 1.4.11 treats as a UI boundary.
     --c-border-control is the one to use on an input, select or any control whose edge is the
     only thing telling you where it is: 4.76:1 on white, where slate-200/300/400 all fail 3:1.
     --c-text-muted is slate-600, not slate-500: slate-500 measures 4.48:1 on Paper and misses
     AA body text by 0.02. */
  --c-border:         #e2e8f0; /* slate-200 — card edges, dividers, table rules. Decorative. */
  --c-border-control: #64748b; /* slate-500 — input/control boundaries. Meets 3:1 on white. */
  --c-text-muted:     #475569; /* slate-600 — labels, meta, captions. AA on Paper at 7.13:1. */

  /* Added 22 Oct 2026 (redmatic-site), measured before writing:
     --c-text is the body colour per theme, so plain CSS needn't know which of ink/paper applies.
     --c-focus is the focus ring. Signal Red on Paper is 2.88:1 and FAILS 3:1 for a focus indicator;
     Brand Red is 4.81:1. In dark mode Signal Red is 6.4:1 and is used there.
     --c-action is the primary button fill. White on Signal Red is 3.06:1 and FAILS AA for 14px
     label text; white on Brand Red is 5.11:1. Hover goes to Deep Red (6.0:1). */
  --c-text:   #0b0d11;
  --c-focus:  #d42438;
  --c-action: #d42438;
  --c-action-hover: #c31832;
  --c-on-action:    #ffffff; /* label on --c-action, both themes */

  /* ---- Semantic -----------------------------------------------------------
     Danger is Deep Red, not Signal Red: separated from the interactive accent
     by lightness (L≈0.48 vs 0.68) and by a mandatory icon. See PDL §1.2. */
  --c-danger:  #c31832;
  --c-warning: #b45309; /* amber-700 — passes AA on Paper, unlike lighter ambers */
  --c-success: #047857; /* emerald-700 */
  --c-info:    #334155; /* slate-700 — info is structural, not blue */

  /* ---- Product accents (Handoff §04) — DETAIL ONLY -------------------------
     Sanctioned product use: chart series and product-identity chips.
     Never a button fill, card fill, or nav surface. */
  --c-accent-redai:    #ffb27a;
  --c-accent-redmatic: #ff9a3d;
  --c-accent-redeal:   #ffd166;
  --c-accent-retrack:  #5fd8bd;
  --c-accent-albot:    #8e9bff;

  /* ---- Chart series -------------------------------------------------------
     Ordered for maximum hue separation. Never place series 3/4/5 adjacent —
     interleave, or the chart reads as one orange smear. Signal Red is NOT a
     series colour: in a chart, red means "look here". */
  --chart-1: var(--c-accent-albot);
  --chart-2: var(--c-accent-retrack);
  --chart-3: var(--c-accent-redmatic);
  --chart-4: var(--c-accent-redeal);
  --chart-5: var(--c-accent-redai);
  --chart-6: #64748b; /* slate-500 */
  --chart-highlight: var(--c-signal-red);
  --chart-grid: rgb(15 23 42 / 0.10);

  /* ---- Typography (Handoff §06) -------------------------------------------
     Inter is the interface face. Tektur is NEVER typed — placed SVG only. */
  --font-sans: "Inter var", "Inter", ui-sans-serif, system-ui, -apple-system,
    "Segoe UI Variable Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, "SF Mono", "Cascadia Mono", "JetBrains Mono", Menlo, monospace;

  --text-display: 1.875rem; --leading-display: 2.25rem; --tracking-display: -0.024em;
  --text-h1:      1.5rem;   --leading-h1:      2rem;    --tracking-h1:      -0.024em;
  --text-h2:      1rem;     --leading-h2:      1.5rem;  --tracking-h2:      -0.018em;
  --text-body:    0.875rem; --leading-body:    1.25rem;
  --text-caption: 0.75rem;  --leading-caption: 1rem;    --tracking-caption: 0.005em;
  /* Weights: 400 body, 500 label/button, 600 heading. Nothing above 600. */

  /* ---- Space — 4px base. These eight values only. -------------------------- */
  --space-1: 0.25rem; --space-2: 0.5rem;  --space-3: 0.75rem; --space-4: 1rem;
  --space-6: 1.5rem;  --space-8: 2rem;    --space-12: 3rem;   --space-16: 4rem;

  /* ---- Radii — one per element class --------------------------------------- */
  --radius-control: 0.5rem;   /* buttons, inputs, chips */
  --radius-card:    0.75rem;  /* cards, tables, panels */
  --radius-pill:    9999px;

  /* ---- Elevation — layered low-opacity, never one hard drop shadow ---------- */
  --shadow-xs:         0 1px 2px 0 rgb(15 23 42 / 0.04);
  --shadow-card:       0 1px 2px -1px rgb(15 23 42 / 0.06), 0 2px 6px -1px rgb(15 23 42 / 0.05);
  --shadow-card-hover: 0 4px 12px -2px rgb(15 23 42 / 0.10), 0 12px 28px -8px rgb(15 23 42 / 0.12);
  --shadow-pop:        0 8px 24px -6px rgb(15 23 42 / 0.14), 0 20px 48px -12px rgb(15 23 42 / 0.16);

  /* ---- Motion — nothing over 300ms ----------------------------------------- */
  --dur-fast:   120ms; /* colour / opacity hover */
  --dur-enter:  180ms; /* fade + 4px rise */
  --dur-panel:  240ms; /* drawer, modal, sheet */
  --dur-exit:   140ms;
  --ease-out:    cubic-bezier(0, 0, 0.2, 1);
  --ease-in:     cubic-bezier(0.4, 0, 1, 1);
  --ease-spring: cubic-bezier(0.16, 1, 0.3, 1);

  /* ---- Density ------------------------------------------------------------- */
  --row-h:            2.5rem;   /* 40px table row, comfortable */
  --row-h-compact:    2.25rem;  /* 36px */
  --control-h:        2.25rem;  /* 36px */
  --control-h-filter: 2rem;     /* 32px */
  --touch-min:        2.75rem;  /* 44px minimum hit area on touch-primary screens */
  --content-max:      90rem;    /* 1440px */
}

.dark {
  /* Cool near-black, not pure black — easier over a long session, and it lets
     elevated surfaces actually read as raised. */
  --surface:        9 11 18;
  --surface-raised: 17 20 30;
  --surface-sunken: 6 8 13;

  --c-paper: #e6e8ee;
  --c-ink:   #0b0d11;

  /* Measured on --surface (9 11 18) and --surface-raised (17 20 30), 22 Oct 2026:
     text 16.05:1; muted slate-400 7.67 / 7.15:1 (slate-600 fails here); focus Signal Red 6.43:1;
     control border slate-500 4.13 / 3.85:1 (unchanged). Border is decorative, like the light one. */
  --c-text:         #e6e8ee;
  --c-text-muted:   #94a3b8; /* slate-400 */
  --c-border:       #1e293b; /* slate-800 */
  --c-focus:        #ff5964;

  /* Deep Red loses too much contrast on a near-black ground; danger lightens
     toward Brand Red in dark mode while staying below Signal Red. */
  --c-danger:  #e0455a;
  --c-warning: #f59e0b;
  --c-success: #34d399;
  --c-info:    #94a3b8;

  --chart-grid: rgb(226 232 240 / 0.10);

  --shadow-card:       0 1px 2px -1px rgb(0 0 0 / 0.40), 0 2px 6px -1px rgb(0 0 0 / 0.35);
  --shadow-card-hover: 0 4px 12px -2px rgb(0 0 0 / 0.50), 0 12px 28px -8px rgb(0 0 0 / 0.45);
  --shadow-pop:        0 8px 24px -6px rgb(0 0 0 / 0.55), 0 20px 48px -12px rgb(0 0 0 / 0.50);
}
