/* Astronomical Ice Age — dark starfield theme */

:root {
  --bg: #05070f;
  --bg-panel: rgba(13, 20, 38, 0.72);
  --line: rgba(148, 163, 184, 0.16);
  --text: #e2e8f0;
  --text-dim: #94a3b8;
  --accent: #38bdf8;
  --amber: #fbbf24;
  --violet: #a78bfa;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    "Helvetica Neue", Arial, sans-serif;
  overflow: hidden;
}

body {
  display: flex;
  flex-direction: column;
  height: 100vh;
}

/* ---------- header ---------- */

#site-header {
  display: flex;
  align-items: baseline;
  padding: 10px 20px 8px;
  border-bottom: 1px solid var(--line);
  background: rgba(10, 15, 30, 0.6);
  backdrop-filter: blur(6px);
  flex: none;
}

#site-header h1 {
  margin: 0;
  font-size: 18px;
  font-weight: 650;
  letter-spacing: 1.5px;
  color: #f1f5f9;
}

#site-header h1 span {
  font-size: 12px;
  font-weight: 400;
  letter-spacing: 1px;
  color: var(--text-dim);
  margin-left: 10px;
}

#menuBtn {
  flex: none;
  align-self: center;
  width: 30px;
  height: 30px;
  margin-right: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: transparent;
  color: var(--text-dim);
  font-size: 15px;
  line-height: 1;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
}

#menuBtn:hover {
  color: var(--text);
  border-color: rgba(251, 191, 36, 0.5);
}

/* ---------- about sidebar ---------- */

#overlay {
  position: fixed;
  inset: 0;
  background: rgba(2, 6, 18, 0.55);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.25s, visibility 0.25s;
  z-index: 9;
}

#overlay.open {
  opacity: 1;
  visibility: visible;
}

#sidebar {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: min(360px, 88vw);
  padding: 22px 22px 28px;
  overflow-y: auto;
  background: rgba(10, 15, 30, 0.97);
  border-right: 1px solid var(--line);
  backdrop-filter: blur(8px);
  transform: translateX(-105%);
  visibility: hidden;
  transition: transform 0.28s ease, visibility 0.28s;
  z-index: 10;
  font-size: 13px;
  line-height: 1.75;
  color: var(--text-dim);
}

#sidebar.open {
  transform: none;
  visibility: visible;
}

#sidebar h2 {
  margin: 20px 0 8px;
  font-size: 13px;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--text);
}

#sidebar h2:first-of-type {
  margin-top: 28px;
}

#sidebar p {
  margin: 0 0 10px;
}

#sidebar ul {
  margin: 0 0 10px;
  padding-left: 18px;
}

#sidebar li {
  margin-bottom: 4px;
}

#sidebar b {
  color: var(--text);
  font-weight: 600;
}

#sidebar a {
  color: var(--accent);
  text-decoration: none;
}

#sidebar a:hover {
  text-decoration: underline;
}

#sidebarClose {
  position: absolute;
  top: 10px;
  right: 12px;
  border: none;
  background: transparent;
  color: var(--text-dim);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
}

#sidebarClose:hover {
  color: var(--text);
}

/* ---------- layout ---------- */

#layout {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  max-width: 1500px;
  width: 100%;
  margin: 0 auto;
  padding: 10px 16px 0;
  gap: 10px;
}

#stage {
  position: relative;
  flex: 1;
  min-height: 260px;
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
  background: radial-gradient(ellipse at 50% 42%, #101a33 0%, #0a1128 55%, #05070f 100%);
  display: flex;
}

#paneOrbit, #paneEarth {
  position: relative;
  min-width: 0;
  min-height: 0;
}

#paneOrbit { flex: 11 1 0; }

#paneEarth {
  flex: 9 1 0;
  border-left: 1px solid var(--line);
}

#scene, #earth {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

.panel {
  background: var(--bg-panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  backdrop-filter: blur(6px);
  box-shadow: 0 2px 14px rgba(0, 0, 0, 0.35);
}

#hud {
  position: absolute;
  top: 14px;
  left: 14px;
  padding: 12px 16px;
  min-width: 210px;
  pointer-events: none;
}

#summerWrap {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
}

#summerSceneBox {
  position: relative;
  flex: 1;
  min-height: 0;
}

#summer {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

#summerChart {
  flex: none;
  width: 100%;
  height: 64px;
  display: block;
  border-top: 1px solid var(--line);
  background: rgba(10, 15, 30, 0.55);
}

.hud-time {
  font-size: 22px;
  font-weight: 650;
  letter-spacing: 1px;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
  margin-bottom: 6px;
}

.hud-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: 12px;
  line-height: 1.7;
  color: var(--text-dim);
}

