/* ===== Reset & Base ===== */
*, *::before, *::after { box-sizing: border-box; }

:root {
  --header-h: 64px;
  --accent: #6ae3ff;
  --accent2: #8df291;
  --gold: #ffd27e;
  --card: rgba(255,255,255,0.05);
  --border: rgba(106,227,255,0.15);
  --glow-color: rgba(106,227,255,0.12);
}

html { height: 100%; overflow-x: hidden; }

body {
  min-height: 100%; margin: 0;
  font-family: 'Inter', system-ui, -apple-system, Arial, sans-serif;
  color: #e8eef6;
  background: #000;
  overflow-x: hidden;
  overscroll-behavior-x: none;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.visually-hidden {
  position: absolute !important; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ===== Header ===== */
#main-header {
  position: fixed; top: 0; left: 0; right: 0;
  height: var(--header-h);
  display: grid; grid-template-columns: auto 1fr auto;
  align-items: center; gap: 12px; padding: 0 20px;
  background: rgba(5,8,14,0.88);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(14px);
  z-index: 100;
}

#main-header .logo {
  width: 52px; height: 52px;
  display: grid; place-items: center;
  cursor: pointer; flex-shrink: 0;
}
#logo-canvas { width: 48px; height: 48px; display: block; }

#menu-open {
  justify-self: center;
  width: 40px; height: 40px;
  background: rgba(106,227,255,0.06);
  color: var(--accent);
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 18px; cursor: pointer;
  display: grid; place-items: center;
  transition: background 0.2s, border-color 0.2s;
}
#menu-open:hover { background: rgba(106,227,255,0.12); border-color: var(--accent); }
#menu-open:focus { outline: 2px solid var(--accent); outline-offset: 2px; }

.header-actions.column {
  display: flex; flex-direction: column;
  gap: 5px; align-items: flex-end;
}

#quiz-mode-toggle, #audio-toggle {
  padding: 5px 10px;
  font-size: 0.72rem; font-weight: 700;
  background: rgba(106,227,255,0.06);
  color: var(--accent);
  border: 1px solid var(--border);
  border-radius: 8px; cursor: pointer;
  transition: background 0.2s;
  white-space: nowrap;
}
#quiz-mode-toggle:hover, #audio-toggle:hover {
  background: rgba(106,227,255,0.14);
}

/* ===== Off-canvas Menu ===== */
#side-menu {
  position: fixed; top: 0; left: 0; bottom: 0;
  width: min(86vw, 320px);
  background: rgba(5,8,14,0.97);
  border-right: 1px solid var(--border);
  transform: translateX(-102%);
  transition: transform 0.28s cubic-bezier(0.4,0,0.2,1);
  z-index: 1100; padding: 16px; overflow: auto;
  backdrop-filter: blur(20px);
}
#side-menu[aria-hidden="false"] { transform: translateX(0); }

#side-menu-backdrop {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 1090;
  backdrop-filter: blur(2px);
}

#side-menu .menu-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 4px 14px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 12px;
  font-family: 'Pacifico', cursive;
  font-size: 1.1rem; color: var(--accent);
}

#menu-close {
  background: transparent; color: #aaa;
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 8px; padding: 4px 10px; cursor: pointer;
  font-size: 1rem;
  transition: color 0.2s, border-color 0.2s;
}
#menu-close:hover { color: #fff; border-color: rgba(255,255,255,0.4); }

#side-menu nav ul { list-style: none; margin: 0; padding: 4px 0; display: flex; flex-direction: column; gap: 4px; }
#side-menu nav a {
  color: #b8c8dc; padding: 10px 12px;
  border-radius: 10px; display: block;
  font-size: 0.9rem; font-weight: 600;
  letter-spacing: 0.04em;
  transition: background 0.15s, color 0.15s;
}
#side-menu nav a:hover {
  background: rgba(106,227,255,0.08);
  color: var(--accent);
  text-decoration: none;
}

