/* ------------------------------------------------------------------------- *
 * ZD — stage
 * The scroll track, the sticky stage, the SVG layer, the HUD and the loop.
 * ------------------------------------------------------------------------- */

.page-home {
  background: var(--zd-black);
  --track-height: 980vh;
}

/* ------------------------------------------------------------------ topbar */

.topbar {
  position: fixed;
  inset: 0 0 auto 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 20px var(--gutter);
  pointer-events: none;
}

.topbar > * {
  pointer-events: auto;
}

.topnav {
  display: flex;
  align-items: center;
  gap: clamp(18px, 3vw, 42px);
}

/* ----------------------------------------------------------------- journey */

.journey {
  position: relative;
  height: var(--track-height);
}

.stage {
  position: sticky;
  top: 0;
  height: 100svh;
  display: grid;
  place-items: center;
  overflow: hidden;
  isolation: isolate;
}

/* --------------------------------------------------------------- atmosphere */

/* The room around the illustration. Colours, light positions and densities are
   written as custom properties every frame from the interpolated mood; the
   elements themselves never change. */
.stage__atmosphere {
  position: absolute;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
}

/* One canvas paints the base, both lights and the vignette at one third of
   the CSS size; it is scaled up and only redrawn ~18 times per second. */
.stage__halo {
  position: absolute;
  left: -3%;
  top: -3%;
  display: block;
  width: 106%;
  height: 106%;
  transform: translate3d(var(--atmo-px, 0px), var(--atmo-py, 0px), 0);
}

.stage__grain {
  position: absolute;
  inset: 0;
  background-image: var(--atmo-grain-image, none);
  background-size: 160px 160px;
  opacity: var(--atmo-grain, 0.4);
}

.stage__dust {
  position: absolute;
  inset: 0;
  opacity: var(--atmo-dust, 0);
}

.stage__dust span {
  position: absolute;
  left: var(--x, 50%);
  top: var(--y, 50%);
  width: var(--s, 1.5px);
  height: var(--s, 1.5px);
  border-radius: 50%;
  background: var(--atmo-dust-color, #dde7f0);
  opacity: var(--o, 0.3);
  transform: translate3d(
    calc(var(--atmo-px, 0px) * var(--k, 1)),
    calc(var(--atmo-py, 0px) * var(--k, 1)),
    0
  );
}

/* The camera and the scene layers rotate around the viewBox centre; CSS
   transforms on SVG content use the local user units. */
#zd-camera,
.zd-layer {
  transform-box: view-box;
  transform-origin: 500px 500px;
}

.stage__frame {
  position: relative;
  width: min(78svh, 92vw, 760px);
  max-width: 100%;
  aspect-ratio: 1;
  transition: opacity 0.62s var(--ease-out), transform 0.85s var(--ease-out);
}

/* Closing loop: the last logo fades and recedes, the scroll resets invisibly
   behind the black, and the first logo returns. */
.stage.is-looping {
  pointer-events: none;
}

.stage.is-looping .stage__frame {
  opacity: 0;
  transform: scale(0.955);
}

/* The hotspots set pointer-events: auto explicitly; keep them inert while the
   frame is fading out so a click cannot navigate mid-loop. */
.stage.is-looping .zd-hotspot {
  pointer-events: none;
}

.stage__canvas {
  position: absolute;
  inset: 0;
  opacity: 0;
  transform: scale(1.035);
  transition: opacity 1.1s var(--ease-out), transform 1.8s var(--ease-out);
}

html.is-ready .stage__canvas {
  opacity: 1;
  transform: none;
}

.zd-svg {
  width: 100%;
  height: 100%;
  overflow: visible;
}

/* Every decorative layer ignores the pointer; only the two hotspots react. */
.zd-layer {
  pointer-events: none;
}

/* Utility stroke weights used by the scene illustrations. They are expressed
   in SVG user units, so they get a slight bump on small screens where the
   stage is scaled down. */
.fx-line {
  fill: none;
}

.fx-hair {
  stroke-width: 1.4;
}

@media (max-width: 720px) {
  .fx-hair {
    stroke-width: 2.4;
  }
}

#zd-camera {
  transform-box: view-box;
  transform-origin: 500px 500px;
  will-change: transform;
}

.zd-hotspot {
  pointer-events: auto;
  outline: none;
}

.zd-hotspot__scale {
  transform-box: fill-box;
  transform-origin: center;
  transition: transform 0.55s var(--ease-out);
}

.zd-hotspot.is-hotspot-active:hover .zd-hotspot__scale,
.zd-hotspot.is-hotspot-active:focus-visible .zd-hotspot__scale {
  transform: scale(1.045);
}

.zd-hotspot__hit {
  cursor: pointer;
}

.zd-hotspot__halo {
  opacity: 0;
  transition: opacity 0.3s var(--ease-out);
}

.zd-hotspot:focus-visible .zd-hotspot__halo {
  opacity: 0.9;
}

.zd-hotspot:focus {
  outline: none;
}

/* ------------------------------------------------------------ annotations */

.stage__labels {
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.9s var(--ease-out) 0.35s;
}

html.is-ready .stage__labels {
  opacity: 1;
}

