/* ════════════════════════════════════════════════════════════════
   DENY GEATER — A JOURNEY IN SIX CHAPTERS
   Editorial, cinematic, scroll-driven. The page itself travels
   dark → bone → charcoal → cinema black → light → dark; JS lerps
   --bg / --ink / --accent between chapter stops every frame.
   ════════════════════════════════════════════════════════════════ */

/* the film-grade hue is registered so it TRANSITIONS numerically
   (cutting-edge CSS; browsers without @property simply snap) */
@property --gh {
  syntax: "<number>";
  inherits: true;
  initial-value: 40;
}

:root {
  --bg: #0c0c0e;
  --ink: #f2efe8;
  --accent: #8fa0ff;
  --muted: color-mix(in srgb, var(--ink) 64%, var(--bg));
  --hair: color-mix(in srgb, var(--ink) 18%, transparent);
  --serif: "Instrument Serif", Georgia, serif;
  --sans: "Inter Tight", system-ui, sans-serif;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html { scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

body {
  background: var(--bg);
  color: var(--ink);
  font: 400 16px/1.6 var(--sans);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
  transition: none; /* bg is JS-lerped per frame — no CSS transition fighting it */
}

::selection { background: var(--accent); color: var(--bg); }

a { color: inherit; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
em { font-family: var(--serif); font-style: italic; font-weight: 400; }
strong { font-weight: 600; }

:where(a, button, [tabindex]):focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 2px;
}

.skip-link {
  position: fixed; top: 10px; left: 10px; z-index: 200;
  padding: 10px 16px; background: var(--ink); color: var(--bg);
  font-size: 0.8rem; text-decoration: none; border-radius: 3px;
  transform: translateY(-300%);
}
.skip-link:focus { transform: none; }

/* ── fixed layers ──────────────────────────────────────────── */
#stage { position: fixed; inset: 0; width: 100%; height: 100%; z-index: 1; }

#grain {
  position: fixed; inset: -120px; z-index: 70; pointer-events: none;
  background-image: 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='0.8' numOctaves='2'/%3E%3C/filter%3E%3Crect width='160' height='160' filter='url(%23n)' opacity='0.5'/%3E%3C/svg%3E");
  opacity: 0.055;
  mix-blend-mode: overlay;
  animation: grain-shift 0.9s steps(3) infinite;
}
@keyframes grain-shift {
  0% { transform: translate(0, 0); }
  33% { transform: translate(-40px, 30px); }
  66% { transform: translate(35px, -25px); }
  100% { transform: translate(0, 0); }
}

/* JS-created film-grade wash (chapter five) */
#grade {
  position: fixed; inset: 0; z-index: 2; pointer-events: none;
  background: radial-gradient(72% 60% at 50% 46%, hsl(var(--gh) 65% 52% / 0.16), transparent 70%);
  opacity: 0;
  transition: opacity 0.6s var(--ease), --gh 0.6s var(--ease);
}
#grade.on { opacity: 1; }

/* ── header / progress / rail — difference-blended chrome ───── */
#head, #rail, #progress, #cursor { mix-blend-mode: difference; color: #fff; }

#head {
  position: fixed; top: 0; left: 0; right: 0; z-index: 100;
  display: flex; justify-content: space-between; align-items: center;
  padding: 22px clamp(20px, 4vw, 48px);
  pointer-events: none;
}
#head-name {
  pointer-events: auto;
  font-size: 0.95rem; letter-spacing: 0.01em; font-weight: 500;
}
#head-name em { font-size: 1.05em; }
#head-chapter {
  display: flex; align-items: baseline; gap: 10px;
  font-size: 0.72rem; letter-spacing: 0.22em; text-transform: uppercase;
}
#head-ch-label { transition: opacity 0.3s; }
#head-ch-label.swap { opacity: 0; }
.head-idx { opacity: 0.55; letter-spacing: 0.1em; }

