:root {
  --bg: #03040a;
  --fg: #e8ecff;
  --muted: #8a92b8;
  --accent: #6ea8ff;
  --accent-2: #b98cff;
  --panel: rgba(12, 16, 34, 0.55);
  --border: rgba(120, 150, 255, 0.18);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--fg);
  font-family: "Space Grotesk", system-ui, sans-serif;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

#scene {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  display: block;
  touch-action: none;
}

/* ---------- Warp arrival flash ---------- */
#flash {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: radial-gradient(ellipse at center, #ffffff 0%, #cfe0ff 70%, #a9c6ff 100%);
  opacity: 0;
  pointer-events: none;
  will-change: opacity;
}
#flash.fire { animation: warpflash 0.7s ease-out forwards; }
@keyframes warpflash {
  0% { opacity: 0; }
  10% { opacity: 0.95; }
  100% { opacity: 0; }
}

/* ---------- Beacon labels (nav) ---------- */
#labels {
  position: fixed;
  inset: 0;
  z-index: 15;
  pointer-events: none;
}
.beacon-label {
  position: absolute;
  transform: translate(-50%, -50%);
  font-family: "Orbitron", sans-serif;
  font-size: 11px;
  letter-spacing: 3px;
  color: var(--fg);
  white-space: nowrap;
  padding: 5px 12px;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: rgba(8, 12, 28, 0.5);
  backdrop-filter: blur(6px);
  text-shadow: 0 0 10px rgba(110, 168, 255, 0.6);
  transition: transform 0.2s, background 0.2s, color 0.2s;
}
.beacon-label.hot {
  color: #06081a;
  background: var(--fg);
  transform: translate(-50%, -50%) scale(1.12);
}

/* ---------- Page overlay ---------- */
#page {
  position: fixed;
  z-index: 20;
  left: clamp(20px, 5vw, 64px);
  top: 50%;
  transform: translateY(-50%) translateX(-30px);
  width: min(440px, 82vw);
  padding: 40px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 22px;
  backdrop-filter: blur(18px);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.5s, transform 0.5s, visibility 0.5s;
}
#page.show {
  opacity: 1;
  visibility: visible;
  transform: translateY(-50%) translateX(0);
  pointer-events: auto;
}
.page-close {
  font-family: "Orbitron", sans-serif;
  font-size: 11px;
  letter-spacing: 2px;
  padding: 9px 16px;
  border-radius: 40px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.04);
  color: var(--fg);
  cursor: pointer;
  margin-bottom: 24px;
  transition: transform 0.2s, border-color 0.2s;
}
.page-close:hover { transform: translateX(-3px); border-color: var(--accent); }
.page-title {
  font-family: "Orbitron", sans-serif;
  font-size: clamp(28px, 4vw, 36px);
  margin-bottom: 18px;
  background: linear-gradient(120deg, var(--accent), var(--accent-2));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.page-body { color: var(--muted); font-size: 16px; line-height: 1.75; white-space: pre-line; }

/* "message sent" confirmation */
.form-confirm {
  display: none;
  align-items: flex-start;
  gap: 10px;
  padding: 16px 18px;
  border-radius: 14px;
  border: 1px solid rgba(138, 255, 192, 0.4);
  background: rgba(60, 200, 130, 0.12);
  color: var(--fg);
  font-size: 14px;
  line-height: 1.5;
}
.form-confirm.show { display: flex; }
.confirm-check {
  flex: 0 0 auto;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #4fe08a;
  color: #06120a;
  font-weight: 700;
  font-size: 13px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* let the page scroll if the form makes it tall */
#page { max-height: 84vh; overflow-y: auto; }

/* alien-encoded page text */
#page.encoded .page-title,
#page.encoded .page-body { letter-spacing: 3px; }
#page.encoded .page-body {
  color: var(--accent);
  text-shadow: 0 0 12px rgba(110, 168, 255, 0.5);
}

#pageDecode { margin: 4px 0 20px; }

/* after sending, collapse the card to just Back + confirmation */
#page.sent .page-title,
#page.sent .page-body,
#page.sent #pageDecode { display: none; }

/* contact form */
.contact-form {
  display: none;
  flex-direction: column;
  gap: 12px;
}
.contact-form input,
.contact-form textarea {
  width: 100%;
  font-family: "Space Grotesk", sans-serif;
  font-size: 14px;
  color: var(--fg);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 14px;
  outline: none;
  resize: vertical;
  transition: border-color 0.2s, background 0.2s;
}
.contact-form input::placeholder,
.contact-form textarea::placeholder { color: var(--muted); }
.contact-form input:focus,
.contact-form textarea:focus {
  border-color: var(--accent);
  background: rgba(255, 255, 255, 0.07);
}
.transmit-btn {
  margin-top: 4px;
  font-family: "Orbitron", sans-serif;
  font-size: 13px;
  letter-spacing: 2px;
  padding: 13px 0;
  border-radius: 40px;
  border: none;
  cursor: pointer;
  color: #06081a;
  background: linear-gradient(120deg, var(--accent), var(--accent-2));
  box-shadow: 0 6px 24px rgba(110, 168, 255, 0.35);
  transition: transform 0.2s, box-shadow 0.25s;
}
.transmit-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 30px rgba(110, 168, 255, 0.5);
}

