/* Earth Seasons Explorer 3D — dark theme, contrast checked against #0b0f1a. */

:root {
  --bg: #0b0f1a;
  --bg-panel: #131a2b;
  --bg-raised: #1c2438;
  --border: #2a3550;
  --text: #e8eefc;
  --text-dim: #a7b4d0;
  --accent: #ffd166;
  --accent-cool: #7fb8ff;
  --hot: #ff2d95;
  --radius: 10px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  line-height: 1.5;
}

h1, h2 { line-height: 1.2; }

/* ---------- Header ---------- */

.site-header {
  padding: 22px 24px 10px;
  max-width: 1400px;
  margin: 0 auto;
}

.site-header h1 {
  margin: 0 0 6px;
  font-size: clamp(1.5rem, 3vw, 2.1rem);
}

.badge {
  font-size: 0.55em;
  vertical-align: super;
  color: var(--bg);
  background: var(--accent);
  border-radius: 5px;
  padding: 2px 7px;
  letter-spacing: 0.06em;
}

.tagline {
  margin: 0;
  max-width: 68ch;
  color: var(--text-dim);
}

.tagline strong { color: var(--accent); }

/* ---------- Layout ---------- */

main {
  max-width: 1400px;
  margin: 0 auto;
  padding: 12px 24px 40px;
  display: grid;
  gap: 16px;
  grid-template-columns: minmax(0, 1fr) 320px;
  grid-template-areas:
    'stage panel'
    'controls controls'
    'flatmap flatmap'
    'missions missions';
}

.stage { grid-area: stage; }
.panel { grid-area: panel; }
.controls { grid-area: controls; }
.flatmap-section { grid-area: flatmap; }
.missions-section { grid-area: missions; }

@media (max-width: 900px) {
  main {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas: 'stage' 'panel' 'controls' 'flatmap' 'missions';
  }
}

/* ---------- 3D stage ---------- */

.stage {
  position: relative;
  background: #05070f;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

#scene {
  display: block;
  width: 100%;
  height: min(62vh, 620px);
  min-height: 340px;
  touch-action: none;
  cursor: grab;
}

#scene:active { cursor: grabbing; }

.scale-note {
  position: absolute;
  left: 12px;
  bottom: 8px;
  margin: 0;
  font-size: 0.72rem;
  color: #8fa0c4;
  pointer-events: none;
  text-shadow: 0 1px 3px #000;
}

/* Explains the globe's shading, over the canvas so it does not steal any height. */
.stage-legend {
  position: absolute;
  left: 12px;
  top: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 3px;
  font-size: 0.72rem;
  color: #c3cee6;
  pointer-events: none;
  text-shadow: 0 1px 3px #000, 0 0 8px #000;
}

.stage-legend li {
  display: flex;
  align-items: center;
  gap: 7px;
}

.key {
  width: 16px;
  height: 10px;
  border-radius: 2px;
  display: inline-block;
  flex: 0 0 auto;
  border: 1px solid rgba(255, 255, 255, 0.25);
}

