:root {
  --bg: #05060a;
  --ink: #eef2f7;
  --muted: #7f8aa3;
  --accent: #36f0ff;
  --accent2: #1e5bff;
  --line: rgba(238, 242, 247, 0.16);
  --panel: rgba(10, 12, 20, 0.55);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  background: var(--bg);
  color: var(--ink);
  font-family: "Space Grotesk", system-ui, sans-serif;
  overflow-x: hidden;
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
}
/* lock scroll until the experience launches */
body.locked { overflow: hidden; height: 100%; }

/* +15% global type scale (applied to text layers only, not the WebGL canvas) */
.intro-inner, .loader-inner, .content, .hud-brand, .section-nav,
.ghost-btn, .hud-counter, .nav-btn, .audio-meta, .caption, .hint-bubble { zoom: 1.15; }

#space { position: fixed; inset: 0; z-index: 0; display: block; background: #04060a; }
#model3d { position: fixed; inset: 0; z-index: 1; display: block; pointer-events: none; }
#yt-host { position: fixed; width: 1px; height: 1px; left: -9999px; top: -9999px; opacity: 0; pointer-events: none; }

/* grain + scanlines */
.grain {
  position: fixed; inset: -50%; z-index: 50; pointer-events: none; opacity: 0.045;
  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.85' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  animation: grain .6s steps(2) infinite;
}
@keyframes grain { 0%{transform:translate(0,0)} 50%{transform:translate(-3%,2%)} 100%{transform:translate(2%,-2%)} }
.scanlines {
  position: fixed; inset: 0; z-index: 49; pointer-events: none; opacity: .35;
  background: repeating-linear-gradient(to bottom, rgba(255,255,255,0) 0 2px, rgba(0,0,0,.18) 2px 4px);
  mix-blend-mode: overlay;
}

/* screens */
.screen { position: fixed; inset: 0; z-index: 20; display: flex; align-items: center; justify-content: center; text-align: center; padding: 6vw; }
.screen.hidden { display: none; }

