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

:root { color-scheme: dark; }

/* ── Accessibility ────────────────────────────────────────── */
.visually-hidden {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  white-space: nowrap;
  border: 0;
}

/* ── Base ─────────────────────────────────────────────────── */
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: #0d1117;
  color: #e6edf3;
  min-height: 100vh;
  padding: 40px 20px;
  position: relative;
  overflow-x: hidden;
}

#stars {
  position: fixed;
  inset: 0;
  width: 100%; height: 100%;
  z-index: 0;
  pointer-events: none;
}

.container {
  position: relative;
  z-index: 1;
  max-width: 980px;
  margin: 0 auto;
}

/* ── Header ───────────────────────────────────────────────── */
header { margin-bottom: 40px; }
header h1 {
  font-size: 2.4rem;
  font-weight: 700;
  color: #e6edf3;
  margin-bottom: 10px;
  line-height: 1.15;
}
header h1 span { color: #58a6ff; }
header p {
  color: #8b949e;
  font-size: 0.95rem;
  max-width: 480px;
  line-height: 1.6;
}
@media (max-width: 639px) {
  header h1 { font-size: 1.7rem; }
}

/* ── Search ───────────────────────────────────────────────── */
.search-wrap { position: relative; margin-bottom: 32px; }
.search-row  { display: flex; gap: 10px; }

input[type="text"] {
  flex: 1;
  padding: 11px 14px;
  background: rgba(22, 27, 34, 0.85);
  backdrop-filter: blur(6px);
  border: 1px solid #30363d;
  border-radius: 8px;
  color: #e6edf3;
  font-size: 1rem;
  outline: none;
  transition: border-color 0.2s;
}
input[type="text"]:focus { border-color: #58a6ff; }

button[type="submit"] {
  padding: 0 14px;
  background: transparent;
  color: #8b949e;
  border: 1px solid #30363d;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.2s, border-color 0.2s;
}
button[type="submit"]:hover { color: #e6edf3; border-color: #58a6ff; }
button[type="submit"] svg  { display: block; }

/* ── Autocomplete ─────────────────────────────────────────── */
.autocomplete-list {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 90px;
  background: rgba(22, 27, 34, 0.97);
  border: 1px solid #30363d;
  border-radius: 8px;
  z-index: 100;
  overflow: hidden;
  display: none;
}
.autocomplete-list.open { display: block; }
.autocomplete-item {
  padding: 10px 14px;
  cursor: pointer;
  font-size: 0.9rem;
  color: #e6edf3;
}
.autocomplete-item:hover,
.autocomplete-item.active { background: #21262d; }
.autocomplete-item small  { color: #8b949e; margin-left: 6px; }

/* ── Messages ─────────────────────────────────────────────── */
.error { color: #f85149; margin-bottom: 20px; font-size: 0.95rem; }
.meta  { color: #8b949e; margin-bottom: 16px; font-size: 0.9rem; }

/* ── Legend ───────────────────────────────────────────────── */
.legend-section {
  background: rgba(22, 27, 34, 0.6);
  border: 1px solid #30363d;
  border-radius: 10px;
  padding: 16px 20px;
  margin-bottom: 20px;
}
.legend-heading {
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: #555d68;
  margin-bottom: 12px;
}
.legend {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px 24px;
}
.legend-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
}
.legend-bar {
  width: 4px;
  height: 36px;
  border-radius: 2px;
  flex-shrink: 0;
  margin-top: 2px;
}
.lb-golden { background: #f0a500; }
.lb-visible { background: #1f6feb; }
.lb-low {
  background: repeating-linear-gradient(
    to bottom,
    #555d68 0px, #555d68 4px,
    transparent 4px, transparent 8px
  );
}
.lb-none { background: #30363d; }
.legend-label {
  font-size: 0.82rem;
  font-weight: 600;
  color: #e6edf3;
  display: block;
  margin-bottom: 2px;
}
.legend-desc {
  font-size: 0.75rem;
  color: #8b949e;
  line-height: 1.4;
}
@media (max-width: 639px) {
  .legend { grid-template-columns: 1fr; }
}

/* ── Badges ───────────────────────────────────────────────── */
.badge {
  display: inline-block;
  font-size: 0.68rem;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 20px;
  vertical-align: middle;
  margin-left: 4px;
}
.badge-golden { background: rgba(240,165,0,0.15); color: #f0a500; border: 1px solid rgba(240,165,0,0.25); }
.badge-v      { background: rgba(31,111,235,0.12); color: #58a6ff; border: 1px solid rgba(88,166,255,0.2); }
.badge-low    { background: rgba(139,148,158,0.1); color: #8b949e; border: 1px solid rgba(139,148,158,0.2); }

/* ══════════════════════════════════════════════════════════
   DESKTOP TABLE (≥ 640px)
══════════════════════════════════════════════════════════ */
.pass-table { width: 100%; border-collapse: collapse; font-size: 0.9rem; table-layout: fixed; }
.pass-table th {
  background: rgba(22, 27, 34, 0.7);
  color: #8b949e;
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid #30363d;
  font-weight: 500;
  overflow: hidden;
}
.pass-table td { padding: 10px 12px; border-bottom: 1px solid #21262d; overflow: hidden; white-space: nowrap; }

/* Column widths — fixed so expanding rows don't shift layout */
.pass-table th:nth-child(1) { width: 26%; }
.pass-table th:nth-child(2) { width: 15%; }
.pass-table th:nth-child(3) { width: 12%; }
.pass-table th:nth-child(4) { width: 16%; }
.pass-table th:nth-child(5) { width: 16%; }
.pass-table th:nth-child(6) { width: auto; }

.pass-table tr.hl-3 td { background: rgba(240,165,0,0.10); }
.pass-table tr.hl-3 td:first-child { border-left: 3px solid #f0a500; padding-left: 9px; }

.pass-table tr.hl-2 td { background: rgba(240,165,0,0.04); color: #c9d1d9; }
.pass-table tr.hl-2 td:first-child { border-left: 3px solid rgba(240,165,0,0.4); padding-left: 9px; }

.pass-table tr.hl-1 td { color: #8b949e; }
.pass-table tr.hl-1 td:first-child { border-left: 3px dashed rgba(240,165,0,0.25); padding-left: 9px; }

.pass-table tr.hl-v td:first-child { border-left: 3px solid #1f6feb; padding-left: 9px; }

.pass-table tr.hl-0 td { color: #8b949e; }

.pass-table tr.low-pass.hl-3 td { background: rgba(240,165,0,0.05); }
.pass-table tr.low-pass:not(.hl-0) td:first-child { border-left-style: dashed !important; opacity: 0.7; }

/* ══════════════════════════════════════════════════════════
   MOBILE CARDS (< 640px)
══════════════════════════════════════════════════════════ */
.pass-cards { display: none; }

.pass-card {
  background: rgba(22, 27, 34, 0.75);
  backdrop-filter: blur(4px);
  border: 1px solid #21262d;
  border-radius: 10px;
  padding: 14px 16px;
  margin-bottom: 12px;
  border-left: 3px solid #30363d;
}
.pass-card.hl-3 { border-left-color: #f0a500; background: rgba(240,165,0,0.08); }
.pass-card.hl-2 { border-left-color: rgba(240,165,0,0.4); background: rgba(240,165,0,0.03); }
.pass-card.hl-1 { border-left-color: rgba(240,165,0,0.2); border-left-style: dashed; color: #8b949e; }
.pass-card.hl-v { border-left-color: #1f6feb; }
.pass-card.hl-0 { color: #8b949e; }
.pass-card.low-pass:not(.hl-0) { border-left-style: dashed; opacity: 0.8; }

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}
.card-date { font-weight: 600; font-size: 0.95rem; color: #e6edf3; }
.card-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 12px; }
.card-field { font-size: 0.82rem; }
.card-label { color: #8b949e; display: block; font-size: 0.72rem; margin-bottom: 1px; }
.card-value { color: #e6edf3; }
.card-weather { margin-top: 8px; padding-top: 8px; border-top: 1px solid #21262d; font-size: 0.82rem; }
.card-hidden { display: none; }

.show-more-btn {
  width: 100%;
  padding: 12px;
  background: transparent;
  border: 1px solid #30363d;
  border-radius: 10px;
  color: #8b949e;
  font-size: 0.85rem;
  cursor: pointer;
  transition: border-color 0.2s, color 0.2s;
  margin-top: 4px;
}
.show-more-btn:hover { border-color: #58a6ff; color: #e6edf3; }


@media (max-width: 639px) {
  body { padding: 24px 14px; }
  header h1 { font-size: 1.4rem; }
  .search-row { flex-direction: row; }
  button[type="submit"] { width: 46px; height: 46px; }
  .autocomplete-list { right: 0; }
  .pass-table-wrap { display: none; }
  .pass-cards { display: block; }
}

/* ── ISS Footer ───────────────────────────────────────────── */
.iss-footer {
  margin-top: 80px;
  padding-top: 40px;
  border-top: 1px solid #21262d;
  text-align: center;
}
.iss-footer-heading {
  font-size: 0.72rem;
  color: #8b949e;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  margin-bottom: 28px;
}
.iss-footer-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px 32px;
  margin-bottom: 20px;
  max-width: 640px;
  margin-left: auto;
  margin-right: auto;
}
.iss-fact { display: flex; flex-direction: column; gap: 4px; align-items: center; }
.iss-fact-label { font-size: 0.68rem; color: #8b949e; text-transform: uppercase; letter-spacing: 0.06em; }
.iss-fact-value { font-size: 1.05rem; color: #e6edf3; font-weight: 500; }
.iss-footer-note {
  font-size: 0.8rem;
  color: #8b949e;
  max-width: 520px;
  margin: 0 auto 48px;
  line-height: 1.6;
}

/* ── Deorbit block ────────────────────────────────────────── */
.deorbit-block {
  background: rgba(22, 27, 34, 0.7);
  border: 1px solid #30363d;
  border-radius: 12px;
  padding: 36px 24px 32px;
  max-width: 680px;
  margin: 0 auto 48px;
}
.deorbit-title {
  font-size: 0.75rem;
  font-weight: 600;
  color: #f0a500;
  margin-bottom: 12px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}
.deorbit-desc {
  font-size: 0.85rem;
  color: #8b949e;
  line-height: 1.7;
  margin-bottom: 32px;
  max-width: 520px;
  margin-left: auto;
  margin-right: auto;
}
.countdown-label {
  font-size: 0.68rem;
  color: #555d68;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-bottom: 20px;
}
.countdown { display: flex; align-items: flex-start; gap: 10px; flex-wrap: wrap; justify-content: center; }

/* ── Flip clock ───────────────────────────────────────────── */
.flip-unit { display: flex; flex-direction: column; align-items: center; gap: 8px; }
.flip-unit-label { font-size: 0.6rem; color: #555d68; letter-spacing: 0.12em; text-transform: uppercase; }

.flip-card {
  position: relative;
  width: 68px; height: 82px;
  font-family: 'Courier New', Courier, monospace;
  font-size: 3.2rem;
  font-weight: 700;
  perspective: 300px;
}
.flip-card.wide { width: 96px; }

.flip-top, .flip-bot {
  position: absolute; left: 0; right: 0;
  height: 50%; overflow: hidden;
  background: #161b22;
  display: flex; align-items: flex-end; justify-content: center;
}
.flip-top { top: 0; border-radius: 6px 6px 0 0; border-bottom: 1px solid #0d1117; align-items: flex-start; }
.flip-bot { bottom: 0; border-radius: 0 0 6px 6px; align-items: flex-end; }
.flip-top span, .flip-bot span {
  display: block;
  line-height: 82px;
  color: #58a6ff;
  text-shadow: 0 0 18px rgba(88,166,255,0.5);
  user-select: none;
}
.flip-flap {
  position: absolute; left: 0; right: 0; top: 0; height: 50%;
  overflow: hidden;
  background: #1c2128;
  border-radius: 6px 6px 0 0;
  transform-origin: bottom center;
  transform: rotateX(0deg);
  backface-visibility: hidden;
  display: flex; align-items: flex-start; justify-content: center;
  border-bottom: 1px solid #0d1117;
}
.flip-flap span {
  display: block;
  line-height: 82px;
  color: #58a6ff;
  text-shadow: 0 0 18px rgba(88,166,255,0.5);
  user-select: none;
}
.flip-flap.flipping { animation: flipDown 0.35s ease-in forwards; }
@keyframes flipDown {
  0%   { transform: rotateX(0deg);   background: #1c2128; }
  50%  { transform: rotateX(-90deg); background: #0d1117; }
  100% { transform: rotateX(-90deg); background: #0d1117; }
}
.cd-sep {
  font-family: 'Courier New', Courier, monospace;
  font-size: 2.6rem;
  font-weight: 700;
  color: #21262d;
  line-height: 82px;
}
.iss-copyright { font-size: 0.72rem; color: #555d68; padding-bottom: 24px; }

@media (max-width: 639px) {
  .iss-footer-grid { grid-template-columns: repeat(2, 1fr); }
  .flip-card { width: 50px; height: 62px; font-size: 2.3rem; }
  .flip-card.wide { width: 72px; }
  .flip-top span, .flip-bot span, .flip-flap span { line-height: 62px; }
  .cd-sep { font-size: 1.9rem; line-height: 62px; }
}

/* ── Compass overlay ──────────────────────────────────────── */
.compass-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(13, 17, 23, 0.96);
  backdrop-filter: blur(8px);
  z-index: 1000;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.compass-overlay.open { display: flex; }

.compass-close {
  position: absolute;
  top: 20px; right: 20px;
  background: none;
  border: 1px solid #30363d;
  border-radius: 8px;
  color: #8b949e;
  font-size: 1.2rem;
  width: 40px; height: 40px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.compass-close:hover { color: #e6edf3; border-color: #58a6ff; }

.compass-title { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.12em; color: #8b949e; margin-bottom: 6px; }
.compass-date  { font-size: 1.1rem; font-weight: 600; color: #e6edf3; margin-bottom: 28px; }

.compass-ring { position: relative; width: 280px; height: 280px; margin-bottom: 28px; }
.compass-ring svg { width: 100%; height: 100%; }

.compass-instruction {
  font-size: 0.85rem;
  color: #8b949e;
  text-align: center;
  max-width: 280px;
  line-height: 1.6;
  margin-bottom: 20px;
}
.compass-instruction strong { color: #e6edf3; }

.compass-legend { display: flex; gap: 20px; font-size: 0.78rem; color: #8b949e; }
.compass-legend span { display: flex; align-items: center; gap: 6px; }
.leg-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }

.compass-permission-btn {
  padding: 12px 24px;
  background: #1f6feb;
  border: none;
  border-radius: 8px;
  color: #fff;
  font-size: 0.9rem;
  cursor: pointer;
  margin-bottom: 16px;
}
.compass-permission-btn:hover { background: #388bfd; }

.compass-no-sensor {
  display: none;
  font-size: 0.85rem;
  color: #f0a500;
  text-align: center;
  max-width: 260px;
  line-height: 1.6;
}

/* ── Desktop toast ────────────────────────────────────────── */
#compass-toast {
  position: fixed;
  bottom: 32px;
  left: 50%;
  transform: translateX(-50%) translateY(calc(100% + 48px));
  transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
  background: #161b22;
  border: 1px solid #30363d;
  border-radius: 12px;
  padding: 20px 24px;
  font-size: 0.85rem;
  color: #e6edf3;
  z-index: 2000;
  text-align: center;
  max-width: 320px;
  line-height: 1.6;
  box-shadow: 0 8px 32px rgba(0,0,0,0.6);
}
#compass-toast.toast-visible {
  transform: translateX(-50%) translateY(0);
}
#compass-toast.toast-hiding {
  transform: translateX(-50%) translateY(calc(100% + 48px));
  transition: transform 0.35s ease-in;
  pointer-events: none;
}

/* ── Site nav ─────────────────────────────────────────────── */
.site-nav {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 32px;
  flex-wrap: wrap;
}
.site-nav a {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border: 1px solid #30363d;
  border-radius: 20px;
  color: #8b949e;
  text-decoration: none;
  font-size: 0.82rem;
  transition: color 0.2s, border-color 0.2s;
}
.site-nav a:hover     { color: #e6edf3; border-color: #58a6ff; }
.site-nav a.active    { color: #e6edf3; border-color: #58a6ff; background: rgba(88,166,255,0.08); }
.site-nav a svg       { flex-shrink: 0; }

/* Invisible passes table */
.pass-table-dim { opacity: 0.55; }
.pass-table-dim:hover { opacity: 0.8; transition: opacity 0.2s; }


/* ── Table show-more / fade ───────────────────────────────── */
.row-hidden { display: none; }

.pass-table-wrap {
  position: relative;
}

.table-fade {
  position: absolute;
  bottom: 44px; /* sit above the button */
  left: 0; right: 0;
  height: 80px;
  background: linear-gradient(to bottom, transparent, #0d1117);
  pointer-events: none;
}

.table-show-more {
  display: block;
  width: 100%;
  margin-top: 0;
  padding: 10px;
  background: none;
  border: 1px solid #21262d;
  border-top: none;
  border-radius: 0 0 8px 8px;
  color: #8b949e;
  font-size: 0.82rem;
  cursor: pointer;
  text-align: center;
  transition: color 0.2s, background 0.2s;
}
.table-show-more:hover { color: #e6edf3; background: rgba(255,255,255,0.03); }

/* Invisible passes table */
.pass-table-dim { opacity: 0.55; transition: opacity 0.2s; }
.pass-table-dim:hover { opacity: 0.8; }
