/* Celestia — deep-space theme with frosted glass panels. */

:root {
  --bg: #05060f;
  --ink: #e9ecff;
  --muted: #9aa3c7;
  --violet: #8b5cf6;
  --cyan: #22d3ee;
  --gold: #f5c97b;
  --glass: rgba(255, 255, 255, 0.045);
  --stroke: rgba(255, 255, 255, 0.09);
}

* { box-sizing: border-box; }

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  font-weight: 300;
  line-height: 1.65;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, .logo, .btn, .fact-num {
  font-family: "Space Grotesk", "Inter", system-ui, sans-serif;
}

#cosmos {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: -1;
  display: block;
  background: var(--bg);
}

#progress {
  position: fixed;
  top: 0;
  left: 0;
  height: 3px;
  width: 100%;
  transform: scaleX(0);
  transform-origin: 0 50%;
  background: linear-gradient(90deg, var(--violet), var(--cyan), var(--gold));
  z-index: 50;
  box-shadow: 0 0 18px rgba(34, 211, 238, 0.55);
}

/* ---------- navigation ---------- */
.nav {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.1rem clamp(1.2rem, 4vw, 3.4rem);
  backdrop-filter: blur(10px);
  background: linear-gradient(180deg, rgba(5, 6, 15, 0.72), transparent);
}

.logo {
  font-weight: 700;
  letter-spacing: 0.28em;
  font-size: 0.85rem;
  color: #fff;
  text-shadow: 0 0 18px rgba(139, 92, 246, 0.8);
}

.nav nav { display: flex; gap: 1.6rem; }

.nav a {
  color: var(--muted);
  text-decoration: none;
  font-size: 0.85rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  transition: color 0.25s ease;
}

