:root {
  --void: #050508;
  --void-2: #0a0d14;
  --gold: #FFD166;
  --cyan: #00E5FF;
  --cyan-soft: #A8F0FF;
  --orange: #FF8C42;
  --green: #39FF87;
  --steel: #5BA4CF;
  --idle-y: 88%;
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  background: var(--void);
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  overflow: hidden;
  color: #E8ECF4;
}

.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  white-space: nowrap;
  border: 0;
}

/* ---------- Stage ---------- */
#stage {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100dvh;
  background:
    radial-gradient(ellipse at 50% 30%, #10141f 0%, var(--void) 60%),
    var(--void);
  overflow: hidden;
  z-index: 1;
}

#stage.hidden { display: none; }

/* Interactive neural-network background — sits behind everything else */
#neural-bg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  pointer-events: none;
}

/* Faint void grid, evokes "empty canvas waiting to be built" */
#void-grid {
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(168,240,255,0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(168,240,255,0.04) 1px, transparent 1px);
  background-size: 48px 48px;
  opacity: 0;
  transition: opacity 1.5s ease;
  pointer-events: none;
}
#stage.built #void-grid { opacity: 1; }

/* ---------- Title (built letter-by-letter, distinct display font) ---------- */
#title-construct {
  position: absolute;
  left: 50%;
  top: var(--title-y, 6%);
  transform: translate(-50%, -50%);
  text-align: center;
  z-index: 5;
  pointer-events: none;
  width: 98vw;
}

#title-main {
  position: relative;
  display: block;
  white-space: nowrap;
  font-family: "Orbitron", "Segoe UI", system-ui, sans-serif;
  font-size: clamp(1.1rem, 4.3vw, 2.7rem);
  font-weight: 700;
  letter-spacing: 0.02em;
  color: #F5F7FF;
  text-shadow: 0 0 14px rgba(168,240,255,0.75), 0 0 40px rgba(0,229,255,0.45), 0 0 80px rgba(0,229,255,0.2);
  transition: font-size 0.5s cubic-bezier(.22,1,.36,1), color 0.4s ease;
}
/* Stage A: revealed letters pulse together, in sync, in one shared color */
#title-main.final {
  font-size: clamp(1.4rem, 5.4vw, 3.4rem);
  color: #FFFFFF;
  text-shadow: 0 0 18px rgba(255,255,255,0.85), 0 0 48px rgba(255, 209, 102, 0.5), 0 0 90px rgba(255, 209, 102, 0.25);
}
#title-main .ch {
  display: inline-block;
  white-space: pre;
  opacity: 0;
  transform: translateY(12px) scale(0.8);
  filter: blur(3px);
}
#title-main .ch.built {
  animation: char-lock-in 0.4s ease forwards, char-pulse-color 1.1s ease-in-out infinite 0.4s;
}
#title-main.final .ch.built {
  animation: none;
  opacity: 1;
  transform: none;
  filter: none;
  color: inherit;
}
@keyframes char-lock-in {
  0% { opacity: 0; transform: translateY(12px) scale(0.8); filter: blur(3px); }
  60% { opacity: 1; transform: translateY(-3px) scale(1.06); filter: blur(0); }
  100% { opacity: 1; transform: translateY(0) scale(1); filter: blur(0); }
}
@keyframes char-pulse-color {
  0%, 100% { color: #A8F0FF; text-shadow: 0 0 10px rgba(168,240,255,0.55); }
  50% { color: #00E5FF; text-shadow: 0 0 24px rgba(0,229,255,0.95); }
}
/* Scan bar: sweeps left-to-right across the name as it's illuminated,
   then fades (the surge + .final state read as it "fixing" in center). */
#title-scan {
  position: absolute;
  top: 0;
  left: 0;
  width: 4px;
  height: 100%;
  background: linear-gradient(to bottom, transparent, #EAFEFF 45%, #EAFEFF 55%, transparent);
  box-shadow: 0 0 18px 5px rgba(168, 240, 255, 0.85);
  opacity: 0;
  pointer-events: none;
  z-index: 6;
}
#title-scan.active { opacity: 1; }

/* Surge: brief flash across the whole name the instant the last letter locks in */
#title-main.surge::after {
  content: "";
  position: absolute;
  inset: -20% -6%;
  background: radial-gradient(ellipse at center, rgba(255,255,255,0.9), rgba(255,255,255,0) 70%);
  animation: title-surge 0.55s ease-out forwards;
  pointer-events: none;
}
@keyframes title-surge {
  0% { opacity: 0; transform: scale(0.7); }
  35% { opacity: 1; }
  100% { opacity: 0; transform: scale(1.3); }
}

/* ---------- Status readout: hauled in and parked at the bottom during
   construction; docks beneath the company name once it becomes the
   standing tagline. ---------- */
#status-readout {
  position: absolute;
  left: 50%;
  top: var(--status-y, 91%);
  transform: translate(-50%, -50%);
  text-align: center;
  z-index: 5;
  pointer-events: none;
  opacity: 0;
  width: min(90vw, 640px);
  transition: opacity 0.7s ease, top 0.9s cubic-bezier(.45,0,.55,1);
}
#status-readout.revealed { opacity: 1; }
#status-readout.docked { top: var(--tagline-y, 15%); }

