/* ============================================================
   PRIMORDIAL DESIGN SYSTEM — colors_and_type.css
   Single source of truth for color + type tokens.
   Source: source/primordial-design-system.md (Beta 3.0, Apr 2025)
   v3.3 (Sep 2026): --radius-xs, chart palette.
   v3.2 (Sep 2026): dark-surface state tokens, dark fg-muted, pager.
   v3.1 (Sep 2026): modal radius, border-width rename, purple tints,
   progress/neutral states, App type scale. See CHANGELOG.md.

   FONTS:
   Brand fonts are loaded from the project-local `fonts/`
   directory via @font-face below. Founders Grotesk + Founders
   Grotesk X-Condensed (Klim Type Foundry, licensed) provide
   --font-primary and --font-display. Fira Code is bundled for
   --font-mono (alias-mapped to "Fira Mono").

   To use this CSS from any HTML file, ensure the relative
   `fonts/` path resolves — i.e. drop pages at the project root,
   or override @font-face urls per-page if nesting deeper.
   ============================================================ */

/* ── BRAND FONTS ──────────────────────────────────────────── */

/* Founders Grotesk — Primary */
@font-face { font-family: "Founders Grotesk"; src: url("fonts/FoundersGrotesk-Light.otf")           format("opentype"); font-weight: 300; font-style: normal; font-display: swap; }
@font-face { font-family: "Founders Grotesk"; src: url("fonts/FoundersGrotesk-Regular.otf")         format("opentype"); font-weight: 400; font-style: normal; font-display: swap; }
@font-face { font-family: "Founders Grotesk"; src: url("fonts/FoundersGrotesk-Italic.otf")          format("opentype"); font-weight: 400; font-style: italic; font-display: swap; }
@font-face { font-family: "Founders Grotesk"; src: url("fonts/FoundersGrotesk-Medium.otf")          format("opentype"); font-weight: 500; font-style: normal; font-display: swap; }
@font-face { font-family: "Founders Grotesk"; src: url("fonts/FoundersGrotesk-MediumItalic.otf")    format("opentype"); font-weight: 500; font-style: italic; font-display: swap; }
@font-face { font-family: "Founders Grotesk"; src: url("fonts/FoundersGrotesk-Semibold.otf")        format("opentype"); font-weight: 600; font-style: normal; font-display: swap; }
@font-face { font-family: "Founders Grotesk"; src: url("fonts/FoundersGrotesk-SemiboldItalic.otf")  format("opentype"); font-weight: 600; font-style: italic; font-display: swap; }
@font-face { font-family: "Founders Grotesk"; src: url("fonts/FoundersGrotesk-Bold.otf")            format("opentype"); font-weight: 700; font-style: normal; font-display: swap; }
@font-face { font-family: "Founders Grotesk"; src: url("fonts/FoundersGrotesk-BoldItalic.otf")      format("opentype"); font-weight: 700; font-style: italic; font-display: swap; }

/* Founders Grotesk X-Condensed — Display */
@font-face { font-family: "Founders Grotesk X-Cond"; src: url("fonts/FoundersGroteskXCond-Regular.otf")  format("opentype"); font-weight: 400; font-style: normal; font-display: swap; }
@font-face { font-family: "Founders Grotesk X-Cond"; src: url("fonts/FoundersGroteskXCond-Medium.otf")   format("opentype"); font-weight: 500; font-style: normal; font-display: swap; }
@font-face { font-family: "Founders Grotesk X-Cond"; src: url("fonts/FoundersGroteskXCond-Semibold.otf") format("opentype"); font-weight: 600; font-style: normal; font-display: swap; }
@font-face { font-family: "Founders Grotesk X-Cond"; src: url("fonts/FoundersGroteskXCond-Bold.otf")     format("opentype"); font-weight: 700; font-style: normal; font-display: swap; }

/* Token alias — "Founders Grotesk X-Cond SmBd" maps to Semibold */
@font-face { font-family: "Founders Grotesk X-Cond SmBd"; src: url("fonts/FoundersGroteskXCond-Semibold.otf") format("opentype"); font-weight: 400 700; font-style: normal; font-display: swap; }