.nav a:hover { color: #fff; }

/* ---------- hero ---------- */
.hero {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 6rem clamp(1.2rem, 5vw, 3rem) 4rem;
  position: relative;
}

.eyebrow {
  font-size: 0.78rem;
  letter-spacing: 0.34em;
  text-transform: uppercase;
  color: var(--cyan);
  margin: 0 0 1.2rem;
  text-shadow: 0 0 20px rgba(34, 211, 238, 0.6);
}

.hero h1 {
  margin: 0;
  font-size: clamp(3.2rem, 13vw, 9.5rem);
  font-weight: 700;
  letter-spacing: 0.06em;
  line-height: 0.95;
  background: linear-gradient(180deg, #ffffff 0%, #c9b8ff 55%, #6d7dff 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 0 42px rgba(139, 92, 246, 0.55));
}

.lede {
  max-width: 34rem;
  margin: 1.8rem auto 0;
  color: var(--muted);
  font-size: clamp(0.98rem, 1.6vw, 1.15rem);
}

.cta {
  display: flex;
  gap: 1rem;
  margin-top: 2.4rem;
  flex-wrap: wrap;
  justify-content: center;
}

.btn {
  display: inline-block;
  padding: 0.85rem 1.7rem;
  border-radius: 999px;
  text-decoration: none;
  font-size: 0.9rem;
  letter-spacing: 0.08em;
  border: 1px solid transparent;
  transition: transform 0.25s ease, box-shadow 0.25s ease, background 0.25s ease;
}

.btn.primary {
  color: #06070f;
  background: linear-gradient(120deg, #c9b8ff, #8b5cf6 45%, #22d3ee);
  box-shadow: 0 0 34px rgba(139, 92, 246, 0.55);
}

.btn.ghost {
  color: var(--ink);
  border-color: var(--stroke);
  background: var(--glass);
  backdrop-filter: blur(8px);
}

.btn:hover { transform: translateY(-3px); }
.btn.primary:hover { box-shadow: 0 0 52px rgba(34, 211, 238, 0.6); }
.btn.ghost:hover { background: rgba(255, 255, 255, 0.1); }

.hint {
  margin-top: 2.6rem;
  font-size: 0.76rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: rgba(154, 163, 199, 0.7);
}

.scroll-cue {
  position: absolute;
  bottom: 2rem;
  left: 50%;
  transform: translateX(-50%);
  width: 24px;
  height: 40px;
  border: 1px solid var(--stroke);
  border-radius: 999px;
  display: flex;
  justify-content: center;
  padding-top: 7px;
}

.scroll-cue span {
  width: 4px;
  height: 8px;
  border-radius: 999px;
  background: var(--cyan);
  box-shadow: 0 0 12px var(--cyan);
  animation: fall 1.8s ease-in-out infinite;
}

@keyframes fall {
  0% { transform: translateY(0); opacity: 0; }
  35% { opacity: 1; }
  100% { transform: translateY(16px); opacity: 0; }
}

/* ---------- sections ---------- */
.section {
  max-width: 1180px;
  margin: 0 auto;
  padding: clamp(4rem, 9vw, 8rem) clamp(1.2rem, 4vw, 3rem);
}

.section h2 {
  font-size: clamp(1.9rem, 4.5vw, 3rem);
  font-weight: 700;
  letter-spacing: 0.01em;
  margin: 0 0 0.6rem;
  background: linear-gradient(120deg, #ffffff, #b9a7ff 60%, #22d3ee);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.section-sub {
  color: var(--muted);
  margin: 0 0 3rem;
  max-width: 40rem;
}

.grid { display: grid; gap: 1.4rem; }

.planets {
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
}

.facts {
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

/* ---------- cards ---------- */
.planet-card,
.fact-card {
  position: relative;
  background: var(--glass);
  border: 1px solid var(--stroke);
  border-radius: 20px;
  padding: 1.6rem 1.4rem 1.7rem;
  backdrop-filter: blur(12px);
  transition: transform 0.35s cubic-bezier(0.2, 0.7, 0.2, 1), box-shadow 0.35s ease,
    border-color 0.35s ease;
  overflow: hidden;
}

.planet-card::before,
.fact-card::before {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(
    120% 120% at 50% 0%,
    rgba(139, 92, 246, 0.22),
    transparent 60%
  );
  opacity: 0;
  transition: opacity 0.35s ease;
  pointer-events: none;
}

.planet-card:hover,
.fact-card:hover {
  transform: translateY(-7px);
  border-color: rgba(139, 92, 246, 0.5);
  box-shadow: 0 24px 50px -20px rgba(88, 60, 200, 0.75);
}

.planet-card:hover::before,
.fact-card:hover::before { opacity: 1; }

.planet-icon {
  display: block;
  margin: 0 auto 1rem;
  width: 140px;
  height: 140px;
  filter: drop-shadow(0 12px 28px rgba(0, 0, 0, 0.55));
}

.planet-card h3 {
  margin: 0 0 0.4rem;
  font-size: 1.15rem;
  font-weight: 500;
  text-align: center;
  letter-spacing: 0.03em;
}

.planet-card p {
  margin: 0;
  font-size: 0.88rem;
  color: var(--muted);
  text-align: center;
}

.fact-card { padding-top: 2rem; }

.fact-num {
  display: block;
  font-size: clamp(1.8rem, 4vw, 2.6rem);
  font-weight: 700;
  background: linear-gradient(120deg, var(--cyan), #ffffff 50%, var(--gold));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  margin-bottom: 0.5rem;
}

.fact-card p {
  margin: 0;
  font-size: 0.9rem;
  color: var(--muted);
}

/* ---------- footer ---------- */
footer {
  text-align: center;
  padding: 4rem 1.5rem 5rem;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  color: var(--muted);
  font-size: 0.9rem;
}

footer strong { color: #fff; font-weight: 500; }
footer .muted { font-size: 0.8rem; opacity: 0.65; margin-top: 0.3rem; }

/* ---------- reveal-on-scroll ---------- */
.reveal {
  opacity: 0;
  transform: translateY(28px);
  transition: opacity 0.9s cubic-bezier(0.2, 0.7, 0.2, 1),
    transform 0.9s cubic-bezier(0.2, 0.7, 0.2, 1);
}

.reveal.visible {
  opacity: 1;
  transform: none;
}

/* stagger cards a touch */
.grid .reveal:nth-child(2) { transition-delay: 0.06s; }
.grid .reveal:nth-child(3) { transition-delay: 0.12s; }
.grid .reveal:nth-child(4) { transition-delay: 0.18s; }
.grid .reveal:nth-child(5) { transition-delay: 0.24s; }
.grid .reveal:nth-child(6) { transition-delay: 0.3s; }
.grid .reveal:nth-child(7) { transition-delay: 0.36s; }
.grid .reveal:nth-child(8) { transition-delay: 0.42s; }

.no-wasm #cosmos {
  background: radial-gradient(circle at 70% 35%, #1b1440, #05060f 70%);
}

/* ---------- planet profile link ---------- */
.planet-card {
  cursor: pointer;
  outline: none;
}

.planet-card:focus-visible {
  border-color: var(--cyan);
  box-shadow: 0 0 0 2px rgba(34, 211, 238, 0.45), 0 24px 50px -20px rgba(88, 60, 200, 0.75);
}

.profile-link {
  display: inline-block;
  margin-top: 0.9rem;
  font-size: 0.72rem;
  font-weight: 500;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--cyan);
  text-shadow: 0 0 16px rgba(34, 211, 238, 0.55);
}

.profile-link .arrow {
  display: inline-block;
  transition: transform 0.3s cubic-bezier(0.2, 0.7, 0.2, 1);
}

.planet-card:hover .profile-link .arrow,
.planet-card:focus-visible .profile-link .arrow {
  transform: translateX(6px);
}

/* ---------- planet profile modal ---------- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: clamp(0.8rem, 3vw, 2rem);
  /* No backdrop-filter here on purpose: the cosmos behind animates every
     frame, and blurring it re-filters the full screen each frame. */
  background:
    radial-gradient(120% 120% at 50% 40%, rgba(8, 10, 24, 0.62), rgba(3, 4, 10, 0.92)),
    rgba(3, 4, 10, 0.86);
  opacity: 0;
  transition: opacity 0.28s ease;
}

.modal-backdrop.open { opacity: 1; }
.modal-backdrop[hidden] { display: none; }

.modal {
  position: relative;
  width: min(960px, 100%);
  max-height: min(88vh, 100%);
  overflow-y: auto;
  background: rgba(10, 12, 26, 0.82);
  border: 1px solid var(--stroke);
  border-radius: 24px;
  padding: clamp(1.4rem, 3.5vw, 2.4rem);
  transform: scale(0.92) translateY(16px);
  transition: transform 0.35s cubic-bezier(0.2, 0.7, 0.2, 1);
  box-shadow: 0 40px 90px -30px rgba(0, 0, 0, 0.85), 0 0 60px -20px rgba(139, 92, 246, 0.35);
}

.modal-backdrop.open .modal { transform: none; }

.modal-close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 1px solid var(--stroke);
  background: var(--glass);
  color: var(--ink);
  font-size: 0.95rem;
  cursor: pointer;
  transition: background 0.25s ease, transform 0.25s ease;
}

.modal-close:hover {
  background: rgba(255, 255, 255, 0.12);
  transform: rotate(90deg);
}

.modal-body {
  display: grid;
  grid-template-columns: minmax(220px, 280px) 1fr;
  gap: clamp(1.4rem, 3vw, 2.4rem);
  align-items: start;
}

#modalPlanet {
  width: 100%;
  max-width: 280px;
  aspect-ratio: 1;
  margin: 0.6rem auto 0;
  display: block;
  animation: planetFloat 7s ease-in-out infinite;
}

@keyframes planetFloat {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}

.modal-order {
  margin: 0 0 0.2rem;
  font-size: 0.72rem;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  color: var(--cyan);
}

.modal-info h3 {
  margin: 0 0 0.5rem;
  font-size: clamp(1.7rem, 4vw, 2.4rem);
  font-weight: 700;
  letter-spacing: 0.02em;
  background: linear-gradient(120deg, #ffffff, #c9b8ff 55%, #22d3ee);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.modal-desc {
  margin: 0 0 1.2rem;
  color: var(--muted);
  font-size: 0.95rem;
  max-width: 36rem;
}

.orbit-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin: 0 0 0.4rem;
}

#modalOrbit {
  width: min(100%, 240px);
  aspect-ratio: 1;
  display: block;
}

.orbit-caption {
  margin: 0.5rem 0 0;
  font-size: 0.7rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: rgba(154, 163, 199, 0.75);
}

.data-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(196px, 1fr));
  gap: 0.7rem;
  margin: 1.2rem 0 0;
}