/* ===== Breadcrumbs ===== */
.breadcrumbs {
  position: sticky; top: var(--header-h);
  background: rgba(5,8,14,0.8);
  border-bottom: 1px solid rgba(255,255,255,0.06);
  z-index: 5;
  padding: 8px clamp(12px, 5vw, 48px);
  backdrop-filter: blur(10px);
}
.breadcrumbs ol { list-style: none; margin: 0; padding: 0; display: flex; gap: 6px; flex-wrap: wrap; }
.breadcrumbs li { font-size: 0.75rem; color: #7a8fa6; }
.breadcrumbs li + li::before { content: "›"; margin-right: 6px; opacity: 0.5; }
.breadcrumbs a { color: var(--accent); }
.breadcrumbs li[aria-current] { color: #e8eef6; }

/* ===== Hero ===== */
.hero-section {
  min-height: calc(70vh + var(--header-h));
  padding-top: calc(var(--header-h) + 24px);
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  text-align: center;
  padding-inline: clamp(16px, 6vw, 64px);
  position: relative; overflow: hidden;
}
.hero-section::before {
  content: '';
  position: absolute; inset: 0;
  background: radial-gradient(ellipse 80% 60% at 50% 40%, rgba(106,227,255,0.06) 0%, transparent 70%);
  pointer-events: none;
}

.hero-section h1 {
  font-family: 'Pacifico', cursive;
  font-size: clamp(2.2rem, 7vw, 5rem);
  font-weight: 400;
  color: #eef3fb;
  line-height: 1.1;
  margin: 0 0 16px;
  text-shadow: 0 0 60px rgba(106,227,255,0.2), 0 2px 20px rgba(0,0,0,0.8);
  animation: heroFloat 4s ease-in-out infinite;
}

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

.hero-section .tagline {
  font-size: clamp(1rem, 2.5vw, 1.3rem);
  color: #7a8fa6;
  max-width: 560px;
  line-height: 1.7;
  margin: 0 auto;
}

/* ===== Canvas ===== */
#canvas-container { position: fixed; inset: 0; z-index: 0; pointer-events: none; }
#canvas-container canvas { width: 100%; height: 100%; display: block; }

/* ===== Planet Sections ===== */
section {
  position: relative;
  min-height: 100vh;
  border-bottom: 1px solid rgba(255,255,255,0.06);
  z-index: 1;
  padding-inline: clamp(12px, 5vw, 48px);
}

.planet-section {
  display: flex; align-items: center;
  justify-content: space-between;
  gap: clamp(16px, 3vw, 32px);
  width: 100%; max-width: 1400px; margin-inline: auto;
}
.planet-section.reverse { flex-direction: row-reverse; }

/* Per-planet glows */
.planet-section::before {
  content: ""; position: absolute; inset: 0;
  background: var(--glow, radial-gradient(60% 60% at 50% 50%, rgba(106,227,255,0.05), transparent 60%));
  z-index: -1; pointer-events: none; filter: blur(40px);
}
#mercury { --glow: radial-gradient(50% 70% at 15% 50%, rgba(255,160,60,0.14), transparent 65%); }
#venus   { --glow: radial-gradient(50% 70% at 85% 50%, rgba(255,230,80,0.14), transparent 65%); }
#earth   { --glow: radial-gradient(50% 70% at 15% 50%, rgba(60,160,255,0.16), transparent 65%); }
#mars    { --glow: radial-gradient(50% 70% at 85% 50%, rgba(255,80,50,0.16), transparent 65%); }
#jupiter { --glow: radial-gradient(50% 70% at 15% 50%, rgba(255,200,120,0.14), transparent 65%); }
#saturn  { --glow: radial-gradient(50% 70% at 85% 50%, rgba(180,210,255,0.12), transparent 65%); }
#uranus  { --glow: radial-gradient(50% 70% at 15% 50%, rgba(130,240,255,0.14), transparent 65%); }
#neptune { --glow: radial-gradient(50% 70% at 85% 50%, rgba(100,140,255,0.16), transparent 65%); }

/* Cards */
.planet-text {
  flex: 0 1 46vw;
  max-width: min(680px, 90vw);
  padding: clamp(20px, 3vw, 32px);
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 16px;
  backdrop-filter: blur(8px);
  display: flex; flex-direction: column;
  box-shadow: 0 8px 40px rgba(0,0,0,0.4);
  transition: border-color 0.3s, box-shadow 0.3s;
}
.planet-text:hover {
  border-color: rgba(106,227,255,0.2);
  box-shadow: 0 12px 60px rgba(0,0,0,0.5);
}

.planet-text h2 {
  font-family: 'Acme', sans-serif;
  font-size: clamp(1.3rem, 3vw, 1.9rem);
  letter-spacing: 0.04em;
  color: #eef3fb;
  margin: 0 0 12px;
  line-height: 1.2;
}

.spacer {
  flex: 1 1 46vw; min-height: 60vh;
  background: transparent; pointer-events: none;
  max-width: 100%;
}

/* Content elements */
.lead {
  font-size: 1.05rem;
  font-weight: 600;
  color: #c8d8e8;
  line-height: 1.6;
  margin-bottom: 10px;
}

.funfact {
  margin: 10px 0;
  padding: 10px 14px;
  background: rgba(106,227,255,0.06);
  border-left: 3px solid var(--accent);
  border-radius: 0 8px 8px 0;
  font-size: 0.9rem;
  color: #a8c8dc;
  line-height: 1.5;
}

.more {
  max-width: 90%; margin-top: 12px;
  line-height: 1.65;
  overflow: hidden; max-height: 0; opacity: 0;
  transition: max-height 400ms ease, opacity 300ms ease;
  color: #9aabbc;
  font-size: 0.95rem;
}
.more[aria-hidden="false"] { opacity: 1; }

.moral {
  margin-top: 12px;
  font-style: italic;
  color: var(--gold);
  font-size: 0.9rem;
  padding: 8px 12px;
  background: rgba(255,210,126,0.06);
  border-radius: 8px;
}

.toggle {
  margin-top: 14px;
  padding: 9px 20px;
  background: transparent;
  color: var(--accent);
  border: 1px solid var(--border);
  border-radius: 20px;
  cursor: pointer;
  font-size: 0.8rem; font-weight: 700;
  letter-spacing: 0.08em;
  align-self: flex-start;
  transition: background 0.2s, border-color 0.2s;
}
.toggle:hover { background: rgba(106,227,255,0.08); border-color: var(--accent); }
.toggle:focus { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Quiz */
.quiz {
  margin-top: 16px;
  background: rgba(0,0,0,0.3);
  border: 1px solid rgba(255,255,255,0.07);
  padding: 14px 16px;
  border-radius: 12px;
}
.quiz .q {
  font-weight: 700; font-size: 0.9rem;
  color: #c8d8e8; margin: 0 0 10px;
}
.quiz .choices { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.quiz .choices button {
  padding: 8px 16px;
  border-radius: 20px;
  border: 1px solid rgba(106,227,255,0.25);
  background: rgba(106,227,255,0.05);
  color: var(--accent);
  font-size: 0.82rem; font-weight: 700;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s;
}
.quiz .choices button:hover { background: rgba(106,227,255,0.14); border-color: var(--accent); }
.quiz .choices button.correct { background: rgba(141,242,145,0.15); border-color: var(--accent2); color: var(--accent2); }
.quiz .choices button.wrong { background: rgba(255,80,80,0.12); border-color: rgba(255,80,80,0.5); color: #ff7070; }
.quiz .feedback {
  margin-top: 10px; min-height: 1.2em;
  font-size: 0.85rem; font-weight: 700;
}

/* ===== Timeline ===== */
#timeline {
  position: fixed; left: max(8px, env(safe-area-inset-left));
  top: 50%; transform: translateY(-50%);
  z-index: 2;
  background: rgba(5,8,14,0.8);
  border: 1px solid var(--border);
  border-radius: 12px; padding: 8px;
  max-width: 150px;
  backdrop-filter: blur(12px);
}
#timeline ul { list-style: none; margin: 0; padding: 0; }
#timeline li {
  padding: 6px 10px; margin: 3px 0;
  border-radius: 8px; cursor: pointer;
  font-size: 0.78rem; font-weight: 600;
  color: #7a8fa6;
  transition: background 0.15s, color 0.15s;
}
#timeline li:hover { background: rgba(106,227,255,0.07); color: #b8c8dc; }
#timeline li.active {
  background: rgba(106,227,255,0.14);
  color: var(--accent); font-weight: 700;
}

/* ===== Facts Panel ===== */
#facts {
  position: fixed;
  right: max(10px, env(safe-area-inset-right));
  top: calc(var(--header-h) + 16px);
  z-index: 2;
  background: rgba(5,8,14,0.85);
  border: 1px solid var(--border);
  border-radius: 14px; padding: 12px;
  width: clamp(200px, 22vw, 260px);
  max-width: calc(100vw - 24px);
  backdrop-filter: blur(12px);
  box-shadow: 0 8px 32px rgba(0,0,0,0.4);
}
#facts h3 {
  margin: 4px 4px 8px;
  font-size: 0.78rem;
  font-weight: 700; letter-spacing: 0.15em;
  text-transform: uppercase; color: var(--accent);
}
#facts ul {
  margin: 0; padding: 0 0 0 14px;
  font-size: 0.82rem; color: #9aabbc; line-height: 1.6;
}
#facts .only-mobile { display: none; }