/* Founders Grotesk Mono */
@font-face { font-family: "Founders Grotesk Mono"; src: url("fonts/FoundersGroteskMono-Regular.otf") format("opentype"); font-weight: 400; font-style: normal; font-display: swap; }
@font-face { font-family: "Founders Grotesk Mono"; src: url("fonts/FoundersGroteskMono-Medium.otf")  format("opentype"); font-weight: 500; font-style: normal; font-display: swap; }
@font-face { font-family: "Founders Grotesk Mono"; src: url("fonts/FoundersGroteskMono-Bold.otf")    format("opentype"); font-weight: 700; font-style: normal; font-display: swap; }

/* Fira Code — Mono / Code */
@font-face { font-family: "Fira Code"; src: url("fonts/FiraCode-Regular.woff2")  format("woff2"); font-weight: 400; font-style: normal; font-display: swap; }
@font-face { font-family: "Fira Code"; src: url("fonts/FiraCode-Medium.woff2")   format("woff2"); font-weight: 500; font-style: normal; font-display: swap; }
@font-face { font-family: "Fira Code"; src: url("fonts/FiraCode-SemiBold.woff2") format("woff2"); font-weight: 600; font-style: normal; font-display: swap; }
@font-face { font-family: "Fira Code"; src: url("fonts/FiraCode-Bold.woff2")     format("woff2"); font-weight: 700; font-style: normal; font-display: swap; }

/* Token alias — "Fira Mono" → Fira Code (the design-system spec name) */
@font-face { font-family: "Fira Mono"; src: url("fonts/FiraCode-Regular.woff2")  format("woff2"); font-weight: 400; font-style: normal; font-display: swap; }
@font-face { font-family: "Fira Mono"; src: url("fonts/FiraCode-Medium.woff2")   format("woff2"); font-weight: 500; font-style: normal; font-display: swap; }
@font-face { font-family: "Fira Mono"; src: url("fonts/FiraCode-SemiBold.woff2") format("woff2"); font-weight: 600; font-style: normal; font-display: swap; }
@font-face { font-family: "Fira Mono"; src: url("fonts/FiraCode-Bold.woff2")     format("woff2"); font-weight: 700; font-style: normal; font-display: swap; }