/* Transient construction-progress caption, shares the status-readout's spot
   during assembly and hands off to it once the hologram powers on. */
#build-log {
  position: absolute;
  left: 50%;
  top: var(--buildlog-y, 34%);
  transform: translate(-50%, -50%);
  text-align: center;
  z-index: 5;
  pointer-events: none;
  opacity: 0;
  width: min(90vw, 500px);
  transition: opacity 0.35s ease;
}
#build-log.visible { opacity: 1; }
#build-log-text {
  display: block;
  font-family: "Rajdhani", "Segoe UI", system-ui, sans-serif;
  font-size: clamp(0.85rem, 1.9vw, 1.05rem);
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--steel);
  opacity: 0.85;
}

#title-suffix {
  display: block;
  font-family: "Rajdhani", "Segoe UI", system-ui, sans-serif;
  font-size: clamp(1.1rem, 2.8vw, 1.65rem);
  font-weight: 600;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--cyan-soft);
  text-shadow: 0 0 10px rgba(168, 240, 255, 0.65);
  animation: holo-pulse 0.9s ease-in-out infinite;
}
#title-suffix.swapping { animation: none; opacity: 0; transition: opacity 0.25s ease; }
/* Boot-sequence typing: steady text + blinking caret while it types itself in */
#title-suffix.typing {
  animation: none;
  opacity: 1;
}
#title-suffix.typing::after {
  content: "▌";
  margin-left: 0.1em;
  animation: caret-blink 0.7s steps(1, end) infinite;
}
@keyframes caret-blink {
  0%, 49% { opacity: 1; }
  50%, 100% { opacity: 0; }
}
@keyframes holo-pulse {
  0%, 100% { opacity: 0.55; transform: scale(1); }
  50% { opacity: 1; transform: scale(1.04); }
}

/* Standing tagline (post-construction, permanent): its own distinct type
   treatment — larger, warm gold-white, mixed case, calmer — so it reads as
   the finished brand line rather than the busy technical readout. */
#title-suffix.standing {
  font-family: "Rajdhani", "Segoe UI", system-ui, sans-serif;
  font-weight: 500;
  font-size: clamp(1.3rem, 3.4vw, 2.05rem);
  letter-spacing: 0.035em;
  text-transform: none;
  color: #FCE9C6;
  text-shadow: 0 0 12px rgba(255, 209, 102, 0.55), 0 0 28px rgba(255, 209, 102, 0.25);
  animation: standing-glow 4.5s ease-in-out infinite;
}
@keyframes standing-glow {
  0%, 100% { opacity: 0.88; }
  50% { opacity: 1; }
}

/* ---------- Pedestal / hologram projector (bots build it piece by piece) ---------- */
#pedestal {
  position: absolute;
  left: 50%;
  top: var(--ped-y, 58%);
  /* Hero-scale: fills essentially the whole stage. Capped against both
     viewport axes so the machine can't overflow on wide or short screens.
     The vh term is a WIDTH cap but the pedestal's own aspect ratio
     (320x260, ~1.23:1) means Nvh here actually renders ~0.81*N vh tall —
     86vh keeps rendered height around ~70vh, comfortably inside the
     stage on ordinary (non-fullscreen) desktop windows. */
  width: var(--ped-w, min(2200px, 98vw, 86vh));
  transform: translate(-50%, -50%);
  z-index: 2;
}
#pedestal svg { display: block; width: 100%; height: auto; overflow: visible; }
#pedestal::before {
  content: "";
  position: absolute;
  inset: -4%;
  background: radial-gradient(ellipse at 50% 12%, rgba(255,255,255,0.14), transparent 55%);
  mix-blend-mode: overlay;
  pointer-events: none;
  z-index: 1;
}

