:root {
  --bg: #04050a;
  --ink: #ece6dc;
  --ink-dim: rgba(236, 230, 220, .55);
  --ink-faint: rgba(236, 230, 220, .22);
  --gold: #e9b95a;
  --gold-hi: #fff1c4;
  --cold: #8fa4c9;
  --serif: "Instrument Serif", "Times New Roman", serif;
  --sans: "Geist", system-ui, sans-serif;
  --mono: "Geist Mono", ui-monospace, monospace;
  --gutter: clamp(16px, 3.2vw, 44px);
  --ease: cubic-bezier(.22, 1, .36, 1);
}

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

html { background: var(--bg); }
html.lenis, html.lenis body { height: auto; }
.lenis.lenis-smooth { scroll-behavior: auto !important; }

body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
body.is-loading { overflow: hidden; height: 100svh; }

button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
a { color: inherit; text-decoration: none; }
em { font-style: italic; }

#scroller { height: 1900vh; pointer-events: none; }

/* stage */
#stage {
  position: fixed;
  inset: 0;
  overflow: hidden;
  will-change: transform;
}
#gl {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

#crack {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  mix-blend-mode: screen;
}
#crack path {
  fill: none;
  stroke: #f4f7ff;
  stroke-linecap: round;
  stroke-linejoin: round;
  vector-effect: non-scaling-stroke;
}

#flash {
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 50% 50%, #fff 0%, #d8e2ff 30%, rgba(160, 180, 255, 0) 75%);
  opacity: 0;
  pointer-events: none;
  mix-blend-mode: screen;
}

/* hud */
.hud {
  position: absolute;
  top: 0; left: 0; right: 0;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  padding: var(--gutter);
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--ink-dim);
  z-index: 5;
}
.hud__brand { justify-self: start; text-transform: none; letter-spacing: 0; font-family: var(--serif); font-size: 19px; color: var(--ink); }
.hud__brand em { color: var(--ink-dim); }
.hud__act { display: flex; align-items: center; gap: 12px; }
.hud__sep { width: 28px; height: 1px; background: var(--ink-faint); }
.hud__sound { justify-self: end; display: flex; align-items: center; gap: 10px; font-size: 11px; letter-spacing: .14em; text-transform: uppercase; color: var(--ink-dim); }
.eq { display: flex; align-items: flex-end; gap: 2px; height: 12px; }
.eq i { width: 2px; height: 3px; background: currentColor; transition: height .3s; }
.sound-on .eq i { animation: eq 1.1s ease-in-out infinite; }
.sound-on .eq i:nth-child(2) { animation-delay: -.3s; }
.sound-on .eq i:nth-child(3) { animation-delay: -.6s; }
.sound-on .eq i:nth-child(4) { animation-delay: -.8s; }
@keyframes eq { 0%, 100% { height: 3px; } 50% { height: 12px; } }

.counter {
  position: absolute;
  left: var(--gutter);
  bottom: calc(var(--gutter) + 46px);
  display: flex;
  flex-direction: column;
  gap: 6px;
  z-index: 4;
  opacity: 0;
}
.counter__label { font-family: var(--mono); font-size: 11px; letter-spacing: .2em; text-transform: uppercase; color: var(--ink-dim); }
.counter__value { font-family: var(--mono); font-weight: 300; font-size: clamp(44px, 7vw, 96px); line-height: .9; letter-spacing: -.04em; font-variant-numeric: tabular-nums; }

.doorframe {
  position: absolute;
  top: 12vh;
  bottom: 12vh;
  right: calc(var(--gutter) + 8px);
  width: 120px;
  z-index: 3;
  opacity: 0;
  pointer-events: none;
}
.doorframe__wood {
  position: absolute;
  right: 0; top: 0; bottom: 0;
  width: 1px;
  background: linear-gradient(to bottom, transparent, var(--ink-faint) 10%, var(--ink-faint) 90%, transparent);
}
.doorframe__marks { position: absolute; inset: 0; }
.mark {
  position: absolute;
  right: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  transform-origin: right center;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: .1em;
  color: var(--ink-dim);
}
.mark::after { content: ""; width: 34px; height: 1px; background: var(--ink); opacity: .7; }
.mark--current::after { width: 54px; background: var(--gold-hi); opacity: 1; box-shadow: 0 0 10px rgba(255, 230, 170, .8); }