:root {
  /* ============================================================
     COLOR — base tokens
     ============================================================ */

  /* Purple scale (canonical, per Slide 16) */
  --color-purple-01:   #2D2246;   /* Deep Navy Purple — deepest dark BG */
  --color-purple-02:   #331862;   /* Dark Purple — supporting dark BG */
  --color-purple-03:   #7E44F1;   /* Core Purple — primary CTA accent */
  --color-purple-04:   #A080FF;   /* Mid Purple — hover / secondary */
  --color-purple-05:   #BBB0F7;   /* Light Lavender — light tints */

  /* Resolved: Purple-04 canonical = #A080FF (slide 16 label).
     XML hover variant kept as a separate token for hover states. */
  --color-purple-bright:   #8046FF;  /* Hover state for purple-03 */
  --color-lavender-pale:   #D7BBFA;  /* Pale Lavender — Soup swatch (slide 17) */

  /* Brand surface (most-used dark) */
  --color-ui-purple:   #4D3680;   /* UI Purple — primary brand surface */

  /* Accents */
  --color-cyan:        #6ADDDD;   /* Teal/Cyan — energy, life */
  --color-magenta:     #F869FC;   /* Hot Magenta — vivid spot */
  --color-coral:       #E2492F;   /* Coral — warmth contrast */

  /* UI utility */
  --color-muted-pink:  #CA88CA;   /* "//" separator (display contexts) */
  --color-muted-grey:  #92809D;   /* "//" separator (utility); muted labels */
  --color-grey-06:     #EFEAF5;   /* purple-tinted near-white — disabled surfaces */
  --color-grey-04:     #A79CB3;   /* purple-tinted mid grey — disabled text/border */
  /* v3.2 — light state inks for text on dark surfaces (from the product). The -500
     steps are fills; on purple-01 they fail contrast, so dark UI uses these. */
  --color-success-300: #5FD394;
  --color-warning-300: #F4C95D;
  --color-error-300:   #FF806D;
  --color-info-300:    var(--color-cyan);
  --color-text-dark:   #333333;   /* Body text on white */
  --color-border:      #333333;
  --color-white:       #FFFFFF;
  --color-black:       #000000;

  /* ============================================================
     COLOR — semantic tokens (light context = on white)
     ============================================================ */

  --bg-app:        var(--color-white);
  --bg-surface:    var(--color-white);
  --bg-raised:     #FAF8FE;                       /* faint lavender wash */
  --bg-inverse:    var(--color-ui-purple);

  --fg-default:    var(--color-text-dark);
  --fg-muted:      var(--color-muted-grey);
  --fg-subtle:     #6B5F77;
  --fg-inverse:    var(--color-white);
  --fg-brand:      var(--color-ui-purple);
  --fg-link:       var(--color-purple-03);

  --border-subtle: rgba(45, 34, 70, 0.10);
  --border-default: rgba(45, 34, 70, 0.20);
  --border-strong:  var(--color-text-dark);

  --accent-primary:    var(--color-purple-03);    /* CTAs, links */
  --accent-primary-hover: var(--color-purple-bright);
  --accent-secondary:  var(--color-cyan);
  --accent-tertiary:   var(--color-magenta);
  --accent-warm:       var(--color-coral);

  /* ============================================================
     SEMANTIC STATE COLORS — confirmed Apr 2026
     Three-step scale per state. All -500 hit AA (≥4.5:1) on white;
     all -700 hit AAA (≥7:1). -50 are tinted backgrounds for alerts.
     Targets: AA (4.5:1) for body text · AA (3:1) for large/UI · AAA (7:1) aspirational.
     ============================================================ */

  /* Success — fresh green, distinct from cyan accent */
  --color-success-50:   #EAF7F0;
  --color-success-500:  #1B9E5A;   /* AA on white (4.51:1) */
  --color-success-700:  #0F6B3D;   /* AAA on white (7.65:1) */

  /* Warning — amber, distinct from error red */
  --color-warning-50:   #FFF3E0;
  --color-warning-500:  #B86E0A;   /* AA on white (4.62:1) */
  --color-warning-700:  #7A4A07;   /* AAA on white (8.91:1) */

  /* Error — harmonised with brand coral but darkened for AA */
  --color-error-50:     #FCE9E5;
  --color-error-500:    #C53D26;   /* AA on white (5.10:1); replaces #E2492F for text use */
  --color-error-700:    #8A2A1A;   /* AAA on white (9.42:1) */

  /* Info — darkened cyan for legible text-on-light */
  --color-info-50:      #E0F5F5;
  --color-info-500:     #1A8C8C;   /* AA on white (4.55:1); replaces #6ADDDD for text use */
  --color-info-700:     #0F5F5F;   /* AAA on white (8.13:1) */

  /* Aliases — components reference these, not raw hex */
  --state-success:  var(--color-success-500);
  --state-warning:  var(--color-warning-500);
  --state-error:    var(--color-error-500);
  --state-info:     var(--color-info-500);

  /* Surface tints for alerts/banners (use bg with -700 text) */
  --state-success-bg: var(--color-success-50);
  --state-warning-bg: var(--color-warning-50);
  --state-error-bg:   var(--color-error-50);
  --state-info-bg:    var(--color-info-50);

  /* v3.1: in-progress / waiting-on-user. Brand purple, kept separate from info (teal). */
  --state-progress:     var(--color-purple-03);
  --state-progress-bg:  color-mix(in srgb, var(--color-purple-03) 10%, white);
  --state-progress-ink: var(--color-ui-purple);
  --state-neutral-bg:   color-mix(in srgb, var(--color-purple-01) 6%, white);
  --state-neutral-ink:  var(--fg-subtle);
  --state-success-ink:  var(--color-success-700);
  --state-warning-ink:  var(--color-warning-700);
  --state-error-ink:    var(--color-error-700);
  --state-info-ink:     var(--color-info-700);
  --input-bg:           var(--color-white);

  /* WCAG 2.1 contrast targets — confirmed Apr 2026 */
  --contrast-aa-normal:  4.5;   /* @kind other */
  --contrast-aa-large:   3.0;   /* @kind other */
  --contrast-aaa-normal: 7.0;   /* @kind other */

  /* ============================================================
     COLOR — dark-context overrides
     Apply by adding `data-theme="dark"` or `.theme-dark` to scope.
     ============================================================ */

  /* ============================================================
     SHADOWS / ELEVATION — confirmed Apr 2026
     5-step scale tinted with brand purple (rgba 45,34,70) so shadows
     read warm on light surfaces. Dark theme inverts to use deeper black.
     ============================================================ */

  --shadow-xs: 0 1px 2px  rgba(45, 34, 70, 0.08);
  --shadow-sm: 0 2px 8px  rgba(45, 34, 70, 0.12);
  --shadow-md: 0 4px 16px rgba(45, 34, 70, 0.16);
  --shadow-lg: 0 8px 32px rgba(45, 34, 70, 0.20);
  --shadow-xl: 0 16px 48px rgba(45, 34, 70, 0.28);

  /* Component-specific aliases */
  --shadow-card:     var(--shadow-sm);    /* resting cards */
  --shadow-card-raised: var(--shadow-md); /* hover-lifted cards */
  --shadow-dropdown: var(--shadow-md);    /* menus, popovers */
  --shadow-modal:    var(--shadow-xl);    /* dialogs */
  --shadow-toast:    var(--shadow-lg);    /* floating alerts */

  /* ============================================================
     TYPOGRAPHY — families
     ============================================================ */

  --font-primary: "Founders Grotesk", "Inter", "Helvetica Neue", Arial, sans-serif;
  --font-display: "Founders Grotesk X-Cond SmBd", "Founders Grotesk X-Cond", "Impact", "Arial Narrow", sans-serif;
  --font-mono:    "Fira Mono", "Fira Code", "Founders Grotesk Mono", "Consolas", "Courier New", monospace;

  /* ============================================================
     TYPOGRAPHY — base (raw type scale, in px, derived from spec pt)
     ============================================================ */

  --text-micro:       6px;   /* 4.27pt */
  --text-page-num:    10px;  /* 7.13pt */
  --text-footnote:    12px;  /* 8.74pt */
  --text-nav-tag:     12px;  /* 9.26pt */
  --text-caption:     14px;

  /* v3.1 — App (dense UI) scale. Use these inside product screens; the editorial
     scale above stays for marketing and decks. Six steps, nothing in between. */
  --text-app-2xs: 10px;   /* mono micro labels, table header meta */
  --text-app-xs:  11px;   /* mono labels, tags, table headers */
  --text-app-sm:  12px;   /* secondary text, captions in tables */
  --text-app-md:  13px;   /* default UI text: table cells, inputs, compact buttons */
  --text-app-lg:  14px;   /* body copy inside panels */
  --text-app-xl:  15px;   /* emphasised UI text, default buttons */  /* 10.69pt */
  --text-meta:        17px;  /* 12.83pt */
  --text-nav-num:     21px;  /* 15.88pt */
  --text-body-lg:     24px;  /* 17.81pt */
  --text-section-sub: 28px;  /* 21.38pt */
  --text-h3:          36px;  /* 27.08pt */
  --text-h2:          48px;  /* 35.63pt */
  --text-h1:          64px;  /* 48.71pt */
  --text-display-sm:  84px;  /* 62.19pt */
  --text-display:     104px; /* 78.38pt */
  --text-hero:        148px; /* 110pt */
  --text-colossal:    298px; /* 223.73pt */

  /* Line heights */
  --lh-tight:   1.0;     /* @kind font */
  --lh-snug:    1.1;     /* @kind font */
  --lh-normal:  1.35;    /* @kind font */
  --lh-relaxed: 1.5;     /* @kind font */

  /* Letter spacing */
  --tracking-tight:  -0.01em;
  --tracking-normal: 0;
  --tracking-wide:   0.04em;     /* nav labels, // tags */
  --tracking-wider:  0.08em;     /* all-caps display */

  /* ============================================================
     SPACING — 8px base scale (4px half-step)
     Confirmed Apr 2026. Used for padding, gaps, vertical rhythm.
     ============================================================ */

  --space-xs:  4px;     /* hairline gaps, icon-text spacing */
  --space-sm:  8px;     /* compact spacing inside controls */
  --space-md:  16px;    /* default between related elements */
  --space-lg:  24px;    /* between groups within a section */
  --space-xl:  32px;    /* between sub-sections */
  --space-2xl: 48px;    /* major block separation */
  --space-3xl: 64px;    /* section-level rhythm */
  --space-4xl: 96px;    /* full editorial section padding */

  /* Page edge margin — outer gutter on web.
     Was 57.6px (4% of 1440); rounded to 64 to align with --space-3xl. */
  --margin-edge:        64px;     /* desktop ≥1024 */
  --margin-edge-tablet: 32px;     /* 640–1023 */
  --margin-edge-mobile: 24px;     /* <640 */

  /* ============================================================
     GRID — 12-col available; editorial pages use single 720 column
     ============================================================ */

  --grid-cols:        12;        /* @kind other */
  --grid-gutter:      24px;
  --grid-max-width:   1280px;
  --column-narrow:    720px;     /* editorial / marketing default */
  --column-wide:      960px;     /* longer-form articles */

  /* ============================================================
     BREAKPOINTS — mobile / tablet / desktop / wide
     ============================================================ */

  --bp-tablet:   640px;
  --bp-desktop:  1024px;
  --bp-wide:     1440px;

  /* ============================================================
     RADIUS — sharp by default, soft for surfaces
     Brand uses sharp `//` separators; buttons match that energy.
     ============================================================ */

  --radius-none:   0;        /* buttons, CTAs, mono labels */
  --radius-xs:     2px;      /* v3.3: data-viz marks (bars, heat cells, swatches), checkbox */
  --radius-sm:     4px;      /* inputs, small chips */
  --radius-md:     8px;      /* cards, panels */
  --radius-lg:     16px;     /* large surfaces, modals (rare) */
  --radius-pill:   999px;    /* tags / status badges only */
  --radius-circle: 50%;      /* avatars, monogram chips */

  /* Component-specific aliases (single source of truth) */
  --radius-button: var(--radius-none);
  --radius-input:  var(--radius-sm);
  --radius-card:   var(--radius-md);
  --radius-modal:  var(--radius-none);   /* v3.1: sharp, matches buttons */
  --radius-badge:  var(--radius-pill);
  --radius-avatar: var(--radius-circle);

  /* v3.3 — chart palette. Series order is fixed; use the first N. */
  --chart-1: var(--color-purple-03);
  --chart-2: var(--color-cyan);
  --chart-3: var(--color-purple-04);
  --chart-4: var(--color-magenta);
  --chart-5: var(--color-coral);
  --chart-6: var(--color-muted-grey);
  --chart-grid: var(--border-subtle);
  --chart-axis: var(--fg-subtle);
  --chart-positive: var(--color-success-500);
  --chart-negative: var(--color-error-500);

  /* Border widths. v3.1: renamed from --border-default, which collided with the
     border COLOUR token and broke every `1px solid var(--border-default)`. */
  --border-thin: 1px;
  --border-width-default: 1px;
  --border-thick: 2px;

  /* ============================================================
     MOTION (NOT in source spec — derived for product use)
     ============================================================ */

  /* Durations — confirmed Apr 2026 */
  --motion-instant: 80ms;     /* @kind other */
  --motion-fast:    120ms;    /* @kind other */
  --motion-base:    200ms;    /* @kind other */
  --motion-slow:    320ms;    /* @kind other */
  --motion-deliberate: 480ms; /* @kind other */

  /* Easings */
  --ease-standard: cubic-bezier(0.2, 0, 0.2, 1);   /* @kind other */
  --ease-entrance: cubic-bezier(0, 0, 0.2, 1);     /* @kind other */
  --ease-exit:     cubic-bezier(0.4, 0, 1, 1);     /* @kind other */
  --ease-emphasis: cubic-bezier(0.2, 0, 0, 1);     /* @kind other */
}

