/* ============================================================
   Architecture Walkthrough — scroll-linked styles
   ============================================================ */
:root {
  --bg: #07080a;
  --ink: #f4f1ea;
  --muted: rgba(244, 241, 234, 0.62);
  --faint: rgba(244, 241, 234, 0.38);
  --accent: #d8b27a;          /* warm brass */
  --accent-2: #f4d9a8;
  --glass: rgba(18, 20, 24, 0.45);
  --glass-brd: rgba(255, 255, 255, 0.14);
  --shadow: 0 18px 60px rgba(0, 0, 0, 0.55);
  --serif: "Fraunces", Georgia, "Times New Roman", serif;
  --sans: "Space Grotesk", system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }   /* author display rules must not override the hidden attribute */

html { scroll-behavior: auto; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
}

button { font-family: inherit; cursor: pointer; }
svg { width: 100%; height: 100%; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* ===================== SCENE (pinned to viewport) ===================== */
.scene {
  position: fixed;
  inset: 0;
  background: #000;
  overflow: hidden;
  z-index: 1;
}
.film {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: #000;
  pointer-events: none;
}

/* The tall spacer that gives the page its scroll length. */
.track { position: relative; width: 100%; z-index: 0; }

/* Cinematic overlays */
.vignette {
  position: absolute; inset: 0; pointer-events: none;
  background:
    radial-gradient(120% 90% at 50% 42%, transparent 52%, rgba(0,0,0,0.55) 100%),
    linear-gradient(to bottom, rgba(0,0,0,0.32) 0%, transparent 20%, transparent 68%, rgba(0,0,0,0.5) 100%);
  opacity: 1;
  transition: opacity 0.4s var(--ease);
  z-index: 2;
}
.vignette.off { opacity: 0; }

.grain {
  position: absolute; inset: -50%;
  pointer-events: none;
  opacity: 0.05;
  z-index: 2;
  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.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  animation: grain 6s steps(6) infinite;
  mix-blend-mode: overlay;
}
.grain.off { display: none; }
@keyframes grain {
  0%,100%{transform:translate(0,0)} 20%{transform:translate(-4%,3%)}
  40%{transform:translate(3%,-3%)} 60%{transform:translate(-2%,2%)}
  80%{transform:translate(2%,-2%)}
}

/* ===================== SCROLL PROGRESS BAR ===================== */
.bar {
  position: absolute; top: 0; left: 0; right: 0; height: 3px;
  background: rgba(255,255,255,0.10);
  z-index: 6;
}
.bar__fill {
  display: block; height: 100%; width: 100%;
  transform-origin: left center; transform: scaleX(0);
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  box-shadow: 0 0 14px rgba(244,217,168,0.6);
}

/* ===================== HUD (room label) ===================== */
.hud {
  position: absolute; top: 0; left: 0; right: 0;
  display: flex; align-items: flex-start;
  gap: 16px; padding: 30px clamp(20px, 4vw, 52px);
  z-index: 5;
  background: linear-gradient(to bottom, rgba(0,0,0,0.5), transparent);
  pointer-events: none;
}
.hud__room { display: flex; align-items: baseline; gap: 16px; }
.hud__index {
  font-family: var(--serif); font-size: 14px; color: var(--accent-2);
  letter-spacing: 0.1em;
}
.hud__name {
  margin: 0; font-family: var(--serif); font-weight: 400;
  font-size: clamp(22px, 3.4vw, 38px); letter-spacing: 0.01em;
  text-shadow: 0 2px 24px rgba(0,0,0,0.6);
}
.hud__name.flip { animation: labelIn 0.55s var(--ease) both; }
@keyframes labelIn {
  from { opacity: 0; transform: translateY(10px); filter: blur(6px); }
  to   { opacity: 1; transform: none; filter: blur(0); }
}

/* ===================== CHECKPOINT RAIL ===================== */
.rail {
  position: absolute; right: clamp(16px, 3vw, 40px); top: 50%;
  transform: translateY(-50%);
  margin: 0; padding: 0; list-style: none;
  display: flex; flex-direction: column; align-items: flex-end; gap: 26px;
  z-index: 5; pointer-events: none;
}
.rail::before {
  content: ""; position: absolute; right: 5.5px; top: 6px; bottom: 6px;
  width: 1px; background: rgba(255,255,255,0.16);
}
.rail li {
  position: relative;             /* width collapses to the dot; label is absolute */
  display: flex; align-items: center;
}
.rail__btn {
  appearance: none; -webkit-appearance: none;
  margin: 0; padding: 8px 0 8px 14px;   /* hit area grows left/up/down; dot stays flush right */
  border: 0; background: none; color: inherit; font: inherit;
  display: flex; align-items: center;
  cursor: pointer; pointer-events: auto;
}
.rail__btn:focus-visible { outline: none; }
.rail__btn:hover .rail__dot,
.rail__btn:focus-visible .rail__dot {
  border-color: var(--accent-2); transform: scale(1.18);
  box-shadow: 0 0 0 3px rgba(244,217,168,0.22), 0 0 14px rgba(244,217,168,0.5);
}
.rail__btn:hover .rail__lbl,
.rail__btn:focus-visible .rail__lbl {
  opacity: 1; transform: translate(0, -50%); color: var(--ink);
}
.rail__dot {
  position: relative; z-index: 1;
  width: 12px; height: 12px; border-radius: 50%;
  border: 1.5px solid rgba(255,255,255,0.4);
  background: rgba(0,0,0,0.4);
  transition: all .4s var(--ease);
}
.rail__lbl {
  position: absolute; right: calc(100% + 12px); top: 50%;
  transform: translate(8px, -50%); white-space: nowrap;
  font-size: 11px; letter-spacing: 0.16em; text-transform: uppercase;
  color: var(--faint);
  opacity: 0;
  transition: all .4s var(--ease);
  text-shadow: 0 1px 10px rgba(0,0,0,0.7);
}
.rail li.done .rail__dot { border-color: var(--accent); background: rgba(216,178,122,0.5); }
.rail li.active .rail__dot {
  border-color: var(--accent-2); background: var(--accent-2);
  box-shadow: 0 0 0 4px rgba(244,217,168,0.18), 0 0 16px rgba(244,217,168,0.7);
  transform: scale(1.25);
}
.rail li.active .rail__lbl { opacity: 1; transform: translate(0, -50%); color: var(--ink); }

/* ===================== SCROLL HINT ===================== */
.hint {
  position: absolute; left: 50%; bottom: clamp(22px, 5vh, 46px);
  transform: translateX(-50%);
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  z-index: 5; pointer-events: none;
  font-size: 11px; letter-spacing: 0.32em; text-transform: uppercase;
  color: var(--muted);
  text-shadow: 0 1px 12px rgba(0,0,0,0.8);
  transition: opacity .5s var(--ease), transform .5s var(--ease);
}
.hint svg { width: 22px; height: 22px; color: var(--accent-2); animation: nudge 1.8s var(--ease) infinite; }
.hint.gone { opacity: 0; transform: translate(-50%, 10px); }
@keyframes nudge { 0%,100%{transform:translateY(0); opacity:.7} 50%{transform:translateY(6px); opacity:1} }

/* ===================== LOADER ===================== */
.loader {
  position: absolute; inset: 0; display: grid; place-items: center;
  z-index: 7; background: rgba(0,0,0,0.35); backdrop-filter: blur(2px);
}
.loader__spin {
  width: 46px; height: 46px; border-radius: 50%;
  border: 2px solid rgba(255,255,255,0.15);
  border-top-color: var(--accent-2);
  animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ===================== INTRO ===================== */
.intro {
  position: fixed; inset: 0; z-index: 20;
  display: grid; place-items: center;
  background: radial-gradient(120% 120% at 50% 0%, #14110c 0%, #07080a 55%, #050506 100%);
  transition: opacity 0.7s var(--ease), visibility 0.7s;
}
.intro.hide { opacity: 0; visibility: hidden; }
.intro__bg {
  position: absolute; inset: 0; pointer-events: none; opacity: 0.5;
  background:
    radial-gradient(40% 50% at 78% 20%, rgba(216,178,122,0.18), transparent 70%),
    radial-gradient(50% 60% at 12% 85%, rgba(216,178,122,0.12), transparent 70%);
}
.intro__inner { position: relative; text-align: center; padding: 32px; max-width: 760px; }
.intro__eyebrow {
  margin: 0 0 18px; font-size: 12px; letter-spacing: 0.42em; text-transform: uppercase;
  color: var(--accent-2);
  animation: rise 0.8s var(--ease) 0.05s both;
}
.intro__title {
  margin: 0; font-family: var(--serif); font-weight: 300;
  font-size: clamp(40px, 8vw, 96px); line-height: 1.02; letter-spacing: -0.015em;
  animation: rise 0.9s var(--ease) 0.12s both;
}
.intro__sub {
  margin: 20px auto 0; max-width: 460px; color: var(--muted);
  font-size: clamp(15px, 2vw, 18px); line-height: 1.6;
  animation: rise 0.9s var(--ease) 0.2s both;
}
.begin {
  margin-top: 38px;
  display: inline-flex; align-items: center; gap: 12px;
  height: 58px; padding: 0 30px; border-radius: 999px; border: 0;
  font-size: 16px; letter-spacing: 0.04em; font-weight: 600; color: #1a1408;
  background: linear-gradient(135deg, var(--accent-2), var(--accent));
  box-shadow: 0 20px 60px rgba(216,178,122,0.34);
  transition: transform .25s var(--ease), box-shadow .25s var(--ease), filter .25s var(--ease);
  animation: rise 0.9s var(--ease) 0.3s both;
}
.begin svg { width: 22px; height: 22px; stroke-width: 2; }
.begin:hover { transform: translateY(-3px); box-shadow: 0 26px 70px rgba(216,178,122,0.5); }
.begin:active { transform: translateY(0); }
.begin--sm { height: 50px; padding: 0 24px; font-size: 15px; }

.intro__credit {
  margin-top: 30px; font-size: 12px; letter-spacing: 0.2em; text-transform: uppercase;
  color: var(--faint);
  animation: rise 0.9s var(--ease) 0.4s both;
}
.intro__missing {
  position: absolute; left: 50%; bottom: 30px; transform: translateX(-50%);
  width: min(560px, 90vw); text-align: center; line-height: 1.6;
  font-size: 13px; color: var(--muted);
  background: rgba(40,28,12,0.5); border: 1px solid rgba(216,178,122,0.3);
  border-radius: 14px; padding: 16px 20px; backdrop-filter: blur(8px);
}
.intro__missing strong { color: var(--accent-2); display: block; margin-bottom: 4px; }
.intro__missing code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  background: rgba(255,255,255,0.08); padding: 1px 6px; border-radius: 5px;
}

@keyframes rise { from{opacity:0; transform:translateY(16px)} to{opacity:1; transform:none} }

/* ===================== END CARD ===================== */
.end {
  position: fixed; inset: 0; z-index: 18; display: grid; place-items: center;
  background: rgba(5,5,6,0.55); backdrop-filter: blur(8px);
  animation: rise 0.6s var(--ease) both;
}
.end__inner { text-align: center; padding: 32px; }
.end__eyebrow {
  margin: 0 0 12px; font-size: 12px; letter-spacing: 0.4em; text-transform: uppercase; color: var(--accent-2);
}
.end__title {
  margin: 0 0 28px; font-family: var(--serif); font-weight: 300;
  font-size: clamp(26px, 5vw, 48px);
}
.end__actions { display: flex; gap: 12px; justify-content: center; }

/* ===================== RESPONSIVE ===================== */
@media (max-width: 600px) {
  .hud { padding: 20px; }
  .rail__lbl { display: none; }
  .rail { gap: 20px; right: 14px; }
  .hint { letter-spacing: 0.22em; }
}

@media (prefers-reduced-motion: reduce) {
  .grain { display: none; }
  .hint svg { animation: none; }
}
