/* ═══════════════════════════════════════════════════════════════════
   EXELERATE · GLOBAL STYLES
   Editorial cinema palette + acceleration metaphor
   ═══════════════════════════════════════════════════════════════════ */

:root {
  /* Core palette (paper / ink / signal) */
  --paper: oklch(0.96 0.012 85);
  --paper-deep: oklch(0.92 0.018 80);
  --ink: oklch(0.14 0.005 280);
  --ink-soft: oklch(0.22 0.008 280);
  --signal: oklch(0.68 0.22 35);    /* hot orange-red — only accent */
  --signal-deep: oklch(0.55 0.22 32);

  /* Chapter tints (drive section-to-section color morph) */
  --cobalt: oklch(0.32 0.12 255);
  --plum:   oklch(0.28 0.09 320);
  --sage:   oklch(0.42 0.06 150);
  --terra:  oklch(0.55 0.13 45);
  --bone:   oklch(0.88 0.015 75);

  /* Live chapter colors — JS animates these */
  --bg: var(--paper);
  --fg: var(--ink);
  --fg-soft: oklch(from var(--fg) l c h / 0.55);
  --rule: oklch(from var(--fg) l c h / 0.15);

  /* Type */
  --serif: 'Instrument Serif', 'Times New Roman', serif;
  --sans:  'Space Grotesk', system-ui, sans-serif;
  --mono:  'JetBrains Mono', ui-monospace, monospace;

  --frame: 28px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { width: 100%; }
html { background: var(--ink); }
body {
  font-family: var(--sans);
  background: var(--bg);
  color: var(--fg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
  transition: background-color 0.6s ease, color 0.6s ease;
  cursor: none;
}
@media (max-width: 768px) { body { cursor: auto; } }

::selection { background: var(--signal); color: var(--paper); }

a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; background: none; border: none; cursor: pointer; }
img { display: block; max-width: 100%; }

/* ─── Lenis ─────────────────────────────────────────────────────── */
html.lenis, html.lenis body { height: auto; }
.lenis.lenis-smooth { scroll-behavior: auto !important; }
.lenis.lenis-smooth [data-lenis-prevent] { overscroll-behavior: contain; }
.lenis.lenis-stopped { overflow: clip; }

/* ─── Cursor ────────────────────────────────────────────────────── */
.cursor-dot, .cursor-ring {
  position: fixed; top: 0; left: 0;
  pointer-events: none; z-index: 9999;
  mix-blend-mode: difference;
  will-change: transform;
}
.cursor-dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--paper);
  transform: translate(-50%, -50%);
}
.cursor-ring {
  width: 36px; height: 36px; border-radius: 50%;
  border: 1px solid var(--paper);
  transform: translate(-50%, -50%);
  transition: width 0.25s cubic-bezier(.2,.7,.2,1), height 0.25s cubic-bezier(.2,.7,.2,1),
              background-color 0.2s ease, border-color 0.2s ease;
}
.cursor-ring.is-hover { width: 70px; height: 70px; background: oklch(from var(--paper) l c h / 0.08); }
.cursor-ring.is-press { width: 24px; height: 24px; }
@media (max-width: 768px) { .cursor-dot, .cursor-ring { display: none; } }

/* ─── Letterbox frame ───────────────────────────────────────────── */
.frame {
  position: fixed; inset: 0;
  pointer-events: none;
  z-index: 100;
  padding: var(--frame);
  display: grid;
  grid-template-rows: auto 1fr auto;
}
.frame-bar {
  display: flex; align-items: center; justify-content: space-between;
  font-family: var(--mono);
  font-size: 11px; letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--fg);
  mix-blend-mode: difference;
  filter: invert(1);
}
.frame-bar > * { pointer-events: auto; }
.frame-corner {
  position: absolute;
  width: 14px; height: 14px;
  border: 1px solid var(--fg);
  mix-blend-mode: difference;
  filter: invert(1);
}
.frame-corner.tl { top: var(--frame); left: var(--frame); border-right: none; border-bottom: none; }
.frame-corner.tr { top: var(--frame); right: var(--frame); border-left: none; border-bottom: none; }
.frame-corner.bl { bottom: var(--frame); left: var(--frame); border-right: none; border-top: none; }
.frame-corner.br { bottom: var(--frame); right: var(--frame); border-left: none; border-top: none; }

/* progress strip across the frame's bottom */
.frame-progress {
  position: relative;
  height: 1px; width: 100%;
  background: oklch(from var(--fg) l c h / 0.15);
}
.frame-progress-fill {
  position: absolute; left: 0; top: 0; bottom: 0;
  background: var(--signal);
  width: var(--progress, 0%);
  transition: width 0.05s linear;
}