/* Honor user preference — disable non-essential motion */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* ── Dark-context theme override (purple-on-purple surfaces) ─── */
[data-theme="dark"], .theme-dark {
  --bg-app:        var(--color-purple-01);
  --bg-surface:    var(--color-ui-purple);
  --bg-raised:     #5A4296;
  --bg-inverse:    var(--color-white);

  --fg-default:    var(--color-white);
  --fg-muted:      #BDB2C9;   /* v3.2: lightened from muted-grey for AA on purple-01 / ui-purple (from the product, PRI-75) */
  --fg-subtle:     var(--color-purple-05);
  --fg-inverse:    var(--color-purple-01);
  --fg-brand:      var(--color-purple-04);
  --fg-link:       var(--color-purple-04);

  --border-subtle: rgba(255, 255, 255, 0.10);
  --border-default: rgba(255, 255, 255, 0.20);
  --border-strong:  var(--color-white);


  /* Shadows on dark surfaces — deeper black, lower opacity so they read */
  --shadow-xs: 0 1px 2px  rgba(0, 0, 0, 0.30);
  --shadow-sm: 0 2px 8px  rgba(0, 0, 0, 0.35);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.40);
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.45);
  --shadow-xl: 0 16px 48px rgba(0, 0, 0, 0.55);
}