/* Each structural piece starts hidden; JS adds .built to one at a time as the
   bots reach it, so the pedestal visibly assembles instead of appearing at once. */
#pedestal #ped-shadow,
#pedestal #ped-base,
#pedestal #ped-conduits,
#pedestal #ped-panel-l,
#pedestal #ped-panel-r,
#pedestal #ped-column,
#pedestal #ped-emitter,
#pedestal #ped-lens {
  opacity: 0;
  transform-box: fill-box;
  transform-origin: center;
  transform: scale(0.4);
  transition: opacity 0.5s ease, transform 0.5s cubic-bezier(.34,1.56,.64,1);
}
#pedestal #ped-shadow.built,
#pedestal #ped-base.built,
#pedestal #ped-conduits.built,
#pedestal #ped-panel-l.built,
#pedestal #ped-panel-r.built,
#pedestal #ped-column.built,
#pedestal #ped-emitter.built,
#pedestal #ped-lens.built {
  opacity: 1;
  transform: scale(1);
}
/* Reduced-motion / instant-state fallback: show every piece at once */
#pedestal.built-all #ped-shadow,
#pedestal.built-all #ped-base,
#pedestal.built-all #ped-conduits,
#pedestal.built-all #ped-panel-l,
#pedestal.built-all #ped-panel-r,
#pedestal.built-all #ped-column,
#pedestal.built-all #ped-emitter,
#pedestal.built-all #ped-lens {
  opacity: 1;
  transform: scale(1);
  transition: none;
}
#pedestal.working #ped-led-1,
#pedestal.working #ped-led-2,
#pedestal.working #ped-led-3 {
  animation: tool-flicker 0.8s ease-in-out infinite;
}

/* Emitter rings swirl continuously once the emitter piece is built (feedback #3) */
#pedestal #ped-ring-outer,
#pedestal #ped-ring-inner {
  transform-box: fill-box;
  transform-origin: center;
}
#pedestal #ped-emitter.built #ped-ring-outer {
  animation: ring-spin 9s linear infinite;
}
#pedestal #ped-emitter.built #ped-ring-inner {
  animation: ring-spin-rev 6s linear infinite;
}
@keyframes ring-spin { to { transform: rotate(360deg); } }
@keyframes ring-spin-rev { to { transform: rotate(-360deg); } }

/* Diagnostic screen scan, driven by the nettech bot's construction beat */
#pedestal #ped-screen {
  transform-box: fill-box;
  transform-origin: center;
}
#pedestal.diagnosing #ped-screen {
  animation: tool-flicker 0.3s ease-in-out infinite;
}

/* Side digital panels: gentle always-on scan-line flicker once built */
#pedestal #ped-panel-l.built #ped-panel-l-scan,
#pedestal #ped-panel-r.built #ped-panel-r-scan {
  animation: laser-sweep 2.1s ease-in-out infinite;
}
#pedestal #ped-column.built #ped-led-screen {
  animation: laser-sweep 1.7s ease-in-out infinite;
}

#hologram-beam,
#beam-ray-l,
#beam-ray-r {
  position: absolute;
  left: 50%;
  top: var(--beam-top, 6%);
  height: var(--beam-h, 13%);
  transform: translateX(-50%) scaleY(0);
  transform-origin: bottom center;
  opacity: 0;
  z-index: 3;
  pointer-events: none;
  transition: transform 1.8s cubic-bezier(.22,1,.36,1), opacity 0.9s ease;
}
#hologram-beam {
  width: clamp(190px, 34vw, 560px);
  clip-path: polygon(40% 100%, 60% 100%, 100% 0%, 0% 0%);
  background: linear-gradient(to top, rgba(168,240,255,0.5), rgba(168,240,255,0.06));
  mix-blend-mode: screen;
}
/* Fan rays either side, "searchlight" style (feedback #4) */
#beam-ray-l,
#beam-ray-r {
  width: clamp(90px, 16vw, 220px);
  clip-path: polygon(40% 100%, 60% 100%, 100% 0%, 0% 0%);
  background: linear-gradient(to top, rgba(168,240,255,0.32), rgba(168,240,255,0.03));
  mix-blend-mode: screen;
  height: calc(var(--beam-h, 26%) * 0.86);
}
#beam-ray-l { transform: translateX(-50%) rotate(-13deg) scaleY(0); transform-origin: bottom center; }
#beam-ray-r { transform: translateX(-50%) rotate(13deg) scaleY(0); transform-origin: bottom center; }
#beam-ray-l.active { opacity: 0.85; transform: translateX(-50%) rotate(-13deg) scaleY(1); }
#beam-ray-r.active { opacity: 0.85; transform: translateX(-50%) rotate(13deg) scaleY(1); }
#hologram-beam.active { opacity: 1; transform: translateX(-50%) scaleY(1); }