.progress {
  position: absolute;
  right: 10px;
  top: 50%;
  height: 140px;
  width: 1px;
  transform: translateY(-50%);
  background: var(--ink-faint);
  z-index: 4;
}
.progress span { position: absolute; left: 0; top: 0; width: 1px; height: 100%; background: var(--ink); transform-origin: top; transform: scaleY(0); }

/* story */
.story { position: absolute; inset: 0; pointer-events: none; z-index: 2; }
.line {
  position: absolute;
  font-family: var(--serif);
  font-weight: 400;
  font-size: clamp(28px, 3.3vw, 54px);
  line-height: 1.04;
  letter-spacing: -.015em;
  opacity: 0;
  visibility: hidden;
  text-wrap: balance;
}
.line em { color: var(--ink-dim); }
.line--l { left: calc(var(--gutter) + 2vw); top: 50%; transform: translateY(-50%); max-width: min(10em, 30vw); }
.line--r { right: calc(var(--gutter) + 150px); top: 50%; transform: translateY(-50%); max-width: min(10em, 30vw); text-align: right; }
.line--c { left: 50%; top: 50%; transform: translate(-50%, -50%); text-align: center; width: min(92vw, 15em); }
.line--big { font-size: clamp(44px, 8vw, 140px); }

.line--hero {
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  font-size: clamp(52px, 11vw, 190px);
  line-height: .9;
  text-align: center;
  white-space: nowrap;
  letter-spacing: -.035em;
}
.line--hint {
  left: 50%;
  bottom: calc(var(--gutter) + 56px);
  transform: translateX(-50%);
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: .24em;
  text-transform: uppercase;
  color: var(--ink-dim);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}
.hint__arrow { width: 1px; height: 42px; background: linear-gradient(var(--ink), transparent); animation: hint 2.2s var(--ease) infinite; transform-origin: top; }
@keyframes hint { 0% { transform: scaleY(0); } 50% { transform: scaleY(1); transform-origin: top; } 51% { transform-origin: bottom; } 100% { transform: scaleY(0); transform-origin: bottom; } }