/* ============================================================
   SEMANTIC TYPE CLASSES
   Use either as class names or copy declarations.
   ============================================================ */

.t-hero,
h1.hero {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: var(--text-hero);
  line-height: var(--lh-tight);
  letter-spacing: var(--tracking-tight);
  text-transform: uppercase;
}

.t-display {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: var(--text-display);
  line-height: var(--lh-tight);
  letter-spacing: var(--tracking-tight);
  text-transform: uppercase;
}

.t-h1 {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: var(--text-h1);
  line-height: var(--lh-snug);
  letter-spacing: var(--tracking-tight);
  text-transform: uppercase;
}

.t-h2 {
  font-family: var(--font-primary);
  font-weight: 700;
  font-size: var(--text-h2);
  line-height: var(--lh-snug);
  letter-spacing: var(--tracking-tight);
}

.t-h3 {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: var(--text-h3);
  line-height: 1.15;
  letter-spacing: var(--tracking-normal);
}

.t-section-sub {
  font-family: var(--font-primary);
  font-weight: 500;
  font-size: var(--text-section-sub);
  line-height: 1.25;
}

.t-body-lg {
  font-family: var(--font-primary);
  font-weight: 400;
  font-size: var(--text-body-lg);
  line-height: var(--lh-normal);
}

.t-body {
  font-family: var(--font-primary);
  font-weight: 400;
  font-size: var(--text-meta);
  line-height: var(--lh-normal);
}