/* transmit → eject a pill that bullets toward the upper-right corner */
.launch-pill {
  position: fixed;
  width: 118px;
  height: 44px;
  margin-left: -59px;
  margin-top: -22px;
  border-radius: 40px;
  background: linear-gradient(120deg, var(--accent), var(--accent-2));
  box-shadow: 0 0 30px rgba(110, 168, 255, 0.85);
  z-index: 60;
  pointer-events: none;
  transform: translate(0, 0) scale(1) rotate(-45deg);
  opacity: 1;
  transition: transform 0.5s cubic-bezier(0.16, 0.84, 0.24, 1),
    opacity 0.5s ease-in;
}
/* speed streak trailing behind the pill */
.launch-pill::after {
  content: "";
  position: absolute;
  right: 100%;
  top: 50%;
  width: 30px;
  height: 6px;
  transform: translateY(-50%);
  background: linear-gradient(to left, rgba(185, 140, 255, 0.95), rgba(110, 168, 255, 0));
  border-radius: 6px;
  opacity: 0;
  transition: width 0.4s ease, opacity 0.3s ease;
}
.launch-pill.fire {
  transform: translate(85vw, -85vh) scale(0.28) rotate(-45deg);
  opacity: 0;
}
.launch-pill.fire::after { width: 170px; opacity: 1; }

/* the form recoils toward the corner as it "becomes" the pill */
.contact-form.eject {
  transition: transform 0.28s cubic-bezier(0.5, 0, 1, 0.4), opacity 0.28s ease-in;
  transform: translate(80px, -80px) scale(0.35) rotate(12deg);
  opacity: 0;
}

/* a fresh blank form springs back in (slight overshoot) */
@keyframes reappearForm {
  0% { opacity: 0; transform: translateY(18px) scale(0.9); }
  60% { opacity: 1; transform: translateY(-3px) scale(1.03); }
  100% { opacity: 1; transform: none; }
}
.contact-form.reappear { animation: reappearForm 0.55s cubic-bezier(0.2, 0.8, 0.2, 1); }

/* ignition flash */
.launch-flash {
  position: fixed;
  width: 64px;
  height: 64px;
  margin: -32px 0 0 -32px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.95), rgba(110, 168, 255, 0.5) 40%, rgba(110, 168, 255, 0));
  z-index: 62;
  pointer-events: none;
  transform: scale(0.2);
  opacity: 0.9;
  transition: transform 0.45s ease-out, opacity 0.45s ease-out;
}
.launch-flash.go { transform: scale(2.8); opacity: 0; }

/* transmit → multi-step: fold into a real capsule, arm it, launch across the sky */

/* Step 1 — collapse the panel into a true pill (animate real size, no squish) */
#page.folding {
  min-height: 0 !important;
  max-height: none !important;
  padding: 0;
  overflow: hidden;
  border-radius: 40px;
  background: linear-gradient(120deg, var(--accent), var(--accent-2));
  box-shadow: 0 0 42px rgba(110, 168, 255, 0.75);
  pointer-events: none;
  transition: width 1.05s cubic-bezier(0.85, 0, 0.15, 1),
    height 1.05s cubic-bezier(0.85, 0, 0.15, 1), border-radius 1.05s ease,
    background 0.7s ease, box-shadow 0.9s ease, padding 0.8s ease;
}
#page.folding > * {
  opacity: 0;
  transition: opacity 0.5s ease;
  pointer-events: none;
}

/* Step 2 — stand the pill up like a missile on the launch pad */
#page.ready {
  transition: transform 0.5s cubic-bezier(0.2, 0.85, 0.2, 1), box-shadow 0.5s ease;
  transform: translate3d(0, calc(-50% - 10px), 0) rotate(-82deg) scale(1.12);
  box-shadow: 0 0 72px rgba(110, 168, 255, 0.95), 0 0 30px rgba(185, 140, 255, 0.9);
}

