/* ==========================================================================
   viklab — space pages (APOD, near-Earth asteroids)
   A fixed starfield behind the page, glass consoles and panels that follow
   the light/dark theme, and "viewports" into deep space that stay dark in
   both themes. Loaded only by view/apod.php and view/asteroids.php.
   ========================================================================== */

@font-face {
  font-family: 'Unbounded';
  font-style: normal;
  font-weight: 200 900;
  font-display: swap;
  src: url('../assets/fonts/unbounded-var-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA,
    U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193,
    U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'Unbounded';
  font-style: normal;
  font-weight: 200 900;
  font-display: swap;
  src: url('../assets/fonts/unbounded-var-latin-ext.woff2') format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF,
    U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020,
    U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

/* --------------------------------------------------------------------------
   Tokens
   -------------------------------------------------------------------------- */
.space-page {
  --sp-display: 'Unbounded', var(--font-sans);

  /* page-level (follow the theme) */
  --sp-glass: rgba(14, 15, 26, 0.62);
  --sp-glass-line: rgba(255, 255, 255, 0.09);
  --sp-title-grad: linear-gradient(180deg, #ffffff 20%, #b9c0ff 75%, #7dd3fc 110%);
  --sp-haz: #fbbf24;
  --sp-haz-ink: #fcd34d;
  --sp-haz-soft: rgba(251, 191, 36, 0.14);

  /* deep-space viewports (always dark) */
  --sp-void: #04050c;
  --sp-void-2: #0a0d1f;
  --sp-ink: #e8eaff;
  --sp-ink-2: rgba(232, 234, 255, 0.66);
  --sp-ink-3: rgba(232, 234, 255, 0.42);
  --sp-line: rgba(160, 175, 255, 0.16);
  --sp-cyan: #67e8f9;
  --sp-safe: #c7d2fe;
}

[data-theme='light'] .space-page {
  --sp-glass: rgba(255, 255, 255, 0.72);
  --sp-glass-line: rgba(9, 9, 11, 0.09);
  --sp-title-grad: linear-gradient(180deg, #131316 25%, #3f3fa8 80%, #0e7490 115%);
  --sp-haz: #d97706;
  --sp-haz-ink: #b45309;
  --sp-haz-soft: rgba(217, 119, 6, 0.12);
}

/* --------------------------------------------------------------------------
   Starfield (fixed, behind everything)
   -------------------------------------------------------------------------- */
.sp-sky {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  overflow: hidden;
  background:
    radial-gradient(ellipse 80% 55% at 50% -10%, rgba(76, 89, 220, 0.22), transparent 70%),
    radial-gradient(ellipse 60% 50% at 100% 100%, rgba(34, 211, 238, 0.07), transparent 70%),
    var(--bg);
}

.sp-sky__stars {
  position: absolute;
  inset: -50%;
  background-repeat: repeat;
}

/* two tiles of hand-placed stars, offset so the repeat never lines up */
.sp-sky__stars--far {
  background-image:
    radial-gradient(1px 1px at 20px 30px, rgba(255, 255, 255, 0.55), transparent 60%),
    radial-gradient(1px 1px at 140px 80px, rgba(255, 255, 255, 0.4), transparent 60%),
    radial-gradient(1px 1px at 90px 160px, rgba(200, 210, 255, 0.5), transparent 60%),
    radial-gradient(1px 1px at 220px 210px, rgba(255, 255, 255, 0.35), transparent 60%),
    radial-gradient(1px 1px at 260px 40px, rgba(255, 255, 255, 0.45), transparent 60%),
    radial-gradient(1px 1px at 180px 270px, rgba(180, 230, 255, 0.4), transparent 60%),
    radial-gradient(1px 1px at 40px 240px, rgba(255, 255, 255, 0.3), transparent 60%);
  background-size: 290px 290px;
  animation: sp-drift 240s linear infinite;
}

.sp-sky__stars--near {
  background-image:
    radial-gradient(1.5px 1.5px at 60px 110px, #fff, transparent 60%),
    radial-gradient(1.5px 1.5px at 330px 60px, rgba(190, 205, 255, 0.95), transparent 60%),
    radial-gradient(2px 2px at 250px 380px, rgba(255, 255, 255, 0.85), transparent 60%),
    radial-gradient(1.5px 1.5px at 430px 260px, rgba(160, 240, 255, 0.9), transparent 60%),
    radial-gradient(1.5px 1.5px at 150px 470px, rgba(255, 255, 255, 0.8), transparent 60%);
  background-size: 520px 520px;
  animation: sp-drift 160s linear infinite reverse, sp-twinkle 6s ease-in-out infinite alternate;
}

.sp-sky__nebula {
  position: absolute;
  width: 70vmax;
  height: 70vmax;
  left: -25vmax;
  top: 35vh;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(167, 139, 250, 0.1), transparent 65%);
  filter: blur(20px);
}

[data-theme='light'] .sp-sky {
  background:
    radial-gradient(ellipse 80% 55% at 50% -10%, rgba(79, 93, 232, 0.12), transparent 70%),
    radial-gradient(ellipse 60% 50% at 100% 100%, rgba(8, 145, 178, 0.08), transparent 70%),
    var(--bg);
}

[data-theme='light'] .sp-sky__stars {
  filter: invert(1);
  opacity: 0.22;
}

[data-theme='light'] .sp-sky__nebula {
  opacity: 0.5;
}

@keyframes sp-drift {
  to {
    transform: translate3d(290px, 145px, 0);
  }
}

@keyframes sp-twinkle {
  from {
    opacity: 0.55;
  }
  to {
    opacity: 1;
  }
}

/* --------------------------------------------------------------------------
   Head
   -------------------------------------------------------------------------- */
.sp-wrap {
  position: relative;
}

.sp-head {
  max-width: 860px;
  margin-bottom: clamp(1.75rem, 4vh, 2.5rem);
}

.sp-kicker {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.38rem 0.8rem 0.38rem 0.65rem;
  border: 1px solid var(--sp-glass-line);
  border-radius: 999px;
  background: var(--sp-glass);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  font-family: var(--font-mono);
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-2);
  margin-bottom: 1.1rem;
}

.sp-kicker__dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent-2);
  box-shadow: 0 0 0 0 rgba(34, 211, 238, 0.6);
  animation: sp-ping 2.4s var(--ease) infinite;
}

@keyframes sp-ping {
  0% {
    box-shadow: 0 0 0 0 rgba(34, 211, 238, 0.55);
  }
  70%,
  100% {
    box-shadow: 0 0 0 9px rgba(34, 211, 238, 0);
  }
}

.sp-title {
  font-family: var(--sp-display);
  font-weight: 600;
  font-size: clamp(2rem, 5.2vw, 3.9rem);
  line-height: 1.04;
  letter-spacing: -0.03em;
  margin: 0 0 1rem;
  background: var(--sp-title-grad);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  text-wrap: balance;
}

.sp-sub {
  font-size: clamp(1rem, 1.4vw, 1.125rem);
  line-height: 1.6;
  color: var(--text-2);
  max-width: 640px;
  margin: 0;
  text-wrap: pretty;
}

/* --------------------------------------------------------------------------
   Console (date picker + actions)
   -------------------------------------------------------------------------- */
.sp-console {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 0.75rem 1rem;
  padding: 0.9rem;
  margin-bottom: 1.5rem;
  border: 1px solid var(--sp-glass-line);
  border-radius: 18px;
  background: var(--sp-glass);
  backdrop-filter: blur(14px) saturate(1.2);
  -webkit-backdrop-filter: blur(14px) saturate(1.2);
}

.sp-field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin: 0;
}