.t-caption {
  font-family: var(--font-primary);
  font-weight: 400;
  font-size: var(--text-caption);
  line-height: 1.4;
  color: var(--fg-muted);
}

.t-nav-num {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: var(--text-nav-num);
  letter-spacing: var(--tracking-wide);
}

.t-nav-tag {
  font-family: var(--font-mono);
  font-weight: 500;
  font-size: var(--text-nav-tag);
  letter-spacing: var(--tracking-wide);
  text-transform: uppercase;
}

.t-page-num {
  font-family: var(--font-primary);
  font-weight: 700;
  font-size: var(--text-page-num);
  letter-spacing: var(--tracking-wide);
}

.t-mono {
  font-family: var(--font-mono);
  font-weight: 400;
  font-size: var(--text-meta);
  line-height: var(--lh-normal);
}

/* ── The "//" separator device ──────────────────────────────── */

/* Inline span to color a // separator when it can't be auto-styled */
.dbl-slash {
  color: var(--color-muted-grey);
  font-weight: inherit;
  font-family: inherit;
}
.dbl-slash--display {
  color: var(--color-muted-pink);
}

/* ── Default elements (when used as a stylesheet, not classes) ─ */

html, body {
  font-family: var(--font-primary);
  font-size: var(--text-meta);
  line-height: var(--lh-normal);
  color: var(--fg-default);
  background: var(--bg-app);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
h1 { font: 700 var(--text-h1)/1.05 var(--font-display); text-transform: uppercase; letter-spacing: var(--tracking-tight); margin: 0; }
h2 { font: 700 var(--text-h2)/1.1 var(--font-primary); margin: 0; }
h3 { font: 600 var(--text-h3)/1.15 var(--font-display); margin: 0; }
h4 { font: 600 var(--text-section-sub)/1.25 var(--font-primary); margin: 0; }
p  { margin: 0 0 1em; }
code, pre, kbd { font-family: var(--font-mono); font-size: 0.95em; }
a  {
  color: var(--fg-link);
  text-decoration: none;
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
  transition: color var(--motion-fast) var(--ease-standard),
              text-decoration-color var(--motion-fast) var(--ease-standard);
}
a:hover { color: var(--color-purple-04); text-decoration: underline; }
a:active { color: var(--color-purple-02); }
a:focus-visible {
  outline: 2px solid var(--color-purple-03);
  outline-offset: 2px;
  border-radius: 2px;
}
hr { border: 0; border-top: 1px solid var(--border-default); margin: var(--space-xl) 0; }

/* ============================================================
   INTERACTIVE STATES — confirmed Apr 2026
   Reusable tokens and component classes for buttons, inputs, etc.
   ============================================================ */
:root {
  /* State-specific tokens */
  --state-hover-tint:    color-mix(in srgb, var(--color-purple-03) 10%, transparent);   /* subtle purple wash */
  --state-active-tint:   color-mix(in srgb, var(--color-purple-03) 20%, transparent);
  --focus-halo:          0 0 0 3px color-mix(in srgb, var(--color-purple-03) 20%, transparent);   /* v3.1: input focus / selected halo */
  --focus-halo-error:    0 0 0 3px color-mix(in srgb, var(--state-error) 25%, transparent);
  --state-disabled-bg:   var(--color-grey-06);
  --state-disabled-fg:   var(--color-grey-04);
  --state-disabled-border: var(--color-grey-04);

  /* Focus ring — used everywhere a keyboard user lands */
  --focus-ring-color:  var(--color-purple-03);
  --focus-ring-width:  2px;
  --focus-ring-offset: 2px;

  /* Standard transition for interactive surfaces */
  --transition-state: background-color var(--motion-fast) var(--ease-standard),
                      border-color var(--motion-fast) var(--ease-standard),
                      color var(--motion-fast) var(--ease-standard),
                      transform var(--motion-fast) var(--ease-standard),
                      box-shadow var(--motion-fast) var(--ease-standard);
}

/* Universal focus ring (keyboard only) */
.focus-ring:focus-visible,
button:focus-visible,
[role="button"]:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: var(--focus-ring-width) solid var(--focus-ring-color);
  outline-offset: var(--focus-ring-offset);
}

