:root {
  color-scheme: dark;
  --cabin: #101218;
  --ink: #f4f1ea;
  --muted: #b7b1a6;
  --line: rgba(244, 241, 234, 0.18);
  --moon: 0;
  --look-x: 0;
  --look-y: 0;
  --float-x: 0;
  --float-y: 0;
  --float-r: 0;
  --plate: 0;
  /* Static grain tile. A live turbulence filter re-rasterized every frame and
     dropped the replay to a handful of frames per second. */
  --grain: url("grain.png");
  font-family: "Iowan Old Style", Palatino, "Palatino Linotype", Georgia, serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--cabin);
  color: var(--ink);
  overflow: hidden;
}

button, input { font: inherit; color: inherit; }

#stage { position: relative; height: 100%; }

/* The viewport is the inner face of a cone panel, not a page with a
   picture frame on it. Aluminum pressure-vessel cone: NASA crew-module
   reference. Openings: NASA image jsc2022e045980. */
#cabin {
  position: absolute;
  inset: 0;
  background: #0b0c10;
  overflow: hidden;
  opacity: 0;
}

#stage.live #cabin {
  opacity: 1;
  transition: opacity 1.05s ease;
}

#wall {
  position: absolute;
  inset: -4%;
  /* Cabin lights are off in the interior photos, so the cone reads as a dark
     surround. Spill from the glass is the only bright metal. */
  background-color: #07080c;
  background-image:
    radial-gradient(ellipse 42% 36% at 50% 48%, rgba(186, 196, 208, calc(var(--moon) * 0.22)), transparent 70%),
    var(--grain),
    linear-gradient(168deg, #2a313b 0%, #14181f 32%, #07080c 100%);
  background-size: auto, 128px 128px, auto;
  transform: none;
  box-shadow: inset 0 0 180px rgba(0, 0, 0, 0.55);
  will-change: transform;
}

#shade {
  position: absolute;
  inset: 0;
  background: #05060a;
  opacity: calc(var(--moon) * 0.42);
  pointer-events: none;
  z-index: 1;
}

#window {
  position: absolute;
  z-index: 2;
  left: 50%;
  top: 50%;
  /* Face near the glass. 1.58 is the landscape rounded rectangle from
     jsc2022e045980, not a measured clear aperture. */
  width: min(96vw, calc(104vh * 1.58));
  aspect-ratio: 1.58 / 1;
  transform: translate(-50%, -50%);
  will-change: transform;
}