#progress {
  position: fixed; top: 0; left: 0; right: 0; height: 2px; z-index: 101;
}
#progress-bar {
  display: block; height: 100%; width: 100%;
  background: #fff; transform-origin: left;
  transform: scaleX(0);
}

#rail {
  position: fixed; right: clamp(14px, 3vw, 38px); top: 50%; z-index: 100;
  transform: translateY(-50%);
  display: flex; flex-direction: column; gap: 4px;
}
#rail button {
  position: relative; padding: 7px 4px;
  font-size: 0.62rem; letter-spacing: 0.14em;
  opacity: 0.38;
  transition: opacity 0.3s, transform 0.3s var(--ease);
}
#rail button::before {
  content: ""; position: absolute; right: -8px; top: 50%;
  width: 3px; height: 3px; border-radius: 50%; background: #fff;
  transform: translateY(-50%) scale(0);
  transition: transform 0.3s var(--ease);
}
#rail button:hover { opacity: 0.85; }
#rail button.on { opacity: 1; transform: translateX(-6px); }
#rail button.on::before { transform: translateY(-50%) scale(1); }

/* ── cursor ─────────────────────────────────────────────────── */
#cursor {
  position: fixed; z-index: 150; pointer-events: none;
  width: 10px; height: 10px; border-radius: 50%;
  background: #fff;
  transform: translate(-50%, -50%) scale(1);
  transition: transform 0.25s var(--ease), opacity 0.3s;
  opacity: 0;
}
#cursor.big { transform: translate(-50%, -50%) scale(3.4); }
body.has-cursor #cursor { opacity: 1; }
@media (pointer: fine) {
  body.has-cursor, body.has-cursor a, body.has-cursor button { cursor: none; }
}

/* ── preloader ──────────────────────────────────────────────── */
#loader {
  position: fixed; inset: 0; z-index: 300;
  background: #f2efe8; color: #141416;
  display: grid; place-items: center;
  transition: transform 0.9s cubic-bezier(0.76, 0, 0.24, 1);
}
#loader.done { transform: translateY(-101%); }
#loader.gone { display: none; }
.loader-inner { text-align: center; width: min(420px, 80vw); }
.loader-name { font-size: clamp(1.6rem, 5vw, 2.4rem); letter-spacing: -0.01em; font-weight: 500; }
.loader-track { height: 1px; background: rgba(20, 20, 22, 0.15); margin: 26px 0 14px; overflow: hidden; }
#loader-bar { display: block; height: 100%; width: 0%; background: #141416; transition: width 0.25s ease-out; }
.loader-pct { font-size: 0.72rem; letter-spacing: 0.3em; color: rgba(20, 20, 22, 0.5); }

/* ── journey shell ─────────────────────────────────────────── */
#journey { position: relative; z-index: 10; }

.ch { position: relative; min-height: 100vh; display: flex; align-items: center; }
.ch-inner {
  width: min(1060px, 100%);
  margin: 0 auto;
  padding: clamp(90px, 16vh, 160px) clamp(22px, 6vw, 64px);
}

.ch-num {
  font: italic 400 clamp(4.5rem, 11vw, 9rem)/1 var(--serif);
  color: transparent;
  -webkit-text-stroke: 1px var(--muted);
  opacity: 0.5;
  margin-bottom: -0.32em;
  user-select: none;
}

.overline {
  font-size: 0.72rem; letter-spacing: 0.3em; text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 22px;
}

h1, h2 { font-weight: 500; letter-spacing: -0.025em; text-wrap: balance; }
h2 { font-size: clamp(2.2rem, 6vw, 4.4rem); line-height: 1.04; max-width: 15ch; }
h2 em { letter-spacing: -0.01em; }

.ch-body { max-width: 54ch; margin-top: 34px; display: grid; gap: 18px; }
.ch-body p { color: var(--muted); font-size: clamp(1rem, 1.6vw, 1.15rem); line-height: 1.75; }
.ch-body strong { color: var(--ink); }