.line--nightmare {
  font-size: clamp(48px, 10vw, 170px);
  white-space: nowrap;
  width: auto;
  color: #c9cfdb;
  text-shadow: -3px 0 rgba(255, 40, 60, .55), 3px 0 rgba(60, 140, 255, .55);
  transform: translate(calc(-50% + var(--gx, 0px)), -50%) skewX(var(--sk, 0deg));
}
.line--nightmare em { color: #8e2b36; }

.line--fail { top: 30%; font-size: clamp(34px, 5vw, 84px); width: auto; white-space: nowrap; }

/* final title: letters in 3D, "bad" shatters, "big" is forged in gold */
.line--final {
  top: 64%;
  font-size: clamp(46px, 9.4vw, 160px);
  white-space: nowrap;
  width: auto;
  line-height: 1;
  perspective: 900px;
}
.line--final .ch { display: inline-block; transform-origin: 50% 80%; will-change: transform, filter, opacity; }
.swap { position: relative; display: inline-block; }
.swap__old, .swap__new { display: inline-block; font-style: italic; }
.swap__old { color: var(--ink-dim); }
.swap__new { position: absolute; left: 50%; top: 0; transform: translateX(-50%); white-space: nowrap; filter: drop-shadow(0 0 22px rgba(233, 185, 90, .55)); }
.swap__new .ch {
  background: linear-gradient(100deg, #9a6418 0%, #e9b95a 30%, #fff6d8 48%, #ffffff 50%, #fff6d8 52%, #e9b95a 70%, #9a6418 100%);
  background-size: 400% 100%;
  background-position: 100% 0;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  padding: 0 .04em;
  margin: 0 -.04em;
}

.line--truth { top: 70%; font-size: clamp(24px, 2.8vw, 44px); width: min(92vw, 20em); }
.line--reveal { font-size: clamp(20px, 2.1vw, 32px); top: auto; bottom: calc(var(--gutter) + 64px); transform: translateX(-50%); white-space: nowrap; width: auto; }
.line--reveal em { color: var(--gold-hi); }

.line--credit {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 26px;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: .24em;
  text-transform: uppercase;
  color: var(--ink-dim);
  white-space: nowrap;
  pointer-events: auto;
}
.line--credit a { color: var(--ink); border-bottom: 1px solid var(--ink-faint); padding-bottom: 2px; transition: color .4s, border-color .4s; }
.line--credit a:hover { color: var(--gold); border-color: var(--gold); }

/* hold (the fight) */
.hold {
  position: absolute;
  left: 50%;
  bottom: calc(var(--gutter) + 58px);
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  z-index: 6;
  opacity: 0;
  visibility: hidden;
  user-select: none;
}
.hold__ring { position: relative; width: 84px; height: 84px; }
.hold__ring svg { width: 100%; height: 100%; transform: rotate(-90deg); overflow: visible; }
.hold__track { fill: none; stroke: var(--ink-faint); stroke-width: 1; }
.hold__fill {
  fill: none;
  stroke: var(--gold-hi);
  stroke-width: 2;
  stroke-linecap: round;
  stroke-dasharray: 289;
  stroke-dashoffset: 289;
  filter: drop-shadow(0 0 6px rgba(233, 185, 90, .9));
}
.hold__core {
  position: absolute;
  left: 50%; top: 50%;
  width: 8px; height: 8px;
  margin: -4px 0 0 -4px;
  border-radius: 50%;
  background: #ffb35a;
  box-shadow: 0 0 18px 4px rgba(255, 150, 60, .7);
  animation: pulse 1.4s ease-in-out infinite;
}
.hold__label { font-family: var(--mono); font-size: 11px; letter-spacing: .28em; text-transform: uppercase; color: var(--ink); }
.hold__sub { font-family: var(--mono); font-size: 9px; letter-spacing: .24em; text-transform: uppercase; color: var(--ink-faint); }
.is-holding .hold__ring { animation: strain .09s linear infinite; }
@keyframes strain { 0% { transform: translate(0, 0); } 25% { transform: translate(1px, -1px); } 50% { transform: translate(-1px, 1px); } 75% { transform: translate(1px, 1px); } 100% { transform: translate(0, 0); } }
body.gate-on { cursor: grab; }
body.gate-on.is-holding { cursor: grabbing; }

.split-word { display: inline-block; will-change: transform, filter, opacity; }

/* values */
.values {
  position: fixed;
  left: 50%;
  bottom: var(--gutter);
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 14px;
  list-style: none;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: .32em;
  text-transform: uppercase;
  color: var(--ink);
  z-index: 50;
  white-space: nowrap;
  opacity: 0;
  transition: text-shadow 1.2s, color 1.2s;
}
.values__dot { width: 3px; height: 3px; border-radius: 50%; background: var(--ink-dim); }
.values.is-glow { color: var(--gold-hi); text-shadow: 0 0 14px rgba(233, 185, 90, .9), 0 0 40px rgba(233, 185, 90, .4); }
.values.is-glow .values__dot { background: var(--gold); }

/* loader */
#loader {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: var(--bg);
  display: grid;
  place-items: center;
}
.loader__grain, body::after {
  position: absolute;
  inset: -50%;
  pointer-events: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='160' height='160'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/></filter><rect width='100%' height='100%' filter='url(%23n)' opacity='.5'/></svg>");
  opacity: .08;
  animation: grain 1s steps(6) infinite;
}
body::after { content: ""; position: fixed; z-index: 60; opacity: .05; }
@keyframes grain {
  0% { transform: translate(0, 0); } 20% { transform: translate(-4%, 3%); } 40% { transform: translate(3%, -5%); }
  60% { transform: translate(-6%, -2%); } 80% { transform: translate(5%, 4%); } 100% { transform: translate(0, 0); }
}
.loader__center { position: relative; display: flex; flex-direction: column; align-items: center; gap: 28px; padding: 0 16px; text-align: center; }
.loader__kicker { font-family: var(--mono); font-size: 11px; letter-spacing: .4em; text-transform: uppercase; color: var(--ink-dim); }
.loader__title { font-family: var(--serif); font-weight: 400; font-size: clamp(40px, 7vw, 108px); letter-spacing: -.03em; line-height: .95; min-height: 1em; }
.loader__title .ch { display: inline-block; white-space: pre; }
.loader__bar { width: min(320px, 70vw); height: 1px; background: var(--ink-faint); overflow: hidden; }
.loader__bar span { display: block; height: 100%; background: var(--ink); transform: scaleX(0); transform-origin: left; }
.loader__count { font-family: var(--mono); font-size: 12px; letter-spacing: .2em; color: var(--ink-dim); font-variant-numeric: tabular-nums; }
.loader__count i { font-style: normal; margin-left: 2px; }
.loader__enter { display: flex; flex-wrap: wrap; justify-content: center; gap: 12px; opacity: 0; visibility: hidden; }
.loader__hint { width: 100%; font-family: var(--mono); font-size: 10px; letter-spacing: .3em; text-transform: uppercase; color: var(--ink-faint); margin-top: 6px; }
.loader__meta { position: absolute; bottom: var(--gutter); font-family: var(--mono); font-size: 10px; letter-spacing: .24em; text-transform: uppercase; color: var(--ink-faint); }
.loader__meta--l { left: var(--gutter); }
.loader__meta--r { right: var(--gutter); }

.btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 15px 24px;
  border: 1px solid var(--ink-faint);
  border-radius: 999px;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: .2em;
  text-transform: uppercase;
  overflow: hidden;
  isolation: isolate;
  transition: border-color .5s var(--ease), color .5s var(--ease);
}
.btn::before {
  content: "";
  position: absolute;
  inset: 0;
  background: var(--ink);
  border-radius: inherit;
  transform: translateY(101%);
  transition: transform .6s var(--ease);
  z-index: -1;
}
.btn:hover { color: var(--bg); border-color: var(--ink); }
.btn:hover::before { transform: translateY(0); }
.btn--primary { border-color: var(--ink); }
.btn__dot { width: 6px; height: 6px; border-radius: 50%; background: var(--gold); box-shadow: 0 0 12px var(--gold); animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .35; } }