/* ---------- Bots ---------- */
.bot {
  position: absolute;
  left: var(--x, 50%);
  top: var(--y, 50%);
  width: var(--w, 190px);
  transform: translate(-50%, -50%) scale(var(--s, 1));
  transform-origin: center;
  will-change: left, top, transform;
  z-index: 4;
}
.bot svg { display: block; width: 100%; height: auto; overflow: visible; }

/* Lightweight polish pass (full character redesign deferred to a separate
   asset project): a soft top-lit sheen so the flat chassis reads less flat. */
.bot::before {
  content: "";
  position: absolute;
  inset: -4%;
  background: radial-gradient(ellipse at 50% 18%, rgba(255,255,255,0.16), transparent 58%);
  mix-blend-mode: overlay;
  pointer-events: none;
  z-index: 1;
}

.bot[data-bot="drone"] { --w: 128px; z-index: 6; }
.bot[data-bot="hauler"] { --w: 200px; z-index: 3; }
.bot[data-bot="hauler2"] { --w: 200px; z-index: 3; }
.bot[data-bot="mech"] { --w: 210px; }

/* Text-grid prop referenced the old "code cascades into typography" climax,
   which the pedestal/hologram climax (addendum §2) replaced. */
#bot-nettech svg [id$="-text-grid"] { display: none; }

/* Animatable rig parts: pivot from natural anchor, not raw bbox center */
.bot svg [id$="-left-arm"],
.bot svg [id$="-right-arm"],
.bot svg [id$="-wrench"],
.bot svg [id$="-plasma-welder"],
.bot svg [id$="-clipboard"],
.bot svg [id$="-rotors"],
.bot svg [id$="-laser-grid"] {
  transform-box: fill-box;
  transform-origin: top center;
  transition: transform 0.35s cubic-bezier(.34,1.56,.64,1);
}
.bot svg [id$="-wheel-fl"],
.bot svg [id$="-wheel-fr"],
.bot svg [id$="-wheel-rl"],
.bot svg [id$="-wheel-rr"] {
  transform-box: fill-box;
  transform-origin: center;
}

/* Drone: wide scanning beam, sweeping continuously the whole time it's on
   stage — its range is scaled well past the drone body so it reads as
   actively scanning the crew and the machine below it. */
.bot[data-bot="drone"] svg [id$="-laser-grid"] {
  transform-box: fill-box;
  transform-origin: top center;
  transform: scale(3.4);
  animation: drone-scan-sweep 1.5s ease-in-out infinite;
}
.bot[data-bot="drone"].constructing svg [id$="-laser-grid"] {
  animation: drone-scan-sweep 1.1s ease-in-out infinite;
}
@keyframes drone-scan-sweep {
  0%, 100% { opacity: 0.45; }
  50% { opacity: 0.95; }
}

/* Drone: active construction-assist pass — hovers and scans over the build
   site instead of just parking there (feedback #3). */
.bot[data-bot="drone"].constructing {
  animation: drone-scan 6s ease-in-out infinite;
}
@keyframes drone-scan {
  0%   { transform: translate(-50%, -50%) scale(var(--s,1)) translate(0, 0) rotate(0deg); }
  14%  { transform: translate(-50%, -50%) scale(var(--s,1)) translate(46px, -14px) rotate(-8deg); }
  28%  { transform: translate(-50%, -50%) scale(var(--s,1)) translate(64px, 10px) rotate(6deg); }
  42%  { transform: translate(-50%, -50%) scale(var(--s,1)) translate(30px, 30px) rotate(10deg); }
  50%  { transform: translate(-50%, -50%) scale(var(--s,1)) translate(0, 22px) rotate(0deg); }
  64%  { transform: translate(-50%, -50%) scale(var(--s,1)) translate(-46px, -14px) rotate(8deg); }
  78%  { transform: translate(-50%, -50%) scale(var(--s,1)) translate(-64px, 10px) rotate(-6deg); }
  92%  { transform: translate(-50%, -50%) scale(var(--s,1)) translate(-30px, 30px) rotate(-10deg); }
  100% { transform: translate(-50%, -50%) scale(var(--s,1)) translate(0, 0) rotate(0deg); }
}