/* Inner wrapper: the scroll fade is written inline here, while the outer
   element keeps the intro transition. */
.stage__labels-scroll {
  position: absolute;
  inset: 0;
}

.hotspot-label {
  position: absolute;
  display: flex;
  align-items: baseline;
  gap: 10px;
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 500;
  line-height: 1.2;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  white-space: nowrap;
  color: rgba(244, 245, 247, 0.66);
}

.hotspot-label--hosting {
  left: 34.5%;
  top: 24.4%;
}

.hotspot-label--labs {
  left: 55.5%;
  top: 73.2%;
}

.hotspot-label__num {
  font-size: 11px;
  color: var(--zd-cyan);
}

.hotspot-label__num::after {
  content: "";
  display: inline-block;
  width: 14px;
  height: 1px;
  margin-left: 8px;
  vertical-align: middle;
  background: rgba(125, 227, 255, 0.4);
}

/* --------------------------------------------------------------------- HUD */

.stage__hud {
  position: absolute;
  left: var(--gutter);
  bottom: calc(26px + env(safe-area-inset-bottom, 0px));
  display: flex;
  align-items: baseline;
  gap: 14px;
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--zd-muted);
  opacity: 0;
  transition: opacity 1s var(--ease-out) 0.5s;
}

html.is-ready .stage__hud {
  opacity: 1;
}

.hud__count {
  color: var(--zd-faint);
  font-variant-numeric: tabular-nums;
}

.hud__current {
  color: var(--zd-paper);
}

.hud__slash {
  margin: 0 2px;
  color: var(--zd-faint);
}

.hud__rule {
  width: 22px;
  height: 1px;
  background: var(--zd-line-strong);
}

.hud__title {
  color: var(--zd-muted);
}

.stage__progress {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 1px;
  background: rgba(244, 245, 247, 0.09);
  transition: opacity 0.3s var(--ease-out);
}

.stage.is-looping .stage__progress {
  opacity: 0;
}

.stage__progress span {
  display: block;
  height: 100%;
  background: var(--zd-orange);
  transform: scaleX(0);
  transform-origin: left center;
}

/* --------------------------------------------------------------- scroll cue */

.scroll-cue {
  position: absolute;
  left: 50%;
  bottom: calc(52px + env(safe-area-inset-bottom, 0px));
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  color: var(--zd-muted);
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  transition: opacity 0.6s var(--ease-out), transform 0.6s var(--ease-out);
  pointer-events: none;
}

.scroll-cue.is-hidden {
  opacity: 0;
  transform: translate(-50%, 6px);
}

.scroll-cue__rail {
  position: relative;
  width: 1px;
  height: 38px;
  background: linear-gradient(to bottom, rgba(244, 245, 247, 0.02), rgba(244, 245, 247, 0.4));
  overflow: hidden;
}

.scroll-cue__dot {
  position: absolute;
  top: -6px;
  left: -1px;
  width: 3px;
  height: 6px;
  background: var(--zd-orange);
  animation: zd-scroll-dot 2.6s var(--ease-soft) infinite;
}

@keyframes zd-scroll-dot {
  0% { transform: translateY(0); opacity: 0; }
  25% { opacity: 1; }
  100% { transform: translateY(50px); opacity: 0; }
}

/* --------------------------------------------------------------- loop exit */

.stage.is-looping .scroll-cue {
  opacity: 0;
}

/* -------------------------------------------------------------- no-JS panel */

.noscript {
  margin: 0 var(--gutter) 0;
  padding: 40px 0 80px;
  border-top: 1px solid var(--zd-line);
}

.noscript p {
  max-width: 46ch;
  color: var(--zd-muted);
}

.noscript__links {
  display: flex;
  gap: 28px;
  margin-top: 18px;
}

.noscript__links a {
  border-bottom: 1px solid var(--zd-line-strong);
  padding-bottom: 4px;
}

/* --------------------------------------------------------------- responsive */

@media (max-width: 1024px) {
  .page-home {
    --track-height: 880vh;
  }
}

@media (max-width: 900px) {
  .stage__labels {
    display: none;
  }
}

@media (max-width: 720px) {
  .page-home {
    --track-height: 760vh;
  }

  .stage__frame {
    width: min(74svh, 94vw);
  }

  .topbar {
    padding: 16px var(--gutter);
  }

  .brand__name span {
    display: none;
  }

  .nav-hide {
    display: none;
  }

  .nav-link {
    font-size: 10px;
    letter-spacing: 0.1em;
  }

  .stage__hud {
    bottom: calc(22px + env(safe-area-inset-bottom, 0px));
    gap: 10px;
    font-size: 9px;
  }

  .hud__title {
    display: none;
  }

  .scroll-cue {
    bottom: calc(26px + env(safe-area-inset-bottom, 0px));
    font-size: 8px;
    gap: 9px;
  }

  .scroll-cue__rail {
    height: 32px;
  }

  .scroll-cue__label {
    text-align: center;
    line-height: 1.6;
  }
}

@media (max-width: 480px) {
  .topnav {
    gap: 16px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .stage__canvas {
    opacity: 1;
    transform: none;
  }

  .scroll-cue__dot {
    display: none;
  }
}