@media (max-width: 768px) {
  :root { --frame: 14px; }
  .frame-bar { font-size: 9px; }
}

/* ─── Typography helpers ────────────────────────────────────────── */
.serif { font-family: var(--serif); font-weight: 400; letter-spacing: -0.02em; }
.mono  { font-family: var(--mono); letter-spacing: 0.04em; text-transform: uppercase; }
.eyebrow {
  font-family: var(--mono); font-size: 11px; letter-spacing: 0.3em;
  text-transform: uppercase; color: var(--fg-soft);
}

.display {
  font-family: var(--serif);
  font-size: clamp(54px, 12vw, 220px);
  line-height: 0.9;
  letter-spacing: -0.035em;
  font-weight: 400;
}
.display em { font-style: italic; color: var(--signal); }

/* Per-letter reveal */
.split-char {
  display: inline-block;
  transform: translateY(110%) rotate(6deg);
  opacity: 0;
  will-change: transform, opacity;
}
.split-char.is-in {
  transform: translateY(0) rotate(0);
  opacity: 1;
  transition: transform 0.9s cubic-bezier(.2,.7,.2,1), opacity 0.9s cubic-bezier(.2,.7,.2,1);
  transition-delay: var(--delay, 0ms);
}

/* ─── Layout primitives ─────────────────────────────────────────── */
section { position: relative; }

.chapter {
  position: relative;
  padding: 12vh 6vw;
  min-height: 100vh;
}

.container {
  max-width: 1480px;
  margin: 0 auto;
  width: 100%;
}

.rule { height: 1px; background: var(--rule); width: 100%; }

/* ─── Buttons (magnetic) ────────────────────────────────────────── */
.btn {
  position: relative;
  display: inline-flex; align-items: center; gap: 14px;
  padding: 22px 36px;
  border: 1px solid var(--fg);
  border-radius: 999px;
  font-family: var(--mono);
  font-size: 13px; letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--fg);
  background: transparent;
  overflow: hidden;
  isolation: isolate;
  will-change: transform;
}
.btn::before {
  content: '';
  position: absolute; inset: 0; z-index: -1;
  background: var(--signal);
  transform: translateY(101%);
  transition: transform 0.5s cubic-bezier(.2,.8,.2,1);
}
.btn:hover { color: var(--paper); border-color: var(--signal); }
.btn:hover::before { transform: translateY(0); }
.btn-signal { background: var(--signal); border-color: var(--signal); color: var(--paper); }
.btn-signal::before { background: var(--ink); }
.btn-signal:hover { color: var(--paper); border-color: var(--ink); }

.btn .arrow {
  display: inline-block;
  transition: transform 0.4s cubic-bezier(.2,.8,.2,1);
}
.btn:hover .arrow { transform: translateX(6px); }

/* ─── Marquee ───────────────────────────────────────────────────── */
.marquee {
  display: flex; overflow: hidden;
  width: 100%;
  user-select: none;
  mask-image: linear-gradient(90deg, transparent, #000 8%, #000 92%, transparent);
}
.marquee-track {
  display: flex; flex-shrink: 0;
  animation: marquee-scroll var(--duration, 40s) linear infinite;
  gap: 64px;
  padding-right: 64px;
}
@keyframes marquee-scroll {
  from { transform: translateX(0); }
  to   { transform: translateX(-100%); }
}

/* ─── Tilt card ─────────────────────────────────────────────────── */
.tilt-card {
  perspective: 1200px;
  transform-style: preserve-3d;
}
.tilt-inner {
  transform-style: preserve-3d;
  transition: transform 0.3s cubic-bezier(.2,.8,.2,1);
}

/* ─── Speed lines / acceleration FX ─────────────────────────────── */
.speedlines {
  position: absolute; inset: 0;
  overflow: hidden;
  pointer-events: none;
}
.speedline {
  position: absolute;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--fg), transparent);
  opacity: 0.3;
  transform-origin: left center;
  animation: speed-fly var(--dur, 2s) linear infinite;
  animation-delay: var(--delay, 0s);
}
@keyframes speed-fly {
  0%   { transform: translateX(-120%) scaleX(0.3); opacity: 0; }
  40%  { opacity: 0.4; }
  100% { transform: translateX(120vw) scaleX(2); opacity: 0; }
}

/* ─── Pinned chapter helpers ────────────────────────────────────── */
.pin-frame {
  position: relative;
  height: 400vh;
}
.pin-stage {
  position: sticky; top: 0;
  height: 100vh;
  overflow: hidden;
  display: flex; align-items: center; justify-content: center;
}

/* ─── Reduced motion ────────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
