/* ===== Tokens ===== */
:root {
  --void: #080b10;
  --panel: #0f1620;
  --panel-2: #131b27;
  --border: #223041;
  --border-soft: #1a2531;
  --cyan: #4fd8e8;
  --cyan-dim: #2b7d8a;
  --amber: #ffb454;
  --text: #e7edf3;
  --text-dim: #7c8a9a;
  --text-faint: #4b5866;
  --danger: #ff5470;
  --font-display: 'Space Grotesk', sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--void);
  color: var(--text);
  font-family: var(--font-display);
  -webkit-font-smoothing: antialiased;
}

body {
  background-image:
    radial-gradient(circle at 15% 10%, rgba(79, 216, 232, 0.06), transparent 40%),
    radial-gradient(circle at 85% 90%, rgba(255, 180, 84, 0.05), transparent 45%);
}

/* ===== Layout ===== */
.hud {
  height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 14px 16px 16px;
  gap: 14px;
}

.main {
  flex: 1;
  display: grid;
  grid-template-columns: 1fr 300px;
  gap: 14px;
  min-height: 0;
}

/* ===== Top bar ===== */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 18px;
  background: linear-gradient(180deg, var(--panel), var(--panel-2));
  border: 1px solid var(--border);
  border-radius: 10px;
}

.brand { display: flex; align-items: center; gap: 12px; }

.brand-mark {
  font-size: 22px;
  color: var(--cyan);
  animation: spin 6s linear infinite;
  display: inline-block;
}

@keyframes spin { to { transform: rotate(360deg); } }

.brand-text h1 {
  margin: 0;
  font-size: 15px;
  letter-spacing: 0.14em;
  font-weight: 700;
  color: var(--text);
}

.brand-sub {
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--text-dim);
  letter-spacing: 0.04em;
}

.tabs {
  display: flex;
  gap: 4px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 3px;
}

.tab-btn {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.04em;
  color: var(--text-dim);
  background: transparent;
  border: none;
  padding: 6px 14px;
  border-radius: 16px;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.tab-btn:hover { color: var(--text); }

.tab-btn.active {
  background: rgba(79, 216, 232, 0.12);
  color: var(--cyan);
}

.topbar-right { display: flex; align-items: center; gap: 16px; }

.clock {
  font-family: var(--font-mono);
  font-size: 15px;
  color: var(--text);
  letter-spacing: 0.05em;
}

.clock-zone {
  font-size: 10px;
  color: var(--text-faint);
  margin-left: 6px;
}

.live-pill {
  display: flex;
  align-items: center;
  gap: 7px;
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.12em;
  color: var(--cyan);
  border: 1px solid var(--cyan-dim);
  padding: 5px 10px;
  border-radius: 20px;
  background: rgba(79, 216, 232, 0.06);
}

.live-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--cyan);
  box-shadow: 0 0 8px var(--cyan);
  animation: pulse 1.6s ease-in-out infinite;
}

.live-pill.stale { color: var(--amber); border-color: #8a6a2b; background: rgba(255,180,84,0.06); }
.live-pill.stale .live-dot { background: var(--amber); box-shadow: 0 0 8px var(--amber); }

@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.35; transform: scale(0.8); }
}

/* ===== Map panel ===== */
.map-panel {
  position: relative;
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  background: var(--panel);
}

#map {
  width: 100%;
  height: 100%;
  background: var(--void) !important;
}

.leaflet-control-attribution {
  background: rgba(8, 11, 16, 0.6) !important;
  color: var(--text-faint) !important;
  font-family: var(--font-mono);
  font-size: 9px !important;
}
.leaflet-control-attribution a { color: var(--text-dim) !important; }

.leaflet-control-zoom a {
  background: var(--panel-2) !important;
  color: var(--cyan) !important;
  border: 1px solid var(--border) !important;
}
.leaflet-control-zoom a:hover { background: var(--border) !important; }

.map-corner {
  position: absolute;
  width: 22px;
  height: 22px;
  border-color: var(--cyan-dim);
  border-style: solid;
  border-width: 0;
  pointer-events: none;
  opacity: 0.7;
  z-index: 500;
}
.map-corner.tl { top: 8px; left: 8px; border-top-width: 2px; border-left-width: 2px; }
.map-corner.tr { top: 8px; right: 8px; border-top-width: 2px; border-right-width: 2px; }
.map-corner.bl { bottom: 8px; left: 8px; border-bottom-width: 2px; border-left-width: 2px; }
.map-corner.br { bottom: 8px; right: 8px; border-bottom-width: 2px; border-right-width: 2px; }

.map-label {
  position: absolute;
  left: 14px;
  bottom: 12px;
  z-index: 500;
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.05em;
  color: var(--text-dim);
  background: rgba(8, 11, 16, 0.55);
  padding: 4px 8px;
  border-radius: 4px;
  border: 1px solid var(--border-soft);
  pointer-events: none;
}