/* ── Button: primary (filled purple) ────────────────────────── */
.btn {
  font-family: var(--font-primary);
  font-weight: 600;
  font-size: var(--text-meta);
  line-height: 1;
  padding: 12px 20px;
  border: 1px solid transparent;
  border-radius: var(--radius-button);
  cursor: pointer;
  transition: var(--transition-state);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  user-select: none;
  text-decoration: none;
}

.btn-primary {
  background: var(--color-purple-03);
  color: var(--color-white);
  border-color: var(--color-purple-03);
}
.btn-primary:hover { background: var(--color-purple-04); border-color: var(--color-purple-04); }
.btn-primary:active { background: var(--color-purple-02); border-color: var(--color-purple-02); transform: translateY(1px); }
.btn-primary:disabled,
.btn-primary[aria-disabled="true"] {
  background: var(--state-disabled-bg);
  border-color: var(--state-disabled-bg);
  color: var(--state-disabled-fg);
  cursor: not-allowed;
  transform: none;
}

/* ── Button: secondary (outlined) ───────────────────────────── */
.btn-secondary {
  background: transparent;
  color: var(--color-purple-03);
  border-color: var(--color-purple-03);
}
.btn-secondary:hover { background: var(--state-hover-tint); }
.btn-secondary:active { background: var(--state-active-tint); transform: translateY(1px); }
.btn-secondary:disabled,
.btn-secondary[aria-disabled="true"] {
  background: transparent;
  color: var(--state-disabled-fg);
  border-color: var(--state-disabled-border);
  cursor: not-allowed;
  transform: none;
}

/* ── Button: ghost (text-only) ──────────────────────────────── */
.btn-ghost {
  background: transparent;
  color: var(--color-purple-03);
  border-color: transparent;
  padding-left: 12px;
  padding-right: 12px;
}
.btn-ghost:hover { background: var(--state-hover-tint); }
.btn-ghost:active { background: var(--state-active-tint); }
.btn-ghost:disabled,
.btn-ghost[aria-disabled="true"] {
  color: var(--state-disabled-fg);
  cursor: not-allowed;
}