/* Nearest lip, a few pixels soft. The glass and inner steps stay sharp. */
#near {
  position: absolute;
  inset: -2%;
  z-index: 0;
  border-radius: clamp(40px, 5.2vw, 96px);
  padding: clamp(22px, 2.6vw, 46px);
  pointer-events: none;
  filter: blur(2.2px);
  background:
    radial-gradient(ellipse at 50% 46%, rgba(196, 204, 214, calc(var(--moon) * 0.2)) 58%, transparent 80%),
    var(--grain),
    linear-gradient(168deg, #4a5260 0%, #1c222b 40%, #0a0c10 100%);
  background-size: auto, 140px 140px, auto;
  -webkit-mask:
    linear-gradient(#000 0 0) content-box,
    linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask:
    linear-gradient(#000 0 0) content-box,
    linear-gradient(#000 0 0);
  mask-composite: exclude;
}

.reveal {
  height: 100%;
  box-sizing: border-box;
}

/* Outer retainer: fused-silica thermal pane, the outermost lite.
   Light on each step comes from the opening. Corners of the recess stay darker. */
.thermal {
  position: relative;
  z-index: 1;
  padding: clamp(14px, 1.7vw, 28px);
  border-radius: clamp(34px, 4.4vw, 72px);
  background-color: #161a20;
  background-image:
    radial-gradient(ellipse at 50% 48%, rgba(210, 216, 224, calc(var(--moon) * 0.16)) 60%, transparent 82%),
    var(--grain),
    linear-gradient(168deg, #3a424e 0%, #1a1f27 18%, #10141a 100%);
  background-size: auto, 140px 140px, auto;
  box-shadow:
    inset 22px 16px 28px rgba(0, 0, 0, 0.55),
    inset -14px 18px 24px rgba(0, 0, 0, 0.35),
    inset 0 -18px 22px rgba(0, 0, 0, 0.5),
    inset 0 1px 0 rgba(255, 255, 255, calc(0.06 + var(--moon) * 0.1)),
    0 18px 36px rgba(0, 0, 0, 0.45);
}

/* Middle step: pressure pane, set back from the thermal retainer. */
.pressure {
  height: 100%;
  padding: clamp(12px, 1.5vw, 22px);
  border-radius: clamp(26px, 3.6vw, 58px);
  background-color: #14181e;
  background-image:
    radial-gradient(ellipse at 50% 50%, rgba(210, 216, 224, calc(var(--moon) * 0.16)) 62%, transparent 82%),
    var(--grain),
    linear-gradient(180deg, #2a3038 0%, #12151a 100%);
  background-size: auto, 120px 120px, auto;
  box-shadow:
    inset 16px 14px 22px rgba(0, 0, 0, 0.55),
    inset -12px 10px 18px rgba(0, 0, 0, 0.35),
    inset 0 -12px 16px rgba(0, 0, 0, 0.4);
}

/* Innermost lip: acrylic pane. NASA states the innermost cone-window pane is acrylic. */
.acrylic {
  height: 100%;
  padding: clamp(5px, 0.45vw, 9px);
  border-radius: clamp(16px, 2.2vw, 36px);
  background-color: #2a3038;
  background-image:
    radial-gradient(ellipse at 50% 50%, rgba(228, 232, 238, calc(0.08 + var(--moon) * 0.42)) 52%, transparent 78%),
    var(--grain),
    linear-gradient(155deg, #8e98a4 0%, #3c444e 22%, #161a20 100%);
  background-size: auto, 90px 90px, auto;
  box-shadow:
    inset 6px 5px 10px rgba(0, 0, 0, 0.45),
    inset -4px 6px 8px rgba(0, 0, 0, 0.28),
    inset 0 1px 0 rgba(255, 255, 255, calc(0.16 + var(--moon) * 0.4)),
    inset 0 0 12px rgba(214, 220, 228, calc(var(--moon) * 0.28));
}

#glass {
  position: relative;
  height: 100%;
  border-radius: clamp(12px, 1.8vw, 30px);
  overflow: hidden;
  background: #000;
  box-shadow:
    inset 0 0 0 1px rgba(0, 0, 0, 0.65),
    inset 0 18px 28px rgba(0, 0, 0, 0.28);
}

#glass img {
  position: absolute;
  inset: -10%;
  width: 120%;
  height: 120%;
  object-fit: cover;
  opacity: 0;
  transform-origin: 50% 46%;
  will-change: transform, opacity;
}

.reflect {
  position: absolute;
  inset: -8%;
  background:
    linear-gradient(
      112deg,
      rgba(255, 255, 255, 0.07) 0%,
      rgba(255, 255, 255, 0.02) 14%,
      transparent 32%
    ),
    radial-gradient(
      ellipse 36% 22% at 28% 22%,
      rgba(255, 255, 255, 0.05),
      transparent 70%
    );
  mix-blend-mode: soft-light;
  opacity: 0.85;
  pointer-events: none;
}

.vignette {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse at center, transparent 48%, rgba(0, 0, 0, 0.28) 78%, rgba(0, 0, 0, 0.62) 100%);
  pointer-events: none;
}

#glance {
  position: absolute;
  z-index: 3;
  left: max(16px, 2vw);
  bottom: max(16px, 3vh);
  width: min(210px, 22vw);
  margin: 0;
  padding: 8px 8px 10px;
  background: rgba(12, 13, 16, 0.82);
  border: 1px solid rgba(244, 241, 234, 0.16);
  border-radius: 10px;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.45);
}

#glance img {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 4px;
}

