/* ============================================================
   Sun's Life-Cycle Flipbook — NASA telescope redesign
   ============================================================
   Aesthetic: Hubble / JWST / SDO image releases.
   Pure black, monospace HUD chrome, granulated solar surface,
   real-feeling star fields, telemetry strip + caption card.
   ============================================================ */

:root {
  --hud-ink: #c8d4e6;
  --hud-dim: #6a7a8e;
  --hud-amber: #ffb347;
  --hud-cyan: #6ad5ff;
  --hud-line: rgba(170, 200, 230, 0.18);
  --hud-line-strong: rgba(170, 200, 230, 0.42);
  --story-ink: #f4ecdc;
  --story-dim: rgba(244, 236, 220, 0.62);
  --bg: #03050a;
}

/* ---------- Launch button (lives on the Sun detail page) ---------- */
.lifecycle-launch {
  position: absolute;
  top: 18px;
  right: 18px;
  z-index: 35;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  background: rgba(8, 10, 16, 0.78);
  border: 1px solid var(--hud-line-strong);
  color: var(--hud-ink);
  font-family:
    "Inter",
    ui-sans-serif,
    system-ui,
    -apple-system,
    sans-serif;
  font-size: 11px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  padding: 10px 16px 10px 12px;
  border-radius: 2px;
  cursor: pointer;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  transition: all 0.2s ease;
}
.lifecycle-launch:hover {
  border-color: var(--hud-amber);
  color: #fff;
  box-shadow:
    0 0 0 1px rgba(255, 179, 71, 0.35),
    0 8px 32px rgba(255, 179, 71, 0.18);
}
.lifecycle-launch .launch-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--hud-amber);
  box-shadow: 0 0 8px var(--hud-amber);
  animation: hud-pulse 2s ease-in-out infinite;
}
@keyframes hud-pulse {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.4;
  }
}

/* ---------- Overlay ---------- */
.lifecycle-overlay {
  position: fixed;
  inset: 0;
  z-index: 80;
  background: var(--bg);
  display: grid;
  grid-template-rows: auto 1fr auto;
  cursor: pointer;
  animation: fade-in 0.5s ease;
  overflow: hidden;
  font-family:
    "Inter",
    ui-sans-serif,
    system-ui,
    -apple-system,
    sans-serif;
  color: var(--story-ink);
}
@keyframes fade-in {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

/* Subtle vignette so the edges feel telescope-y */
.lifecycle-overlay::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: none;
  z-index: 50;
}

/* ============================================================
   TOP HUD STRIP — telemetry / instrument / timestamp
   ============================================================ */
.hud-top {
  position: relative;
  z-index: 60;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 24px;
  padding: 16px 24px 14px;
  border-bottom: 1px solid var(--hud-line);
  font-family:
    "Inter",
    ui-sans-serif,
    system-ui,
    -apple-system,
    sans-serif;
  font-size: 10.5px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--hud-dim);
  background: linear-gradient(
    180deg,
    rgba(8, 10, 16, 0.85),
    rgba(8, 10, 16, 0.55)
  );
}
.hud-top .hud-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--hud-ink);
}
.hud-top .hud-brand .brand-mark {
  width: 22px;
  height: 22px;
  border: 1px solid var(--hud-line-strong);
  border-radius: 50%;
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.hud-top .hud-brand .brand-mark::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--hud-amber);
  box-shadow: 0 0 6px var(--hud-amber);
}
.hud-top .hud-brand .brand-mark::after {
  content: "";
  position: absolute;
  inset: -4px;
  border: 1px solid var(--hud-line);
  border-radius: 50%;
  opacity: 0.5;
}
.hud-top .hud-brand .brand-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  line-height: 1;
}
.hud-top .hud-brand .brand-text .lg {
  font-size: 11.5px;
  letter-spacing: 0.32em;
  color: #fff;
}
.hud-top .hud-brand .brand-text .sm {
  font-size: 9.5px;
  color: var(--hud-dim);
  letter-spacing: 0.24em;
}

.hud-top .hud-mid {
  display: flex;
  justify-content: center;
  gap: 28px;
  flex-wrap: wrap;
}
.hud-top .hud-mid .kv {
  display: inline-flex;
  gap: 8px;
}
.hud-top .hud-mid .kv .k {
  color: var(--hud-dim);
}
.hud-top .hud-mid .kv .v {
  color: var(--hud-ink);
}

.hud-top .hud-right {
  display: inline-flex;
  align-items: center;
  gap: 14px;
}
.hud-top .hud-right .rec {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--hud-amber);
}
.hud-top .hud-right .rec .dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--hud-amber);
  box-shadow: 0 0 8px var(--hud-amber);
  animation: hud-pulse 1.4s ease-in-out infinite;
}
.hud-top .hud-right .frame-num {
  color: #fff;
}

/* ============================================================
   CENTER STAGE — image area
   ============================================================ */
