/* ---- Reset & base ---- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #0f0f1a;
  --bg-card: #161626;
  --bg-card-hover: #1e1e32;
  --bg-elevated: #1a1a2e;
  --text: #e0e0e8;
  --text-muted: #888;
  --text-dim: #555;
  --border: #2a2a40;

  --red: #c0392b;
  --red-bg: #3a1010;
  --red-text: #e74c3c;
  --amber: #d4a84b;
  --amber-bg: #3a2a10;
  --amber-text: #f0c040;
  --green: #2d4a1e;
  --green-bg: #1e2a1e;
  --green-text: #7bc67e;

  --radius: 6px;
  --font: system-ui, -apple-system, sans-serif;
  --font-mono: 'SF Mono', 'Fira Code', monospace;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  line-height: 1.5;
}

.page {
  max-width: 860px;
  margin: 0 auto;
  padding: 24px 16px 64px;
}

a { color: inherit; text-decoration: none; }

/* ---- Index header ---- */
.index-header { margin-bottom: 24px; }
.index-header h1 { font-size: 1.75rem; font-weight: 700; }
.index-header__top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}
.subtitle { color: var(--text-muted); font-size: 0.9rem; margin-top: 4px; }
.last-updated { color: var(--text-dim); font-size: 0.8rem; margin-top: 4px; }

/* ---- Stats bar ---- */
.stats-bar {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 16px;
}

.stat-block {
  background: var(--bg-elevated);
  border-radius: var(--radius);
  padding: 14px;
  text-align: center;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.stat-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.stat-value {
  font-size: 2rem;
  font-weight: 700;
  line-height: 1;
}
.stat-value--notable { color: var(--amber); }
.stat-value--hazardous { color: var(--red-text); }

/* ---- Filter bar ---- */
.filter-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}

.filter-label { font-size: 0.8rem; color: var(--text-muted); }

.filter-btn {
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-muted);
  border-radius: 20px;
  padding: 4px 14px;
  font-size: 0.8rem;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.filter-btn:hover { background: var(--bg-card-hover); color: var(--text); }
.filter-btn.active { background: var(--bg-elevated); color: var(--text); border-color: #444; }

.filter-separator {
  color: var(--text-dim);
  font-size: 0.85rem;
  padding: 0 2px;
  user-select: none;
}

/* ---- Asteroid card (index list) ---- */
.asteroid-list { display: flex; flex-direction: column; gap: 6px; }

.asteroid-card {
  display: block;
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 12px 14px;
  border-left: 3px solid var(--border);
  cursor: pointer;
  transition: background 0.15s;
}
.asteroid-card:hover { background: var(--bg-card-hover); }

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.card-name { font-size: 1rem; font-weight: 600; }

.badge {
  font-size: 0.7rem;
  padding: 2px 8px;
  border-radius: 12px;
  white-space: nowrap;
  flex-shrink: 0;
}

.card-meta { color: var(--text-muted); font-size: 0.82rem; margin-top: 4px; }
.card-summary { color: var(--text-dim); font-size: 0.78rem; margin-top: 3px; font-style: italic; }

/* ---- Skeleton ---- */
.skeleton-card {
  height: 60px;
  background: var(--bg-card);
  border-radius: var(--radius);
  border-left: 3px solid var(--border);
  animation: pulse 1.5s ease-in-out infinite;
}
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.5; } }

.skeleton-message { padding: 24px; text-align: center; color: var(--text-muted); }
.empty-state { padding: 24px; text-align: center; color: var(--text-muted); }

/* ---- Pagination ---- */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  margin-top: 20px;
  font-size: 0.85rem;
  color: var(--text-muted);
}
.pagination button {
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--radius);
  padding: 6px 14px;
  cursor: pointer;
}
.pagination button:disabled { opacity: 0.4; cursor: default; }

/* ---- Detail page ---- */
.breadcrumb { margin-bottom: 16px; }
.breadcrumb a { color: var(--text-muted); font-size: 0.85rem; }
.breadcrumb a:hover { color: var(--text); }

.detail-header { margin-bottom: 20px; }
.detail-header h1 { font-size: 1.6rem; font-weight: 700; }
.detail-header__top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

/* ---- Unit toggle ---- */
.unit-toggle {
  display: flex;
  gap: 2px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2px;
  flex-shrink: 0;
}
.unit-toggle__btn {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 0.75rem;
  padding: 3px 8px;
  border-radius: 4px;
  cursor: pointer;
  font-family: var(--font);
}
.unit-toggle__btn--active {
  background: var(--bg-card-hover);
  color: var(--text);
}