.data-grid .cell {
  background: rgba(255, 255, 255, 0.035);
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: 12px;
  padding: 0.7rem 0.85rem 0.75rem;
  transition: border-color 0.25s ease, background 0.25s ease;
}

.data-grid .cell:hover {
  border-color: rgba(139, 92, 246, 0.5);
  background: rgba(139, 92, 246, 0.08);
}

.data-grid dt {
  font-size: 0.64rem;
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0 0 0.25rem;
}

.data-grid dd {
  margin: 0;
  font-size: 0.92rem;
  color: #fff;
}

.modal-nav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1.1rem;
  margin-top: 1.8rem;
  padding-top: 1.4rem;
  border-top: 1px solid rgba(255, 255, 255, 0.07);
}

.nav-btn {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: 1px solid var(--stroke);
  background: var(--glass);
  color: var(--ink);
  font-size: 1.2rem;
  line-height: 1;
  cursor: pointer;
  transition: background 0.25s ease, box-shadow 0.25s ease, transform 0.2s ease;
}

.nav-btn:hover {
  background: rgba(139, 92, 246, 0.25);
  box-shadow: 0 0 22px rgba(139, 92, 246, 0.5);
  transform: translateY(-2px);
}

#modalCounter {
  font-size: 0.78rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--muted);
  min-width: 9rem;
  text-align: center;
}