/* ===== Scroll to Top ===== */
#to-top {
  position: fixed;
  right: max(16px, env(safe-area-inset-right));
  bottom: max(16px, env(safe-area-inset-bottom));
  z-index: 3;
  width: 42px; height: 42px; border-radius: 50%;
  background: rgba(5,8,14,0.75);
  color: var(--accent);
  border: 1px solid var(--border);
  font-size: 1rem; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  opacity: 0; pointer-events: none;
  transition: opacity 0.25s, transform 0.25s, background 0.2s;
  backdrop-filter: blur(10px);
}
#to-top.show { opacity: 1; pointer-events: auto; transform: translateY(0); }
#to-top:hover { background: rgba(106,227,255,0.1); }

/* ===== Quiz-only mode ===== */
body.quiz-only .lead,
body.quiz-only .funfact,
body.quiz-only .moral,
body.quiz-only .toggle { display: none !important; }
body.quiz-only .more { max-height: none !important; opacity: 1 !important; }
body.quiz-only .planet-text p:not(.lead):not(.funfact):not(.moral) { display: none; }
body.quiz-only .more > * { display: none; }
body.quiz-only .more > .quiz { display: block; }

/* ===== FAQ ===== */
.faq-section {
  padding: 60px clamp(16px, 5vw, 64px);
  background: rgba(255,255,255,0.02);
  border-top: 1px solid rgba(255,255,255,0.07);
}
.faq-section h2 {
  font-family: 'Acme', sans-serif;
  font-size: clamp(1.4rem, 3vw, 2rem);
  letter-spacing: 4px; text-transform: uppercase;
  color: #eef3fb; margin: 0 0 24px;
}
.faq-section details {
  margin: 10px 0;
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 12px; padding: 14px 18px;
  transition: border-color 0.2s;
}
.faq-section details[open] { border-color: rgba(106,227,255,0.2); }
.faq-section summary {
  cursor: pointer; font-weight: 700;
  color: #c8d8e8; font-size: 0.95rem;
  list-style: none;
}
.faq-section summary::marker,
.faq-section summary::-webkit-details-marker { display: none; }
.faq-section summary::before {
  content: '+ '; color: var(--accent);
}
details[open] summary::before { content: '− '; }
.faq-section p { margin: 10px 0 0; color: #7a8fa6; font-size: 0.9rem; line-height: 1.6; }

/* ===== Footer ===== */
footer {
  text-align: center;
  padding: 32px 24px;
  border-top: 1px solid rgba(255,255,255,0.06);
  color: #4a5a6a;
  font-size: 0.8rem;
}

/* ===== Responsive ===== */
@media (max-width: 900px) {
  .planet-section,
  .planet-section.reverse { flex-direction: column; align-items: center; }
  .planet-text { flex-basis: auto; width: min(92vw, 680px); border-radius: 14px; }
  .more { max-width: 100%; }
  .spacer { display: none; }
  #timeline { display: none; }
  #facts {
    left: max(10px, env(safe-area-inset-left));
    right: max(10px, env(safe-area-inset-right));
    bottom: max(10px, env(safe-area-inset-bottom));
    top: auto; width: auto; padding: 0; max-width: none;
    border-radius: 14px 14px 0 0;
  }
  #facts .only-mobile {
    display: flex; width: 100%;
    justify-content: center; padding: 12px;
    background: transparent; color: var(--accent);
    border: none; border-radius: 14px 14px 0 0;
    font-weight: 700; font-size: 0.8rem; cursor: pointer;
    letter-spacing: 0.1em;
  }
  #facts .facts-body { display: none; padding: 12px; }
  #facts[aria-expanded="true"] .facts-body { display: block; }
}

@media (max-width: 480px) {
  #main-header .logo { width: 44px; height: 44px; }
  #logo-canvas { width: 40px; height: 40px; }
  #menu-open { width: 36px; height: 36px; font-size: 16px; }
  .hero-section h1 { font-size: clamp(1.8rem, 10vw, 2.8rem); }
  #quiz-mode-toggle, #audio-toggle { font-size: 0.65rem; padding: 4px 8px; }
}

@media (prefers-reduced-motion: reduce) {
  .hero-section h1 { animation: none; }
  .more { transition: none; }
}
