@import url('https://fonts.googleapis.com/css2?family=DM+Serif+Display&family=Inter:wght@300;400;500;600&family=JetBrains+Mono:wght@400;500&display=swap');

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg-primary:    #0a0d14;
  --bg-secondary:  #0f1520;
  --bg-card:       #131c2e;
  --accent-blue:   #4a9eff;
  --accent-glow:   #1a6bcc;
  --text-primary:  #e8eaf0;
  --text-secondary:#8892a4;
  --text-muted:    #4a5568;
  --border:        #1e2d45;
  --success:       #34d399;
  --warning:       #fbbf24;
  --danger:        #f87171;
  --font-heading:  'DM Serif Display', serif;
  --font-body:     'Inter', sans-serif;
  --font-mono:     'JetBrains Mono', monospace;
}

html, body {
  height: 100%;
}

body {
  background: var(--bg-primary);
  color: var(--text-primary);
  font-family: var(--font-body);
  line-height: 1.6;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* ── Stars ── */
#stars {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
}

/* ── Nav ── */
.nav {
  position: relative;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1.5rem;
  background: rgba(10, 13, 20, 0.85);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(8px);
  flex-shrink: 0;
}

.home-link {
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.8rem;
  letter-spacing: 0.03em;
  transition: color 0.2s;
}
.home-link:hover { color: var(--accent-blue); }

.nav-title {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-family: var(--font-heading);
  font-size: 1.2rem;
  color: var(--text-primary);
}

.nav-icon { font-size: 1.1rem; }

.nav-status {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--success);
  letter-spacing: 0.1em;
}

/* pulsing live dot */
.pulse-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 0 0 rgba(52, 211, 153, 0.6);
  animation: pulse 2s infinite;
}
.pulse-dot.stale { background: var(--warning); box-shadow: 0 0 0 0 rgba(251, 191, 36, 0.6); animation: pulse-warn 2s infinite; }
@keyframes pulse {
  0%   { box-shadow: 0 0 0 0 rgba(52, 211, 153, 0.6); }
  70%  { box-shadow: 0 0 0 8px rgba(52, 211, 153, 0); }
  100% { box-shadow: 0 0 0 0 rgba(52, 211, 153, 0); }
}
@keyframes pulse-warn {
  0%   { box-shadow: 0 0 0 0 rgba(251, 191, 36, 0.6); }
  70%  { box-shadow: 0 0 0 8px rgba(251, 191, 36, 0); }
  100% { box-shadow: 0 0 0 0 rgba(251, 191, 36, 0); }
}

/* ── Layout ── */
.layout {
  position: relative;
  z-index: 5;
  flex: 1;
  display: flex;
  overflow: hidden;
}

/* ── Sidebar ── */
.sidebar {
  width: 260px;
  flex-shrink: 0;
  background: var(--bg-secondary);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.sidebar::-webkit-scrollbar { width: 4px; }
.sidebar::-webkit-scrollbar-track { background: transparent; }
.sidebar::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

/* ── Cards ── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.9rem 1rem;
}

.card-title {
  font-family: var(--font-heading);
  font-size: 0.95rem;
  color: var(--accent-blue);
  margin-bottom: 0.6rem;
  letter-spacing: 0.01em;
}

/* ── Stat rows ── */
.stat-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 0.2rem 0;
  border-bottom: 1px solid rgba(30, 45, 69, 0.5);
}
.stat-row:last-child { border-bottom: none; }

.stat-label {
  font-size: 0.65rem;
  color: var(--text-muted);
  letter-spacing: 0.1em;
}

.stat-value {
  font-size: 0.85rem;
  color: var(--text-primary);
  letter-spacing: 0.03em;
}