.sp-field__label {
  font-family: var(--font-mono);
  font-size: 0.66rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-3);
  padding-left: 0.15rem;
}

.sp-field__input {
  height: 44px;
  min-width: 190px;
  padding: 0 0.9rem;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 0.95rem;
  font-variant-numeric: tabular-nums;
  outline: none;
  transition: border-color var(--dur-2) var(--ease), box-shadow var(--dur-2) var(--ease);
}

.sp-field__input:focus-visible {
  border-color: var(--accent);
  box-shadow: var(--ring);
}

.sp-field__input::-webkit-calendar-picker-indicator {
  cursor: pointer;
  opacity: 0.7;
}

.sp-console__quick {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-left: auto;
}

.sp-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  height: 44px;
  min-width: 44px;
  justify-content: center;
  padding: 0 0.95rem;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  color: var(--text-2);
  font-size: 0.9rem;
  font-weight: 500;
  text-decoration: none;
  transition: color var(--dur-1) var(--ease), border-color var(--dur-1) var(--ease),
    background-color var(--dur-1) var(--ease);
}

.sp-chip:hover {
  color: var(--text);
  border-color: var(--text-3);
  background: var(--surface);
}

.sp-chip .icon {
  width: 16px;
  height: 16px;
}

.sp-chip.is-loading {
  pointer-events: none;
  opacity: 0.6;
}

.sp-flip {
  transform: scaleX(-1);
}

/* --------------------------------------------------------------------------
   Viewport: a window into deep space (dark in both themes)
   -------------------------------------------------------------------------- */