@media (max-width: 640px) {
  .modal-body {
    grid-template-columns: 1fr;
  }
  #modalPlanet {
    max-width: 220px;
  }
  .data-grid {
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  }
  #modalCounter {
    min-width: 7rem;
  }
}

/* ---------- audio toggle ---------- */
.audio-btn {
  background: var(--glass);
  border: 1px solid var(--stroke);
  border-radius: 999px;
  color: var(--ink);
  font-size: 0.85rem;
  padding: 0.28rem 0.7rem;
  cursor: pointer;
  transition: background 0.25s ease, box-shadow 0.25s ease;
}

.audio-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  box-shadow: 0 0 16px rgba(34, 211, 238, 0.35);
}

.audio-btn[aria-pressed="true"] {
  border-color: rgba(34, 211, 238, 0.55);
  box-shadow: 0 0 18px rgba(34, 211, 238, 0.45);
}

/* ---------- date scrubber ---------- */
.date-controls {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.9rem;
  width: min(100%, 260px);
}

.mini-btn {
  background: var(--glass);
  border: 1px solid var(--stroke);
  border-radius: 8px;
  color: var(--ink);
  font-size: 0.68rem;
  font-weight: 500;
  letter-spacing: 0.06em;
  padding: 0.34rem 0.55rem;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.2s ease, border-color 0.2s ease;
}

.mini-btn:hover {
  background: rgba(139, 92, 246, 0.25);
  border-color: rgba(139, 92, 246, 0.55);
}

.mini-btn.wide {
  padding-inline: 0.8rem;
}

#dateSlider {
  flex: 1;
  min-width: 60px;
  accent-color: #8b5cf6;
  cursor: pointer;
}

/* ---------- calculators ---------- */
.calc {
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
}

.calc-card {
  background: var(--glass);
  border: 1px solid var(--stroke);
  border-radius: 20px;
  padding: 1.8rem 1.6rem;
  backdrop-filter: blur(12px);
  transition: transform 0.35s cubic-bezier(0.2, 0.7, 0.2, 1), box-shadow 0.35s ease, border-color 0.35s ease;
}

.calc-card:hover {
  transform: translateY(-5px);
  border-color: rgba(34, 211, 238, 0.45);
  box-shadow: 0 24px 50px -20px rgba(20, 90, 120, 0.6);
}

.calc-card h3 {
  margin: 0 0 1.1rem;
  font-size: 1.05rem;
  font-weight: 500;
  letter-spacing: 0.02em;
  color: #fff;
}

.calc-label {
  display: block;
  font-size: 0.72rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 0.45rem;
}

.calc-input {
  width: 100%;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--stroke);
  border-radius: 10px;
  color: #fff;
  font-size: 1rem;
  padding: 0.6rem 0.8rem;
  outline: none;
  transition: border-color 0.25s ease, box-shadow 0.25s ease;
}

.calc-input:focus {
  border-color: rgba(34, 211, 238, 0.6);
  box-shadow: 0 0 0 3px rgba(34, 211, 238, 0.15);
}

.calc-input::-webkit-calendar-picker-indicator {
  filter: invert(0.8);
  cursor: pointer;
}

.calc-note {
  margin: 0.8rem 0 0.2rem;
  font-size: 0.85rem;
  color: var(--cyan);
}

.calc-results {
  margin-top: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.calc-hint {
  color: var(--muted);
  font-size: 0.88rem;
  margin: 0.4rem 0 0;
}

.calc-row {
  display: grid;
  grid-template-columns: 4.6rem 1fr auto;
  align-items: center;
  gap: 0.7rem;
  font-size: 0.88rem;
}

.calc-row .calc-name {
  color: var(--muted);
}

.calc-row .calc-val {
  color: #fff;
  font-weight: 500;
  white-space: nowrap;
}

.calc-row .calc-sub {
  font-size: 0.7rem;
  color: rgba(154, 163, 199, 0.8);
  white-space: nowrap;
}

.calc-bar {
  position: relative;
  height: 5px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.07);
  overflow: hidden;
}

.calc-bar i {
  position: absolute;
  inset: 0 auto 0 0;
  border-radius: 999px;
  background: linear-gradient(90deg, #22d3ee, #8b5cf6);
  box-shadow: 0 0 8px rgba(34, 211, 238, 0.5);
  transition: width 0.4s cubic-bezier(0.2, 0.7, 0.2, 1);
}

@media (max-width: 480px) {
  .calc-row {
    grid-template-columns: 4rem 1fr auto;
  }
}

@media (prefers-reduced-motion: reduce) {
  .reveal { transition: none; opacity: 1; transform: none; }
  .scroll-cue span { animation: none; }
}
