/* ==========================================================================
   Polymorra — Design Tokens (Motion Storytelling design system)
   Cinematic dark canvas · crystalline indigo accent · scene-based chapters.
   Emitted ONCE. Never hard-code colors/spacing anywhere else.
   ========================================================================== */

:root {
  color-scheme: dark;

  /* ---- Canvas + scene backgrounds (chapters transition between these) ---- */
  --bg-base:     #04050a;
  --bg-scene-1:  #05070f;
  --bg-scene-2:  #090713;
  --bg-scene-3:  #040c11;
  --bg-scene-4:  #0c0907;
  --bg-elevated: #10121b;

  /* ---- Cinematic gradients (scene atmospheres) ---- */
  --grad-scene:  radial-gradient(60% 70% at 50% 30%, rgba(99,102,241,.28), transparent 60%);
  --grad-accent: linear-gradient(120deg, #818cf8 0%, #6366f1 34%, #06b6d4 72%, #22d3ee 100%);
  --grad-aurora: radial-gradient(42% 52% at 18% 16%, rgba(99,102,241,.32) 0%, transparent 62%),
                 radial-gradient(46% 56% at 82% 26%, rgba(6,182,212,.24) 0%, transparent 64%),
                 radial-gradient(52% 62% at 58% 92%, rgba(236,72,153,.16) 0%, transparent 66%);
  --grad-mesh:   radial-gradient(80% 60% at 12% 0%,  rgba(99,102,241,.20) 0%, transparent 58%),
                 radial-gradient(70% 55% at 92% 8%,  rgba(6,182,212,.15)  0%, transparent 60%),
                 radial-gradient(90% 70% at 50% 108%, rgba(236,72,153,.12) 0%, transparent 62%);
  --grad-text:   linear-gradient(96deg, #ffffff 0%, #dbe1ff 38%, #a5b4fc 68%, #67e8f9 100%);
  --grad-num:    linear-gradient(180deg, #ffffff 0%, #b9c2f5 100%);
  --grad-border: linear-gradient(150deg, rgba(255,255,255,.20) 0%, rgba(255,255,255,.05) 32%,
                                 rgba(99,102,241,.00) 55%, rgba(6,182,212,.16) 100%);
  --grad-border-hot: linear-gradient(150deg, rgba(165,180,252,.55) 0%, rgba(99,102,241,.20) 40%,
                                 rgba(6,182,212,.35) 100%);
  --grad-sheen:  linear-gradient(105deg, transparent 20%, rgba(255,255,255,.34) 48%, transparent 76%);
  --grad-fade-x: linear-gradient(90deg, transparent 0, #000 6%, #000 94%, transparent 100%);

  /* Film grain — inline SVG turbulence, no network request */
  --noise: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='160' height='160' filter='url(%23n)' opacity='.55'/%3E%3C/svg%3E");

  /* ---- Surfaces ---- */
  --surface-1: rgba(255,255,255,.032);
  --surface-2: rgba(255,255,255,.055);
  --surface-3: #14161f;
  --surface-solid: #10121b;
  --surface-glass: rgba(9,11,18,.62);
  --surface-inset: rgba(4,5,10,.55);

  /* ---- Text ramp ---- */
  --text-primary:   #f6f7fc;
  --text-secondary: #c3c8d8;
  --text-muted:     #939ab2;
  --text-faint:     #646b83;
  --text-on-accent: #06040f;

  /* ---- Hairlines (panels/inputs only — NEVER between scenes) ---- */
  --border-subtle:  rgba(255,255,255,.07);
  --border-default: rgba(255,255,255,.13);
  --border-strong:  rgba(255,255,255,.22);
  --ring:           #a5b4fc;

  /* ---- Accent thread ---- */
  --accent:       #6366f1;
  --accent-hover: #7d84f9;
  --accent-press: #5457e6;
  --accent-2:     #22d3ee;
  --accent-3:     #f472b6;
  --accent-soft:  rgba(99,102,241,.16);
  --accent-softer:rgba(99,102,241,.08);
  --accent-2-soft:rgba(34,211,238,.14);

  /* ---- Semantic ---- */
  --success: #34d399; --success-soft: rgba(52,211,153,.16);
  --warning: #fbbf24; --warning-soft: rgba(251,191,36,.16);
  --error:   #fb7185; --error-soft:   rgba(251,113,133,.16);
  --info:    #38bdf8; --info-soft:    rgba(56,189,248,.16);

  /* ---- Elevation ---- */
  --shadow-sm: 0 1px 2px rgba(0,0,0,.5);
  --shadow-md: 0 18px 48px -12px rgba(0,0,0,.62);
  --shadow-lg: 0 40px 90px -24px rgba(0,0,0,.72);
  --shadow-xl: 0 60px 140px -36px rgba(0,0,0,.8);
  --glow:        0 0 0 1px rgba(99,102,241,.30), 0 18px 50px -14px rgba(99,102,241,.55);
  --glow-soft:   0 24px 70px -28px rgba(99,102,241,.65);
  --inner-top:   inset 0 1px 0 rgba(255,255,255,.07);

  /* ---- Type ---- */
  --font-sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-display: "Inter Tight", "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-mono: "JetBrains Mono", "SF Mono", ui-monospace, Menlo, Consolas, monospace;

  --fs-display: clamp(2.85rem, 1.3rem + 7.0vw, 6.5rem);
  --fs-h1:      clamp(2.3rem, 1.5rem + 3.5vw, 4.125rem);
  --fs-h2:      clamp(1.8rem, 1.3rem + 2.3vw, 3rem);
  --fs-h3:      clamp(1.375rem, 1.15rem + 1.1vw, 1.9375rem);
  --fs-h4:      clamp(1.125rem, 1.02rem + .5vw, 1.375rem);
  --fs-lead:    clamp(1.125rem, 1.01rem + .58vw, 1.4375rem);
  --fs-body:    1rem;
  --fs-body-lg: 1.0625rem;
  --fs-small:   .875rem;
  --fs-micro:   .75rem;

  --tracking-display: -.035em;
  --tracking-tight:   -.02em;
  --tracking-wide:    .1em;

  /* ---- Spacing (4-pt base / 8-pt rhythm) ---- */
  --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-20: 80px;
  --space-24: 96px;  --space-28: 112px;--space-32: 128px;--space-40: 160px;

  /* ---- Radii ---- */
  --radius-sm: 8px;  --radius-md: 12px; --radius-lg: 18px;
  --radius-xl: 24px; --radius-2xl: 32px; --radius-pill: 999px;

  /* ---- Containers ---- */
  --container-sm: 680px;  --container-md: 840px;  --container-lg: 1080px;
  --container-xl: 1200px; --container-2xl: 1380px;
  --gutter: clamp(20px, 5vw, 48px);

  /* ---- Section / scene rhythm ---- */
  --section-y:    clamp(80px, 9.5vw, 152px);
  --section-y-lg: clamp(112px, 13vw, 208px);
  --stack: clamp(16px, 2vw, 24px);

  /* ---- Scroll tracks ---- */
  --track-short: 150vh;
  --track:       250vh;
  --track-long:  360vh;

  /* ---- Motion ---- */
  --dur-fast: 160ms; --dur-base: 280ms; --dur-slow: 560ms; --dur-slower: 900ms;
  --ease-out:    cubic-bezier(.2, 1, .3, 1);
  --ease-in-out: cubic-bezier(.65, 0, .35, 1);
  --ease-emph:   cubic-bezier(.16, 1, .3, 1);
  --ease-ref:    cubic-bezier(.165, .84, .44, 1);
  --ease-spring: cubic-bezier(.34, 1.4, .48, 1);
}

/* Optional light theme — cinematic dark remains the default identity. */
[data-theme="light"] {
  color-scheme: light;
  --bg-base: #f6f7fc;
  --bg-scene-1: #f2f4fb; --bg-scene-2: #f5f2fc;
  --bg-scene-3: #edf6f8; --bg-scene-4: #fbf4f0;
  --bg-elevated: #ffffff;
  --surface-1: rgba(12,16,32,.028);
  --surface-2: rgba(12,16,32,.052);
  --surface-3: #ffffff;
  --surface-solid: #ffffff;
  --surface-glass: rgba(255,255,255,.74);
  --surface-inset: rgba(12,16,32,.04);
  --text-primary: #0a0c14; --text-secondary: #39405a;
  --text-muted: #5c6480; --text-faint: #858ca4;
  --text-on-accent: #ffffff;
  --border-subtle: rgba(10,12,20,.09); --border-default: rgba(10,12,20,.15);
  --border-strong: rgba(10,12,20,.26);
  --accent: #4f46e5; --accent-hover: #4338ca; --accent-press: #3730a3;
  --accent-2: #0891b2; --accent-3: #db2777;
  --accent-soft: rgba(79,70,229,.11); --accent-softer: rgba(79,70,229,.06);
  --accent-2-soft: rgba(8,145,178,.12);
  --ring: #4338ca;
  --grad-text: linear-gradient(96deg, #0a0c14 0%, #4f46e5 58%, #0891b2 100%);
  --grad-num:  linear-gradient(180deg, #0a0c14 0%, #4f46e5 100%);
  --grad-accent: linear-gradient(120deg, #6366f1 0%, #4f46e5 38%, #0891b2 100%);
  --grad-border: linear-gradient(150deg, rgba(10,12,20,.14) 0%, rgba(10,12,20,.04) 40%, rgba(8,145,178,.14) 100%);
  --grad-border-hot: linear-gradient(150deg, rgba(79,70,229,.5) 0%, rgba(8,145,178,.35) 100%);
  --grad-aurora: radial-gradient(42% 52% at 18% 16%, rgba(79,70,229,.14) 0%, transparent 62%),
                 radial-gradient(46% 56% at 82% 26%, rgba(8,145,178,.12) 0%, transparent 64%),
                 radial-gradient(52% 62% at 58% 92%, rgba(219,39,119,.08) 0%, transparent 66%);
  --grad-mesh:   radial-gradient(80% 60% at 12% 0%, rgba(79,70,229,.10) 0%, transparent 58%),
                 radial-gradient(70% 55% at 92% 8%, rgba(8,145,178,.09) 0%, transparent 60%),
                 radial-gradient(90% 70% at 50% 108%, rgba(219,39,119,.07) 0%, transparent 62%);
  --shadow-md: 0 18px 48px -14px rgba(16,24,40,.16);
  --shadow-lg: 0 40px 90px -30px rgba(16,24,40,.22);
  --shadow-xl: 0 60px 140px -40px rgba(16,24,40,.26);
  --glow: 0 0 0 1px rgba(79,70,229,.22), 0 18px 50px -18px rgba(79,70,229,.42);
  --glow-soft: 0 24px 70px -32px rgba(79,70,229,.5);
  --inner-top: inset 0 1px 0 rgba(255,255,255,.9);
}

/* ========================================================================
   Precision refinement — restrained industrial visual language
   ======================================================================== */
:root {
  /* Neutral foundations with a single cool accent family. */
  --bg-base: #07080c;
  --bg-scene-1: #090b11;
  --bg-scene-2: #0b0c13;
  --bg-scene-3: #080d11;
  --bg-scene-4: #0d0c0a;
  --bg-elevated: #11131a;

  --surface-1: rgba(255,255,255,.035);
  --surface-2: rgba(255,255,255,.06);
  --surface-3: #161820;
  --surface-solid: #101219;
  --surface-glass: rgba(8,10,15,.88);
  --surface-inset: rgba(0,0,0,.22);

  --text-primary: #f3f4f7;
  --text-secondary: #bdc2ce;
  --text-muted: #8d94a3;
  --text-faint: #656c79;

  --border-subtle: rgba(255,255,255,.075);
  --border-default: rgba(255,255,255,.12);
  --border-strong: rgba(255,255,255,.2);

  --accent: #8b93ff;
  --accent-hover: #a4aaff;
  --accent-press: #727bef;
  --accent-2: #55c8d9;
  --accent-3: #d47faf;
  --accent-soft: rgba(139,147,255,.13);
  --accent-softer: rgba(139,147,255,.07);
  --accent-2-soft: rgba(85,200,217,.1);

  /* Gradients are reserved for ambient light and rare emphasis. */
  --grad-scene: radial-gradient(55% 65% at 50% 24%, rgba(139,147,255,.11), transparent 68%);
  --grad-accent: linear-gradient(110deg, #8b93ff 0%, #71a9ed 58%, #55c8d9 100%);
  --grad-aurora: radial-gradient(48% 60% at 20% 18%, rgba(139,147,255,.11), transparent 68%),
                 radial-gradient(45% 55% at 84% 32%, rgba(85,200,217,.07), transparent 72%);
  --grad-mesh: radial-gradient(70% 55% at 14% -6%, rgba(139,147,255,.09), transparent 66%),
               radial-gradient(62% 48% at 94% 8%, rgba(85,200,217,.055), transparent 70%);
  --grad-text: linear-gradient(96deg, #f7f8fa 0%, #d8dcff 62%, #9edbe4 100%);
  --grad-num: linear-gradient(180deg, #f7f8fa 0%, #c9cddd 100%);
  --grad-border: linear-gradient(150deg, rgba(255,255,255,.14), rgba(255,255,255,.055));
  --grad-border-hot: linear-gradient(150deg, rgba(139,147,255,.38), rgba(85,200,217,.18));
  --grad-sheen: none;

  /* Elevation is functional, never decorative. */
  --shadow-sm: 0 1px 2px rgba(0,0,0,.26);
  --shadow-md: 0 12px 32px -18px rgba(0,0,0,.56);
  --shadow-lg: 0 22px 56px -28px rgba(0,0,0,.7);
  --shadow-xl: 0 32px 72px -36px rgba(0,0,0,.76);
  --glow: none;
  --glow-soft: none;
  --inner-top: none;

  /* A deliberate major-third display scale with conservative body sizes. */
  --fs-display: clamp(3rem, 2.05rem + 4.5vw, 5.5rem);
  --fs-h1: clamp(2.5rem, 1.9rem + 2.8vw, 4rem);
  --fs-h2: clamp(2rem, 1.65rem + 1.7vw, 3.25rem);
  --fs-h3: clamp(1.375rem, 1.22rem + .7vw, 1.75rem);
  --fs-h4: clamp(1.125rem, 1.04rem + .35vw, 1.3125rem);
  --fs-lead: clamp(1.0625rem, 1rem + .35vw, 1.25rem);
  --tracking-display: -.045em;
  --tracking-tight: -.025em;
  --tracking-wide: .085em;

  --radius-lg: 16px;
  --radius-xl: 20px;
  --radius-2xl: 24px;
  --section-y: clamp(72px, 8vw, 128px);
  --section-y-lg: clamp(96px, 11vw, 176px);
}

[data-theme="light"] {
  --bg-base: #f7f8fa;
  --bg-scene-1: #f4f5f8;
  --bg-scene-2: #f6f5f8;
  --bg-scene-3: #f2f7f8;
  --bg-scene-4: #f8f6f3;
  --bg-elevated: #ffffff;
  --surface-1: rgba(17,24,39,.03);
  --surface-2: rgba(17,24,39,.055);
  --surface-solid: #ffffff;
  --surface-glass: rgba(250,251,252,.9);
  --surface-inset: rgba(17,24,39,.035);
  --text-primary: #111318;
  --text-secondary: #414754;
  --text-muted: #626a78;
  --text-faint: #858c98;
  --accent: #4b50c7;
  --accent-hover: #3e43ad;
  --accent-press: #343896;
  --accent-2: #087f91;
  --accent-soft: rgba(75,80,199,.09);
  --accent-softer: rgba(75,80,199,.055);
  --accent-2-soft: rgba(8,127,145,.08);
  --grad-mesh: radial-gradient(70% 55% at 14% -6%, rgba(75,80,199,.055), transparent 68%),
               radial-gradient(62% 48% at 94% 8%, rgba(8,127,145,.04), transparent 72%);
  --grad-aurora: radial-gradient(48% 60% at 20% 18%, rgba(75,80,199,.065), transparent 70%),
                 radial-gradient(45% 55% at 84% 32%, rgba(8,127,145,.04), transparent 74%);
  --shadow-md: 0 12px 32px -20px rgba(17,24,39,.25);
  --shadow-lg: 0 22px 56px -32px rgba(17,24,39,.3);
  --shadow-xl: 0 32px 72px -40px rgba(17,24,39,.34);
}
