:root {
  color-scheme: dark;
  --bg: #0d1117;
  --panel-bg: #161b22;
  --border: #30363d;
  --text: #c9d1d9;
  --text-dim: #8b949e;
  --accent: #58a6ff;
  --warn: #f0883e;
  --danger: #f85149;
  --ok: #3fb950;
}

/* This site is deliberately a fixed dark "space" theme, not adaptive to
   the visitor's OS light/dark preference -- a light background would
   wash out the real satellite-photo backdrop (see #backdrop below),
   which is the whole point of it. */

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  position: relative;
}

/* Rotating backdrop of real satellite-captured photos (EPIC/GOES/Hubble-JWST
   -- see app.js's startBackdropRotation). Fixed behind everything. The
   overlay is a light dimming only near the very bottom of the page (where
   the footer text sits) -- the photo itself should stay clearly visible,
   not hidden behind a near-opaque sheet. Panels keep their own solid
   background so text stays readable regardless. */
#backdrop {
  position: fixed;
  inset: 0;
  z-index: -1;
  overflow: hidden;
  background: var(--bg);
}

#backdrop-image {
  position: absolute;
  inset: 0;
  background-size: cover;
  background-position: center;
  transition: opacity 1.5s ease-in-out, background-image 0.5s;
  opacity: 0.85;
}

#backdrop-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(13, 17, 23, 0.25) 0%, rgba(13, 17, 23, 0.35) 60%, rgba(13, 17, 23, 0.65) 100%);
}

#backdrop-caption {
  position: fixed;
  bottom: 0.5rem;
  right: 0.75rem;
  z-index: 1;
  font-size: 0.75rem;
  color: var(--text-dim);
  background: rgba(13, 17, 23, 0.6);
  padding: 0.2rem 0.6rem;
  border-radius: 6px;
  max-width: 90vw;
  display: none; /* shown only once a backdrop photo actually loads -- see app.js setBackdrop() */
}

#backdrop-caption.visible {
  display: block;
}

header {
  padding: 1.5rem 1.5rem 0.5rem;
}

header h1 {
  margin: 0;
  font-size: 1.6rem;
  text-shadow: 0 0 20px rgba(88, 166, 255, 0.4);
}

.tagline {
  color: var(--text-dim);
  margin: 0.25rem 0 0;
  font-size: 0.95rem;
}

main {
  padding: 0 1.5rem 1.5rem;
  max-width: 1100px;
  margin: 0 auto;
}

.controls {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin: 1rem 0;
  flex-wrap: wrap;
}

.controls select {
  padding: 0.4rem 0.6rem;
  background: var(--panel-bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 1rem;
}

.generated-at {
  color: var(--text-dim);
  font-size: 0.85rem;
}

.panels {
  display: grid;
  grid-template-columns: 1.3fr 1fr;
  gap: 1rem;
  align-items: start;
}

@media (max-width: 800px) {
  .panels {
    grid-template-columns: 1fr;
  }
}

.globe-column {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  /* CSS Grid items default to min-width: auto, which means a grid item
     won't shrink below its content's intrinsic size -- and globe.gl's
     <canvas> reports an intrinsic width equal to whatever pixel size it
     was last drawn at. Without this, that canvas silently forced this
     whole column past its 1.3fr track width, squeezing .info-panels down
     to a few px and pushing it off-screen (looked like every other panel
     had vanished, when they were just shoved out of the visible area). */
  min-width: 0;
}

.globe {
  height: 480px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #000;
  overflow: hidden;
}

/* Matches the globe's height and scrolls internally instead of either
   trailing off with empty space next to a shorter globe, or stretching
   the whole page far past it -- there are more cards than fit in one
   screen (status, instruments, imagery, collision risk, crew, history). */
.info-panels {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  max-height: 480px;
  overflow-y: auto;
  padding-right: 0.3rem;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

.info-panels::-webkit-scrollbar {
  width: 8px;
}

.info-panels::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 8px;
}

@media (max-width: 800px) {
  .info-panels {
    max-height: none;
    overflow-y: visible;
  }
}

.panel {
  background: rgba(22, 27, 34, 0.9);
  backdrop-filter: blur(6px);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1rem;
}

.panel h2 {
  margin: 0 0 0.6rem;
  font-size: 1.05rem;
}

.badge {
  display: inline-block;
  padding: 0.1rem 0.5rem;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 600;
}

.badge-ok {
  background: rgba(63, 185, 80, 0.15);
  color: var(--ok);
}

.badge-warn {
  background: rgba(240, 136, 62, 0.15);
  color: var(--warn);
}

.badge-danger {
  background: rgba(248, 81, 73, 0.15);
  color: var(--danger);
}

.status-row {
  margin-bottom: 0.5rem;
}

.status-row .label {
  color: var(--text-dim);
  font-size: 0.85rem;
}

#imagery-content img {
  max-width: 100%;
  border-radius: 6px;
  display: block;
}

#imagery-content .caption {
  color: var(--text-dim);
  font-size: 0.85rem;
  margin-top: 0.4rem;
}

#imagery-content .no-imagery,
#collision-content .no-imagery,
#crew-content .no-imagery,
#history-timeline .no-imagery,
#achievement-content .no-imagery {
  color: var(--text-dim);
  font-style: italic;
}

.imagery-switcher {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
  margin-bottom: 0.6rem;
}

.imagery-switcher button {
  background: var(--panel-bg);
  color: var(--text-dim);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.25rem 0.7rem;
  font-size: 0.8rem;
  cursor: pointer;
}

.imagery-switcher button.active {
  color: var(--accent);
  border-color: var(--accent);
}

#crew-content ul {
  margin: 0.4rem 0 0;
  padding-left: 1.2rem;
}

#history-toggle {
  background: var(--panel-bg);
  color: var(--accent);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.4rem 0.8rem;
  font-size: 0.85rem;
  cursor: pointer;
}

#history-timeline {
  margin-top: 0.8rem;
  max-height: 300px;
  overflow-y: auto;
}

.panel-note {
  color: var(--text-dim);
  font-size: 0.85rem;
  margin: 0 0 1rem;
}

#achievement-content .achievement-headline {
  font-weight: 600;
  margin: 0 0 0.4rem;
}

#achievement-content .achievement-detail {
  font-size: 0.9rem;
  color: var(--text-dim);
  margin: 0;
}

#achievement-content .achievement-progress {
  margin: 0.6rem 0 0;
  font-size: 0.75rem;
  color: var(--text-dim);
  text-align: right;
}

footer {
  padding: 1rem 1.5rem 2rem;
  text-align: center;
  color: var(--text-dim);
  font-size: 0.85rem;
}

footer a {
  color: var(--accent);
}