.stat-value-tag {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  padding: 0.15rem 0.5rem;
  border-radius: 4px;
  letter-spacing: 0.05em;
}
.stat-value-tag.daylight  { background: rgba(251, 191, 36, 0.15); color: var(--warning); border: 1px solid rgba(251, 191, 36, 0.3); }
.stat-value-tag.eclipse   { background: rgba(74, 158, 255, 0.1);  color: var(--accent-blue); border: 1px solid rgba(74, 158, 255, 0.25); }

/* ── Currently over ── */
.over-text {
  font-size: 0.85rem;
  color: var(--text-primary);
  line-height: 1.4;
  min-height: 1.5rem;
}

/* ── Crew ── */
.crew-count {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-bottom: 0.4rem;
  letter-spacing: 0.05em;
}

.crew-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.crew-list li {
  font-size: 0.78rem;
  color: var(--text-secondary);
  padding: 0.2rem 0;
  border-bottom: 1px solid rgba(30, 45, 69, 0.4);
  display: flex;
  align-items: center;
  gap: 0.4rem;
}
.crew-list li:last-child { border-bottom: none; }

.crew-list li::before {
  content: '👨‍🚀';
  font-size: 0.7rem;
}

/* ── Trail toggle ── */
.trail-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 0.2rem 0;
  margin-bottom: 0.5rem;
}

.trail-toggle {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.78rem;
  color: var(--text-secondary);
  cursor: pointer;
  user-select: none;
}

.trail-toggle input[type="checkbox"] {
  accent-color: var(--accent-blue);
  width: 14px;
  height: 14px;
  cursor: pointer;
}

/* ── Last update ── */
.last-update {
  font-size: 0.65rem;
  color: var(--text-muted);
  letter-spacing: 0.05em;
  text-align: center;
  padding-top: 0.25rem;
}

/* ── Map ── */
.map-wrap {
  flex: 1;
  position: relative;
  overflow: hidden;
}

#map {
  width: 100%;
  height: 100%;
  background: var(--bg-primary);
}

/* Leaflet overrides */
.leaflet-container { background: #060a12 !important; }
.leaflet-control-zoom a {
  background: var(--bg-card) !important;
  color: var(--text-primary) !important;
  border-color: var(--border) !important;
}
.leaflet-control-zoom a:hover { background: var(--accent-glow) !important; }
.leaflet-control-attribution {
  background: rgba(10, 13, 20, 0.7) !important;
  color: var(--text-muted) !important;
  font-size: 0.6rem !important;
}
.leaflet-control-attribution a { color: var(--text-muted) !important; }

/* map top-left coords overlay */
.map-overlay-tl {
  position: absolute;
  top: 10px;
  left: 50px;
  z-index: 500;
  background: rgba(10, 13, 20, 0.75);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 0.3rem 0.6rem;
  font-size: 0.65rem;
  color: var(--accent-blue);
  letter-spacing: 0.05em;
  backdrop-filter: blur(4px);
  pointer-events: none;
}

/* ── ISS marker icon ── */
.iss-marker-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  filter: drop-shadow(0 0 8px rgba(74, 158, 255, 0.8));
  animation: iss-spin 10s linear infinite;
  transform-origin: center;
}

@keyframes iss-spin {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}

/* ── Utility ── */
.mono { font-family: var(--font-mono); }

/* ── Mobile ── */
@media (max-width: 700px) {
  body { overflow: auto; }

  .layout {
    flex-direction: column;
    overflow: auto;
    height: auto;
  }

  .sidebar {
    width: 100%;
    border-right: none;
    border-bottom: 1px solid var(--border);
    flex-direction: row;
    flex-wrap: wrap;
    gap: 0.6rem;
    padding: 0.75rem;
    overflow: visible;
  }

  .sidebar .card {
    flex: 1 1 calc(50% - 0.3rem);
    min-width: 140px;
  }

  .sidebar .last-update {
    width: 100%;
  }

  .map-wrap {
    height: 55vh;
    min-height: 300px;
    flex: none;
  }

  .nav-title span:last-child { display: none; }
}
