@property --camera-x { syntax:"<number>"; inherits:false; initial-value:.5; }
@property --camera-y { syntax:"<number>"; inherits:false; initial-value:.5; }

/* The world, the optical overlays and the travel shots keep the original
   illustration's aspect ratio. Only the camera aperture changes on a phone. */
@media (orientation:portrait) and (max-width:700px), (orientation:portrait) and (any-pointer:coarse) and (max-width:1100px), (orientation:landscape) and (max-width:1000px) and (max-height:540px), (orientation:landscape) and (any-pointer:coarse) and (max-width:1450px) and (max-height:1100px) {
  html { scrollbar-gutter:auto; }
  html, body { overflow:hidden; }
  #status {position:fixed;inset:0 auto auto 0;margin:0;}
  main { display:block; min-height:0; }
  main .base-shell, main .base-shell:has(#base.scene[data-guide]) {
    --world-w:max(100vw, calc(100dvh * 1672 / 941));
    --world-h:max(100dvh, calc(100vw * 941 / 1672));
    position:relative; display:block; width:100%; height:100vh; height:100dvh; overflow:hidden;
  }
  main .base-shell > .viewport, main .base-shell:has(#base.scene[data-guide]) > .viewport {
    width:100%; height:100%; overflow:clip;
  }
  .panorama-frame, #tour-shot {
    position:absolute; width:var(--world-w); height:var(--world-h); inset:auto;
    top:clamp(calc(100% - var(--world-h)), calc(50% - var(--camera-y,.5) * var(--world-h)), 0px);
    left:clamp(calc(100% - var(--world-w)), calc(50% - var(--camera-x,.5) * var(--world-w)), 0px);
  }
  .panorama-frame { transition:--camera-x .72s cubic-bezier(.4,0,.22,1),--camera-y .72s cubic-bezier(.4,0,.22,1); }
  .panorama-frame[data-zoom] { transition:none; }
  .panorama-frame:has(.scene[data-beat]) { --camera-x:.5; --camera-y:.58; }
  .scene { width:100%; height:100%; }
  .guide-console {
    position:absolute; inset:auto 0 0; z-index:4; width:100%; margin:0;
    display:grid; grid-template-columns:minmax(0,1fr) auto; gap:.35rem .5rem;
    padding:.6rem max(.75rem,env(safe-area-inset-right)) max(.55rem,env(safe-area-inset-bottom)) max(.75rem,env(safe-area-inset-left));
    max-height:40%; overflow:auto; overscroll-behavior:contain; scrollbar-width:thin;
    border-top:1px solid #91e3da66;
    background:linear-gradient(170deg,#10242deb,#08161dee); box-shadow:0 -8px 30px #06101a32;
  }
  .guide-console .guide-top {min-width:0;flex-wrap:wrap;gap:.15rem .4rem;}
  .guide-console .guide-actions {justify-content:flex-end; gap:.35rem;}
  .guide-console button {min-height:44px;}
  #guide-caption {min-height:0; display:block; padding:.25rem .6rem; background:#07151c99;}
  #guide-caption h2 {margin:0 0 .15rem;}
  #guide-caption p {font-size:1rem; line-height:1.36;}
  .scene-speaker[data-audio-toggle], .menu-speaker[data-audio-toggle] {
    width:44px;height:44px;top:max(.5rem,env(safe-area-inset-top));right:max(.6rem,env(safe-area-inset-right));
  }
  .base-contact {top:max(.5rem,env(safe-area-inset-top));}
  /* A single flat strip turns from glass to bulkhead. Both walls stay opaque until the hatch moves. */
  .arrival {overflow:hidden;background:#121921}
  .arrival .seat-view {inset:0;width:100%;height:100%;perspective:none;background:transparent;overflow:visible}
  .arrival .seat-room {transform-style:flat;transform:translate3d(0,0,0);will-change:transform}
  .arrival .front-wall,.arrival .exit-wall {transform:none;backface-visibility:visible}
  .arrival .front-wall {transform-origin:right center;transform:scaleX(var(--turn-width,1))}
  .arrival .exit-wall {left:100%;width:100%;transform-origin:left center;transform:scaleX(var(--turn-width,1))}
  .arrival:not([data-phase="exit"]) .exit-wall {background:#202428 url('/assets/exit-door.webp') center/100% 100%}
  .arrival:is([data-phase="terminal"],[data-phase="exit"]) .seat-room {transform:translate3d(-100%,0,0)}
  .arrival[data-phase="exit"] {background:transparent}
  .arrival .door-leaf {will-change:transform}
  .arrival-skip {
    right:max(.75rem,env(safe-area-inset-right));bottom:max(.75rem,env(safe-area-inset-bottom));
    min-height:44px; font-size:.92rem;
  }
  .door-terminal {width:min(85vw,48rem);font-size:1rem;max-height:min(95%,calc(100dvh - 3rem));}
  .language-keys button,.door-terminal .open-hatch {min-height:44px;}
  #station-panel {padding:max(1rem,env(safe-area-inset-top)) 1rem max(1rem,env(safe-area-inset-bottom));}
  .base-shell:has(#station-panel:not([hidden])) .guide-console {visibility:hidden;}
  .site-menu[open] {overflow:auto;align-content:safe center;padding:max(1.2rem,env(safe-area-inset-top)) max(1.2rem,env(safe-area-inset-right)) max(1.2rem,env(safe-area-inset-bottom)) max(1.2rem,env(safe-area-inset-left));}
  @media (prefers-reduced-motion:reduce) { .panorama-frame { transition:none; } }
}
@media (orientation:portrait) and (max-width:700px), (orientation:portrait) and (any-pointer:coarse) and (max-width:1100px) {
  .guide-robot {width:min(35vw,22dvh);bottom:15%;}
  .scene[data-beat] {transform-origin:50% 106%;transform:scale(1.55);}
  .holo-screen {left:50%;bottom:64%;width:min(82vw,24rem);min-height:0;transform:translateX(-50%);
    padding:.55rem .8rem;gap:.2rem;font-size:clamp(.9rem,3.8vw,1.1rem);}
  .door-terminal {width:min(98%,32rem);padding:clamp(.28rem,1.3vw,.62rem);}
  .monitor-glass {padding:clamp(.28rem,1.4vw,.65rem);}
  .door-terminal h2 {font-size:1.05rem;margin:0 0 .6rem;}
  .language-keys {grid-template-columns:repeat(5,minmax(0,1fr));gap:clamp(2px,.7vw,5px);}
  .language-keys button {min-width:0;min-height:50px;flex-direction:column;justify-content:center;gap:.32em;
    padding:.35em 0;font-size:clamp(.68rem,3.08vw,.92rem);line-height:1.1;}
  .language-keys .language-flag {width:1.78em;height:1.19em;}
  @media (max-width:420px) {
    .language-keys button:is([lang="uk"],[lang="nl"]) bdi {letter-spacing:-.025em;transform:scaleX(.84);}
    .language-keys button[lang="pt"] bdi {letter-spacing:-.025em;}
  }
  .hatch-controls {padding:.6rem .2rem .15rem;}
  .menu-inner {flex-direction:column-reverse;align-items:stretch;gap:1.2rem;}
  .menu-inner img {width:min(30vw,16dvh); margin-inline-end:1.7rem;align-self:flex-end;}
  /* Keep the first painted windshield legible while the live optical surfaces decode. */
  .arrival-poster {
    background:url('/assets/saucer-hatch.webp') center/100% 100%,
      linear-gradient(transparent 15%,#100c1a 18.8%,#100b1a 29%,transparent 33%),
      #080d15 url('/assets/lunar-overflight.webp') center/cover;
  }
  .arrival-poster::before {
    content:"";position:absolute;top:24%;left:50%;width:124vw;aspect-ratio:1672/125;
    transform:translate(-50%,-50%);background:url('/assets/lunar-overflight.webp') center 21%/100% auto;
    mix-blend-mode:screen;pointer-events:none;
  }
  @media (max-height:650px) {
    .guide-console {max-height:32%;}
  }
  @media (max-width:360px) {
    .guide-console {grid-template-columns:minmax(0,1fr);}
    .guide-console .guide-actions {justify-content:flex-start;}
  }
  @media (prefers-reduced-motion:reduce) { .scene[data-beat] {transform:none;} }
}
@media (orientation:landscape) and (max-width:1000px) and (max-height:540px), (orientation:landscape) and (any-pointer:coarse) and (max-width:1450px) and (max-height:1100px) {
  .guide-console {inset:auto auto max(.45rem,env(safe-area-inset-bottom)) max(.5rem,env(safe-area-inset-left));
    width:38%; max-height:69%; border:1px solid #91e3da66;border-radius:.6rem;padding:.55rem .65rem;grid-template-columns:minmax(0,1fr);}
  .guide-console .guide-actions {justify-content:flex-start;}
  .guide-robot {width:min(13vw,27dvh);bottom:12%;}
  .scene[data-beat] {transform-origin:50% 82%;}
  .menu-inner {flex-direction:row;}.menu-inner img {width:min(22vw,45dvh);}
  .menu-copy h1 {font-size:clamp(2rem,8dvh,3.5rem);margin-bottom:.3em;}
  .menu-copy nav {gap:0;}.menu-copy nav>* {min-height:40px;padding:.4em .1em;}
  .door-terminal{width:min(74vw,42rem);}
}

.tour-room-layer {display:contents;}
.tour-extension {display:none;}
@media (orientation:portrait) and (max-width:700px), (orientation:portrait) and (any-pointer:coarse) and (max-width:1100px), (orientation:landscape) and (max-width:1000px) and (max-height:540px), (orientation:landscape) and (any-pointer:coarse) and (max-width:1450px) and (max-height:1100px) {
  .viewport[data-tour-lens] :is(.panorama-frame,#tour-shot) {
    left:0;top:0;transform-origin:0 0;transform:var(--tour-transform);
    transition:none;isolation:isolate;overflow:visible;
  }
  .viewport[data-tour-lens] .panorama-frame {z-index:1;}
  .viewport[data-tour-lens] .tour-room-layer {
    position:absolute;inset:0;z-index:2;display:block;overflow:hidden;pointer-events:none;
    opacity:var(--tour-reveal,0);
  }
  [data-extended] > .tour-extension {
    display:block;position:absolute;z-index:-1;pointer-events:none;
    background-size:100% 100%;background-repeat:no-repeat;
    border-style:solid;border-color:transparent;border-image-slice:64 fill;border-image-repeat:stretch;
  }
  .scene[data-extended] > .landscape, #tour-shot[data-extended] > canvas:first-of-type {
    mask-image:linear-gradient(to bottom,transparent,#000 5%,#000 95%,transparent),
      linear-gradient(to right,transparent,#000 3%,#000 97%,transparent);
    mask-composite:intersect;
  }
  .scene[data-extended] > img.landscape:has(+ .sky-landscape) {opacity:0;}
  /* The old van photograph was shot through a porthole. The portrait
     continues that arch at the outside of the new composition. */
  #tour-shot[data-extended="designers"] > canvas:first-of-type {
    mask-image:linear-gradient(to bottom,transparent,#000 5%,#000 95%,transparent),
      linear-gradient(to right,transparent,#000 3%,#000 97%,transparent),
      radial-gradient(ellipse 19% 42% at top left,transparent 62%,#000),
      radial-gradient(ellipse 19% 42% at top right,transparent 62%,#000);
    mask-composite:intersect;
  }
  .viewport[data-tour-lens] .ray-glow {
    stroke:#ff5738;stroke-width:calc(5.5 * var(--beam-pixel,1px));opacity:.48;
  }
  .viewport[data-tour-lens] .ray-core {
    stroke:#ffe0ad;stroke-width:calc(1.65 * var(--beam-pixel,1px));stroke-linecap:round;
  }
  .viewport[data-tour-lens] #guide-target circle:first-child {
    r:calc(6 * var(--beam-pixel,1px));stroke:#ffa87b;stroke-width:calc(1.4 * var(--beam-pixel,1px));
  }
  .viewport[data-tour-lens] .scene[data-stop="satellite"] .ray-core {stroke-width:calc(2.8 * var(--beam-pixel,1px));}

}
@media (orientation:landscape) and (max-width:1000px) and (max-height:540px), (orientation:landscape) and (any-pointer:coarse) and (max-width:1450px) and (max-height:1100px) {
  .base-shell:has(.viewport[data-tour-lens]) .guide-console {
    inset:auto 0 0;width:100%;max-height:33%;border-radius:0;
    grid-template-columns:auto 1fr auto;align-items:center;padding:.35rem max(.75rem,env(safe-area-inset-right)) max(.35rem,env(safe-area-inset-bottom)) max(.75rem,env(safe-area-inset-left));
  }
  .base-shell:has(.viewport[data-tour-lens]) #guide-caption {grid-column:2;grid-row:1;}
  .base-shell:has(.viewport[data-tour-lens]) .guide-actions {grid-column:3;grid-row:1;}
}

@media (orientation:portrait) and (max-width:700px), (orientation:portrait) and (any-pointer:coarse) and (max-width:1100px), (orientation:landscape) and (max-width:1000px) and (max-height:540px), (orientation:landscape) and (any-pointer:coarse) and (max-width:1450px) and (max-height:1100px) {
  .viewport:not([data-tour-lens]) .panorama-frame:has(.scene[data-extended]) {
    left:0;top:0;transform:var(--landing-transform);transform-origin:0 0;
  }
  .guide-optics {overflow:visible;}
}
@media (orientation:portrait) and (max-width:700px), (orientation:portrait) and (any-pointer:coarse) and (max-width:1100px) {
  /* The foreground guide recedes faster than the station as the lens opens. */
  .scene[data-extended] .guide-robot {
    width:calc(26% - 11% * var(--map-overview,0));
    bottom:calc(-32% + 25% * var(--map-overview,0));
  }
  .viewport:not([data-tour-lens]) .scene[data-extended]:not([data-beat]) .holo-screen {
    top:var(--holo-offset);bottom:auto;left:50%;width:min(71vw,24rem);
    transform-origin:center top;transform:translateX(-50%) scale(var(--holo-scale));
  }
}
@media (orientation:landscape) and (max-width:1000px) and (max-height:540px), (orientation:landscape) and (any-pointer:coarse) and (max-width:1450px) and (max-height:1100px) {
  .viewport[data-tour-lens] .guide-robot {bottom:4.5%;}
}

@keyframes rover-arrives {
  0% {transform:translate(-67%,-8%) scale(.82)}
  64% {transform:translate(-48%,1%) scale(1.025)}
  100% {transform:translate(-50%,0) scale(1)}
}
@keyframes rover-greets {
  0%,100% {transform:perspective(440px) rotateY(-4deg)}
  22% {transform:perspective(440px) rotateY(16deg) rotateZ(2deg)}
  46%,75% {transform:perspective(440px) rotateY(-8deg) rotateX(5deg)}
}
@keyframes rover-scans {
  0%,100% {transform:perspective(440px) rotateY(0)}
  35% {transform:perspective(440px) rotateY(-26deg) rotateZ(-3deg)}
  74% {transform:perspective(440px) rotateY(26deg) rotateZ(2deg)}
}
@media (orientation:portrait) and (max-width:700px), (orientation:portrait) and (any-pointer:coarse) and (max-width:1100px), (orientation:landscape) and (max-width:1000px) and (max-height:540px), (orientation:landscape) and (any-pointer:coarse) and (max-width:1450px) and (max-height:1100px) {
  .scene[data-rolling] .guide-robot {animation:rover-arrives 2.2s ease-in-out both;transform-origin:50% 96%}
  .scene[data-guide="choice"] .guide-head,.scene[data-guide="idle"] .guide-head {animation:rover-greets 6.5s ease-in-out infinite}
  .scene[data-guide="scanning"] .guide-head {animation:rover-scans 1.6s ease-in-out both}
  @media (prefers-reduced-motion:reduce) {
    html:not([data-full-motion]) .scene :is(.guide-robot,.guide-head) {animation:none}
  }
}

/* The glass switch sits inside the original metal frame of the flight yoke. */
.flight-start {
  position:absolute; z-index:2; left:50%; bottom:0; width:min(92%,76dvh,30rem);
  aspect-ratio:2.48; transform:translateX(-50%); container-type:inline-size;
  padding:0; border:0; background:transparent; color:#ceffef;
  cursor:pointer; touch-action:manipulation; -webkit-tap-highlight-color:transparent;
}
.flight-yoke {
  position:absolute; inset:0; border:solid transparent; border-width:0 29cqw;
  border-image:url('/assets/flight-yoke.webp') 0 38% fill stretch;
  filter:drop-shadow(0 3px 4px #08070799); pointer-events:none;
}
.flight-display {
  position:absolute; left:50%; top:65.4%; transform:translate(-50%,-50%);
  width:39%; min-height:17%; box-sizing:border-box; display:grid; place-items:center;
  border:1px solid #7ec797; border-bottom-color:#347f58; border-radius:.34rem;
  background-color:rgb(11 93 48 / .86);
  background-image:
    linear-gradient(165deg, rgb(240 255 222 / .23), transparent 42%),
    linear-gradient(to bottom, rgb(169 255 183 / .25), rgb(99 235 145 / .10) 46%, rgb(1 50 24 / .24) 50%, rgb(77 224 116 / .24));
  box-shadow:inset 0 1px 1px #dcffd7bb, inset 0 -2px 3px #8affab52,
    0 1px 0 2px #14271d, 0 0 9px #57e77a4d;
  color:#edffe9; text-shadow:0 1px 1px #083416, 0 0 4px #abffa570;
  font:700 clamp(.875rem,4.25cqw,1.1rem)/1 ui-monospace,monospace;
  letter-spacing:.14em; text-indent:.14em;
}
.flight-start:focus-visible {outline:none}
.flight-start:focus-visible .flight-display {outline:2px solid #ddffdb;outline-offset:3px}
@media (hover:hover) {
  .flight-start:hover .flight-display {background-color:rgb(16 115 57 / .91)}
}
.flight-start:active .flight-display {
  transform:translate(-50%,calc(-50% + 1px));
  background-color:rgb(7 76 39 / .93); box-shadow:inset 0 2px 4px #062f1cbb, 0 0 0 2px #152c21;
}