.lifecycle-stage-wrap {
  position: relative;
  display: grid;
  place-items: center;
  overflow: hidden;
}

.starfield-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  pointer-events: none;
}
/* When inside the overlay (not the stage-wrap), cover the entire viewport behind everything */
.lifecycle-overlay > .starfield-canvas {
  position: fixed;
}

/* Stage container - no border, no ticks, no chrome around the image.
   The scenes bleed naturally into the starfield background. */
.lifecycle-plate {
  position: relative;
  width: min(92vmin, 920px);
  height: min(92vmin, 920px);
  display: grid;
  place-items: center;
  z-index: 2;
}
/* Full-frame scenes (nebula, white dwarf) cover the entire stage — no centered plate */
.lifecycle-plate.is-fullframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  max-width: none;
  z-index: 1;
}
.plate-tick {
  display: none;
}
.plate-crosshair {
  display: none;
}
.scene-stack {
  position: relative;
  width: 100%;
  height: 100%;
}
.scene-stack > * {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}
/* For full-frame scenes (nebula, planetary nebula), the canvas IS the image.
   For sun-disk scenes, the Three.js canvas is transparent so the starfield shows through. */
.scene-canvas {
  display: block;
  background: transparent;
  width: 100%;
  height: 100%;
  /* Disk-mode (default): soft radial mask so the rectangular painting fades into the starfield */
  -webkit-mask-image: radial-gradient(
    circle at 50% 50%,
    #000 35%,
    rgba(0, 0, 0, 0.85) 55%,
    rgba(0, 0, 0, 0.3) 78%,
    transparent 100%
  );
  mask-image: radial-gradient(
    circle at 50% 50%,
    #000 35%,
    rgba(0, 0, 0, 0.85) 55%,
    rgba(0, 0, 0, 0.3) 78%,
    transparent 100%
  );
  object-fit: cover;
}
/* Full-frame scenes (nebula, white dwarf) — the painting IS the entire backdrop, no mask, no plate edge */
.lifecycle-plate.is-fullframe .scene-canvas {
  -webkit-mask-image: none;
  mask-image: none;
}
.three-canvas {
  display: block;
  background: transparent;
}
.three-canvas,
.three-canvas > canvas {
  /* Soft mask on Three.js output — fades the square canvas edge into the starfield.
     "closest-side" makes the gradient radius equal to half the canvas width (the inscribed circle), 
     so the gradient terminates precisely at the canvas edges in a true circle. */
  -webkit-mask-image: radial-gradient(
    circle closest-side at 50% 50%,
    #000 70%,
    rgba(0, 0, 0, 0.6) 88%,
    transparent 100%
  );
  mask-image: radial-gradient(
    circle closest-side at 50% 50%,
    #000 70%,
    rgba(0, 0, 0, 0.6) 88%,
    transparent 100%
  );
}
.orbits-svg {
  pointer-events: none;
}

/* Scale bar */
.plate-scale {
  position: absolute;
  bottom: -28px;
  left: 0;
  font-family: "Inter", ui-sans-serif, system-ui, sans-serif;
  font-size: 9.5px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--hud-dim);
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.plate-scale .bar {
  display: flex;
  align-items: center;
  gap: 6px;
}
.plate-scale .bar .line {
  display: inline-block;
  width: 80px;
  height: 1px;
  background: var(--hud-line-strong);
  position: relative;
}
.plate-scale .bar .line::before,
.plate-scale .bar .line::after {
  content: "";
  position: absolute;
  top: -3px;
  width: 1px;
  height: 7px;
  background: var(--hud-line-strong);
}
.plate-scale .bar .line::before {
  left: 0;
}
.plate-scale .bar .line::after {
  right: 0;
}

/* Filter / instrument badge bottom-right of plate */
.plate-instrument {
  position: absolute;
  bottom: -28px;
  right: 0;
  font-family: "Inter", ui-sans-serif, system-ui, sans-serif;
  font-size: 9.5px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--hud-dim);
  display: inline-flex;
  gap: 16px;
}
.plate-instrument .pip {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  display: inline-block;
  margin-right: 6px;
  vertical-align: -1px;
}

/* ============================================================
   THE SUN — SVG-based, with granulation, limb, prominences, corona
   ============================================================ */
.sun-svg {
  width: 100%;
  height: 100%;
  display: block;
  overflow: visible;
}

