/*
 * NovaScale design tokens — brand/tokens.css
 * Task T10 · Visual identity and design system · version 0.1.2 · created 2026-11-11, revised 2026-11-12
 * Status: PROPOSED token values. The founder selected the Evidence Ledger direction in D-004
 * (2026-11-11, Business Plan Draft 4 §17 item 2); the exact values here remain PROPOSED, visual proofs
 * are incomplete, and font acquisition, public use and trademark clearance are separate gates.
 * D-001 to D-003 and D-005 to D-007 concern T02. Agent agreement is not approval or permission to publish.
 * Source baseline: Business Plan Draft 4 (2026-11-11) > Brief v1.1 > Mission.
 *
 * Contract (see brand/design-system.md §2):
 *  - Pure CSS custom properties on :root only. No selectors that style elements, no resets,
 *    no @import, no url(), no network requests, no fonts. Import unchanged from any depth:
 *      <link rel="stylesheet" href="../brand/tokens.css">   or   @import url("../brand/tokens.css");
 *  - Font files are loaded separately by brand/fonts/fonts.css (optional). Without it, the font stacks
 *    below fall back to installed system faces.
 *  - Layers: primitives (--ns-<hue>-<step>) → semantic (--ns-color-*, --ns-text-*, …) →
 *    component aliases (--ns-btn-*, --ns-input-*, --ns-score-*, …). Consumers use semantic and
 *    component tokens; primitives are referenced only inside this file.
 *  - Custom properties cannot be used inside @media conditions; breakpoint tokens are reference values.
 *  - Contrast for every permitted pair is computed from THIS file by brand/tools/tokens-lib.mjs
 *    (contrastResults) and enforced by brand/tests/contrast.test.mjs.
 */