/* Hauler: wheels spin while it is actively rolling (entrance / CTA delivery) */
.bot.rolling svg [id$="-wheel-fl"],
.bot.rolling svg [id$="-wheel-fr"],
.bot.rolling svg [id$="-wheel-rl"],
.bot.rolling svg [id$="-wheel-rr"] {
  animation: wheel-spin 0.6s linear infinite;
}
@keyframes wheel-spin {
  to { transform: rotate(360deg); }
}

/* Idle: gentle bob loop, staggered per bot via inline animation-delay */
.bot.idle {
  animation: idle-bob 3.6s ease-in-out infinite;
}
@keyframes idle-bob {
  0%, 100% { transform: translate(-50%, -50%) scale(var(--s,1)) translateY(0); }
  50% { transform: translate(-50%, -50%) scale(var(--s,1)) translateY(-7px); }
}

/* Working loop (Sequence 1 climax): tool glow flicker */
.bot.working svg [id$="-plasma-welder"],
.bot.working svg [id$="-wrench"] {
  animation: tool-flicker 0.9s ease-in-out infinite;
}
.bot.working svg [id$="-terminal"] {
  animation: tool-flicker 0.7s ease-in-out infinite;
}
.bot.working svg [id$="-clipboard"] {
  animation: clipboard-scan 1.4s ease-in-out infinite;
}
.bot.working svg [id$="-laser-grid"] {
  animation: laser-sweep 1.2s ease-in-out infinite;
}
/* Admin has no tool-flicker part by default (its prop is the ledger) — give
   it the same always-on "busy" treatment as everyone else. */
.bot.working svg [id$="-ledger"] {
  animation: tool-flicker 1.6s ease-in-out infinite;
}
.bot[data-bot="admin"].working svg [id$="-right-arm"] {
  animation: admin-check-watch 2.6s ease-in-out infinite;
}
@keyframes admin-check-watch {
  0%, 100% { transform: rotate(0deg); }
  15%, 30% { transform: rotate(-8deg); }
  45% { transform: rotate(0deg); }
}
@keyframes tool-flicker {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.55; }
}
@keyframes clipboard-scan {
  0%, 100% { transform: translate(80px, 190px) rotate(-10deg) translateY(0); }
  50% { transform: translate(80px, 190px) rotate(-10deg) translateY(-3px); }
}
@keyframes laser-sweep {
  0%, 100% { opacity: 0.3; }
  50% { opacity: 0.75; }
}

/* Role-specific construction beats (feedback #3): each bot gets a moment
   visibly tied to a pedestal piece landing, not just a generic "working" loop. */
.bot[data-bot="mech"].welding svg [id$="-plasma-welder"] {
  animation: tool-flicker 0.22s ease-in-out infinite;
}
.bot[data-bot="mech"].welding svg [id$="-right-arm"] {
  animation: weld-jab 0.5s ease-in-out infinite;
}
@keyframes weld-jab {
  0%, 100% { transform: rotate(0deg); }
  50% { transform: rotate(-12deg); }
}
.bot[data-bot="hauler"].delivering {
  animation: none;
  transform: translate(-50%, -50%) scale(var(--s,1)) translateY(4px);
  transition: transform 0.25s ease-in-out;
}
.bot[data-bot="nettech"].diagnosing svg [id$="-terminal"] {
  animation: tool-flicker 0.25s ease-in-out infinite;
}
.bot[data-bot="sci"].checking svg [id$="-clipboard"] {
  animation: tool-flicker 0.3s ease-in-out 3;
}
.bot[data-bot="admin"].directing svg [id$="-left-arm"] {
  animation: weld-jab 0.9s ease-in-out 2;
}

/* Reactive (mouse-proximity) state: pause bob, lift + brighten + gesture */
.bot.reactive {
  animation: none;
  transform: translate(-50%, -50%) scale(calc(var(--s,1) * 1.08)) translateY(-6px);
  transition: transform 0.4s cubic-bezier(.34,1.56,.64,1);
}
.bot.reactive svg [id$="-left-arm"] { transform: rotate(-28deg); }
.bot.reactive svg [id$="-right-arm"] { transform: rotate(20deg); }
.bot.reactive svg [id$="-laser-grid"] { opacity: 0.9; }
.bot[data-bot="drone"].reactive { transform: translate(-50%, -50%) scale(calc(var(--s,1) * 1.1)) translateY(10px); }
.bot[data-bot="hauler"].reactive svg [id$="-cabin"] rect,
.bot[data-bot="hauler"].reactive svg [id$="-cabin"] circle {
  opacity: 1;
}

