/* ---------- Theme tokens ---------- */
:root[data-theme="dark"] {
  --bg: #07071a;
  --bg-elev: #0e0d24;
  --bg-card: rgba(20, 18, 50, 0.55);
  --border: rgba(180, 180, 230, 0.12);
  --text: #ecebff;
  --text-dim: #a9a8c9;
  --accent: #f5c87a;
  --accent-2: #b58cff;
  --shadow: 0 30px 80px -30px rgba(0, 0, 0, 0.8);
  --hero-overlay: linear-gradient(180deg, rgba(7,7,26,0.45) 0%, rgba(7,7,26,0.85) 100%);
  --canvas-bg: radial-gradient(ellipse at center, #0d0a2e 0%, #050414 70%);
}
:root[data-theme="light"] {
  --bg: #f6f3ec;
  --bg-elev: #ffffff;
  --bg-card: rgba(255, 255, 255, 0.75);
  --border: rgba(40, 30, 80, 0.12);
  --text: #1a1735;
  --text-dim: #6a6486;
  --accent: #c2762a;
  --accent-2: #6a3fbf;
  --shadow: 0 30px 80px -30px rgba(40, 30, 80, 0.25);
  --hero-overlay: linear-gradient(180deg, rgba(20,18,50,0.55) 0%, rgba(246,243,236,0.92) 100%);
  --canvas-bg: radial-gradient(ellipse at center, #1a1840 0%, #07071a 70%);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  font-weight: 300;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  transition: background 0.4s ease, color 0.4s ease;
}
h1, h2, h3, h4 {
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-weight: 500;
  letter-spacing: 0.01em;
  margin: 0 0 0.5em;
}
h1 { font-size: clamp(2.4rem, 5vw, 4.2rem); line-height: 1.1; }
h2 { font-size: clamp(1.8rem, 3.5vw, 2.8rem); }
h3 { font-size: 1.6rem; }
a { color: var(--accent); text-decoration: none; }

/* ---------- Topbar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 32px;
  background: color-mix(in oklab, var(--bg) 80%, transparent);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 10px; font-family: 'Cormorant Garamond', serif; font-size: 1.4rem; }
.brand-mark { color: var(--accent); font-size: 1.6rem; }
.nav { display: flex; gap: 28px; }
.nav a { color: var(--text-dim); font-size: 0.95rem; transition: color 0.2s; }
.nav a:hover { color: var(--text); }
.icon-btn {
  background: none; border: 1px solid var(--border); color: var(--text);
  width: 36px; height: 36px; border-radius: 50%;
  cursor: pointer; display: grid; place-items: center;
  font-size: 1.05rem; transition: all 0.25s;
}
.icon-btn:hover { background: var(--bg-card); border-color: var(--accent); }
.icon-sun { display: none; }
:root[data-theme="light"] .icon-moon { display: none; }
:root[data-theme="light"] .icon-sun { display: inline; }

/* ---------- Hero ---------- */
.hero {
  position: relative;
  min-height: 100vh;
  padding: 60px 32px 48px;
  background-image: var(--hero-overlay), url('assets/cosmos-hero.jpeg');
  background-size: cover;
  background-position: center;
  background-attachment: fixed;
  display: flex; flex-direction: column; gap: 32px;
}
.hero-text { max-width: 760px; margin: 0 auto; text-align: center; color: #ecebff; }
.hero-text h1 { color: #fff; text-shadow: 0 4px 30px rgba(0,0,0,0.5); }
.hero-text p { color: #c9c8e8; font-size: 1.1rem; max-width: 620px; margin: 0 auto; text-shadow: 0 2px 16px rgba(0,0,0,0.6); }
.hint { color: var(--text-dim) !important; }

.stage {
  max-width: 1280px; width: 100%; margin: 0 auto;
  display: flex; flex-direction: column; gap: 18px;
}
#canvas-wrap {
  position: relative;
  aspect-ratio: 16/10;
  width: 100%;
  border-radius: 18px;
  overflow: hidden;
  background: var(--canvas-bg);
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
}
#solar-canvas { display: block; width: 100%; height: 100%; cursor: grab; }
#solar-canvas:active { cursor: grabbing; }
.tooltip {
  position: absolute; pointer-events: none;
  padding: 6px 10px;
  background: rgba(15, 12, 35, 0.92);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: #fff;
  font-size: 0.85rem;
  letter-spacing: 0.04em;
  transform: translate(-50%, -130%);
  white-space: nowrap;
  transition: opacity 0.15s;
}
.hint { text-align: center; color: var(--text-dim); font-size: 0.85rem; margin: 0; }

/* ---------- Controls ---------- */
.controls {
  display: flex; flex-direction: column;
  gap: 16px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 16px 20px;
  backdrop-filter: blur(10px);
}
.controls-row {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
}
.control-group { display: flex; flex-direction: column; gap: 8px; }
.control-group label { font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.12em; color: var(--text-dim); }
.view-toggle { flex-direction: row; gap: 0; padding: 4px; border: 1px solid var(--border); border-radius: 999px; background: var(--bg-elev); }
.seg {
  flex: 1; background: none; border: none; color: var(--text-dim);
  padding: 8px 14px; border-radius: 999px; cursor: pointer;
  font: inherit; font-size: 0.9rem; transition: all 0.25s;
}
.seg.active { background: var(--accent); color: #1a1735; font-weight: 500; }
input[type="date"], select {
  background: var(--bg-elev); color: var(--text);
  border: 1px solid var(--border); border-radius: 8px;
  padding: 8px 10px; font: inherit; font-size: 0.9rem;
}
input[type="range"] { accent-color: var(--accent); }
.date-group { flex-direction: row; align-items: end; gap: 8px; flex-wrap: wrap; }
.date-group label { width: 100%; }
.date-group input[type="date"] { flex: 1; min-width: 140px; }
.ghost-btn {
  background: transparent; border: 1px solid var(--border); color: var(--text);
  padding: 8px 14px; border-radius: 8px; cursor: pointer; font: inherit;
  font-size: 0.88rem; transition: all 0.2s;
}
.ghost-btn:hover { border-color: var(--accent); color: var(--accent); }
.play-group { flex-direction: row; gap: 8px; align-items: center; }
.play-group select { flex: 1; }
.year-group { width: 100%; }
.year-group input[type="range"] { width: 100%; }
#year-readout { color: var(--accent); font-weight: 500; }

/* ---------- Sections ---------- */
.planets-section, .zodiac-section {
  max-width: 1200px; margin: 0 auto; padding: 80px 32px;
}
.section-lede { color: var(--text-dim); max-width: 640px; margin: 0 0 36px; font-size: 1.05rem; }

.planet-cards {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 18px;
}
.planet-card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: 14px; padding: 22px;
  cursor: pointer; transition: all 0.3s ease;
  display: flex; flex-direction: column; gap: 10px;
  align-items: flex-start; text-align: left;
  font: inherit; color: inherit;
  backdrop-filter: blur(10px);
}
.planet-card:hover { transform: translateY(-4px); border-color: var(--accent); box-shadow: var(--shadow); }
.planet-orb {
  width: 56px; height: 56px; border-radius: 50%;
  background-size: cover; background-position: center;
  box-shadow: inset -10px -10px 20px rgba(0,0,0,0.45), 0 6px 20px rgba(0,0,0,0.4);
}
.planet-card h3 { margin: 0; font-size: 1.4rem; }
.planet-card .tag { font-size: 0.75rem; letter-spacing: 0.15em; text-transform: uppercase; color: var(--accent); }
.planet-card p { color: var(--text-dim); font-size: 0.92rem; margin: 0; }

.zodiac-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 18px;
}
.zodiac-card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: 14px; padding: 22px;
  display: flex; flex-direction: column; gap: 8px;
  backdrop-filter: blur(10px);
  transition: all 0.3s;
}
.zodiac-card:hover { border-color: var(--accent-2); transform: translateY(-2px); }
.zodiac-glyph { font-size: 2.4rem; color: var(--accent); line-height: 1; font-family: 'Cormorant Garamond', serif; }
.zodiac-card h3 { margin: 0; font-size: 1.3rem; }
.zodiac-meta { font-size: 0.8rem; color: var(--accent-2); letter-spacing: 0.08em; text-transform: uppercase; }
.zodiac-card p { color: var(--text-dim); font-size: 0.92rem; margin: 4px 0 0; }

/* ---------- Modal ---------- */
.modal[hidden] { display: none !important; }
.modal {
  position: fixed; inset: 0; z-index: 100;
  display: grid; place-items: center;
  background: rgba(5, 4, 16, 0.78);
  backdrop-filter: blur(8px);
  padding: 24px;
  animation: fadein 0.25s;
}
@keyframes fadein { from { opacity: 0; } to { opacity: 1; } }
.modal-card {
  position: relative;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 16px;
  max-width: 720px; width: 100%; max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow);
  animation: rise 0.3s cubic-bezier(0.2,0.8,0.2,1);
}
@keyframes rise { from { transform: translateY(20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
.modal-close {
  position: absolute; top: 14px; right: 14px;
  background: none; border: none; color: var(--text-dim);
  width: 32px; height: 32px; border-radius: 50%;
  font-size: 1.5rem; cursor: pointer;
  display: grid; place-items: center;
  transition: all 0.2s;
}
.modal-close:hover { background: var(--bg-card); color: var(--text); }
.modal-body { display: grid; grid-template-columns: 180px 1fr; gap: 28px; padding: 36px; }
.modal-portrait {
  width: 180px; height: 180px; border-radius: 50%;
  background-size: cover; background-position: center;
  box-shadow: inset -20px -20px 40px rgba(0,0,0,0.5), 0 10px 40px rgba(0,0,0,0.5);
}
.modal-tagline { color: var(--accent); letter-spacing: 0.12em; text-transform: uppercase; font-size: 0.78rem; margin: 0 0 18px; }
.modal h4 { margin: 18px 0 6px; font-size: 1.1rem; color: var(--accent-2); }
.modal-text p { margin: 0 0 8px; color: var(--text-dim); }

@media (max-width: 600px) {
  .modal-body { grid-template-columns: 1fr; padding: 24px; }
  .modal-portrait { margin: 0 auto; }
  .topbar { padding: 12px 18px; }
  .nav { display: none; }
  .hero { padding: 40px 16px 32px; }
  .planets-section, .zodiac-section { padding: 56px 18px; }
}

.foot {
  text-align: center; color: var(--text-dim); font-size: 0.85rem;
  padding: 32px 24px 48px; border-top: 1px solid var(--border);
}