/* Dark-context overrides (purple-on-purple surfaces) */
[data-theme="dark"] .btn-primary,
.theme-dark .btn-primary {
  background: var(--color-white);
  color: var(--color-purple-01);
  border-color: var(--color-white);
}
[data-theme="dark"] .btn-primary:hover,
.theme-dark .btn-primary:hover { background: var(--color-purple-05); border-color: var(--color-purple-05); }
[data-theme="dark"] .btn-secondary,
.theme-dark .btn-secondary { color: var(--color-white); border-color: rgba(255,255,255,0.40); }
[data-theme="dark"] .btn-secondary:hover,
.theme-dark .btn-secondary:hover { background: rgba(255,255,255,0.10); border-color: var(--color-white); }

/* ── Button: sizes ──────────────────────────────────────────── */
.btn-sm { font-size: 13px; padding: 8px 14px; }
.btn-lg { font-size: 18px; padding: 16px 26px; }

/* ── Input ──────────────────────────────────────────────────── */
.input {
  font-family: var(--font-primary);
  font-size: var(--text-meta);
  line-height: 1.4;
  color: var(--fg-default);
  background: var(--input-bg);
  padding: 10px 12px;
  border: 1px solid var(--border-default);
  border-radius: var(--radius-input);
  width: 100%;
  transition: var(--transition-state);
}
.input::placeholder { color: var(--fg-muted); }
.input:hover { border-color: var(--color-purple-03); }
.input:focus-visible {
  outline: none;
  border-color: var(--color-purple-03);
  box-shadow: var(--focus-halo);
}
.input:disabled,
.input[aria-disabled="true"] {
  background: var(--state-disabled-bg);
  color: var(--state-disabled-fg);
  border-color: var(--state-disabled-border);
  cursor: not-allowed;
}
.input.is-invalid,
.input[aria-invalid="true"] {
  border-color: var(--state-error);
}
.input.is-invalid:focus-visible,
.input[aria-invalid="true"]:focus-visible {
  box-shadow: var(--focus-halo-error);
}

/* ── Utility ────────────────────────────────────────────────── */

.bg-soup {
  background:
    radial-gradient(60% 80% at 18% 20%, #8046FF 0%, transparent 60%),
    radial-gradient(50% 70% at 80% 30%, #6ADDDD 0%, transparent 55%),
    radial-gradient(50% 60% at 70% 80%, #F869FC 0%, transparent 50%),
    radial-gradient(40% 50% at 25% 85%, #E2492F 0%, transparent 55%),
    linear-gradient(135deg, #2D2246 0%, #4D3680 60%, #331862 100%);
}

/* ── v3.2 dark-surface state tokens ──────────────────────────
   Kept at the end of the file so they win over the :root state
   block above when data-theme sits on <html>. */
[data-theme="dark"], .theme-dark {
  --state-success-bg:  color-mix(in srgb, var(--color-success-500) 22%, transparent);
  --state-warning-bg:  color-mix(in srgb, var(--color-warning-300) 16%, transparent);
  --state-error-bg:    color-mix(in srgb, var(--color-error-500) 24%, transparent);
  --state-info-bg:     color-mix(in srgb, var(--color-cyan) 16%, transparent);
  --state-progress-bg: color-mix(in srgb, var(--color-purple-04) 22%, transparent);
  --state-neutral-bg:  rgba(255, 255, 255, 0.08);
  --state-success-ink: var(--color-success-300);
  --state-warning-ink: var(--color-warning-300);
  --state-error-ink:   var(--color-error-300);
  --state-info-ink:    var(--color-info-300);
  --state-progress-ink: var(--color-purple-05);
  --state-neutral-ink: var(--fg-muted);
  --state-hover-tint:  rgba(255, 255, 255, 0.08);
  --state-active-tint: rgba(255, 255, 255, 0.14);
  --state-disabled-bg: rgba(255, 255, 255, 0.08);
  --state-disabled-fg: rgba(255, 255, 255, 0.38);
  --state-disabled-border: rgba(255, 255, 255, 0.12);
  --focus-ring-color:  var(--color-purple-04);
  --focus-halo:        0 0 0 3px color-mix(in srgb, var(--color-purple-04) 35%, transparent);
  --input-bg:          rgba(0, 0, 0, 0.25);
}