:root {
  /* ───────────── 1. Primitive colors (sRGB hex) ───────────── */
  /* Royal palette (founder instruction 2026-11-17, decision D-024): navy, royal blue, white and gold,
     replacing the Evidence Ledger palette values. Token NAMES are unchanged so every consumer keeps working:
     paper-* now hold whites and cool tints, ink-* navy, teal-700/800 royal blue, teal-300 gold, teal-100 a pale
     royal tint. The gold-* tokens below are new. Previous values: brand/.palette-history/. */
  --ns-paper-0: #FFFFFF;
  --ns-paper-50: #FFFFFF;
  --ns-paper-100: #F2F4F9;
  --ns-rule-200: #E1E5EE;
  --ns-rule-300: #CAD1DE;
  --ns-slate-400: #8A93A6;
  --ns-slate-500: #5E6880;
  --ns-slate-600: #475167;
  --ns-ink-700: #24365F;
  --ns-ink-800: #13265A;
  --ns-ink-900: #0B1A3D;
  --ns-fog-300: #C6CEE0;
  --ns-teal-100: #EAEFFA;
  --ns-teal-300: #D4AF37;
  --ns-teal-700: #1D3E9E;
  --ns-teal-800: #142C73;
  --ns-red-50: #FBECEA;
  --ns-red-700: #A3261C;
  --ns-ochre-100: #F5EAD0;
  --ns-ochre-700: #7A5200;
  --ns-gold-400: #D4AF37;    /* gold accent: rules, labels and buttons on navy (8.12:1 on ink-900) */
  --ns-gold-700: #8A6A1F;    /* deep gold for small text on white (5.05:1) */

  /* ───────────── 2. Semantic colors ───────────── */
  --ns-color-canvas: var(--ns-paper-50);
  --ns-color-surface: var(--ns-paper-0);
  --ns-color-surface-sunken: var(--ns-paper-100);
  --ns-color-surface-accent: var(--ns-teal-100);
  --ns-color-surface-inverse: var(--ns-ink-900);

  --ns-color-text: var(--ns-ink-900);
  --ns-color-text-secondary: var(--ns-slate-600);
  --ns-color-text-inverse: var(--ns-paper-50);
  --ns-color-text-inverse-secondary: var(--ns-fog-300);

  --ns-color-link: var(--ns-teal-700);
  --ns-color-link-hover: var(--ns-teal-800);
  --ns-color-link-inverse: var(--ns-teal-300);
  --ns-color-link-inverse-hover: var(--ns-paper-50);  /* inverse hover/active: paper text + 2px underline */

  --ns-color-accent: var(--ns-teal-700);
  --ns-color-accent-hover: var(--ns-teal-800);
  --ns-color-on-accent: var(--ns-paper-0);

  --ns-color-border-strong: var(--ns-slate-500);   /* essential control boundaries: ≥3:1 */
  --ns-color-border-subtle: var(--ns-rule-300);    /* decorative card edges only */
  --ns-color-rule: var(--ns-rule-200);             /* decorative hairlines only */

  --ns-color-focus: var(--ns-teal-700);
  --ns-color-focus-inverse: var(--ns-teal-300);

  --ns-color-critical: var(--ns-red-700);          /* Critical findings and form errors only */
  --ns-color-critical-surface: var(--ns-red-50);
  --ns-color-on-critical: var(--ns-paper-0);
  --ns-color-error: var(--ns-red-700);

  --ns-color-notice-bg: var(--ns-ochre-100);       /* FICTIONAL / DEMONSTRATION band */
  --ns-color-notice-border: var(--ns-ochre-700);
  --ns-color-notice-text: var(--ns-ink-900);

  --ns-color-disabled-text: var(--ns-slate-400);   /* exempt from 1.4.3; still legible */
  --ns-color-disabled-bg: var(--ns-paper-100);

  --ns-color-gold: var(--ns-gold-400);            /* decorative rules and accents; text only on navy */
  --ns-color-gold-text: var(--ns-gold-700);       /* gold labels on white */

  /* ───────────── 3. Typography ───────────── */
  --ns-font-sans: "IBM Plex Sans", "Helvetica Neue", Helvetica, Arial, system-ui, sans-serif;
  --ns-font-serif: "IBM Plex Serif", Georgia, "Times New Roman", serif;
  --ns-font-mono: "IBM Plex Mono", ui-monospace, "SFMono-Regular", Menlo, Consolas, "Liberation Mono", monospace;

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

  /* Web scale (1rem = 16px at default zoom). Fluid steps combine rem + vw so they still grow with zoom. */
  --ns-text-2xs: 0.8125rem;                                   /* 13px  legal/caption floor */
  --ns-text-xs: 0.875rem;                                     /* 14px  labels, table meta */
  --ns-text-sm: 0.9375rem;                                    /* 15px  secondary body */
  --ns-text-base: 1.0625rem;                                  /* 17px  body */
  --ns-text-md: 1.25rem;                                      /* 20px  lead, H4 */
  --ns-text-lg: 1.5rem;                                       /* 24px  H3 */
  --ns-text-xl: clamp(1.625rem, 1.35rem + 1.1vw, 2rem);       /* 26→32px H2 */
  --ns-text-2xl: clamp(2rem, 1.55rem + 1.9vw, 2.75rem);       /* 32→44px H1 */
  --ns-text-3xl: clamp(2.375rem, 1.7rem + 2.9vw, 3.75rem);    /* 38→60px display */

  --ns-leading-tight: 1.12;
  --ns-leading-snug: 1.3;
  --ns-leading-dense: 1.45;
  --ns-leading-body: 1.6;

  --ns-tracking-display: -0.012em;
  --ns-tracking-label: 0.06em;

  --ns-measure: 68ch;
  --ns-measure-narrow: 52ch;
  --ns-numeric: tabular-nums lining-nums;

  /* ───────────── 4. Spacing (4px base) ───────────── */
  --ns-space-1: 0.25rem;   /* 4 */
  --ns-space-2: 0.5rem;    /* 8 */
  --ns-space-3: 0.75rem;   /* 12 */
  --ns-space-4: 1rem;      /* 16 */
  --ns-space-5: 1.5rem;    /* 24 */
  --ns-space-6: 2rem;      /* 32 */
  --ns-space-7: 3rem;      /* 48 */
  --ns-space-8: 4rem;      /* 64 */
  --ns-space-9: 6rem;      /* 96 */
  --ns-space-10: 8rem;     /* 128 */
  --ns-section-gap: clamp(3rem, 2rem + 4vw, 6rem);

  /* ───────────── 5. Layout ───────────── */
  --ns-container-max: 75rem;        /* 1200px content */
  --ns-container-wide: 85rem;       /* 1360px full-bleed bands */
  --ns-container-reading: 44rem;    /* ≈68ch body column */
  --ns-gutter: clamp(1.25rem, 0.6rem + 2.6vw, 3rem);     /* outer page gutter 20→48px */
  --ns-grid-gap: clamp(1rem, 0.7rem + 1.2vw, 1.5rem);    /* column gap 16→24px */
  --ns-grid-columns-sm: 4;
  --ns-grid-columns-md: 8;
  --ns-grid-columns-lg: 12;
  /* Reference only (cannot be used inside @media): */
  --ns-bp-sm: 30em;   /* 480px */
  --ns-bp-md: 48em;   /* 768px */
  --ns-bp-lg: 64em;   /* 1024px */
  --ns-bp-xl: 80em;   /* 1280px */

  /* ───────────── 6. Boundaries, radii, elevation ───────────── */
  --ns-border-hairline: 1px;
  --ns-border-control: 1px;
  --ns-border-emphasis: 2px;
  --ns-radius-0: 0;
  --ns-radius-1: 2px;
  --ns-radius-2: 4px;
  --ns-shadow-overlay: 0 6px 24px rgba(18, 26, 38, 0.14);

  /* ───────────── 7. Focus and targets ───────────── */
  --ns-focus-width: 3px;
  --ns-focus-offset: 2px;
  --ns-focus-ring: var(--ns-focus-width) solid var(--ns-color-focus);
  --ns-focus-ring-inverse: var(--ns-focus-width) solid var(--ns-color-focus-inverse);
  --ns-target-min: 2.75rem;         /* 44px design default for interactive targets */

  /* ───────────── 8. Motion (restrained; zeroed under reduced motion) ───────────── */
  --ns-duration-fast: 120ms;
  --ns-duration-base: 180ms;
  --ns-ease: cubic-bezier(0.2, 0, 0, 1);

  /* ───────────── 9. Component aliases ───────────── */
  --ns-btn-primary-bg: var(--ns-color-accent);
  --ns-btn-primary-bg-hover: var(--ns-color-accent-hover);
  --ns-btn-primary-fg: var(--ns-color-on-accent);
  --ns-btn-secondary-bg: var(--ns-color-surface);
  --ns-btn-secondary-fg: var(--ns-color-text);
  --ns-btn-secondary-border: var(--ns-color-text);
  /* Inverse surfaces: the light-surface teal fill is NOT permitted on ink (2.5:1 against it). */
  --ns-btn-primary-inverse-bg: var(--ns-teal-300);
  --ns-btn-primary-inverse-bg-hover: var(--ns-paper-50);
  --ns-btn-primary-inverse-fg: var(--ns-ink-900);
  --ns-btn-secondary-inverse-fg: var(--ns-color-text-inverse);
  --ns-btn-secondary-inverse-border: var(--ns-color-text-inverse);
  --ns-btn-secondary-inverse-bg-hover: var(--ns-ink-800);
  --ns-btn-height: var(--ns-target-min);
  --ns-btn-radius: var(--ns-radius-1);

  --ns-input-bg: var(--ns-color-surface);
  --ns-input-fg: var(--ns-color-text);
  --ns-input-border: var(--ns-color-border-strong);
  --ns-input-border-error: var(--ns-color-error);
  --ns-input-height: var(--ns-target-min);

  --ns-card-bg: var(--ns-color-surface);
  --ns-card-border: var(--ns-color-border-subtle);
  --ns-card-padding: clamp(1.25rem, 1rem + 1vw, 2rem);

  --ns-nav-height: 4.5rem;
  --ns-nav-current-indicator: var(--ns-color-accent);

  --ns-notice-bg: var(--ns-color-notice-bg);
  --ns-notice-border: var(--ns-color-notice-border);
  --ns-notice-fg: var(--ns-color-notice-text);

  /* TRACE scorecard: one neutral ink for all score values (no hue per score, no red/green). */
  --ns-score-cell-filled: var(--ns-ink-800);
  --ns-score-cell-empty: var(--ns-color-surface);
  --ns-score-cell-border: var(--ns-color-border-strong);
  --ns-score-hatch: var(--ns-color-border-strong);
  --ns-score-cell-size: 0.875rem;   /* 14px */
  --ns-score-cell-gap: 0.1875rem;   /* 3px */
  --ns-confidence-pip-filled: var(--ns-ink-800);
  --ns-confidence-pip-border: var(--ns-color-border-strong);
  --ns-severity-critical-bg: var(--ns-color-critical);
  --ns-severity-critical-fg: var(--ns-color-on-critical);
  --ns-severity-high-bg: var(--ns-ink-900);
  --ns-severity-high-fg: var(--ns-paper-0);
  --ns-severity-medium-border: var(--ns-ink-900);
  --ns-severity-low-border: var(--ns-color-border-strong);

  /* ───────────── 10. Print and presentation (used by HTML print collateral) ───────────── */
  --ns-print-body: 10.5pt;          /* report body */
  --ns-print-body-dense: 9.5pt;     /* one-pager body */
  --ns-print-small: 8.5pt;          /* tables, captions, evidence references */
  --ns-print-min: 8pt;              /* absolute floor: footers, notices */
  --ns-print-h1: 22pt;
  --ns-print-h2: 15pt;
  --ns-print-h3: 12pt;
  --ns-print-leading: 1.42;
  --ns-print-margin-block: 0.6in;
  --ns-print-margin-inline: 0.75in;
  --ns-print-content-width: 6.75in; /* tables and figures; fits US Letter and A4 at ≥0.75in side margins */
  --ns-print-measure: 5.75in;       /* running prose in reports (≈75–80 characters at 10.5pt, estimated) */
  --ns-print-page-height: 9.7in;    /* usable page body inside Letter margins; A4 has more */
  /* Deck values are unitless px on a 1920×1080 canvas (13.333×7.5in slide: px ÷ 2 = pt). */
  --ns-deck-canvas-width: 1920;
  --ns-deck-title: 72;
  --ns-deck-subtitle: 44;
  --ns-deck-body: 36;
  --ns-deck-body-min: 32;
  --ns-deck-qualifier-min: 24;
  --ns-deck-margin: 96;
}

/* Reduced motion: durations collapse to zero for every consumer that uses the motion tokens. */
@media (prefers-reduced-motion: reduce) {
  :root {
    --ns-duration-fast: 0ms;
    --ns-duration-base: 0ms;
  }
}

/* Print: white canvas, no elevation, print type sizes become the base. Colors stay grayscale-safe. */
@media print {
  :root {
    --ns-color-canvas: var(--ns-paper-0);
    --ns-shadow-overlay: none;
    --ns-text-base: var(--ns-print-body);
    --ns-text-sm: var(--ns-print-small);
    --ns-text-xs: var(--ns-print-small);
    --ns-text-2xs: var(--ns-print-min);
    --ns-leading-body: var(--ns-print-leading);
    --ns-duration-fast: 0ms;
    --ns-duration-base: 0ms;
  }
}