.chips { list-style: none; display: flex; flex-wrap: wrap; gap: 8px; margin-top: 34px; }
.chips li {
  font-size: 0.72rem; letter-spacing: 0.12em; text-transform: uppercase;
  padding: 9px 15px; border: 1px solid var(--hair); border-radius: 99px;
  color: var(--muted);
}

/* ── split & reveal choreography ───────────────────────────── */
[data-split] .w { display: inline-block; overflow: hidden; vertical-align: bottom; }
[data-split] .w > span {
  display: inline-block;
  transform: translateY(115%) rotate(2.5deg);
  transition: transform 0.9s var(--ease);
  transition-delay: calc(var(--i) * 55ms);
}
[data-split].in .w > span { transform: none; }

[data-reveal] {
  opacity: 0; transform: translateY(26px);
  transition: opacity 0.8s var(--ease), transform 0.8s var(--ease);
  transition-delay: calc(var(--i, 0) * 90ms);
}
[data-reveal].in { opacity: 1; transform: none; }

/* ── prologue / hero ───────────────────────────────────────── */
.prologue { min-height: 108vh; }
.hero { text-align: center; }
.hero-name { font-size: clamp(4.2rem, 15.5vw, 12.5rem); line-height: 0.9; letter-spacing: -0.03em; }
.hero-name .line { display: block; }
.hero-name .serif { font-family: var(--serif); font-style: italic; font-weight: 400; letter-spacing: -0.02em; }
.hero-sub { margin-top: 34px; color: var(--muted); font-size: clamp(0.95rem, 1.8vw, 1.15rem); line-height: 1.8; }
.scroll-cue {
  margin-top: 60px; display: inline-flex; flex-direction: column; align-items: center; gap: 12px;
  font-size: 0.68rem; letter-spacing: 0.34em; text-transform: uppercase; color: var(--muted);
}
.scroll-cue i { width: 1px; height: 56px; background: var(--muted); overflow: hidden; position: relative; }
.scroll-cue i::after {
  content: ""; position: absolute; inset: 0; background: var(--ink);
  transform-origin: top; animation: cue-drop 1.8s var(--ease) infinite;
}
@keyframes cue-drop {
  0% { transform: scaleY(0); transform-origin: top; }
  45% { transform: scaleY(1); transform-origin: top; }
  55% { transform: scaleY(1); transform-origin: bottom; }
  100% { transform: scaleY(0); transform-origin: bottom; }
}

/* ── ch02 pinned horizontal ────────────────────────────────── */
.ch-pin { display: block; }              /* JS sets the tall height */
.pin-viewport {
  position: sticky; top: 0; height: 100vh; overflow: hidden;
  display: flex; flex-direction: column; justify-content: center;
  gap: clamp(28px, 5vh, 56px);
}
.pin-head { padding: 0 clamp(22px, 6vw, 64px); max-width: 1060px; margin: 0 auto; width: 100%; }
.pin-track {
  display: flex; gap: clamp(14px, 2vw, 26px);
  padding: 0 clamp(22px, 6vw, 64px);
  will-change: transform;
  width: max-content;
}
.craft-card {
  width: clamp(240px, 26vw, 330px); flex-shrink: 0;
  border: 1px solid var(--hair);
  border-radius: 6px;
  padding: clamp(22px, 2.6vw, 34px);
  min-height: clamp(240px, 34vh, 320px);
  display: flex; flex-direction: column; justify-content: flex-end; gap: 8px;
  background: color-mix(in srgb, var(--ink) 3%, transparent);
  transition: transform 0.45s var(--ease), border-color 0.45s;
}
.craft-card:hover { transform: translateY(-8px); border-color: var(--muted); }
.craft-card i {
  font: italic 400 1.1rem var(--serif); color: var(--accent);
  margin-bottom: auto;
}
.craft-card h3 { font-size: clamp(1.5rem, 2.4vw, 2rem); font-weight: 500; letter-spacing: -0.02em; }
.craft-card p { color: var(--muted); font-size: 0.92rem; }
.craft-end { border-style: dashed; }
.craft-end h3 { font-size: clamp(1.9rem, 3vw, 2.6rem); }