/* Sampled from the shader: a lit ocean, a night ocean, the terminator, a sunbeam. */
.key-day { background: #2f6ba8; }
.key-night { background: #101c33; }

.key-edge {
  background: #fffdf5;
  height: 3px;
  border: 0;
}

.key-ray {
  background: #ffe9a8;
  height: 0;
  border: 0;
  border-top: 2px solid #ffe9a8;
  opacity: 0.75;
}

/* Dimmed while the beams are switched off or too far away to be drawn, so the
   legend never claims something the canvas is not showing. */
.stage-legend li.is-inactive {
  opacity: 0.4;
}

.checkbox-field {
  gap: 6px;
  cursor: pointer;
}

.checkbox-field input[type='checkbox'] {
  accent-color: var(--accent);
  width: 15px;
  height: 15px;
  cursor: pointer;
}

.loading {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: #05070f;
  color: var(--text-dim);
  transition: opacity 0.4s ease;
}

.loading.is-hidden {
  opacity: 0;
  pointer-events: none;
}

/* ---------- Side panel ---------- */

.panel {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  align-content: start;
}

.readout-block {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.readout-block.seasons {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

/* Without this the label wraps and the value slides up alongside it. */
.readout-block.seasons > div {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.readout-block.highlight {
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
}

.readout-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-dim);
}

.readout-value {
  font-size: 1.05rem;
  font-weight: 600;
}

.readout-value.big {
  font-size: 1.45rem;
  color: var(--accent);
}

.readout-sub {
  font-size: 0.8rem;
  color: var(--text-dim);
}

.panel hr {
  border: 0;
  border-top: 1px solid var(--border);
  margin: 2px 0;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.field label,
.slider-field span,
.inline-field {
  font-size: 0.82rem;
  color: var(--text-dim);
}

.field-note {
  margin: 0;
  font-size: 0.76rem;
  color: #8fa0c4;
  min-height: 1.2em;
}

output {
  color: var(--text);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

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

select {
  background: var(--bg-raised);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 7px 9px;
  font: inherit;
  font-size: 0.9rem;
  width: 100%;
}

.inline-field select { width: auto; }

input[type='range'] {
  width: 100%;
  accent-color: var(--accent);
  height: 22px;
}

button.btn {
  background: var(--bg-raised);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 8px 13px;
  font: inherit;
  font-size: 0.88rem;
  cursor: pointer;
}

button.btn:hover { border-color: var(--accent-cool); }

button.btn.primary {
  background: var(--accent);
  color: #241a00;
  border-color: var(--accent);
  font-weight: 650;
  min-width: 84px;
}

button.btn[aria-pressed='true'].cam {
  border-color: var(--accent);
  color: var(--accent);
}

:focus-visible {
  outline: 2px solid var(--accent-cool);
  outline-offset: 2px;
}

/* ---------- Controls bar ---------- */

.controls {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.control-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.inline-field {
  display: inline-flex;
  align-items: center;
  gap: 7px;
}

.jump-group {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.control-row.sliders {
  gap: 22px;
  align-items: stretch;
}

.slider-field {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1 1 260px;
}

/* ---------- Flat map ---------- */

.flatmap-section,
.missions-section {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}

.flatmap-section h2,
.missions-section h2 {
  margin: 0 0 4px;
  font-size: 1.1rem;
}

.section-note {
  margin: 0 0 12px;
  font-size: 0.85rem;
  color: var(--text-dim);
  max-width: 80ch;
}

#flatmap {
  display: block;
  width: 100%;
  height: auto;
  max-width: 900px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #06101c;
}

.legend {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  padding: 0;
  margin: 12px 0 0;
  font-size: 0.8rem;
  color: var(--text-dim);
}

.legend li {
  display: flex;
  align-items: center;
  gap: 7px;
}

.swatch {
  width: 20px;
  height: 0;
  border-top: 2px solid;
  display: inline-block;
}

.swatch.equator { border-color: var(--accent); }
.swatch.tropic { border-top-style: dashed; border-color: #ffc478; }
.swatch.polar { border-top-style: dashed; border-color: #96d2ff; }

.swatch.city {
  height: 10px;
  width: 10px;
  border: 2px solid var(--hot);
  border-radius: 50%;
}

/* ---------- Missions ---------- */

.missions {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 10px;
}

.mission {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
}

.mission.is-done {
  border-color: #4caf72;
  background: #16301f;
}

.mission-box {
  color: var(--text-dim);
  font-size: 1.1rem;
  line-height: 1.35;
}

.mission.is-done .mission-box { color: #6fdc95; }

.mission-text {
  display: flex;
  flex-direction: column;
}

.mission-title { font-weight: 600; font-size: 0.92rem; }

.mission-hint {
  font-size: 0.79rem;
  color: var(--text-dim);
}

.mission-status {
  margin: 12px 0 0;
  font-size: 0.85rem;
  color: var(--accent);
  font-weight: 600;
}

/* ---------- Footer ---------- */

.site-footer {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 24px 30px;
  color: #8fa0c4;
  font-size: 0.78rem;
}

.noscript {
  padding: 16px 24px;
  color: var(--hot);
}

/* ---------- Reduced motion ---------- */

@media (prefers-reduced-motion: reduce) {
  .loading { transition: none; }
}