.detail-meta { display: flex; align-items: center; gap: 10px; margin-top: 8px; flex-wrap: wrap; }
.detail-date { color: var(--text-muted); font-size: 0.85rem; }

.detail-layout {
  display: grid;
  grid-template-columns: 1.5fr 1fr;
  gap: 16px;
  align-items: start;
}

@media (max-width: 640px) {
  .detail-layout { grid-template-columns: 1fr; }
  .stats-bar { grid-template-columns: repeat(3, 1fr); }
  .stat-value { font-size: 1.5rem; }
}

/* ---- Detail cards ---- */
.risk-banner {
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 12px;
  font-size: 0.9rem;
  line-height: 1.5;
}

.detail-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 12px;
}
.detail-card h3 { font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-muted); margin-bottom: 8px; }
.detail-card p { font-size: 0.88rem; line-height: 1.5; color: var(--text-muted); }
.detail-card p + p { margin-top: 6px; }
.detail-card strong { color: var(--text); }

/* ---- Stat cards (detail right column) ---- */
.stat-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 12px;
  text-align: center;
  margin-bottom: 8px;
}
.stat-card .stat-value { font-size: 1.6rem; }
.stat-card .stat-sub { font-size: 0.75rem; color: var(--text-dim); margin-top: 2px; }

/* ---- Observer card ---- */
.observer-card {
  background: var(--bg-elevated);
  border-radius: var(--radius);
  padding: 14px;
  margin-top: 4px;
}
.observer-card .stat-label { margin-bottom: 10px; }
.observer-prompt { font-size: 0.85rem; color: var(--text-muted); margin-bottom: 8px; }

.btn-location {
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--radius);
  padding: 6px 14px;
  font-size: 0.82rem;
  cursor: pointer;
  width: 100%;
  margin-bottom: 6px;
}
.btn-location:hover { background: var(--bg-card-hover); }
.btn-location--secondary { color: var(--text-muted); }

.location-input {
  width: 100%;
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--radius);
  padding: 7px 10px;
  font-size: 0.85rem;
  margin-bottom: 6px;
}
.location-input::placeholder { color: var(--text-dim); }
.location-input:focus { outline: none; border-color: #555; }

.observer-actions { display: flex; gap: 6px; }
.observer-actions .btn-location { margin-bottom: 0; }

.observer-note { font-size: 0.82rem; margin-bottom: 8px; padding: 8px; border-radius: 4px; }
.observer-note--ok { background: var(--green-bg); color: var(--green-text); }
.observer-note--warn { background: var(--amber-bg); color: var(--amber-text); }
.observer-content p { font-size: 0.85rem; color: var(--text-muted); margin-bottom: 4px; }
.observer-content strong { color: var(--text); }

.error { font-size: 0.8rem; color: var(--red-text); margin-top: 6px; }

/* ---- Location prompt bar ---- */
.location-prompt-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 12px;
  font-size: 0.82rem;
  color: var(--text-muted);
  flex-wrap: wrap;
}
.location-prompt-error {
  color: var(--red-text);
  font-size: 0.8rem;
}

/* ---- Card visibility icons ---- */
.card-icons {
  display: flex;
  gap: 12px;
  margin-top: 6px;
  align-items: center;
  flex-wrap: wrap;
}
.card-icon {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.75rem;
  color: var(--text-muted);
  white-space: nowrap;
}
.card-icon--night { color: #7ba7d4; }
.card-icon--day   { color: #d4b96b; }

/* ---- Approach timeline ---- */
.timeline-container {
  margin-bottom: 16px;
}

@media (max-width: 640px) {
  .timeline-container { display: none; }
}

.timeline-tooltip {
  position: fixed;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 0.8rem;
  padding: 4px 10px;
  border-radius: 4px;
  pointer-events: none;
  z-index: 100;
  white-space: nowrap;
  display: none;
}

/* ---- Data source footer ---- */
.data-sources {
  margin-top: 48px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  font-size: 0.78rem;
  color: var(--text-dim);
}
.data-sources h4 {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: 8px;
}
.data-sources ul {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.data-sources a {
  color: var(--text-muted);
  text-decoration: underline;
  text-underline-offset: 2px;
}
.data-sources a:hover { color: var(--text); }
.data-sources strong { color: var(--text-muted); }