.sp-viewport {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  border-radius: 22px;
  border: 1px solid var(--sp-line);
  background:
    radial-gradient(ellipse 70% 60% at 50% 40%, rgba(70, 82, 200, 0.18), transparent 70%),
    radial-gradient(1px 1px at 12% 22%, rgba(255, 255, 255, 0.7), transparent 60%),
    radial-gradient(1px 1px at 78% 14%, rgba(255, 255, 255, 0.5), transparent 60%),
    radial-gradient(1px 1px at 64% 72%, rgba(200, 220, 255, 0.6), transparent 60%),
    radial-gradient(1px 1px at 28% 84%, rgba(255, 255, 255, 0.45), transparent 60%),
    radial-gradient(1px 1px at 90% 58%, rgba(255, 255, 255, 0.55), transparent 60%),
    linear-gradient(180deg, var(--sp-void-2), var(--sp-void));
  color: var(--sp-ink);
  box-shadow: 0 30px 80px -30px rgba(0, 0, 0, 0.7), inset 0 1px 0 rgba(255, 255, 255, 0.05);
  color-scheme: dark;
}

[data-theme='light'] .sp-viewport {
  box-shadow: 0 30px 70px -30px rgba(20, 24, 60, 0.45);
}

/* HUD labels and corner brackets */
.sp-hud {
  position: absolute;
  top: 16px;
  z-index: 3;
  margin: 0;
  padding: 0.32rem 0.6rem;
  border-radius: 6px;
  background: rgba(4, 5, 12, 0.6);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  font-family: var(--font-mono);
  font-size: 0.66rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  line-height: 1.3;
  text-transform: uppercase;
  color: var(--sp-ink-2);
}

.sp-hud--tl {
  left: 16px;
}

.sp-hud--tr {
  right: 16px;
  color: var(--sp-cyan);
}

.sp-corner {
  position: absolute;
  z-index: 3;
  width: 16px;
  height: 16px;
  border: 0 solid rgba(103, 232, 249, 0.55);
  pointer-events: none;
}

.sp-corner--tl {
  top: 8px;
  left: 8px;
  border-top-width: 1.5px;
  border-left-width: 1.5px;
  border-top-left-radius: 6px;
}

.sp-corner--tr {
  top: 8px;
  right: 8px;
  border-top-width: 1.5px;
  border-right-width: 1.5px;
  border-top-right-radius: 6px;
}

.sp-corner--bl {
  bottom: 8px;
  left: 8px;
  border-bottom-width: 1.5px;
  border-left-width: 1.5px;
  border-bottom-left-radius: 6px;
}

.sp-corner--br {
  bottom: 8px;
  right: 8px;
  border-bottom-width: 1.5px;
  border-right-width: 1.5px;
  border-bottom-right-radius: 6px;
}

/* --------------------------------------------------------------------------
   APOD
   -------------------------------------------------------------------------- */
.sp-viewport__media {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 320px;
  color: inherit;
  text-decoration: none;
  cursor: zoom-in;
}

/* the picture itself, blurred, as ambient light around the letterbox */
.sp-viewport__media::before {
  content: '';
  position: absolute;
  inset: -40px;
  z-index: -1;
  background-image: var(--sp-img, none);
  background-size: cover;
  background-position: center;
  filter: blur(40px) saturate(1.3);
  opacity: 0.45;
}

.sp-viewport__media img {
  display: block;
  width: auto;
  max-width: 100%;
  max-height: min(78vh, 860px);
  object-fit: contain;
  transition: transform 1.2s var(--ease);
}

.sp-viewport__media:hover img {
  transform: scale(1.012);
}

.sp-viewport__media--frame,
.sp-viewport__media--link {
  cursor: pointer;
  aspect-ratio: 16 / 9;
  min-height: 0;
}

.sp-viewport__media--frame iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
}

.sp-viewport__media--link img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  max-height: none;
  object-fit: cover;
  opacity: 0.7;
}

.sp-play {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.85rem 1.3rem;
  border-radius: 999px;
  background: rgba(4, 5, 12, 0.7);
  border: 1px solid rgba(255, 255, 255, 0.2);
  backdrop-filter: blur(8px);
  font-weight: 500;
}

.sp-daynav {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 1rem;
  margin: 1rem 0 clamp(2rem, 5vh, 3rem);
}

.sp-daynav__date {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-3);
  text-align: center;
}

.sp-daynav__btn {
  justify-self: start;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.2rem;
  color: var(--text-2);
  font-size: 0.9rem;
  text-decoration: none;
  transition: color var(--dur-1) var(--ease);
}

.sp-daynav__btn--next {
  justify-self: end;
}

.sp-daynav__btn:hover {
  color: var(--text);
}

.sp-daynav__btn .icon {
  width: 16px;
  height: 16px;
  transition: transform var(--dur-2) var(--ease);
}

.sp-daynav__btn:hover .icon {
  transform: translateX(3px);
}