/* Hauler: brief receive-cue when the drone hands off the CTA module */
.bot[data-bot="hauler"].receiving {
  animation: none;
  transform: translate(-50%, -50%) scale(calc(var(--s,1) * 1.06)) translateY(-4px);
  transition: transform 0.3s cubic-bezier(.34,1.56,.64,1);
}
.bot[data-bot="hauler"].receiving svg [id$="-cargo-mounts"] {
  animation: tool-flicker 0.35s ease-in-out 2;
}

/* Secure-tools cue on CTA click, before dissipation */
.bot.securing svg [id$="-left-arm"],
.bot.securing svg [id$="-right-arm"] {
  transform: rotate(0deg);
  transition: transform 0.35s ease;
}
.bot.securing { animation: none; }

/* ---------- Spark particles ---------- */
#spark-field {
  position: absolute;
  left: 50%;
  top: var(--ped-y, 50%);
  width: 0; height: 0;
  z-index: 6;
  pointer-events: none;
}
.spark {
  position: absolute;
  left: 0; top: 0;
  width: 4px; height: 4px;
  border-radius: 50%;
  background: var(--gold);
  box-shadow: 0 0 8px 2px rgba(255, 209, 102, 0.8);
  mix-blend-mode: screen;
  animation: spark-burst 0.9s ease-out forwards;
  z-index: 6;
  pointer-events: none;
}
/* Welding sparks: hotter, whiter core, faster fall-off */
.spark.weld {
  width: 3px; height: 3px;
  background: #FFF6E0;
  box-shadow: 0 0 7px 2px rgba(255, 169, 77, 0.95);
  animation-duration: 0.6s;
}
@keyframes spark-burst {
  0% { transform: translate(0, 0) scale(1); opacity: 1; }
  100% { transform: translate(var(--dx), var(--dy)) scale(0.2); opacity: 0; }
}

/* ---------- CTA module (drone tow-in, hauler anchors) ---------- */
#cta-module {
  position: absolute;
  left: 50%;
  top: 74%;
  transform: translate(-50%, -50%) scale(0.5);
  opacity: 0;
  z-index: 7;
  pointer-events: none;
  transition: transform 0.5s ease, opacity 0.4s ease, left 1s cubic-bezier(.45,0,.55,1), top 1s cubic-bezier(.45,0,.55,1);
}
#cta-module.towing {
  opacity: 1;
  transform: translate(-50%, -50%) scale(0.85);
}
#cta-module.anchored {
  opacity: 1;
  pointer-events: auto;
  transform: translate(-50%, -50%) scale(1);
  transition: transform 0.45s cubic-bezier(.34,1.56,.64,1), opacity 0.4s ease, left 1s cubic-bezier(.45,0,.55,1), top 1s cubic-bezier(.45,0,.55,1);
}
#cta-module.anchored.settle {
  transform: translate(-50%, -50%) scale(1.08);
}

/* Ground tow-link: hauler and CTA now travel with a constant offset (same
   distance, same duration) so they move as one connected unit, not two
   independently-timed elements — the line just makes that connection visible. */
/* Digital tow-chain: a row of glowing links between the hauler and the CTA
   module it's dragging, built from a repeating pattern rather than a solid
   line so it actually reads as a chain, not just a beam. */
#tow-cable {
  position: absolute;
  right: 100%;
  top: 50%;
  width: 0;
  height: 5px;
  background: repeating-linear-gradient(
    to left,
    rgba(168,240,255,0.95) 0px, rgba(168,240,255,0.95) 5px,
    rgba(168,240,255,0.15) 5px, rgba(168,240,255,0.15) 7px,
    transparent 7px, transparent 11px
  );
  border-radius: 2px;
  box-shadow: 0 0 6px rgba(168,240,255,0.5);
  transform-origin: right center;
  transform: translateY(-50%) rotate(5deg) scaleX(0);
  transition: opacity 0.3s ease;
  opacity: 0;
}
#cta-module.towing #tow-cable {
  width: 15.5vw;
  max-width: 160px;
  min-width: 82px;
  opacity: 1;
  animation: chain-link-flow 0.6s linear infinite;
  transform: translateY(-50%) rotate(4deg) scaleX(1);
}
@keyframes chain-link-flow {
  from { background-position: 0 0; }
  to { background-position: -22px 0; }
}