.hud-row b {
  color: var(--text);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

#loading {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  padding: 14px 26px;
  font-size: 14px;
  letter-spacing: 2px;
  color: var(--accent);
  z-index: 2;
}

#loading.error {
  color: #f87171;
  max-width: 520px;
  line-height: 1.8;
  letter-spacing: 0.5px;
}

#legend {
  position: absolute;
  top: 14px;
  right: 14px;
  padding: 8px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 12px;
  color: var(--text-dim);
  pointer-events: none;
}

.legend-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.legend-dot {
  flex: none;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--amber);
  box-shadow: 0 0 6px rgba(251, 191, 36, 0.7);
}

.legend-june {
  background: #fb7185;
  box-shadow: 0 0 6px rgba(251, 113, 133, 0.7);
}

#viewToggle {
  position: absolute;
  top: 14px;
  right: 14px;
  padding: 6px 12px;
  font-size: 12px;
  color: var(--text-dim);
  background: var(--bg-panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  cursor: pointer;
  backdrop-filter: blur(6px);
  transition: color 0.15s, border-color 0.15s;
}

#viewToggle:hover {
  color: var(--text);
  border-color: rgba(251, 191, 36, 0.5);
}

/* ---------- controls ---------- */

#controls {
  flex: none;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 2px 4px;
}

#playBtn {
  flex: none;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1px solid rgba(56, 189, 248, 0.4);
  background: rgba(13, 20, 38, 0.7);
  color: var(--accent);
  font-size: 16px;
  cursor: pointer;
  transition: background 0.15s, box-shadow 0.15s;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}

#playBtn:hover {
  background: rgba(56, 189, 248, 0.15);
  box-shadow: 0 0 12px rgba(56, 189, 248, 0.35);
}

#slider {
  flex: 1;
  -webkit-appearance: none;
  appearance: none;
  height: 22px;
  background: transparent;
  cursor: pointer;
}

#slider::-webkit-slider-runnable-track {
  height: 4px;
  border-radius: 2px;
  background: linear-gradient(90deg, rgba(56, 189, 248, 0.5), rgba(56, 189, 248, 0.18));
}

#slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 16px;
  height: 16px;
  margin-top: -6px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 8px rgba(56, 189, 248, 0.6);
  border: none;
}

#slider::-moz-range-track {
  height: 4px;
  border-radius: 2px;
  background: linear-gradient(90deg, rgba(56, 189, 248, 0.5), rgba(56, 189, 248, 0.18));
}

#slider::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 8px rgba(56, 189, 248, 0.6);
  border: none;
}

#timeLabel {
  flex: none;
  min-width: 96px;
  text-align: right;
  font-size: 14px;
  font-weight: 600;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.5px;
}

/* ---------- charts ---------- */

#charts {
  flex: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.chart {
  width: 100%;
  height: clamp(84px, 12.5vh, 132px);
  display: block;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(10, 15, 30, 0.55);
}

@media (max-width: 900px) {
  /* stacked layout: the page scrolls vertically, so the orbit pane can be
     genuinely tall instead of sharing one viewport with everything else */
  html, body { height: auto; overflow: visible; }
  body { min-height: 100vh; min-height: 100svh; }
  #stage { flex: none; height: auto; min-height: 0; flex-direction: column; }
  #paneOrbit { flex: none; height: 68vh; height: 68svh; }
  #paneEarth {
    flex: none;
    height: 46vh;
    height: 46svh;
    border-left: none;
    border-top: 1px solid var(--line);
  }
  /* the two panels no longer fit side by side: legend moves to the
     bottom-left corner so neither covers the orbit animation */
  #legend { top: auto; right: auto; left: 14px; bottom: 14px; }
}

@media (max-width: 720px) {
  #site-header { padding: 8px 12px 6px; }
  #site-header h1 { font-size: 16px; letter-spacing: 1px; }
  #site-header h1 span { display: none; }
  #menuBtn { width: 28px; height: 28px; font-size: 14px; margin-right: 8px; }
  #layout { padding: 6px 8px 0; gap: 6px; }
  #hud { top: 10px; left: 10px; min-width: 0; padding: 7px 10px; }
  .hud-time { font-size: 16px; }
  .hud-row { font-size: 11px; line-height: 1.55; }
  #legend { left: 10px; bottom: 10px; font-size: 10.5px; padding: 6px 10px; gap: 4px; }
  .legend-dot { width: 8px; height: 8px; }
  #viewToggle { top: 10px; right: 10px; font-size: 11px; padding: 5px 10px; }
  #controls { gap: 10px; }
  #playBtn { width: 34px; height: 34px; font-size: 14px; }
  #timeLabel { font-size: 12px; min-width: 78px; }
  .chart { height: clamp(64px, 10vh, 100px); }
  #summerChart { height: 52px; }
  #sidebar { font-size: 12px; }
}