.lid {
  position: fixed;
  left: 0; right: 0;
  height: 50.5vh;
  background: var(--bg);
  z-index: 90;
  pointer-events: none;
}
.lid--top { top: 0; border-radius: 0 0 50% 50% / 0 0 0 0; }
.lid--bottom { bottom: 0; border-radius: 0 0 0 0 / 0 0 0 0; }

/* cursor */
.cursor {
  position: fixed;
  left: 0; top: 0;
  z-index: 200;
  pointer-events: none;
  mix-blend-mode: difference;
}
.cursor span {
  display: block;
  width: 10px; height: 10px;
  margin: -5px 0 0 -5px;
  border-radius: 50%;
  background: #fff;
  transition: transform .5s var(--ease);
}
.cursor.is-hover span { transform: scale(4.2); }
@media (hover: none) { .cursor { display: none; } }

.noscript { position: fixed; inset: 0; display: grid; place-items: center; font-family: var(--mono); }

/* small screens */
@media (max-width: 720px) {
  .hud { grid-template-columns: 1fr auto; }
  .hud__act { display: none; }
  .hud__soundLabel { display: none; }
  .line--l, .line--r { left: var(--gutter); right: var(--gutter); max-width: none; text-align: left; top: 40%; }
  .line--r { text-align: right; }
  .line--hero, .line--nightmare, .line--final { white-space: normal; width: 92vw; }
  .doorframe { width: 70px; top: 18vh; bottom: 22vh; }
  .values { gap: 8px; letter-spacing: .2em; font-size: 10px; }
  .counter { bottom: calc(var(--gutter) + 40px); }
}

@media (prefers-reduced-motion: reduce) {
  .loader__grain, body::after, .hint__arrow { animation: none; }
}