/* Hauler's own tow-hitch part brightens while it's actively dragging the CTA */
.bot[data-bot="hauler"].dragging svg [id$="-tow-link"] {
  opacity: 1;
  animation: tool-flicker 0.5s ease-in-out infinite;
}

.cta-btn {
  position: relative;
  overflow: hidden;
  font-family: "Consolas", "Courier New", "Rajdhani", monospace;
  font-size: clamp(0.64rem, 1vw, 0.78rem);
  font-weight: 600;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: #EAFEFF;
  background: linear-gradient(135deg, rgba(0,229,255,0.14), rgba(8,14,22,0.94));
  border: 1px solid rgba(168,240,255,0.65);
  border-radius: 2px;
  clip-path: polygon(9px 0, 100% 0, 100% calc(100% - 9px), calc(100% - 9px) 100%, 0 100%, 0 9px);
  padding: 0.65em 1.5em 0.65em 2.1em;
  cursor: pointer;
  box-shadow: 0 0 0 0 rgba(0,229,255,0.5), 0 6px 18px rgba(0,0,0,0.55), inset 0 0 10px rgba(0,229,255,0.08);
  animation: cta-pulse 2.4s ease-in-out infinite;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.cta-btn::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(100deg, transparent 40%, rgba(168,240,255,0.28) 50%, transparent 60%);
  background-size: 260% 100%;
  animation: cta-scan 3.6s linear infinite;
  pointer-events: none;
}
.cta-blip {
  position: absolute;
  left: 0.75em;
  top: 50%;
  transform: translateY(-50%);
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--cyan-soft);
  box-shadow: 0 0 6px 2px rgba(168,240,255,0.85);
  animation: cta-blip 1.3s ease-in-out infinite;
}
.cta-btn:hover, .cta-btn:focus-visible {
  transform: scale(1.06);
  color: #FFFFFF;
}
.cta-btn:focus-visible {
  outline: 3px solid var(--cyan-soft);
  outline-offset: 3px;
}
@keyframes cta-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(0,229,255,0.4), 0 6px 18px rgba(0,0,0,0.55), inset 0 0 10px rgba(0,229,255,0.08); }
  50% { box-shadow: 0 0 0 9px rgba(0,229,255,0), 0 6px 18px rgba(0,0,0,0.55), inset 0 0 10px rgba(0,229,255,0.08); }
}
@keyframes cta-scan {
  0% { background-position: -160% 0; }
  100% { background-position: 160% 0; }
}
@keyframes cta-blip {
  0%, 100% { opacity: 0.4; transform: translateY(-50%) scale(0.85); }
  50% { opacity: 1; transform: translateY(-50%) scale(1.1); }
}

/* Targeting-bracket corners around the module, HUD-style */
.cta-corner {
  position: absolute;
  width: 12px;
  height: 12px;
  border: 0 solid var(--cyan-soft);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.4s ease;
}
#cta-module.anchored .cta-corner { opacity: 0.85; }
.cta-corner.tl { top: -6px; left: -6px; border-top-width: 2px; border-left-width: 2px; }
.cta-corner.tr { top: -6px; right: -6px; border-top-width: 2px; border-right-width: 2px; }
.cta-corner.bl { bottom: -6px; left: -6px; border-bottom-width: 2px; border-left-width: 2px; }
.cta-corner.br { bottom: -6px; right: -6px; border-bottom-width: 2px; border-right-width: 2px; }

/* ---------- Pixel dissipation transition ---------- */
#pixel-overlay {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: repeat(var(--cols, 16), 1fr);
  grid-template-rows: repeat(var(--rows, 10), 1fr);
  pointer-events: none;
}
#pixel-overlay.hidden { display: none; }
.pixel-cell {
  background: var(--void);
  opacity: 1;
}
.pixel-cell.dissolve {
  animation: pixel-fade 0.55s ease forwards;
}
@keyframes pixel-fade {
  to { opacity: 0; transform: scale(0.85); }
}

/* ---------- Corporate stub ---------- */
#corporate-stub {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 1rem;
  padding: 2rem;
  background: radial-gradient(ellipse at 50% 40%, #10141f 0%, var(--void) 70%);
}
#corporate-stub.visible { display: flex; }
#corporate-stub h1 {
  font-size: clamp(1.6rem, 5vw, 2.6rem);
  font-weight: 600;
  color: #F5F7FF;
  text-shadow: 0 0 20px rgba(255, 209, 102, 0.4);
  margin: 0;
}
#corporate-stub p {
  max-width: 46ch;
  color: #A9B2C9;
  font-size: clamp(0.9rem, 1.6vw, 1.05rem);
  margin: 0;
}
#corporate-stub .back-link {
  margin-top: 1rem;
  background: none;
  border: 1px solid rgba(168,240,255,0.4);
  color: var(--cyan-soft);
  padding: 0.6em 1.4em;
  border-radius: 999px;
  font-family: inherit;
  font-size: 0.9rem;
  cursor: pointer;
}
#corporate-stub .back-link:focus-visible { outline: 3px solid var(--cyan-soft); outline-offset: 3px; }