.sun-disk {
  transition:
    r 0.9s cubic-bezier(0.4, 0, 0.2, 1),
    cx 0.9s cubic-bezier(0.4, 0, 0.2, 1),
    cy 0.9s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Orbit dots — Mercury, Venus, Earth */
.orbit-ring {
  fill: none;
  stroke: rgba(170, 200, 230, 0.15);
  stroke-width: 1;
  stroke-dasharray: 2 4;
  transition: opacity 0.7s ease;
}
.orbit-dot {
  transition:
    transform 0.9s cubic-bezier(0.4, 0, 0.2, 1),
    opacity 0.7s ease;
}
.orbit-label {
  font-family: "Inter", ui-sans-serif, system-ui, sans-serif;
  font-size: 8.5px;
  letter-spacing: 0.2em;
  fill: var(--hud-dim);
  text-transform: uppercase;
  transition: opacity 0.7s ease;
}

/* ============================================================
   BOTTOM CAPTION CARD
   ============================================================ */
.hud-bottom {
  position: relative;
  z-index: 60;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: end;
  padding: 18px 24px 22px;
  border-top: 1px solid var(--hud-line);
  background: linear-gradient(
    0deg,
    rgba(8, 10, 16, 0.92),
    rgba(8, 10, 16, 0.55)
  );
  gap: 24px;
}

.caption-card {
  grid-column: 2;
  max-width: 720px;
  text-align: center;
  pointer-events: none;
}
.caption-when {
  display: inline-block;
  font-family: "Inter", ui-sans-serif, system-ui, sans-serif;
  font-size: 10px;
  letter-spacing: 0.32em;
  text-transform: uppercase;
  color: var(--hud-amber);
  padding: 4px 10px;
  border: 1px solid rgba(255, 179, 71, 0.4);
  border-radius: 2px;
  margin-bottom: 14px;
}
.caption-text {
  font-family: "Fraunces", "Iowan Old Style", Georgia, serif;
  font-size: clamp(20px, 2.2vw, 26px);
  line-height: 1.4;
  font-weight: 400;
  color: var(--story-ink);
  text-wrap: pretty;
  text-shadow: 0 2px 22px rgba(0, 0, 0, 0.9);
}

.lifecycle-back {
  grid-column: 1;
  justify-self: start;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: transparent;
  border: 1px solid var(--hud-line-strong);
  color: var(--hud-ink);
  font-family: "Inter", ui-sans-serif, system-ui, sans-serif;
  font-size: 10.5px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  padding: 9px 14px;
  border-radius: 2px;
  cursor: pointer;
  backdrop-filter: blur(8px);
  transition: all 0.2s ease;
}
.lifecycle-back:hover {
  border-color: #fff;
  color: #fff;
  background: rgba(255, 255, 255, 0.04);
}

.tap-hint {
  grid-column: 3;
  justify-self: end;
  align-self: center;
  font-family: "Inter", ui-sans-serif, system-ui, sans-serif;
  font-size: 10px;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  color: var(--hud-dim);
  display: inline-flex;
  align-items: center;
  gap: 10px;
  pointer-events: none;
}
.tap-hint .arrow {
  display: inline-block;
  width: 22px;
  height: 1px;
  background: var(--hud-dim);
  position: relative;
}
.tap-hint .arrow::after {
  content: "";
  position: absolute;
  right: 0;
  top: 50%;
  width: 6px;
  height: 6px;
  border-top: 1px solid var(--hud-dim);
  border-right: 1px solid var(--hud-dim);
  transform: translateY(-50%) rotate(45deg);
}

/* progress dots */
.progress-row {
  position: absolute;
  top: 50%;
  left: 18px;
  transform: translateY(-50%);
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 60;
  pointer-events: none;
}
.progress-row .step {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: "Inter", ui-sans-serif, system-ui, sans-serif;
  font-size: 9px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--hud-dim);
  transition: color 0.4s ease;
}
.progress-row .step .num {
  display: inline-block;
  width: 20px;
  font-variant-numeric: tabular-nums;
}
.progress-row .step .pip {
  width: 8px;
  height: 8px;
  border: 1px solid var(--hud-line-strong);
  border-radius: 50%;
  transition: all 0.4s ease;
}
.progress-row .step.is-active {
  color: #fff;
}
.progress-row .step.is-active .pip {
  background: var(--hud-amber);
  border-color: var(--hud-amber);
  box-shadow: 0 0 10px var(--hud-amber);
}
.progress-row .step.is-past .pip {
  background: var(--hud-line-strong);
  border-color: var(--hud-line-strong);
}

/* ============================================================
   Mobile clamps
   ============================================================ */
@media (max-width: 720px) {
  .hud-top {
    grid-template-columns: 1fr auto;
    gap: 12px;
    padding: 12px 14px;
    font-size: 9.5px;
  }
  .hud-top .hud-mid {
    display: none;
  }
  .lifecycle-plate {
    width: min(82vmin, 520px);
    height: min(82vmin, 520px);
  }
  .hud-bottom {
    grid-template-columns: 1fr;
    gap: 14px;
    padding: 14px 16px 18px;
  }
  .caption-card {
    grid-column: 1;
  }
  .lifecycle-back {
    grid-column: 1;
    justify-self: center;
  }
  .tap-hint {
    grid-column: 1;
    justify-self: center;
  }
  .progress-row {
    left: 8px;
    gap: 6px;
  }
  .progress-row .step .num,
  .progress-row .step .label {
    display: none;
  }
  .caption-text {
    font-size: 18px;
  }
}
