/* ==========================================================================
   HERO: the fog gate, the night skyline, and the scroll "descent".

   How the scroll effect works: js/scroll.js sets a number --p on .hero that
   goes from 0 (top) to 1 (end of hero) as you scroll. The rules below use
   var(--p) to zoom the skyline, fade the title and darken the scene.
   ========================================================================== */

/* ---------- Gate + fog (the first screen) ---------- */
.gate-wrap { position: fixed; inset: 0; z-index: var(--z-gate); }
.go .gate-wrap { pointer-events: none; }
.vl {
  position: absolute; inset: 0; z-index: 29; background: var(--ink); opacity: .5;
  transition: opacity 3.5s ease-in .3s;
}
.go .vl { opacity: 0; }

.fg {
  position: absolute; pointer-events: none; z-index: 30;
  transition: transform 5s cubic-bezier(.55, 0, .25, 1), opacity 5s ease-in;
}
.fg i {
  position: absolute; inset: 0; display: block; filter: blur(10px);
  animation: drift 16s ease-in-out infinite alternate;
  background:
    radial-gradient(circle at 30% 40%, rgba(205,214,232,.97) 0, rgba(140,155,190,.85) 40%, rgba(90,105,145,0) 72%),
    radial-gradient(circle at 72% 62%, rgba(190,200,222,.95) 0, rgba(120,135,175,.8) 40%, rgba(90,105,145,0) 70%);
}
.fa { left: -12%; top: -6%; width: 72%; height: 112%; }
.fb { right: -12%; top: -6%; width: 72%; height: 112%; }
.fc { left: 0; top: -30%; width: 100%; height: 70%; }
.fd { left: 0; bottom: -30%; width: 100%; height: 70%; }
.go .fa { transform: translateX(-90%); opacity: 0; }
.go .fb { transform: translateX(90%); opacity: 0; transition-delay: .4s; }
.go .fc { transform: translateY(-85%); opacity: 0; transition-delay: .2s; }
.go .fd { transform: translateY(85%); opacity: 0; transition-delay: .6s; }
@keyframes drift { from { transform: translateX(-30px); } to { transform: translateX(30px); } }

.gate {
  position: absolute; inset: 0; z-index: 40;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 18px; text-align: center; padding: 24px; color: var(--ink);
  transition: opacity .7s;
}
.go .gate { opacity: 0; }
.gate-title { font: 30px var(--font-display); letter-spacing: .1em; }
.enter-btn {
  min-height: 56px; padding: 0 32px;
  background: var(--ink); color: var(--cream);
  border: 4px solid var(--ochre); box-shadow: 6px 6px 0 #000;
  font: 26px var(--font-comic); letter-spacing: .12em; cursor: pointer;
}
.enter-btn:hover { background: var(--ochre); color: var(--ink); }
.gate-note { font-size: 15px; }