/* ---------- Audio toggle ---------- */
#audio-toggle {
  position: fixed;
  top: max(14px, env(safe-area-inset-top));
  right: max(14px, env(safe-area-inset-right));
  z-index: 30;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 1px solid rgba(168,240,255,0.3);
  background: rgba(10,13,20,0.55);
  color: var(--cyan-soft);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
#audio-toggle:focus-visible { outline: 3px solid var(--cyan-soft); outline-offset: 2px; }
#audio-toggle #audio-mute-x, #audio-toggle #audio-mute-x2 { display: none; }
#audio-toggle #audio-wave { display: block; }
#audio-toggle[aria-pressed="false"] #audio-mute-x,
#audio-toggle[aria-pressed="false"] #audio-mute-x2 { display: block; }
#audio-toggle[aria-pressed="false"] #audio-wave { display: none; }

/* ---------- Responsive: mobile simplification ---------- */
@media (max-width: 760px) {
  :root {
    --idle-y: 82%; --ped-y: 56%; --ped-w: min(185vw, 86vh); --beam-top: 5%; --beam-h: 20%;
    --title-y: 5%; --buildlog-y: 42%; --status-y: 94%; --tagline-y: 13%;
  }
  .bot { --w: 108px; }
  .bot[data-bot="hauler"] { --w: 110px; }
  .bot[data-bot="hauler2"] { --w: 110px; }
  .bot[data-bot="mech"] { --w: 118px; }
  .bot[data-bot="drone"] { --w: 92px; }
  #corporate-stub p { max-width: 34ch; }
  /* The company name was rendering ~98% of the viewport width here (roughly
     4px of margin either side), which both looked over-scaled and ran the
     last letters underneath the audio control in the top-right corner. Pull
     it back to ~70% width so it has real side margins and the corner stays
     clear. Bottom-right is not an option for the control: the construction
     status line occupies that band. */
  /* Sized in vw (not a rem floor) so the side margins hold at 320/360/375 —
     a fixed floor cleared the control at 375 but collided again at 320. */
  #title-main { font-size: clamp(0.8rem, 3.6vw, 2.7rem); }
  #title-main.final { font-size: clamp(0.8rem, 4.1vw, 3.4rem); }
  #audio-toggle {
    width: 32px;
    height: 32px;
    top: max(10px, env(safe-area-inset-top));
    right: max(10px, env(safe-area-inset-right));
  }
}

/* ---------- Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  .bot { transition: none !important; }
  .bot.idle, .bot.reactive, .bot.working { animation: none !important; }
  .cta-btn, .cta-btn::before, .cta-blip { animation: none !important; }
  #title-suffix.typing::after { animation: none !important; }
  .spark { animation: none !important; display: none; }
  .pixel-cell.dissolve { animation: none !important; opacity: 0 !important; }
  #title-construct, #status-readout, #cta-module, #pedestal, #hologram-beam, #tow-cable {
    transition: opacity 0.3s ease !important;
  }
  #tow-cable { animation: none !important; }
  #title-suffix { animation: none !important; }
  #title-main .ch { animation: none !important; opacity: 1 !important; transform: none !important; filter: none !important; }
  #title-scan { display: none !important; }
  #pedestal #ped-shadow, #pedestal #ped-base, #pedestal #ped-conduits,
  #pedestal #ped-panel-l, #pedestal #ped-panel-r,
  #pedestal #ped-column, #pedestal #ped-emitter, #pedestal #ped-lens {
    transition: none !important; opacity: 1 !important; transform: none !important;
  }
  #pedestal #ped-ring-outer, #pedestal #ped-ring-inner { animation: none !important; }
  #beam-ray-l, #beam-ray-r { transition: opacity 0.3s ease !important; }
  #build-log { display: none !important; }
  .bot[data-bot="drone"].constructing { animation: none !important; }
  .bot.welding svg, .bot.delivering, .bot.diagnosing svg, .bot.checking svg, .bot.directing svg {
    animation: none !important;
  }
}
