/*
 * FoloForge design tokens (V2): the single source of truth for colour, type, space, shape, depth and motion,
 * on every page the product draws: the studio, the Builder, sign-in, the developer page and the staff
 * application. Every value a component uses comes from here. Canonical copy of uiux/v2/css/tokens.css (the
 * prototype the design was decided on); a value changed here is changed there too.
 *
 * Three colour layers:
 *   steel   the neutral ground every surface shares
 *   forge   FoloForge's own ember: the brand mark and the primary action in Build mode only
 *   pencil  the AI colour: anything an AI wrote that a person has not confirmed yet
 * Use mode and every outside page use the company's brand (--brand*), derived and contrast-guarded from one
 * hex value by public/ds/brand-guard.js. No dark theme: light only, by decision.
 *
 * The faces are in fonts.css, next to this file.
 */

:root {
  /* ── Steel: the neutral ground ─────────────────────────────── contrast on #FFF */
  --c-canvas: #F4F5F7;          /* app background, sidebar */
  --c-surface: #FFFFFF;         /* content, cards, inputs */
  --c-sunken: #ECEEF1;          /* wells, code, inactive segments */
  --c-hover: #EEF0F3;           /* row and item hover */
  --c-line: #E0E3E8;            /* hairlines between content (decorative) */
  --c-line-strong: #C8CDD5;     /* card and button outlines */
  --c-line-input: #8A93A0;      /* field boundaries: 3.11:1, meets 1.4.11 */
  --c-ink: #10151C;             /* primary text 18.32:1 */
  --c-ink-2: #444D5A;           /* secondary text 8.55:1 */
  --c-muted: #5E6876;           /* tertiary text 5.65:1 (4.86:1 on sunken) */
  --c-disabled: #8A93A0;        /* disabled text only (exempt) */
  --c-scrim: rgba(16, 21, 28, 0.44);

  /* ── Forge: FoloForge's ember. Build mode's primary, the brand mark. Nothing else. ── */
  --c-forge: #C8461B;           /* white text on it 4.83:1 */
  --c-forge-hover: #B23C15;
  --c-forge-press: #9A3311;
  --c-forge-tint: #FBEEE8;
  --c-forge-line: #F0C7B5;

  /* ── Pencil: AI. Draft until a person confirms it. ── */
  --c-ai: #5A4BD6;              /* 6.15:1 */
  --c-ai-ink: #4A3CC4;          /* text on tint 6.71:1 */
  --c-ai-tint: #F0EEFD;
  --c-ai-edge: #7D70E3;         /* the dashed pencil edge, 3.3:1 against white */
  --c-ai-line: #D9D4F8;

  /* ── Meaning ── text colour on its own tint ≥ 4.79:1 */
  --c-success: #127A4A;  --c-success-tint: #E8F5EE;  --c-success-line: #A7D7BD;
  --c-warning: #8F5B00;  --c-warning-tint: #FFF3D1;  --c-warning-line: #F2D48A;  --c-warning-fill: #E3A21A;
  --c-danger:  #C0262D;  --c-danger-tint:  #FDEDED;  --c-danger-line:  #F2B8BB;  --c-danger-hover: #A31F25;
  --c-info:    #1D5FBF;  --c-info-tint:    #EAF1FC;  --c-info-line:    #B5CDF2;
  --c-focus: #2563EB;           /* one focus colour on every surface, 5.17:1 */

  /* ── Brand: the company's own colour (Operate + external). Defaults to steel ink; js/core.js sets these per company. ── */
  --brand: #10151C;
  --brand-hover: #2A313B;
  --brand-press: #3A424D;
  --brand-on: #FFFFFF;          /* text on --brand: white or ink, whichever passes 4.5:1 */
  --brand-text: #10151C;        /* brand-coloured text on white, darkened until it passes 4.5:1 */
  --brand-tint: #ECEEF1;
  --brand-line: #C8CDD5;

  /* Mode accent: what a primary button means right now. Operate → brand, Build → forge. */
  --accent: var(--brand);
  --accent-hover: var(--brand-hover);
  --accent-press: var(--brand-press);
  --accent-on: var(--brand-on);
  --accent-text: var(--brand-text);
  --accent-tint: var(--brand-tint);
  --accent-line: var(--brand-line);       /* an outline in the accent: a pressed toggle, a selected card */

  /* ── Type ── one superfamily: Plex Sans (interface), Plex Mono (data, keys, code), Plex Sans Arabic */
  --font-sans: "Plex Sans", "Plex Sans Arabic", ui-sans-serif, -apple-system, "Segoe UI", sans-serif;
  --font-arabic: "Plex Sans Arabic", "Plex Sans", ui-sans-serif, sans-serif;
  --font-mono: "Plex Mono", ui-monospace, "SF Mono", Menlo, monospace;
  /* External pages are scan pages (frontend laws §L1): no web fonts, they open on bad mobile data.
     Android's face is not named: the house rule bans it as a design font, and on Android `sans-serif` is it. */
  --font-system: -apple-system, BlinkMacSystemFont, "Segoe UI Variable Text", "Segoe UI", "Noto Sans", "Noto Sans Arabic", sans-serif;

  --fs-display: clamp(30px, 1.6vw + 20px, 40px);
  --fs-h1: clamp(24px, 0.6vw + 19px, 28px);
  --fs-h2: 20px;
  --fs-h3: 16px;
  --fs-lg: 16px;                /* reading body, inputs on touch */
  --fs-md: 14px;                /* interface body, table cells */
  --fs-sm: 13px;                /* secondary interface text */
  --fs-xs: 12px;                /* labels, meta. The floor. */

  --lh-tight: 1.15;
  --lh-head: 1.25;
  --lh-ui: 1.45;
  --lh-read: 1.6;

  --tr-display: -0.022em;
  --tr-h1: -0.016em;
  --tr-h2: -0.01em;
  --tr-plate: 0.06em;          /* nameplate labels: condensed, uppercase */

  --fw-regular: 400;
  --fw-medium: 500;
  --fw-semi: 600;

  /* ── Space: one 4px scale ── */
  --s-0: 2px;
  --s-1: 4px;
  --s-2: 8px;
  --s-3: 12px;
  --s-4: 16px;
  --s-5: 20px;
  --s-6: 24px;
  --s-8: 32px;
  --s-10: 40px;
  --s-12: 48px;
  --s-16: 64px;
  --s-20: 80px;

  /* ── Shape ── modest radii: controls 6, containers 10, never everything round */
  --r-xs: 4px;
  --r-sm: 6px;
  --r-md: 8px;
  --r-lg: 10px;
  --r-xl: 14px;
  --r-full: 999px;

  /* ── Depth: hairline first, shadow only for things that float ── */
  --e-1: 0 1px 2px rgba(16, 21, 28, 0.06);
  --e-2: 0 10px 28px -10px rgba(16, 21, 28, 0.22), 0 2px 6px rgba(16, 21, 28, 0.06);
  --e-3: 0 28px 64px -20px rgba(16, 21, 28, 0.34), 0 4px 12px rgba(16, 21, 28, 0.08);

  /* ── Motion: utility surfaces, functional only, ≤150ms per element (frontend laws §L1) ── */
  --t-fast: 100ms;
  --t-base: 140ms;
  --t-panel: 150ms;
  --ease-out: cubic-bezier(0.2, 0.8, 0.2, 1);
  --ease-in: cubic-bezier(0.4, 0, 1, 1);
  --ease-std: cubic-bezier(0.2, 0, 0, 1);

  /* ── Layout ── */
  --sidebar-w: 248px;
  --topbar-h: 56px;
  --content-max: 1280px;
  --reading-max: 68ch;
  --rail-w: 336px;
  --control-h: 36px;
  --control-h-sm: 28px;
  --control-h-lg: 44px;
  --touch: 44px;
}

/*
 * A custom property that names another is resolved where it is declared, so the accent is re-declared
 * on every element that carries a company's brand: there it resolves to that brand.
 */
.shell, .ext, .mailview, .brand-preview, .preview-frame, .ds-main, #overlay-root, body.mode-use {
  --accent: var(--brand);
  --accent-hover: var(--brand-hover);
  --accent-press: var(--brand-press);
  --accent-on: var(--brand-on);
  --accent-text: var(--brand-text);
  --accent-tint: var(--brand-tint);
  --accent-line: var(--brand-line);
}

/* Build mode: the workshop. The primary action is FoloForge's own. */
.shell.mode-build, #overlay-root.mode-build, body.mode-build {
  --accent: var(--c-forge);
  --accent-hover: var(--c-forge-hover);
  --accent-press: var(--c-forge-press);
  --accent-on: #FFFFFF;
  --accent-text: var(--c-forge);
  --accent-tint: var(--c-forge-tint);
  --accent-line: var(--c-forge-line);
}

@media (prefers-reduced-motion: reduce) {
  :root { --t-fast: 0ms; --t-base: 0ms; --t-panel: 0ms; }
}