/* ---------- The scene ---------- */
.hero { position: relative; height: 190vh; height: 190dvh; }
.hero-stage {
  position: sticky; top: 0; height: 100vh; height: 100dvh; min-height: 620px; overflow: hidden;
  background: linear-gradient(180deg, #02030c 0%, #070d2b 45%, #231838 74%, #5a2824 92%, #84481f 100%);
}

.moon {
  position: absolute; right: 16%; top: 9%;
  width: clamp(84px, 10.5vw, 142px); aspect-ratio: 1;
}
/* the picture (craters, seas, halo) is assets/moon.svg, drawn by tools/gen_moon.py. It is 1.7x the moon so the glow has room. */
.moon::before { content: ""; position: absolute; inset: -35%; background: url("../assets/moon.svg") center / 100% 100% no-repeat; filter: brightness(1.18) contrast(1.06); }
.cloud { position: absolute; border-radius: 50%; background: #0a1030; filter: blur(14px); opacity: .7; }
.cloud-a { left: 20%; top: 14%; width: 34vw; height: 50px; }
.cloud-b { right: 4%; top: 26%; width: 40vw; height: 46px; }

/* The searchlight: a lamp behind the rooftops throws a hatched beam up to a "J" on the clouds. */
.signal-svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.sig { transform-box: view-box; transform-origin: 470px 640px; animation: sway 11s ease-in-out infinite alternate; }
@keyframes sway { from { transform: rotate(-.9deg); } to { transform: rotate(1.1deg); } }
.lit, .lit2 { animation: litpulse 7s ease-in-out infinite alternate; }
.lit2 { animation-duration: 4.5s; }
@keyframes litpulse { from { opacity: .88; } to { opacity: 1; } }
@keyframes discpulse { 0%, 100% { opacity: 1; } 50% { opacity: .88; } }
.wisp { animation: wisp 26s ease-in-out infinite alternate; }
.wisp.w2 { animation-duration: 34s; animation-direction: alternate-reverse; }
@keyframes wisp { from { transform: translateX(-90px); } to { transform: translateX(90px); } }
.mote { opacity: 0; animation: mote 7s ease-in-out infinite; }
.mote.m2 { animation-delay: -1.5s; } .mote.m3 { animation-delay: -3s; animation-duration: 9s; } .mote.m4 { animation-delay: -4.5s; } .mote.m5 { animation-delay: -6s; animation-duration: 10s; }
@keyframes mote { 0% { opacity: 0; transform: translate(0,0); } 30%, 70% { opacity: .8; } 100% { opacity: 0; transform: translate(60px,-46px); } }
.lamp { animation: discpulse 3.4s ease-in-out infinite; }

/* Three skyline layers. Nearer layers zoom more as you scroll. */
.layer { position: absolute; left: 0; right: 0; bottom: 0; transform-origin: 50% 100%; }
.layer-far {
  height: 52%; background: url(../assets/sky-far.svg) repeat-x 50% 100% / auto 100%;
  transform: scale(calc(1 + var(--p, 0) * .12));
}
.layer-mid {
  height: 42%; background: url(../assets/sky-mid.svg) repeat-x 50% 100% / auto 100%;
  transform: scale(calc(1 + var(--p, 0) * .3));
}
.layer-near {
  height: 30%; background: url(../assets/sky-near.svg) repeat-x 50% 100% / auto 100%;
  transform: scale(calc(1 + var(--p, 0) * .6));
}

/* Rooftop foreground: the detective (smoking), a cat, a roadside sign.
   Everything here sinks and fades as you scroll. */
.roof { position: absolute; inset: 0; pointer-events: none; transform: translateY(calc(var(--p, 0) * 30%)); }
.roof-bar { position: absolute; left: 0; right: 0; bottom: 0; height: 11%; background: #000; border-top: 3px solid #1a2140; }
.roof-bar::before { content: ""; position: absolute; left: 0; right: 0; top: -14px; height: 11px; background: #05070f;
  clip-path: polygon(0 100%,0 0,6% 0,6% 40%,14% 40%,14% 0,22% 0,22% 40%,30% 40%,30% 0,38% 0,38% 40%,46% 40%,46% 0,54% 0,54% 40%,62% 40%,62% 0,70% 0,70% 40%,78% 40%,78% 0,86% 0,86% 40%,94% 40%,94% 0,100% 0,100% 100%); }
.chimney { position: absolute; left: 48%; bottom: 11%; width: 34px; height: 64px; background: #000; border-top: 5px solid #0e1430; }
.vent { position: absolute; left: 53%; bottom: 11%; width: 9px; height: 40px; background: #000; }
.vent::before { content: ""; position: absolute; left: -7px; top: -8px; width: 23px; height: 10px; background: #000; clip-path: polygon(0 100%,50% 0,100% 100%); }

.detective { position: absolute; left: clamp(6%, 16vw, 18%); bottom: calc(11% - 6px); width: clamp(96px, 11vw, 150px); height: auto; overflow: visible; }
.breathe { transform-box: fill-box; transform-origin: 50% 100%; animation: breathe 4.2s ease-in-out infinite; }
@keyframes breathe { 0%, 100% { transform: scaleY(1); } 50% { transform: scaleY(1.012); } }
.coat-tail { transform-box: fill-box; transform-origin: 100% 0; animation: flap 2.6s ease-in-out infinite alternate; }
@keyframes flap { from { transform: rotate(-2deg) skewY(-3deg); } to { transform: rotate(5deg) skewY(4deg); } }
.arm { transform-box: view-box; transform-origin: 93px 80px; animation: drag 8s ease-in-out infinite; }
@keyframes drag { 0%, 55%, 100% { transform: rotate(14deg); } 62%, 78% { transform: rotate(0deg); } }
.ember { animation: ember 8s ease-in-out infinite; }
.glow { animation: ember 8s ease-in-out infinite; transform-box: fill-box; transform-origin: center; }
@keyframes ember { 0%, 55%, 100% { opacity: .45; } 66%, 76% { opacity: 1; scale: 1.5; } }
.puff { transform-box: fill-box; transform-origin: center; opacity: 0; animation: smoke 7s ease-out infinite; }
.p2 { animation-delay: -1.4s; } .p3 { animation-delay: -2.8s; } .p4 { animation-delay: -4.2s; } .p5 { animation-delay: -5.6s; }
@keyframes smoke { 0% { transform: translate(0,0) scale(.5); opacity: .5; } 40% { transform: translate(10px,-40px) scale(1.4); opacity: .32; } 100% { transform: translate(-6px,-120px) scale(3.4); opacity: 0; } }

.cat { position: absolute; left: 58.5%; bottom: calc(11% + 4px); width: 38px; height: auto; overflow: visible; }
.cat-tail { transform-box: fill-box; transform-origin: 0 100%; animation: tail 3.4s ease-in-out infinite alternate; }
@keyframes tail { from { transform: rotate(-10deg); } to { transform: rotate(16deg); } }
.cat-eyes { transform-box: fill-box; transform-origin: center; animation: blink 6s infinite; filter: drop-shadow(0 0 3px #f2c94c); }
@keyframes blink { 0%, 94%, 100% { transform: scaleY(1); } 96% { transform: scaleY(.1); } }

/* tall roadside fast-food sign: dim, grainy, bulbs chasing, arrow pointing at the diner */
.pylon { position: absolute; left: 30%; bottom: calc(11% - 2px); height: 33vh; min-height: 230px; width: auto; aspect-ratio: 260 / 360; overflow: visible; animation: signdip 13s linear infinite; }
.bulbs circle { animation: bulb 2.4s ease-in-out infinite; }
.bulbs circle:nth-child(2n) { animation-delay: -.6s; } .bulbs circle:nth-child(3n) { animation-delay: -1.2s; } .bulbs circle:nth-child(5n) { animation-delay: -1.8s; }
.chev path { animation: chev 1.2s steps(1) infinite; opacity: .25; }
.chev path:nth-child(2) { animation-delay: .4s; } .chev path:nth-child(3) { animation-delay: .8s; }
@keyframes chev { 0% { opacity: 1; } 33% { opacity: .25; } }
@keyframes signdip { 0%, 100% { opacity: 1; } 62% { opacity: 1; } 63% { opacity: .55; } 65% { opacity: 1; } }


.rain { position: absolute; inset: 0; pointer-events: none; opacity: .18; overflow: hidden; }
/* the streaks live on a taller sheet that SLIDES (a transform costs nothing); animating background-position repainted the whole sky every frame */
.rain::before { content: ""; position: absolute; left: 0; right: 0; top: -160px; bottom: 0;
  background-image: linear-gradient(100deg, transparent 48%, #9fb4e0 49%, #9fb4e0 50%, transparent 51%);
  background-size: 50px 160px;
  animation: rain 1s linear infinite; will-change: transform; }
@keyframes rain { to { transform: translateY(160px); } }
.vignette { position: absolute; inset: 0; pointer-events: none; background: radial-gradient(ellipse at 50% 55%, transparent 55%, rgba(0,0,0,.85) 100%); }
/* Darkens the whole scene as you scroll down into the office. */
.hero-dim { position: absolute; inset: 0; pointer-events: none; background: #05030a; opacity: calc(.18 + var(--p, 0) * var(--p, 0) * .9); }

/* ---------- Comic captions and the title ---------- */

.hero-title {
  position: absolute; left: 0; right: 0; top: 34%; z-index: var(--z-hero-fx);
  text-align: center; padding: 0 16px; pointer-events: none;
  opacity: 0; transform: translateY(34px); transition: opacity 1.6s 3.4s, transform 1.6s 3.4s;
}
.go .hero-title { opacity: 1; transform: none; }
.hero-title-inner { opacity: calc(1 - var(--p, 0) * 2.4); transform: translateY(calc(var(--p, 0) * -80px)); }
.hero-title h1 {
  margin: 0; font: 400 clamp(44px, 9vw, 120px) / 1 var(--font-display); letter-spacing: .04em; color: var(--cream);
  text-shadow: 0 4px 0 #000, 0 0 30px rgba(224,162,58,.45);
}
.subtitle { margin: 16px 0 0; font-size: clamp(16px, 2.2vw, 22px); color: var(--ochre); text-shadow: 0 2px 0 #000; }
.type {
  display: inline-block; overflow: hidden; white-space: nowrap; width: 0; max-width: 100%;
  border-right: 2px solid var(--ochre); vertical-align: bottom;
}
.go .type { animation: typing 2.6s steps(35) 4.4s both; }
@keyframes typing { from { width: 0; } to { width: 32.6ch; } }

.scroll-cue {
  position: absolute; left: 0; right: 0; bottom: 3%; z-index: var(--z-hero-fx);
  text-align: center; text-decoration: none; color: var(--cream); font-size: 15px;
  opacity: 0; transition: opacity 1s 6s;
}
.go .scroll-cue { opacity: 1; }
.scroll-cue span { display: inline-block; opacity: calc(1 - var(--p, 0) * 4); text-shadow: 0 2px 0 #000; }
.scroll-cue span::after {
  content: ""; display: block; width: 14px; height: 14px; margin: 8px auto 0;
  border-right: 3px solid var(--ochre); border-bottom: 3px solid var(--ochre); rotate: 45deg;
  animation: bob 1.6s ease-in-out infinite;
}
@keyframes bob { 0%, 100% { translate: 0 0; } 50% { translate: 0 8px; } }

@media (max-width: 640px) {
  .detective { left: 4%; }
}

/* ---------- Extra flair ---------- */
/* bats crossing the moon */
.bat { position: absolute; left: 0; width: 34px; height: 14px; background: #000; opacity: 0; z-index: 2;
  clip-path: polygon(0 20%,18% 0,32% 40%,42% 20%,50% 70%,58% 20%,68% 40%,82% 0,100% 20%,84% 55%,66% 50%,50% 100%,34% 50%,16% 55%);
  animation: batfly 16s linear infinite, flapbat .3s ease-in-out infinite alternate; }
.bat.b2 { top: 24%; animation-duration: 22s, .26s; animation-delay: -9s, 0s; width: 24px; height: 10px; }
.bat.b1 { top: 12%; }
/* moves with translate (not left): animating left re-does the page layout every frame */
@keyframes batfly { 0% { translate: -6vw 0; opacity: 0; } 6% { opacity: 1; } 94% { opacity: 1; } 100% { translate: 106vw 0; opacity: 0; } }
@keyframes flapbat { from { scale: 1 1; } to { scale: 1 .45; } }
.bat.b2 { margin-top: 30px; }
/* low fog drifting along the rooftops */
.lowfog { position: absolute; left: -20%; right: -20%; bottom: 8%; height: 30%; pointer-events: none; filter: blur(18px);
  background: radial-gradient(ellipse at 30% 60%, rgba(150,165,205,.38), transparent 60%), radial-gradient(ellipse at 75% 50%, rgba(150,165,205,.3), transparent 60%);
  animation: lowfog 24s ease-in-out infinite alternate; }
@keyframes lowfog { from { transform: translateX(-6%); } to { transform: translateX(6%); } }
/* lightning glow: one slow flash at a time, triggered by js/weather.js (never rapid flashing) */
.lightning { position: absolute; inset: 0; pointer-events: none; opacity: 0; --lx: 70%; mix-blend-mode: screen;
  background: radial-gradient(ellipse 70% 55% at var(--lx) 8%, rgba(214,228,255,.95), rgba(120,140,205,.42) 52%, transparent 82%); }
.bolt-svg { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; overflow: visible; }
.bolt-svg path { fill: none; stroke-linejoin: round; stroke-linecap: round; }
.b-core { stroke: #f4f8ff; stroke-width: calc(var(--bw, 2) * 1px); }
.b-br { stroke: #e3ecff; stroke-width: 1.4; opacity: .8; }
.b-glow { stroke: rgba(150,180,255,.85); stroke-width: 18; filter: blur(7px); }
/* the roofs catch the flash for a moment */
.hero-stage .layer, .hero-stage .roof { transition: filter .25s ease-out; }
.hero-stage.struck .layer, .hero-stage.struck .roof { filter: brightness(1.45) saturate(.85); transition-duration: .05s; }
/* distant police siren: slow red/blue glow on the horizon */
.siren { position: absolute; right: -4%; bottom: 13%; width: 40%; height: 20%; pointer-events: none; filter: blur(24px); }
.siren::before, .siren::after { content: ""; position: absolute; inset: 0; border-radius: 50%; animation: siren 4s ease-in-out infinite; }
.siren::before { background: radial-gradient(ellipse, rgba(220,40,50,.55), transparent 65%); }
.siren::after { background: radial-gradient(ellipse, rgba(50,90,230,.55), transparent 65%); animation-delay: -2s; }
@keyframes siren { 0%, 100% { opacity: 0; } 50% { opacity: .9; } }
/* film grain */

.grain { position: absolute; inset: -20%; pointer-events: none; opacity: .3; mix-blend-mode: overlay;
  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='.75' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  animation: grain .5s steps(4) infinite; }
@keyframes grain { 0% { transform: translate(0,0); } 25% { transform: translate(-4%,3%); } 50% { transform: translate(3%,-4%); } 75% { transform: translate(-3%,-2%); } 100% { transform: translate(4%,4%); } }
/* mouse parallax: scroll.js sets --mx (-1..1) */
.layer-far { translate: calc(var(--mx, 0) * -6px) 0; }
.layer-mid { translate: calc(var(--mx, 0) * -14px) 0; }
.layer-near { translate: calc(var(--mx, 0) * -26px) 0; }
.moon { translate: calc(var(--mx, 0) * -3px) 0; }

/* comic-print halftone dots over the lower sky */
.halftone { position: absolute; inset: 0; pointer-events: none; opacity: .28;
  background: radial-gradient(circle, #000 1.2px, transparent 1.6px) 0 0 / 7px 7px;
  -webkit-mask-image: linear-gradient(180deg, transparent 35%, #000 100%); mask-image: linear-gradient(180deg, transparent 35%, #000 100%); }

/* the diner: low, dim, grainy. Pink and blue neon trim, no sign. */
.diner { position: absolute; right: 0.5%; bottom: calc(11% - 3px); width: clamp(280px, 33vw, 470px); height: auto; overflow: visible; }
.tube { animation: tube 7s linear infinite; }
@keyframes tube { 0%, 100% { opacity: .5; } 30% { opacity: .5; } 31% { opacity: .22; } 33% { opacity: .55; } 60% { opacity: .46; } }
.bulb { animation: bulb 5s ease-in-out infinite; }
@keyframes bulb { 0%, 100% { opacity: .85; } 50% { opacity: .6; } }
.sip { transform-box: fill-box; transform-origin: 50% 100%; animation: sip 9s ease-in-out infinite; }
@keyframes sip { 0%, 60%, 100% { transform: translateY(0) rotate(0); } 66%, 74% { transform: translateY(-3px) rotate(-5deg); } }
.steam { animation: steam 3s ease-in-out infinite; }
@keyframes steam { 0%, 100% { opacity: .15; transform: translateY(2px); } 50% { opacity: .55; transform: translateY(-3px); } }
.pinkflick { animation: pinkflick 11s linear infinite; }
@keyframes pinkflick { 0%, 100% { opacity: 1; } 71% { opacity: 1; } 72% { opacity: .4; } 74% { opacity: 1; } }
@media (max-width: 900px) { .pylon { display: none; } .cat { left: 40%; } .chimney { left: 34%; } .vent { left: 40%; } .diner { width: 270px; } }
@media (max-width: 640px) { .cat { display: none; } }

/* ---------- entrance -> corkboard transition: fog rolls in and the scene sinks into darkness ---------- */
.hero-fog { position: absolute; inset: 0; pointer-events: none; opacity: calc(var(--p, 0) * var(--p, 0) * 1.5);
  background: radial-gradient(ellipse 70% 50% at 25% 85%, rgba(170,185,225,.75), transparent 70%), radial-gradient(ellipse 80% 55% at 78% 90%, rgba(150,165,210,.7), transparent 70%), radial-gradient(ellipse 100% 40% at 50% 100%, rgba(190,200,235,.8), transparent 75%);
  animation: lowfog 18s ease-in-out infinite alternate; }

/* an elevated train rumbling past behind the near rooftops */
.train { position: absolute; left: 0; bottom: 31%; width: 420px; height: 17px; pointer-events: none; opacity: .9;
  background: repeating-linear-gradient(90deg, #ffd79a 0 9px, #0a0d20 9px 15px) 0 6px / 100% 7px no-repeat, linear-gradient(#0a0d20, #0a0d20) 0 0 / 100% 17px no-repeat;
  border-radius: 6px 6px 2px 2px; box-shadow: 0 0 18px rgba(255,200,120,.25); animation: train 34s linear infinite; transform: translateX(-460px); }
@keyframes train { 0% { transform: translateX(-460px); } 24% { transform: translateX(calc(100vw + 40px)); } 100% { transform: translateX(calc(100vw + 40px)); } }

/* steam rising from the rooftop chimney */
.chimney::before, .chimney::after { content: ""; position: absolute; left: 6px; top: -14px; width: 22px; height: 22px; border-radius: 50%; background: #c9d2ea; filter: blur(7px); opacity: 0; animation: steamup 6s ease-out infinite; }
.chimney::after { animation-delay: -3s; }
@keyframes steamup { 0% { transform: translate(0,0) scale(.5); opacity: .4; } 100% { transform: translate(14px,-90px) scale(2.6); opacity: 0; } }

/* retro sign: neon swoosh flicker */
.swoosh { animation: swooshflick 8s linear infinite; }
@keyframes swooshflick { 0%, 100% { opacity: 1; } 55% { opacity: 1; } 56% { opacity: .35; } 58% { opacity: 1; } 59% { opacity: .6; } 61% { opacity: 1; } }