#glance figcaption {
  margin-top: 6px;
  font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
  font-size: 11px;
  line-height: 1.35;
  color: rgba(244, 241, 234, 0.78);
}

#subs {
  position: absolute;
  left: 50%;
  bottom: 7%;
  z-index: 2;
  width: max-content;
  max-width: 62%;
  transform: translateX(-50%);
  text-align: center;
  pointer-events: none;
}

/* A dim that hugs the words. The wide plate across the Moon is gone.
   --plate only nudges this local shadow on a bright limb. */
#subs::before {
  content: "";
  position: absolute;
  z-index: -1;
  inset: -0.15em -0.35em;
  border-radius: 0.35em;
  background: rgba(0, 0, 0, calc(0.04 + var(--plate) * 0.16));
  filter: blur(5px);
}

#subs .who,
#subs .say {
  text-shadow:
    0 1px 1px rgba(0, 0, 0, 0.95),
    0 0 2px rgba(0, 0, 0, 0.9),
    0 0 6px rgba(0, 0, 0, 0.65),
    1px 0 0 rgba(0, 0, 0, 0.85),
    -1px 0 0 rgba(0, 0, 0, 0.85),
    0 1px 0 rgba(0, 0, 0, 0.85),
    0 -1px 0 rgba(0, 0, 0, 0.85);
  -webkit-text-stroke: 0.4px rgba(0, 0, 0, 0.78);
  paint-order: stroke fill;
}

#subs .who {
  display: block;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  font-size: 10px;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.88);
  font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
}

#subs .say {
  display: block;
  margin-top: 3px;
  font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
  font-weight: 400;
  font-size: clamp(14px, 1.45vw, 20px);
  line-height: 1.35;
  color: #f7f7f5;
}

#subs.dim { opacity: 0.5; }
#subs.mine .who { color: #fff; }

#credit, #empty {
  position: absolute;
  left: 16px;
  right: 16px;
  font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
  font-size: 11px;
  letter-spacing: 0.02em;
  color: rgba(244, 241, 234, 0.72);
  text-shadow: 0 1px 6px #000;
}

#credit { bottom: 10px; text-align: left; }

#taken {
  position: absolute;
  top: 12px;
  left: 16px;
  right: 16px;
  z-index: 3;
  font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
  font-size: 13px;
  line-height: 1.35;
  color: #f4f1ea;
  text-shadow: 0 1px 2px #000, 0 0 8px #000;
}

#taken:empty { display: none; }

/* Cab Cam already includes whatever the GoPro saw. A drawn bezel would invent hardware. */
#stage.cab #near,
#stage.cab .reflect,
#stage.cab .vignette { display: none; }

#stage.cab .thermal,
#stage.cab .pressure,
#stage.cab .acrylic {
  padding: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  filter: none;
}

#stage.cab #window {
  width: min(96vw, calc(100vh * 4 / 3));
  aspect-ratio: 4 / 3;
}

#stage.cab #glass {
  border-radius: 0;
  box-shadow: none;
}

#stage.cab #glass img {
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
}
#empty {
  top: 42%;
  text-align: center;
  font-size: 16px;
  line-height: 1.45;
}

#enter {
  position: absolute;
  z-index: 8;
  inset: 0;
  width: 100%;
  margin: 0;
  padding: 0 8vw;
  border: 0;
  border-radius: 0;
  background: #000;
  box-shadow: none;
  cursor: pointer;
  text-align: center;
  color: #f4f1ea;
  font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
  font-size: clamp(16px, 2.1vw, 22px);
  font-weight: 400;
  letter-spacing: 0.01em;
  transition: opacity 1s ease;
}

#enter.dismiss {
  opacity: 0;
  pointer-events: none;
}

