/* Scroll-driven 3D aircraft build (assets/aircraft3d.js) */

/* Full-bleed scroll section: the base `section` padding would offset the track
   against the sticky pane and push p=1 past the point where it unpins. */
.build3d { position: relative; padding: 0; }

/* The track is the scroll distance; the sticky pane is what you actually see. */
.build3d-track { position: relative; height: 520vh; }

.build3d-sticky {
  position: sticky;
  top: 0;
  height: 100vh;
  overflow: hidden;
  background:
    radial-gradient(1100px 620px at 70% 8%, var(--stage-glow-1), transparent 62%),
    radial-gradient(900px 560px at 12% 82%, var(--stage-glow-2), transparent 60%),
    linear-gradient(180deg, var(--bg), var(--stage-mid) 60%, var(--bg));
}

.build3d-sticky canvas {
  display: block;
  width: 100%;
  height: 100%;
  /* Nothing to see until the script has a frame ready. */
  opacity: 0;
  transition: opacity .6s var(--ease);
}
.build3d.ready3d .build3d-sticky canvas { opacity: 1; }

/* ---------- overlay chrome ---------- */
.build3d-overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: clamp(22px, 4vw, 54px);
  /* The site header is sticky and sits above this pane, so the kicker needs to
     clear it or it gets sliced in half while the section is pinned. */
  padding-top: calc(clamp(22px, 4vw, 54px) + 78px);
}

/* No CSS transition: the script sets this opacity every scroll frame, so a
   transition on top only lags behind and can stall if frames are throttled. */
.build3d-head { max-width: 42ch; }
.build3d-head .kicker {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.17em;
  text-transform: uppercase;
  color: var(--orange);
  margin-bottom: 12px;
}
.build3d-head .kicker::before {
  content: "";
  width: 22px; height: 2px;
  border-radius: 2px;
  background: var(--grad);
}
.build3d-head h2 {
  font-size: clamp(1.6rem, 3.4vw, 2.6rem);
  line-height: 1.1;
  letter-spacing: -0.028em;
  margin: 0;
  text-shadow: var(--stage-text-shadow);
}

/* The closing camera fills the lower frame with the red carpet, so the readout
   sits on a near-solid card of the page ground with a hairline edge, and its text
   carries a crisp graphite border (not a soft glow — that bloomed over the red).
   paint-order keeps the fill on top so the border never thins the letters. */
.build3d-hud {
  max-width: 46ch;
  width: max-content;
  padding: 12px 16px;
  border-radius: 12px;
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  border: 1px solid var(--line);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}
.build3d-phase, .build3d-caption {
  -webkit-text-stroke: 0.6px color-mix(in srgb, var(--ink) 62%, transparent);
  paint-order: stroke fill;
  text-shadow: none;
}
.build3d-phase {
  display: block;
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--orange);
  margin-bottom: 6px;
}
.build3d-caption {
  margin: 0 0 16px;
  color: var(--ink-dim);
  font-size: 0.96rem;
  /* No glow — the caption sits on the opaque HUD card and carries the graphite
     border set above; the soft stage shadow bloomed over the red carpet. */
  min-height: 2.9em;
}
.build3d-progress {
  height: 2px;
  width: min(420px, 60vw);
  background: var(--line-2);
  border-radius: 2px;
  overflow: hidden;
}
.build3d-progress i {
  display: block;
  height: 100%;
  background: var(--grad);
  transform: scaleX(0);
  transform-origin: left center;
}

/* ---------- fallback when WebGL is unavailable ---------- */
.build3d-fallback {
  display: none;
  position: absolute;
  inset: 0;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 20px;
  text-align: center;
  padding: 40px;
}
.build3d-fallback p {
  max-width: 46ch;
  color: var(--ink-dim);
  margin: 0;
}
.build3d.no3d .build3d-track { height: 60vh; }
.build3d.no3d .build3d-sticky canvas,
.build3d.no3d .build3d-hud { display: none; }
.build3d.no3d .build3d-fallback { display: flex; }

/* ---------- reduced motion: no scroll hijack, just the finished frame ---------- */
.build3d.static3d .build3d-track { height: 100vh; }
.build3d.static3d .build3d-progress { display: none; }

@media (max-width: 900px) {
  .build3d-track { height: 420vh; }
  .build3d-caption { font-size: 0.9rem; }
}

/* A phone frame is about 1:2.2. Fitting a 99-unit wingspan across that width forces
   the camera so far back that the aircraft occupies a fifth of the screen and the
   rest is void. Letterboxing the canvas gives the camera a sane aspect to solve for,
   and the overlay copy uses the space that frees up. */
@media (orientation: portrait) and (max-width: 820px) {
  .build3d-sticky canvas {
    height: 72%;
    margin-top: 14%;
  }
}
@media (max-width: 560px) {
  .build3d-track { height: 360vh; }
  .build3d-head h2 { font-size: 1.45rem; }
  .build3d-caption { min-height: 3.6em; }
}