.sp-daynav__btn:hover .sp-flip {
  transform: scaleX(-1) translateX(3px);
}

.sp-apod__body {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: clamp(1.5rem, 4vw, 4rem);
  align-items: start;
}

.sp-apod__title {
  font-family: var(--sp-display);
  font-weight: 500;
  font-size: clamp(1.5rem, 3vw, 2.3rem);
  line-height: 1.15;
  letter-spacing: -0.02em;
  margin: 0 0 1.25rem;
  text-wrap: balance;
}

.sp-apod__explain {
  font-size: 1.075rem;
  line-height: 1.8;
  color: var(--text-2);
  max-width: 68ch;
  margin: 0;
  text-wrap: pretty;
}

.sp-apod__explain::first-letter {
  float: left;
  font-family: var(--sp-display);
  font-weight: 600;
  font-size: 3.4em;
  line-height: 0.9;
  margin: 0.08em 0.12em 0 0;
  background: var(--grad);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

/* Glass panel (follows the theme) */
.sp-panel {
  border: 1px solid var(--sp-glass-line);
  border-radius: 18px;
  background: var(--sp-glass);
  backdrop-filter: blur(14px) saturate(1.2);
  -webkit-backdrop-filter: blur(14px) saturate(1.2);
  padding: 1.25rem;
}

.sp-apod__meta {
  position: sticky;
  top: calc(var(--nav-h) + 1.5rem);
}

.sp-meta {
  margin: 0 0 1.1rem;
}

.sp-meta > div {
  display: grid;
  gap: 0.2rem;
  padding: 0.7rem 0;
  border-bottom: 1px dashed var(--border-strong);
}

.sp-meta > div:first-child {
  padding-top: 0;
}

.sp-meta dt {
  font-family: var(--font-mono);
  font-size: 0.66rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-3);
}

.sp-meta dd {
  margin: 0;
  color: var(--text);
  font-size: 0.95rem;
}

.sp-source {
  margin: 0.9rem 0 0;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--text-3);
}

/* Idle / error state: an orrery */
.sp-viewport--idle {
  display: grid;
  place-items: center;
  min-height: clamp(380px, 56vh, 560px);
  padding: 2rem 1.25rem;
}

.sp-orbit {
  position: relative;
  width: min(360px, 76vw);
  aspect-ratio: 1;
  grid-area: 1 / 1;
  opacity: 0.9;
}

.sp-orbit__core {
  position: absolute;
  inset: 41%;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #fff4d6, #fbbf24 45%, #f97316 80%);
  box-shadow: 0 0 40px 10px rgba(251, 191, 36, 0.35), 0 0 120px 40px rgba(249, 115, 22, 0.12);
}

.sp-orbit__ring {
  position: absolute;
  border-radius: 50%;
  border: 1px solid var(--sp-line);
  animation: sp-spin linear infinite;
}

.sp-orbit__ring i {
  position: absolute;
  top: -5px;
  left: 50%;
  width: 10px;
  height: 10px;
  margin-left: -5px;
  border-radius: 50%;
}

.sp-orbit__ring--1 {
  inset: 30%;
  animation-duration: 9s;
}

.sp-orbit__ring--1 i {
  background: #a5b4fc;
  width: 7px;
  height: 7px;
  top: -3.5px;
  margin-left: -3.5px;
}

.sp-orbit__ring--2 {
  inset: 16%;
  animation-duration: 16s;
  animation-direction: reverse;
}