/* ── ch03 wave ─────────────────────────────────────────────── */
.wave-zone {
  margin-top: 44px; height: clamp(150px, 26vh, 230px);
  border-top: 1px solid var(--hair); border-bottom: 1px solid var(--hair);
  display: flex; flex-direction: column; justify-content: space-between;
  padding: 14px 2px;
  touch-action: none; cursor: grab; user-select: none;
}
.wave-zone:active { cursor: grabbing; }
.wave-hint { font-size: 0.7rem; letter-spacing: 0.26em; text-transform: uppercase; color: var(--muted); }
.wave-readout {
  align-self: flex-end;
  font: italic 400 clamp(1.3rem, 2.6vw, 1.9rem) var(--serif);
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}

/* ── ch04 games ────────────────────────────────────────────── */
.plat-line { display: flex; align-items: baseline; gap: 20px; margin: 40px 0 50px; }
.plat-count {
  font: italic 400 clamp(4.5rem, 12vw, 9.5rem)/0.9 var(--serif);
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}
.plat-label { font-size: 0.78rem; letter-spacing: 0.2em; text-transform: uppercase; color: var(--muted); line-height: 1.8; }

.game-list { list-style: none; border-top: 1px solid var(--hair); }
.game-list li { border-bottom: 1px solid var(--hair); }
.game-list button {
  width: 100%; display: flex; align-items: baseline; justify-content: space-between; gap: 18px;
  padding: clamp(14px, 2.2vh, 22px) 4px;
  text-align: left;
}
.g-title {
  font-size: clamp(1.5rem, 4.6vw, 3.1rem);
  font-weight: 300; letter-spacing: -0.02em; line-height: 1.1;
  transition: transform 0.4s var(--ease), color 0.3s;
}
.g-title i { font-family: var(--serif); font-style: italic; color: var(--muted); }
.g-year {
  font: italic 400 0.95rem var(--serif); color: var(--muted);
  opacity: 0; transform: translateX(-14px);
  transition: opacity 0.35s, transform 0.35s var(--ease);
}
.game-list button:hover .g-title,
.game-list button:focus-visible .g-title {
  transform: translateX(18px);
  font-family: var(--serif); font-style: italic; font-weight: 400;
  color: var(--accent);
}
.game-list button:hover .g-year,
.game-list button:focus-visible .g-year { opacity: 1; transform: none; }

/* ── ch05 film credits ─────────────────────────────────────── */
.ch-frame .ch-inner { text-align: center; }
.ch-frame h2, .ch-frame .frame-note { margin-left: auto; margin-right: auto; }
.frame-note { max-width: 46ch; margin-top: 26px; color: var(--muted); line-height: 1.75; }
.film-credits {
  list-style: none; margin-top: 66px;
  display: grid; gap: 4px;
}
.film-credits li {
  display: flex; align-items: baseline; justify-content: center; gap: 14px;
  padding: 7px 0;
  opacity: 0.5;
  transition: opacity 0.35s, letter-spacing 0.45s var(--ease);
  cursor: default;
}
.film-credits li span {
  font-size: clamp(1.05rem, 2.6vw, 1.7rem); font-weight: 400; letter-spacing: 0.01em;
}
.film-credits li i { font: italic 400 0.82rem var(--serif); color: var(--muted); }
.film-credits li:hover {
  opacity: 1; letter-spacing: 0.06em;
}
.film-credits li:hover span { font-family: var(--serif); font-style: italic; }