#clocks {
  position: absolute;
  z-index: 5;
  top: 14px;
  right: 16px;
  max-width: min(28rem, calc(100% - 32px));
  padding: 4px 9px 5px;
  border-radius: 8px;
  /* A chip behind the three times only. Not a band across the frame. */
  background: rgba(0, 0, 0, 0.58);
  opacity: 0;
  pointer-events: none;
  font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.03em;
  line-height: 1.45;
  text-align: right;
  color: rgba(244, 241, 234, 0.94);
  text-shadow: 0 1px 1px rgba(0, 0, 0, 0.95);
}

#stage.live #clocks { opacity: 1; transition: opacity 1s ease 0.25s; }

#clocks span + span { margin-left: 0.75em; }
#met:empty { display: none; }

#hint {
  position: absolute;
  z-index: 5;
  left: 50%;
  bottom: 22px;
  transform: translateX(-50%);
  margin: 0;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.45);
  color: rgba(244, 241, 234, 0.82);
  font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
  font-size: 12px;
  letter-spacing: 0.02em;
  white-space: normal;
  text-align: center;
  max-width: 92vw;
  pointer-events: none;
  transition: opacity 600ms ease;
}

#hint.fade { opacity: 0; }

#stage.turning #cabin {
  transition: transform 220ms ease, filter 220ms ease;
}

#stage.turning.turn-out #cabin {
  transform: translateX(calc(var(--turn, 1) * -8%));
  filter: blur(7px);
}

#stage.turning.turn-in #cabin {
  transform: translateX(calc(var(--turn, 1) * 8%));
  filter: blur(7px);
  transition: none;
}

#glass { transition: opacity 180ms linear; }
#stage.xfade #glass { opacity: 0; }

.fine {
  font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

#hud {
  position: absolute;
  z-index: 4;
  inset: 0;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 18px;
  pointer-events: none;
  opacity: 0;
  transition: opacity 280ms ease;
}

#hud.show { opacity: 1; }

#hud .top, #hud .bottom { pointer-events: auto; }

.top, .bottom {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-end;
}

.crew, .cameras, .tracks, .row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

button[data-crew], button[data-cam], button[data-track], button[data-win], #play, #full, #cabrun, #backfly {
  border: 1px solid var(--line);
  background: rgba(8, 9, 12, 0.72);
  border-radius: 999px;
  padding: 6px 12px;
  cursor: pointer;
  font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
  font-size: 13px;
}

button.on, button[aria-pressed="true"] {
  background: #f4f1ea;
  color: #14151a;
  border-color: #f4f1ea;
}

.controls {
  flex: 1;
  background: rgba(8, 9, 12, 0.72);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

#scrub, #offset { flex: 1; accent-color: #f4f1ea; }
.offset {
  display: flex;
  gap: 10px;
  align-items: center;
  font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
  font-size: 13px;
}

#map {
  width: min(360px, 38vw);
  height: auto;
  background: rgba(8, 9, 12, 0.72);
  border: 1px solid var(--line);
  border-radius: 16px;
}

.fine { margin: 0; text-transform: none; letter-spacing: 0; line-height: 1.4; }

#stage:fullscreen #window,
#stage:-webkit-full-screen #window {
  width: min(98vw, calc(108vh * 1.58));
}

@media (max-width: 800px) {
  #window { width: min(118vw, calc(96vh * 1.58)); top: 50%; }
  #near { padding: 16px; border-radius: 28px; filter: blur(1.6px); }
  .thermal { padding: 10px; border-radius: 24px; }
  .pressure { padding: 7px; border-radius: 18px; }
  .acrylic { padding: 4px; border-radius: 12px; }
  .bottom { flex-direction: column; align-items: stretch; }
  #map { width: 100%; }
  #enter .title { font-size: 28px; }
  #glance { width: min(160px, 42vw); }
}

@media (prefers-reduced-motion: reduce) {
  #glass img, #wall, .reflect, #cabin { transform: none; filter: none; }
  #window { transform: translate(-50%, -50%); }
  #stage.live #cabin, #enter, #clocks, #hint { transition: none; }
  #stage.turning #cabin { filter: none; transform: none; }
}