/* intro */
#intro { flex-direction: column; }
.intro-inner { max-width: 820px; }
.eyebrow { font-family: "JetBrains Mono", monospace; font-size: 12px; letter-spacing: 5px; text-transform: uppercase; color: var(--accent); }
.brand { font-family: "Playfair Display", serif; font-weight: 400; font-size: clamp(46px, 12vw, 132px); line-height: .95; margin-top: 14px; letter-spacing: 1px; }
.dotpulse { color: var(--accent); animation: pulse 1.6s ease-in-out infinite; }
.intro-copy { margin-top: 28px; font-size: clamp(15px, 2.2vw, 20px); line-height: 1.7; color: #cdd5e4; font-weight: 300; }
.intro-copy.small { margin-top: 16px; font-size: clamp(12px,1.6vw,15px); color: var(--muted); font-family: "JetBrains Mono", monospace; }

.start-btn {
  margin-top: 44px; background: transparent; border: 1px solid var(--line); color: var(--ink);
  font-family: "JetBrains Mono", monospace; font-size: 13px; letter-spacing: 5px; text-transform: uppercase;
  padding: 18px 50px; border-radius: 100px; cursor: pointer; display: inline-flex; align-items: center; gap: 14px;
  transition: background .5s, color .5s, letter-spacing .5s, box-shadow .5s;
}
.start-btn .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); animation: pulse 2s ease-in-out infinite; }
.start-btn:hover { background: var(--accent); color: #04130f; letter-spacing: 8px; box-shadow: 0 0 40px -8px var(--accent); }
.start-btn:hover .dot { background: #04130f; }
@keyframes pulse { 0%,100%{opacity:1;transform:scale(1)} 50%{opacity:.3;transform:scale(.7)} }
.hint { margin-top: 38px; font-size: 11px; letter-spacing: 3px; text-transform: uppercase; color: var(--muted); }

/* intro stagger */
.l1,.l2,.l3,.l4,.l5,.l6 { opacity: 0; transform: translateY(20px); }
.intro-go .l1 { animation: rise 1s .15s forwards cubic-bezier(.2,.7,.2,1); }
.intro-go .l2 { animation: rise 1.1s .45s forwards cubic-bezier(.2,.7,.2,1); }
.intro-go .l3 { animation: rise 1s .95s forwards cubic-bezier(.2,.7,.2,1); }
.intro-go .l4 { animation: rise 1s 1.3s forwards cubic-bezier(.2,.7,.2,1); }
.intro-go .l5 { animation: rise 1s 1.65s forwards cubic-bezier(.2,.7,.2,1); }
.intro-go .l6 { animation: rise 1s 2s forwards cubic-bezier(.2,.7,.2,1); }
@keyframes rise { to { opacity: 1; transform: translateY(0); } }

.fade-out { animation: fadeOut .9s forwards ease; }
@keyframes fadeOut { to { opacity: 0; visibility: hidden; } }
.fade-in { animation: fadeIn 1s forwards ease; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

/* loader */
/* animated tech grid backdrop */
.loader-grid {
  position: absolute; inset: 0; pointer-events: none; opacity: .5;
  background-image:
    linear-gradient(rgba(54,240,255,.07) 1px, transparent 1px),
    linear-gradient(90deg, rgba(54,240,255,.07) 1px, transparent 1px);
  background-size: 46px 46px;
  mask-image: radial-gradient(circle at 50% 50%, #000 0%, transparent 72%);
  animation: gridpan 8s linear infinite;
}
@keyframes gridpan { from { background-position: 0 0, 0 0; } to { background-position: 46px 46px, 46px 46px; } }

.loader-inner { display: flex; flex-direction: column; align-items: center; gap: 22px; }
.boot-head { font-family: "JetBrains Mono", monospace; font-size: 11px; letter-spacing: 3px; text-transform: uppercase; color: var(--accent); display: flex; align-items: center; gap: 9px; }
.boot-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 10px var(--accent); animation: pulse 1.4s ease-in-out infinite; }

.loader-ring { position: relative; width: 140px; height: 140px; }
.loader-ring svg { transform: rotate(-90deg); width: 140px; height: 140px; }
.loader-ring circle { fill: none; stroke-width: 1.5; }
.loader-ring .track { stroke: var(--line); }
.loader-ring .prog { stroke: var(--accent); stroke-dasharray: 339.292; stroke-dashoffset: 339.292; transition: stroke-dashoffset .2s linear; filter: drop-shadow(0 0 8px var(--accent)); }
.loader-ring .spin { stroke: var(--accent2); stroke-width: 2; stroke-dasharray: 30 250; opacity: .8; transform-origin: 60px 60px; animation: ringspin 1.6s linear infinite; }
@keyframes ringspin { to { transform: rotate(360deg); } }
#loadPct { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: 30px; font-weight: 400; font-family: "JetBrains Mono", monospace; letter-spacing: 1px; }
.ring-unit { position: absolute; top: 50%; left: 50%; transform: translate(28px, -10px); font-family: "JetBrains Mono", monospace; font-size: 12px; color: var(--muted); }

.boot-log { list-style: none; font-family: "JetBrains Mono", monospace; font-size: 12px; line-height: 1.75; color: var(--muted); min-height: 230px; width: 420px; max-width: 86vw; text-align: left; }
.boot-log li { opacity: 0; transform: translateX(-6px); animation: bootline .35s forwards; display: flex; justify-content: space-between; gap: 12px; }
.boot-log li b { color: var(--accent); font-weight: 400; }
.boot-log .bl-final { color: var(--ink); font-size: 13px; margin-top: 4px; }
.boot-log .bl-final .bl-msg { animation: blink 1.1s steps(2) 3; }
@keyframes bootline { to { opacity: 1; transform: translateX(0); } }

.boot-bar { width: 280px; height: 2px; background: var(--line); overflow: hidden; }
.boot-bar span { display: block; height: 100%; width: 0; background: var(--accent); box-shadow: 0 0 12px var(--accent); transition: width .2s linear; }
.loader-label { font-size: 12px; letter-spacing: 3px; text-transform: uppercase; color: var(--muted); font-family: "JetBrains Mono", monospace; }
.blink { animation: blink 1s steps(2) infinite; color: var(--accent); }
@keyframes blink { 50% { opacity: 0; } }

/* experience layout (scroll journey) */
.experience { position: relative; z-index: 10; }
.experience.hidden { display: none; }

.hud-top {
  position: fixed; top: 0; left: 0; right: 0; z-index: 34; display: flex; align-items: center; gap: 20px;
  padding: 22px 32px; pointer-events: none;
  background: linear-gradient(to bottom, rgba(4,6,10,0.65), transparent);
}
.hud-top > * { pointer-events: auto; }
.hud-brand { font-family: "Playfair Display", serif; font-size: 18px; }
.section-nav { display: flex; gap: 6px; margin: 0 auto; flex-wrap: wrap; justify-content: center; }
.section-nav button {
  background: transparent; border: none; color: var(--muted); cursor: pointer;
  font-family: "JetBrains Mono", monospace; font-size: 11px; letter-spacing: 2px; text-transform: uppercase;
  padding: 7px 12px; border-radius: 100px; transition: color .3s, background .3s;
}
.section-nav button:hover { color: var(--ink); }
.section-nav button.active { color: var(--bg); background: var(--accent); }

.ghost-btn {
  background: transparent; border: 1px solid var(--line); color: var(--ink); cursor: pointer;
  font-family: "JetBrains Mono", monospace; font-size: 11px; letter-spacing: 2px; text-transform: uppercase;
  padding: 9px 14px; border-radius: 100px; display: inline-flex; align-items: center; gap: 9px; transition: border-color .3s, color .3s;
}
.ghost-btn:hover { border-color: var(--accent); color: var(--accent); }
.ghost-btn[aria-pressed="true"] { border-color: var(--accent); color: var(--accent); box-shadow: 0 0 24px -10px var(--accent); }
.bars { display: inline-flex; align-items: flex-end; gap: 2px; height: 13px; }
.bars i { width: 2px; background: currentColor; height: 100%; animation: eq 1s ease-in-out infinite; }
.bars i:nth-child(2){animation-delay:.2s} .bars i:nth-child(3){animation-delay:.4s} .bars i:nth-child(4){animation-delay:.6s}
@keyframes eq { 0%,100%{height:30%} 50%{height:100%} }
.ghost-btn[aria-pressed="false"] .bars i { animation-play-state: paused; height: 30%; opacity: .5; }

/* chapters (scroll sections) */
.chapters { width: 100%; }
.chapter {
  min-height: 100vh; display: flex; align-items: center; justify-content: space-between;
  gap: 5vw; padding: 120px 7vw 160px; width: 100%; max-width: 1520px; margin: 0 auto;
}
.chapter:nth-child(even) { flex-direction: row-reverse; } /* alternate sides for rhythm */
.content { flex: 0 1 560px; min-width: 0; position: relative; z-index: 2; }
/* empty spacer — the 3D car→robot morph (model3d.js) occupies this side */
.chapter-aside { flex: 1 1 0; user-select: none; pointer-events: none; }
.sec-tag { font-family: "JetBrains Mono", monospace; font-size: 12px; letter-spacing: 4px; text-transform: uppercase; color: var(--accent); }
.content h2 { font-family: "Playfair Display", serif; font-weight: 400; font-size: clamp(34px, 6vw, 68px); line-height: 1.02; margin-top: 10px; letter-spacing: -0.5px; }
.content .role { color: var(--muted); margin-top: 12px; font-size: 15px; font-family: "JetBrains Mono", monospace; }
.content p { margin-top: 18px; line-height: 1.8; color: #cfd6e6; font-weight: 300; font-size: clamp(15px, 1.7vw, 17px); }
.content ul { margin-top: 18px; list-style: none; display: flex; flex-direction: column; gap: 13px; }
.content li { position: relative; padding-left: 22px; line-height: 1.6; color: #cfd6e6; font-weight: 300; font-size: 15px; }
.content li::before { content: "▹"; position: absolute; left: 0; color: var(--accent); }
.content li b { color: var(--ink); font-weight: 600; }
.content li .when { display: block; font-family: "JetBrains Mono", monospace; font-size: 11px; color: var(--muted); letter-spacing: 1px; margin-top: 3px; }
.chips { margin-top: 20px; display: flex; flex-wrap: wrap; gap: 8px; }
.chip { font-family: "JetBrains Mono", monospace; font-size: 12px; padding: 7px 12px; border: 1px solid var(--line); border-radius: 100px; color: #cfd6e6; transition: border-color .3s, color .3s, transform .3s; }
.chip:hover { transform: translateY(-2px); }
.chip.key { border-color: var(--accent); color: var(--accent); }
.content a { color: var(--accent); text-decoration: none; border-bottom: 1px solid transparent; transition: border-color .3s; }
.content a:hover { border-color: var(--accent); }

/* scroll progress rail */
.scroll-rail { position: fixed; top: 0; right: 0; width: 2px; height: 100vh; background: var(--line); z-index: 33; }
.scroll-rail span { position: absolute; top: 0; left: 0; width: 100%; height: 0; background: var(--accent); box-shadow: 0 0 12px var(--accent); }

/* caption */
.caption {
  position: fixed; left: 6vw; right: 6vw; bottom: 96px; z-index: 35; pointer-events: none;
  font-family: "JetBrains Mono", monospace; font-size: 13px; color: var(--accent); letter-spacing: .5px;
  text-shadow: 0 0 18px rgba(54,240,255,.35); min-height: 18px; opacity: 0; transition: opacity .4s; max-width: 760px;
}
.caption.on { opacity: .9; }

/* bottom HUD */
.hud-bottom { position: fixed; left: 0; right: 0; bottom: 0; z-index: 34; padding: 18px 32px; display: flex; align-items: center; gap: 24px; pointer-events: none; }
.hud-bottom > * { pointer-events: auto; }
.hud-nav { display: flex; align-items: center; gap: 16px; }
.nav-btn { background: transparent; border: 1px solid var(--line); color: var(--ink); width: 42px; height: 42px; border-radius: 50%; font-size: 20px; cursor: pointer; transition: background .3s, color .3s; }
.nav-btn:hover { background: var(--accent); color: var(--bg); }
.hud-counter { font-family: "JetBrains Mono", monospace; font-size: 12px; letter-spacing: 2px; color: var(--muted); min-width: 56px; text-align: center; }

/* ===== minimal audio widget (fixed corner) ===== */
.audio {
  position: fixed; right: 32px; bottom: 26px; z-index: 36; pointer-events: auto;
  display: flex; align-items: center; gap: 13px;
  background: rgba(8, 12, 20, 0.42); border: 1px solid var(--line); border-radius: 100px;
  padding: 8px 16px 8px 8px; backdrop-filter: blur(12px); max-width: 340px;
  transition: border-color .4s, box-shadow .4s, opacity .6s;
}
.audio:hover { border-color: rgba(54, 240, 255, 0.45); box-shadow: 0 0 36px -14px var(--accent); }

/* play / sound-toggle button is a live equalizer */
.eq-btn {
  flex: 0 0 auto; width: 40px; height: 40px; border-radius: 50%;
  border: 1px solid var(--line); background: transparent; cursor: pointer;
  display: flex; align-items: center; justify-content: center; transition: border-color .3s, background .3s;
}
.eq-btn[aria-pressed="true"] { border-color: var(--accent); box-shadow: 0 0 20px -8px var(--accent); }
.eq-btn:hover { background: rgba(54, 240, 255, 0.08); }
.eq { display: inline-flex; align-items: center; gap: 2px; height: 16px; }
.eq i {
  width: 2.5px; height: 30%; border-radius: 2px;
  background: var(--accent); transform-origin: center bottom;
  transition: height .08s linear, opacity .3s;
}
.eq-btn[aria-pressed="false"] .eq i { height: 30% !important; opacity: .4; background: var(--muted); }

.audio-meta { display: flex; flex-direction: column; gap: 3px; min-width: 0; width: 210px; }
.audio-now { display: flex; align-items: baseline; gap: 8px; }
.audio-track { font-weight: 600; font-size: 13px; white-space: nowrap; letter-spacing: .3px; }
.audio-by { font-size: 10px; color: var(--muted); font-family: "JetBrains Mono", monospace; }
.credit-marquee { overflow: hidden; white-space: nowrap; width: 100%; mask-image: linear-gradient(90deg, transparent, #000 10%, #000 90%, transparent); }
.credit-track { display: inline-block; padding-left: 100%; font-family: "JetBrains Mono", monospace; font-size: 9px; color: var(--muted); letter-spacing: .4px; animation: marquee 22s linear infinite; }
.credit-track a { color: var(--accent); text-decoration: none; }
@keyframes marquee { from { transform: translateX(0); } to { transform: translateX(-100%); } }
.switch-btn {
  flex: 0 0 auto; background: transparent; border: none; color: var(--muted); cursor: pointer;
  font-size: 16px; line-height: 1; transition: color .3s, transform .3s;
}
.switch-btn:hover { color: var(--accent); transform: rotate(180deg); }
.vol {
  flex: 0 0 auto; width: 0; opacity: 0; height: 3px; accent-color: var(--accent); cursor: pointer;
  transition: width .35s ease, opacity .35s ease;
}
.audio:hover .vol, .vol:focus { width: 70px; opacity: 1; }

.hint-bubble { position: fixed; left: 50%; bottom: 88px; z-index: 33; transform: translateX(-50%); font-family: "JetBrains Mono", monospace; font-size: 11px; letter-spacing: 2px; text-transform: uppercase; color: var(--muted); animation: floaty 3s ease-in-out infinite; transition: opacity .6s; }
@keyframes floaty { 0%,100%{transform:translate(-50%,0)} 50%{transform:translate(-50%,-6px)} }
.hint-bubble.gone { opacity: 0; pointer-events: none; }

/* one-time narration prompt */
.toast {
  position: fixed; left: 50%; bottom: 112px; z-index: 38;
  transform: translateX(-50%) translateY(22px);
  display: flex; align-items: center; gap: 13px;
  background: rgba(8,12,20,.72); border: 1px solid var(--line); border-radius: 100px;
  padding: 9px 11px 9px 18px; backdrop-filter: blur(12px);
  box-shadow: 0 0 40px -16px var(--accent);
  opacity: 0; pointer-events: none; transition: opacity .5s, transform .5s;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); pointer-events: auto; }
.toast-text { font-size: 13px; color: var(--ink); letter-spacing: .3px; }
.toast-eq { display: inline-flex; gap: 2px; align-items: flex-end; height: 14px; }
.toast-eq i { width: 2px; height: 100%; background: var(--accent); animation: eq 1s ease-in-out infinite; }
.toast-eq i:nth-child(2){ animation-delay:.2s } .toast-eq i:nth-child(3){ animation-delay:.4s }
.toast-yes { background: var(--accent); color: var(--bg); border: none; border-radius: 100px; padding: 7px 16px; font-family: inherit; font-size: 12px; font-weight: 600; letter-spacing: 1px; text-transform: uppercase; cursor: pointer; transition: box-shadow .3s; }
.toast-yes:hover { box-shadow: 0 0 20px -4px var(--accent); }
.toast-no { background: transparent; border: none; color: var(--muted); font-size: 16px; cursor: pointer; padding: 0 6px; }
.toast-no:hover { color: var(--ink); }

/* rotate */
/* rotate-device overlay removed — portrait phones are supported */
@keyframes spin { to { transform: rotate(360deg); } }

/* responsive */
@media (max-width: 880px) {
  .section-nav { display: none; }
  .chapter { width: 100%; padding: 100px 28px 230px; }
  .chapter, .chapter:nth-child(even) { flex-direction: column; align-items: flex-start; gap: 0; }
  .chapter-aside { display: none; } /* the 3D morph sits centered behind content on phones */
  .caption { bottom: 248px; left: 28px; right: 28px; }
  .hud-bottom { gap: 14px; }
  .audio { left: 16px; right: 16px; bottom: 84px; max-width: none; }
  .audio-meta { flex: 1; width: auto; }
}