/* ── ch06 signal ───────────────────────────────────────────── */
.signal-list { list-style: none; margin-top: 50px; border-top: 1px solid var(--hair); }
.signal-list li { border-bottom: 1px solid var(--hair); }
.signal-list button {
  width: 100%; display: grid;
  grid-template-columns: 3.4rem 1fr auto; align-items: baseline; gap: 16px;
  padding: clamp(13px, 2vh, 19px) 4px;
  text-align: left;
}
.s-idx { font: italic 400 0.95rem var(--serif); color: var(--accent); }
.s-name {
  font-size: clamp(1.3rem, 3.4vw, 2.2rem); font-weight: 400; letter-spacing: -0.015em;
  transition: transform 0.4s var(--ease);
}
.signal-list button:hover .s-name, .signal-list button[aria-expanded="true"] .s-name { transform: translateX(14px); }
.s-note {
  justify-self: end; text-align: right;
  max-width: 32ch;
  color: var(--muted); font-size: 0.9rem;
  opacity: 0; transform: translateX(10px);
  transition: opacity 0.4s, transform 0.4s var(--ease);
}
.s-note-mobile { display: none; }   /* only participates in the <760px layout */
.signal-list button:hover .s-note,
.signal-list button:focus-visible .s-note,
.signal-list button[aria-expanded="true"] .s-note { opacity: 1; transform: none; }

/* ── epilogue ──────────────────────────────────────────────── */
.epilogue .ch-inner { text-align: center; }
.epilogue h2 { margin: 0 auto; }
.ep-sub { margin-top: 26px; color: var(--muted); line-height: 1.9; }
.magnetic {
  display: inline-grid; place-items: center;
  width: clamp(150px, 20vw, 190px); aspect-ratio: 1;
  margin-top: 54px;
  border: 1px solid var(--muted); border-radius: 50%;
  text-decoration: none;
  font: italic 400 1.25rem var(--serif);
  transition: border-color 0.3s, background 0.3s, color 0.3s;
  will-change: transform;
}
.magnetic:hover { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.foot {
  margin-top: 110px; padding-top: 26px; border-top: 1px solid var(--hair);
  display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap;
  font-size: 0.78rem; color: var(--muted);
}
.foot a { color: var(--ink); text-decoration-color: var(--muted); text-underline-offset: 3px; }

/* ── responsive ────────────────────────────────────────────── */
@media (max-width: 760px) {
  #rail { display: none; }
  .head-idx { display: inline; }
  .ch-num { -webkit-text-stroke-width: 0.7px; }
  .plat-line { flex-direction: column; gap: 10px; }
  .s-note { display: none; }                     /* replaced by expanding row */
  .signal-list button { grid-template-columns: 2.6rem 1fr; }
  .signal-list li .s-note-mobile {
    display: block;
    grid-column: 1 / -1; color: var(--muted); font-size: 0.88rem;
    max-height: 0; overflow: hidden; opacity: 0;
    transition: max-height 0.4s var(--ease), opacity 0.4s;
  }
  .signal-list button[aria-expanded="true"] + .s-note-mobile,
  .signal-list li.open .s-note-mobile { max-height: 4em; opacity: 1; padding-bottom: 12px; }
  /* pinned chapter falls back to native horizontal swipe */
  .ch-pin { min-height: 100vh; }
  .pin-viewport { position: relative; height: auto; padding: 16vh 0; overflow: visible; }
  .pin-track {
    overflow-x: auto; width: auto;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .pin-track::-webkit-scrollbar { display: none; }
  .craft-card { scroll-snap-align: center; width: 76vw; }
}

/* ── reduced motion ────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001s !important;
    transition-duration: 0.001s !important;
  }
  [data-split] .w > span { transform: none; }
  [data-reveal] { opacity: 1; transform: none; }
  #grain { animation: none; }
  .scroll-cue i::after { animation: none; transform: scaleY(1); }
  .ch-pin { min-height: 100vh; }
  .pin-viewport { position: relative; height: auto; padding: 14vh 0; overflow: visible; }
  .pin-track { flex-wrap: wrap; width: auto; }
}