/* Step 3 — rev: the primed missile vibrates with a hot glow */
@keyframes missileRev {
  0%, 100% { transform: translate3d(0, calc(-50% - 10px), 0) rotate(-82deg) scale(1.12); }
  25% { transform: translate3d(1px, calc(-50% - 12px), 0) rotate(-82.6deg) scale(1.12); }
  50% { transform: translate3d(-1px, calc(-50% - 9px), 0) rotate(-81.4deg) scale(1.13); }
  75% { transform: translate3d(1px, calc(-50% - 10px), 0) rotate(-82deg) scale(1.12); }
}
#page.arming {
  animation: missileRev 0.09s linear infinite;
  box-shadow: 0 0 95px rgba(110, 168, 255, 1), 0 0 42px rgba(185, 140, 255, 1);
}

/* chamber, then fire the pill straight into the screen like a bullet */
@keyframes bulletIn {
  0% {
    transform: perspective(650px) translate3d(0, -50%, 0) scale(1);
    opacity: 1;
    filter: blur(0px);
    animation-timing-function: cubic-bezier(0.25, 0, 0.5, 1); /* quick chamber */
  }
  16% {
    /* chamber — kick toward the viewer and swell, loading the shot */
    transform: perspective(650px) translate3d(0, -50%, 230px) scale(1.22);
    opacity: 1;
    filter: blur(0px);
    animation-timing-function: cubic-bezier(0.85, 0, 1, 1); /* FIRE — hard acceleration */
  }
  100% {
    /* slam straight into the screen, shrinking to nothing */
    transform: perspective(650px) translate3d(0, -50%, -8000px) scale(1);
    opacity: 0;
    filter: blur(10px);
  }
}
#page.launching {
  overflow: visible;
  transform-style: preserve-3d;
  animation: bulletIn 0.28s forwards;
  box-shadow: 0 0 90px rgba(110, 168, 255, 1);
}