.sp-orbit__ring--2 i {
  background: radial-gradient(circle at 35% 35%, #9fd8ff, #2f6fd6);
  box-shadow: 0 0 12px rgba(96, 165, 250, 0.6);
}

.sp-orbit__ring--3 {
  inset: 2%;
  border-style: dashed;
  animation-duration: 30s;
}

.sp-orbit__ring--3 i {
  background: var(--sp-cyan);
  width: 6px;
  height: 6px;
  top: -3px;
  margin-left: -3px;
  box-shadow: 0 0 10px var(--sp-cyan);
}

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

.sp-idle {
  grid-area: 1 / 1;
  align-self: end;
  position: relative;
  z-index: 2;
  text-align: center;
  max-width: 460px;
  padding: 0.9rem 1.2rem;
  border-radius: 14px;
  background: rgba(4, 5, 12, 0.55);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.sp-idle p {
  margin: 0;
}

.sp-idle__title {
  font-family: var(--sp-display);
  font-weight: 500;
  font-size: 1.05rem;
  color: var(--sp-ink);
}

.sp-idle__title--warn {
  font-family: var(--font-sans);
  font-size: 0.95rem;
  line-height: 1.55;
  color: #fcd34d;
}

.sp-idle__text {
  margin-top: 0.3rem !important;
  color: var(--sp-ink-2);
  font-size: 0.92rem;
}

/* --------------------------------------------------------------------------
   Asteroids: stat strip
   -------------------------------------------------------------------------- */
.sp-stats {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}

.sp-stat {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  min-width: 0;
  padding: 1rem 1.1rem;
  border: 1px solid var(--sp-glass-line);
  border-radius: 16px;
  background: var(--sp-glass);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  overflow: hidden;
}

.sp-stat::before {
  content: '';
  position: absolute;
  left: 1.1rem;
  right: 1.1rem;
  top: 0;
  height: 2px;
  border-radius: 0 0 2px 2px;
  background: var(--grad);
  opacity: 0.7;
}

.sp-stat--warn::before {
  background: var(--sp-haz);
  opacity: 1;
}

.sp-stat__label {
  font-family: var(--font-mono);
  font-size: 0.64rem;
  font-weight: 600;
  letter-spacing: 0.13em;
  text-transform: uppercase;
  color: var(--text-3);
}

.sp-stat__value {
  font-family: var(--sp-display);
  font-weight: 500;
  font-size: clamp(1.4rem, 2.4vw, 1.9rem);
  line-height: 1.1;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  color: var(--text);
  white-space: nowrap;
}

.sp-stat__value small {
  font-family: var(--font-mono);
  font-size: 0.48em;
  font-weight: 500;
  letter-spacing: 0.04em;
  color: var(--text-3);
}

.sp-stat--warn .sp-stat__value {
  color: var(--sp-haz-ink);
}

.sp-stat__note {
  font-size: 0.8rem;
  color: var(--text-3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* --------------------------------------------------------------------------
   Asteroids: radar + log
   -------------------------------------------------------------------------- */
.sp-neo {
  display: grid;
  grid-template-columns: minmax(0, 5fr) minmax(0, 7fr);
  gap: 1.25rem;
  align-items: start;
}

.sp-neo--solo {
  grid-template-columns: minmax(0, 1fr);
}

.sp-neo--solo .sp-radar-box {
  max-width: 620px;
  width: 100%;
  margin-inline: auto;
}

.sp-radar-box {
  padding: 3.4rem 1.25rem 1.25rem;
  position: sticky;
  top: calc(var(--nav-h) + 1rem);
}

.sp-neo--solo .sp-radar-box {
  position: relative;
  top: auto;
  display: grid;
}

.sp-neo--solo .sp-radar {
  grid-area: 1 / 1;
}

.sp-idle--radar {
  align-self: center;
  justify-self: center;
}

.sp-radar {
  position: relative;
  width: 100%;
  max-width: 520px;
  margin-inline: auto;
  aspect-ratio: 1;
}

.sp-radar__svg {
  position: relative;
  display: block;
  width: 100%;
  height: 100%;
  overflow: visible;
}

/* rotating sweep, clipped to the rim (rim = 170 of 200 → 85 % of the box) */
.sp-radar__sweep {
  position: absolute;
  inset: 7.5%;
  border-radius: 50%;
  background: conic-gradient(from 0deg, rgba(103, 232, 249, 0.16), rgba(103, 232, 249, 0) 70deg, transparent 360deg);
  animation: sp-spin 7s linear infinite;
  pointer-events: none;
}

.sp-radar__ring {
  fill: none;
  stroke: var(--sp-line);
  stroke-width: 1;
  stroke-dasharray: 2 4;
}

.sp-radar__ring--moon {
  stroke: rgba(226, 232, 255, 0.45);
  stroke-dasharray: none;
}

.sp-radar__ring--rim {
  stroke: rgba(160, 175, 255, 0.28);
  stroke-dasharray: none;
}

.sp-radar__axis {
  stroke: var(--sp-line);
  stroke-width: 1;
}

.sp-radar__label {
  font-family: var(--font-mono);
  font-size: 9.5px;
  letter-spacing: 0.04em;
  fill: var(--sp-ink-3);
  paint-order: stroke;
  stroke: var(--sp-void);
  stroke-width: 3px;
}

.sp-radar__labels {
  pointer-events: none;
}

.sp-radar__label--moon {
  fill: var(--sp-ink);
  font-weight: 600;
}

.sp-radar__tick {
  stroke: rgba(160, 175, 255, 0.35);
  stroke-width: 1;
}

.sp-radar__tick--major {
  stroke: var(--sp-cyan);
  stroke-width: 1.5;
}

.sp-radar__hour {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  fill: var(--sp-ink-2);
}

.sp-radar__hour--utc {
  font-size: 9px;
  font-weight: 500;
  letter-spacing: 0.1em;
  fill: var(--sp-cyan);
}

.sp-radar__key circle {
  fill: none;
  stroke: var(--sp-safe);
  stroke-width: 1;
  opacity: 0.8;
}

.sp-radar__key text {
  font-family: var(--font-mono);
  font-size: 9.5px;
  fill: var(--sp-ink-3);
}

.sp-dot__name {
  font-family: var(--font-sans);
  font-size: 11px;
  font-weight: 600;
  fill: var(--sp-ink);
  paint-order: stroke;
  stroke: var(--sp-void);
  stroke-width: 3.5px;
  pointer-events: none;
}

.sp-radar__earth {
  filter: drop-shadow(0 0 6px rgba(96, 165, 250, 0.8));
}

.sp-dot {
  cursor: pointer;
  outline: none;
}

.sp-dot__hit {
  fill: transparent;
}

.sp-dot__core {
  fill: var(--sp-safe);
  stroke: var(--sp-void);
  stroke-width: 1.5;
  transition: transform var(--dur-2) var(--ease), fill var(--dur-2) var(--ease);
}

.sp-dot--haz .sp-dot__core {
  fill: #fbbf24;
}

.sp-dot__halo {
  fill: none;
  stroke: #fbbf24;
  stroke-width: 1.2;
  opacity: 0.7;
  transform-box: fill-box;
  transform-origin: center;
  animation: sp-halo 2.6s var(--ease) infinite;
}

@keyframes sp-halo {
  0% {
    transform: scale(0.8);
    opacity: 0.8;
  }
  100% {
    transform: scale(1.7);
    opacity: 0;
  }
}

.sp-dot:hover .sp-dot__core,
.sp-dot:focus-visible .sp-dot__core,
.sp-dot.is-on .sp-dot__core {
  transform: scale(1.45);
  fill: #fff;
}

.sp-dot--haz:hover .sp-dot__core,
.sp-dot--haz:focus-visible .sp-dot__core,
.sp-dot--haz.is-on .sp-dot__core {
  fill: #fde68a;
}

.sp-dot:focus-visible .sp-dot__hit {
  stroke: var(--sp-cyan);
  stroke-width: 1.5;
}

.sp-tip {
  position: absolute;
  z-index: 5;
  width: max-content;
  min-width: 210px;
  max-width: min(270px, 100%);
  padding: 0.7rem 0.8rem 0.6rem;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(8, 10, 24, 0.94);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.5);
  color: var(--sp-ink);
  font-family: var(--font-sans);
  line-height: 1.35;
  pointer-events: none;
  transform: translate(-50%, calc(-100% - 14px));
}

.sp-tip__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
  padding-bottom: 0.5rem;
  margin-bottom: 0.35rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.sp-tip__head strong {
  font-size: 0.9rem;
  font-weight: 600;
}

.sp-tip__haz {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.12rem 0.45rem;
  border-radius: 999px;
  background: rgba(251, 191, 36, 0.15);
  color: #fcd34d;
  font-size: 0.68rem;
  font-weight: 600;
  white-space: nowrap;
}

.sp-tip__haz .sp-ico {
  width: 12px;
  height: 12px;
}

.sp-tip__row {
  display: grid;
  grid-template-columns: 18px 1fr auto;
  align-items: start;
  gap: 0.55rem;
  padding: 0.28rem 0;
}

.sp-tip__row .sp-ico {
  width: 17px;
  height: 17px;
  color: var(--sp-cyan);
}

.sp-tip__val {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  font-weight: 600;
  white-space: nowrap;
}

.sp-tip__val small {
  display: block;
  font-size: 0.68rem;
  font-weight: 400;
  color: var(--sp-ink-3);
}

.sp-tip__lab {
  font-size: 0.68rem;
  color: var(--sp-ink-3);
  text-align: right;
  padding-top: 0.08rem;
}

.sp-read {
  margin: 1.1rem auto 0;
  max-width: 460px;
  padding: 0.9rem 1rem;
  border: 1px solid var(--sp-line);
  border-radius: 14px;
  background: rgba(4, 5, 12, 0.45);
}

.sp-read__title {
  margin: 0 0 0.55rem;
  font-family: var(--font-mono);
  font-size: 0.64rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--sp-cyan);
}

.sp-read ul {
  display: grid;
  gap: 0.5rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.sp-read li {
  display: grid;
  grid-template-columns: 22px 1fr;
  gap: 0.6rem;
  align-items: start;
  font-size: 0.8rem;
  line-height: 1.5;
  color: var(--sp-ink-2);
}

.sp-read b {
  color: var(--sp-ink);
  font-weight: 600;
}

.sp-read__ico {
  position: relative;
  width: 22px;
  height: 22px;
  margin-top: -1px;
}

/* distance: Earth inside two rings */
.sp-read__ico--dist {
  border-radius: 50%;
  border: 1px solid rgba(226, 232, 255, 0.6);
  background: radial-gradient(circle, #4f8ef0 0 3px, transparent 3.5px);
}

.sp-read__ico--dist::after {
  content: '';
  position: absolute;
  inset: 4px;
  border-radius: 50%;
  border: 1px dashed rgba(160, 175, 255, 0.5);
}

/* time: a clock hand */
.sp-read__ico--time {
  border-radius: 50%;
  border: 1px solid rgba(160, 175, 255, 0.5);
}

.sp-read__ico--time::before,
.sp-read__ico--time::after {
  content: '';
  position: absolute;
  left: 50%;
  bottom: 50%;
  width: 1.5px;
  margin-left: -0.75px;
  background: var(--sp-cyan);
  transform-origin: 50% 100%;
}

.sp-read__ico--time::before {
  height: 7px;
}

.sp-read__ico--time::after {
  height: 5px;
  transform: rotate(100deg);
}

/* size: three growing dots */
.sp-read__ico--size {
  background:
    radial-gradient(circle at 3px 15px, var(--sp-safe) 0 2px, transparent 2.5px),
    radial-gradient(circle at 9px 13px, var(--sp-safe) 0 3.5px, transparent 4px),
    radial-gradient(circle at 17px 11px, var(--sp-safe) 0 5px, transparent 5.5px);
}

.sp-read__ico--haz {
  background: radial-gradient(circle, #fbbf24 0 5px, rgba(251, 191, 36, 0.25) 5.5px 9px, transparent 9.5px);
}

/* Flyby log */
.sp-log {
  padding: 1.25rem 0 1rem;
  min-width: 0;
}

.sp-log__head {
  padding: 0 1.25rem 0.9rem;
}

.sp-log__title {
  font-family: var(--sp-display);
  font-weight: 500;
  font-size: 1.15rem;
  letter-spacing: -0.01em;
  margin: 0 0 0.2rem;
}

.sp-log__note {
  margin: 0;
  font-size: 0.82rem;
  color: var(--text-3);
}

.sp-log__scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.sp-log .sp-source {
  padding: 0 1.25rem;
}

.sp-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
  font-variant-numeric: tabular-nums;
}

.sp-table th {
  position: sticky;
  top: 0;
  padding: 0;
  text-align: left;
  border-bottom: 1px solid var(--border-strong);
  white-space: nowrap;
}

.sp-table th button {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  width: 100%;
  padding: 0.55rem 0.55rem;
  border: 0;
  background: none;
  font: inherit;
  font-family: var(--font-mono);
  font-size: 0.64rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-3);
  cursor: pointer;
  text-align: inherit;
}

.sp-table th.num button {
  justify-content: flex-end;
}

.sp-table th .sp-ico {
  width: 13px;
  height: 13px;
  opacity: 0.8;
}

.sp-table td .sp-ico {
  display: none;
}

.sp-phone {
  display: none;
}

.sp-table th button:hover {
  color: var(--text);
}

.sp-table th button::after {
  content: '';
  width: 0;
  height: 0;
  border-inline: 3.5px solid transparent;
  border-top: 4px solid currentColor;
  opacity: 0;
  transition: transform var(--dur-1) var(--ease), opacity var(--dur-1) var(--ease);
}

.sp-table th[aria-sort] button {
  color: var(--text);
}

.sp-table th[aria-sort] button::after {
  opacity: 0.9;
}

.sp-table th[aria-sort='ascending'] button::after {
  transform: rotate(180deg);
}

.sp-table th:first-child button,
.sp-table td:first-child {
  padding-left: 1.25rem;
}

.sp-table th:last-child button,
.sp-table td:last-child {
  padding-right: 1.25rem;
}

.sp-table td {
  padding: 0.65rem 0.55rem;
  border-bottom: 1px solid var(--border);
  color: var(--text-2);
  white-space: nowrap;
  vertical-align: middle;
}

.sp-table td.sp-c-name {
  white-space: normal;
  min-width: 7.5rem;
}

.sp-table tbody tr {
  transition: background-color var(--dur-1) var(--ease);
}

.sp-table tbody tr:hover,
.sp-table tbody tr.is-on {
  background: var(--accent-soft);
}

.sp-table tbody tr:last-child td {
  border-bottom: 0;
}

.sp-table .num {
  text-align: right;
  font-family: var(--font-mono);
  font-size: 0.82rem;
}

.sp-table td strong {
  color: var(--text);
  font-weight: 600;
}

.sp-table .unit {
  color: var(--text-3);
  font-size: 0.9em;
}

.sp-table__sub {
  display: block;
  font-size: 0.72rem;
  color: var(--text-3);
}

.sp-table__name {
  color: var(--text);
  font-weight: 500;
  text-decoration: none;
  background-image: linear-gradient(currentColor, currentColor);
  background-size: 0 1px;
  background-position: 0 100%;
  background-repeat: no-repeat;
  transition: background-size var(--dur-2) var(--ease), color var(--dur-1) var(--ease);
}

a.sp-table__name:hover {
  color: var(--accent);
  background-size: 100% 1px;
}

.sp-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.18rem 0.55rem;
  border-radius: 999px;
  border: 1px solid var(--border-strong);
  font-size: 0.74rem;
  font-weight: 500;
  color: var(--text-3);
}

.sp-pill .icon {
  width: 12px;
  height: 12px;
}

.sp-pill--haz {
  border-color: color-mix(in srgb, var(--sp-haz) 50%, transparent);
  background: var(--sp-haz-soft);
  color: var(--sp-haz-ink);
}

/* --------------------------------------------------------------------------
   Responsive
   -------------------------------------------------------------------------- */
@media (max-width: 1100px) {
  .sp-stats {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

/* radar above the log once the log's column gets too narrow for the table */
@media (max-width: 1240px) {
  .sp-neo {
    grid-template-columns: minmax(0, 1fr);
  }

  .sp-radar-box {
    position: relative;
    top: auto;
  }
}

@media (max-width: 860px) {
  .sp-apod__body {
    grid-template-columns: minmax(0, 1fr);
  }

  .sp-apod__meta {
    position: static;
  }
}

@media (max-width: 640px) {
  .sp-console {
    align-items: stretch;
  }

  .sp-field {
    flex: 1 1 100%;
  }

  .sp-field__input {
    width: 100%;
    min-width: 0;
  }

  .sp-console__go {
    flex: 1 1 auto;
  }

  .sp-console__quick {
    margin-left: 0;
  }

  .sp-stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .sp-stats .sp-stat:first-child {
    grid-column: 1 / -1;
  }

  .sp-viewport {
    border-radius: 16px;
  }

  .sp-radar-box {
    padding-inline: 0.5rem;
  }

  .sp-daynav__btn {
    font-size: 0;
    gap: 0;
    padding: 0.6rem;
  }

  .sp-daynav__btn .icon {
    width: 20px;
    height: 20px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .sp-sky__stars,
  .sp-kicker__dot,
  .sp-orbit__ring,
  .sp-radar__sweep,
  .sp-dot__halo {
    animation: none !important;
  }

  .sp-radar__sweep {
    display: none;
  }
}

/* --------------------------------------------------------------------------
   Phones: the date field fits its box (iOS sizes date inputs natively unless
   their appearance is reset); below 760px the flyby log becomes a list of
   cards, every value with its pictogram
   -------------------------------------------------------------------------- */
@media (max-width: 640px) {
  .sp-field {
    min-width: 0;
  }

  .sp-field__input {
    -webkit-appearance: none;
    appearance: none;
    display: block;
    box-sizing: border-box;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    min-height: 44px;
    text-align: left;
  }

  .sp-field__input::-webkit-date-and-time-value {
    text-align: left;
    margin: 0;
  }

}

@media (max-width: 760px) {
  .sp-desk {
    display: none;
  }

  .sp-phone {
    display: inline;
  }

  .sp-log__scroll {
    overflow: visible;
  }

  .sp-table,
  .sp-table tbody {
    display: block;
  }

  .sp-table thead {
    display: none;
  }

  .sp-table tbody tr {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 0.55rem 0.9rem;
    padding: 0.9rem 1.1rem;
    border-bottom: 1px solid var(--border);
  }

  .sp-table tbody tr:last-child {
    border-bottom: 0;
  }

  .sp-table td,
  .sp-table td:first-child,
  .sp-table td:last-child {
    display: flex;
    align-items: flex-start;
    gap: 0.45rem;
    min-width: 0;
    padding: 0;
    border: 0;
    white-space: normal;
    text-align: left;
  }

  .sp-table td .sp-ico {
    display: block;
    flex: none;
    width: 16px;
    height: 16px;
    margin-top: 0.05rem;
    color: var(--accent-2);
  }

  .sp-table .sp-c-name {
    grid-column: 1;
    grid-row: 1;
    align-self: center;
  }

  .sp-table .sp-c-name .sp-table__name {
    font-size: 1rem;
    font-weight: 600;
  }

  .sp-table .sp-c-haz {
    grid-column: 2;
    grid-row: 1;
    justify-content: flex-end;
    align-self: center;
  }

  .sp-table .sp-c-dist {
    grid-column: 1;
    grid-row: 2;
  }

  .sp-table .sp-c-size {
    grid-column: 2;
    grid-row: 2;
  }

  .sp-table .sp-c-time {
    grid-column: 1;
    grid-row: 3;
  }

  .sp-table .sp-c-speed {
    grid-column: 2;
    grid-row: 3;
  }
}