.follow-btn {
  position: absolute;
  right: 14px;
  bottom: 12px;
  z-index: 500;
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.05em;
  color: var(--cyan);
  background: rgba(8, 11, 16, 0.55);
  border: 1px solid var(--cyan-dim);
  padding: 5px 10px;
  border-radius: 4px;
  cursor: pointer;
}
.follow-btn.off {
  color: var(--text-faint);
  border-color: var(--border-soft);
}

/* ISS marker */
.iss-marker { position: relative; width: 26px; height: 26px; }
.iss-marker .ring {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 1px solid var(--cyan);
  opacity: 0.5;
  animation: ring 2s ease-out infinite;
}
.iss-marker .dot {
  position: absolute;
  top: 50%; left: 50%;
  width: 10px; height: 10px;
  margin: -5px 0 0 -5px;
  border-radius: 50%;
  background: var(--cyan);
  box-shadow: 0 0 12px 3px rgba(79, 216, 232, 0.7);
}
@keyframes ring {
  0% { transform: scale(0.4); opacity: 0.8; }
  100% { transform: scale(1.6); opacity: 0; }
}

/* ===== Telemetry sidebar ===== */
.telemetry {
  display: flex;
  flex-direction: column;
  gap: 10px;
  overflow-y: auto;
}

.tele-card {
  background: linear-gradient(180deg, var(--panel), var(--panel-2));
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
  position: relative;
}

.tele-label {
  display: block;
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-dim);
  margin-bottom: 6px;
}

.tele-row {
  display: flex;
  align-items: baseline;
  gap: 8px;
  font-family: var(--font-mono);
}
.tele-row + .tele-row { margin-top: 4px; }

.tele-tag {
  font-size: 10px;
  color: var(--text-faint);
  width: 26px;
}

.tele-value {
  font-size: 16px;
  color: var(--text);
  font-weight: 500;
}

.tele-big {
  font-family: var(--font-mono);
  font-size: 26px;
  font-weight: 700;
  color: var(--cyan);
  line-height: 1.1;
  letter-spacing: 0.01em;
}

.tele-unit {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-faint);
  letter-spacing: 0.06em;
}

.refresh-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px;
  background: var(--panel-2);
  border: 1px solid var(--cyan-dim);
  color: var(--cyan);
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.08em;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.1s ease;
}
.refresh-btn:hover { background: rgba(79, 216, 232, 0.1); }
.refresh-btn:active { transform: scale(0.98); }
.refresh-icon { display: inline-block; transition: transform 0.4s ease; }
.refresh-btn.spinning .refresh-icon { transform: rotate(360deg); }

.status-line {
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--text-faint);
  text-align: center;
  padding-top: 2px;
}

/* ===== About view ===== */
.about-view {
  display: block;
  overflow: hidden;
}

.about-scroll {
  height: 100%;
  overflow-y: auto;
  padding: 4px 4px 24px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  max-width: 760px;
  margin: 0 auto;
}

.about-card {
  background: linear-gradient(180deg, var(--panel), var(--panel-2));
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 20px 22px;
}

.hero-card {
  border-color: var(--cyan-dim);
  background: linear-gradient(160deg, rgba(79,216,232,0.08), var(--panel-2));
}

.eyebrow {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--cyan);
  margin-bottom: 10px;
}

.about-card h2 {
  margin: 0 0 10px;
  font-size: 22px;
  color: var(--text);
}

.about-card h3 {
  margin: 0 0 10px;
  font-size: 14px;
  letter-spacing: 0.03em;
  color: var(--cyan);
}

.about-card p {
  margin: 0;
  font-size: 13.5px;
  line-height: 1.65;
  color: var(--text-dim);
}

.about-card p + p { margin-top: 10px; }

.about-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}

.stat-card {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.stat-label {
  font-family: var(--font-mono);
  font-size: 9.5px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-faint);
}

.stat-value {
  font-family: var(--font-mono);
  font-size: 20px;
  font-weight: 700;
  color: var(--cyan);
}

.stat-unit {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-faint);
}

.faq-item + .faq-item { margin-top: 14px; }

.faq-item h4 {
  margin: 0 0 4px;
  font-size: 13px;
  color: var(--text);
}

#about-crew-list .crew-name {
  color: var(--text);
  font-weight: 500;
}

@media (max-width: 700px) {
  .about-grid { grid-template-columns: repeat(2, 1fr); }
}

/* ===== Responsive ===== */
@media (max-width: 860px) {
  .main { grid-template-columns: 1fr; grid-template-rows: 1fr auto; }
  .map-panel { min-height: 300px; }
  .telemetry { flex-direction: row; flex-wrap: wrap; }
  .tele-card { flex: 1 1 45%; }
  .refresh-btn { flex: 1 1 100%; }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  .brand-mark, .live-dot, .iss-marker .ring, .refresh-icon { animation: none !important; transition: none !important; }
}