/* spark particles */
.spark {
  position: fixed;
  width: 8px;
  height: 8px;
  margin: -4px 0 0 -4px;
  border-radius: 50%;
  background: radial-gradient(circle, #ffffff, var(--accent-2));
  box-shadow: 0 0 10px var(--accent);
  z-index: 61;
  pointer-events: none;
  opacity: 1;
  transform: translate(0, 0) scale(1);
  transition: transform 0.6s cubic-bezier(0.1, 0.7, 0.2, 1), opacity 0.6s ease-out;
}

@media (max-width: 720px) {
  #page { top: auto; bottom: 80px; transform: translateX(-30px); width: calc(100vw - 40px); left: 20px; padding: 26px; }
  #page.show { transform: translateX(0); }
}

/* ---------- Loader ---------- */
#loader {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 26px;
  background: radial-gradient(ellipse at center, #0a1030 0%, #03040a 70%);
  transition: opacity 0.9s ease, visibility 0.9s ease;
}
#loader.hidden { opacity: 0; visibility: hidden; }
.loader-ring {
  width: 62px; height: 62px;
  border-radius: 50%;
  border: 2px solid rgba(110, 168, 255, 0.15);
  border-top-color: var(--accent);
  border-right-color: var(--accent-2);
  animation: spin 0.9s linear infinite;
}
.loader-text {
  font-family: "Orbitron", sans-serif;
  font-size: 12px;
  letter-spacing: 4px;
  color: var(--muted);
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- UI overlay ---------- */
#ui {
  position: fixed;
  inset: 0;
  z-index: 10;
  pointer-events: none;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding: 28px clamp(20px, 5vw, 64px);
}
#ui a, #ui button { pointer-events: auto; }

/* Return-to-Sol button (only visible after a warp jump) */
.return-btn {
  position: absolute;
  top: 28px;
  left: clamp(20px, 5vw, 64px);
  font-family: "Orbitron", sans-serif;
  font-size: 12px;
  letter-spacing: 2px;
  padding: 11px 20px;
  border-radius: 40px;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--fg);
  backdrop-filter: blur(10px);
  cursor: pointer;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s, visibility 0.3s, transform 0.2s, border-color 0.2s;
}
.return-btn:hover { transform: translateX(-3px); border-color: var(--accent); }
.return-btn.show { opacity: 1; visibility: visible; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.brand {
  font-family: "Orbitron", sans-serif;
  font-weight: 900;
  font-size: 20px;
  letter-spacing: 6px;
  display: flex;
  align-items: center;
  gap: 12px;
}
.logo-dot {
  width: 12px; height: 12px;
  border-radius: 50%;
  background: radial-gradient(circle at 30% 30%, #fff, var(--accent) 60%, var(--accent-2));
  box-shadow: 0 0 18px var(--accent);
}
.nav { display: flex; gap: 26px; }
.nav a {
  color: var(--muted);
  text-decoration: none;
  font-size: 13px;
  letter-spacing: 2px;
  text-transform: uppercase;
  transition: color 0.25s;
  position: relative;
}
.nav a::after {
  content: "";
  position: absolute; left: 0; bottom: -6px;
  width: 0; height: 1px; background: var(--accent);
  transition: width 0.25s;
}
.nav a:hover { color: var(--fg); }
.nav a:hover::after { width: 100%; }

/* Hero */
.hero { max-width: 560px; }
.eyebrow {
  font-family: "Orbitron", sans-serif;
  font-size: 11px;
  letter-spacing: 5px;
  color: var(--accent);
  margin-bottom: 22px;
}
.hero h1 {
  font-family: "Orbitron", sans-serif;
  font-weight: 700;
  font-size: clamp(44px, 8vw, 92px);
  line-height: 0.95;
  letter-spacing: -1px;
}
.hero h1 span {
  background: linear-gradient(120deg, var(--accent), var(--accent-2));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.lede {
  margin: 24px 0 32px;
  color: var(--muted);
  font-size: 16px;
  line-height: 1.7;
  max-width: 440px;
}
.cta-row { display: flex; gap: 14px; }
.btn {
  font-family: "Space Grotesk", sans-serif;
  font-size: 14px;
  letter-spacing: 1px;
  padding: 13px 26px;
  border-radius: 40px;
  border: 1px solid var(--border);
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.25s, background 0.25s;
}
.btn:hover { transform: translateY(-2px); }
.btn.primary {
  background: linear-gradient(120deg, var(--accent), var(--accent-2));
  color: #06081a;
  font-weight: 500;
  border: none;
  box-shadow: 0 6px 30px rgba(110, 168, 255, 0.4);
}
.btn.ghost {
  background: rgba(255, 255, 255, 0.03);
  color: var(--fg);
  backdrop-filter: blur(6px);
}
.btn.ghost:hover { background: rgba(255, 255, 255, 0.08); }

/* Planet info panel */
.planet-panel {
  position: absolute;
  right: clamp(20px, 5vw, 64px);
  top: 50%;
  transform: translateY(-50%) translateX(30px);
  width: 300px;
  padding: 26px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 18px;
  backdrop-filter: blur(16px);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.4s, transform 0.4s, visibility 0.4s;
  pointer-events: none;
}
.planet-panel.show {
  opacity: 1;
  visibility: visible;
  transform: translateY(-50%) translateX(0);
}
.panel-index {
  font-family: "Orbitron", sans-serif;
  font-size: 13px;
  color: var(--accent);
  letter-spacing: 3px;
}
.panel-name {
  font-family: "Orbitron", sans-serif;
  font-size: 30px;
  margin: 6px 0 18px;
  letter-spacing: 1px;
}
.panel-stats { display: flex; flex-direction: column; gap: 12px; }
.stat {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  padding-bottom: 10px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}
.stat .k { color: var(--muted); letter-spacing: 1px; }
.stat .v { color: var(--fg); font-variant-numeric: tabular-nums; }

/* alien-encoded state */
.planet-panel.encoded .panel-name,
.planet-panel.encoded .panel-index,
.planet-panel.encoded .stat .k,
.planet-panel.encoded .stat .v {
  letter-spacing: 3px;
  color: var(--accent);
  text-shadow: 0 0 12px rgba(110, 168, 255, 0.55);
}
.planet-panel.encoded .stat .v { color: var(--accent-2); }

.decode-btn {
  margin-top: 8px;
  width: 100%;
  font-family: "Orbitron", sans-serif;
  font-size: 12px;
  letter-spacing: 2px;
  padding: 11px 0;
  border-radius: 40px;
  border: 1px solid var(--border);
  background: linear-gradient(120deg, rgba(110, 168, 255, 0.18), rgba(185, 140, 255, 0.18));
  color: var(--fg);
  cursor: pointer;
  transition: transform 0.2s, border-color 0.2s, background 0.25s;
}
.decode-btn:hover {
  transform: translateY(-2px);
  border-color: var(--accent);
  background: linear-gradient(120deg, rgba(110, 168, 255, 0.32), rgba(185, 140, 255, 0.32));
}

/* Status bar */
.statusbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-family: "Orbitron", sans-serif;
  font-size: 11px;
  letter-spacing: 2px;
  color: var(--muted);
}
.statusbar .hint { color: rgba(138, 146, 184, 0.6); font-size: 10px; }

@media (max-width: 720px) {
  .nav { display: none; }
  .planet-panel { display: none; }
  .statusbar .hint { display: none; }
  #ui { padding: 20px; }
}
