/* ==========================================================================
   Animated galaxy viewer (Milky Way / Andromeda)
   Reuses the solar-system interaction language: moving visual + labelled
   hotspots + a compact control strip.
   ========================================================================== */

.galaxy-viz {
  position: relative;
  height: clamp(340px, 52vh, 560px);
  margin: 26px 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 18px;
  background:
    radial-gradient(ellipse 70% 60% at 50% 42%, rgba(46, 52, 78, 0.35), transparent 72%),
    #05070d;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.4);
}

.galaxy-explore {
  display: grid;
  gap: 6px;
  margin: 30px 0 12px;
}

.galaxy-explore-kicker {
  color: var(--text-dim);
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.07em;
  text-transform: uppercase;
}

.galaxy-explore h2 {
  margin: 0;
  color: var(--text);
  font-size: 20px;
  font-weight: 600;
  letter-spacing: -0.015em;
}

.galaxy-explore p {
  max-width: 680px;
  margin: 0;
  color: var(--text-soft);
  font-size: 13px;
  line-height: 1.7;
}

.galaxy-view-scale {
  position: absolute;
  top: 12px;
  left: 12px;
  z-index: 3;
  padding: 5px 9px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 999px;
  background: rgba(10, 13, 22, 0.55);
  color: rgba(234, 241, 253, 0.78);
  font-size: 8.5px;
  font-weight: 600;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  pointer-events: none;
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
}

.galaxy-neighborhood {
  display: none;
  grid-template-columns: minmax(0, 1fr) 220px;
  gap: 18px;
  align-items: center;
  margin-top: 12px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background:
    linear-gradient(120deg, rgba(190, 214, 255, 0.04), transparent 70%),
    var(--surface);
}

.galaxy-neighborhood.is-visible {
  display: grid;
}

.gn-copy {
  display: grid;
  gap: 7px;
}

.gn-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  color: rgba(234, 241, 253, 0.82);
  font-size: 8.5px;
  font-weight: 600;
  letter-spacing: 0.07em;
  text-transform: uppercase;
}

.gn-head span:last-child {
  color: rgba(234, 241, 253, 0.42);
  font-size: 7.5px;
  font-weight: 600;
  letter-spacing: 0;
}

.gn-map {
  position: relative;
  width: 220px;
  height: 220px;
  aspect-ratio: 1;
  margin: 0;
  justify-self: end;
  border: 1px dashed rgba(255, 255, 255, 0.12);
  border-radius: 50%;
  background:
    radial-gradient(circle at 50% 50%, rgba(219, 232, 255, 0.06), transparent 60%),
    rgba(255, 255, 255, 0.015);
}

.gn-map::before,
.gn-map::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: 50%;
  transform: translate(-50%, -50%);
  pointer-events: none;
}

.gn-map::before {
  width: 50%;
  height: 50%;
}

.gn-map::after {
  width: 78%;
  height: 78%;
}

.gn-star {
  position: absolute;
  left: var(--x);
  top: var(--y);
  z-index: 1;
  display: grid;
  place-items: center;
  min-width: 20px;
  transform: translate(-50%, -50%);
  color: rgba(238, 243, 252, 0.86);
  text-align: center;
  text-decoration: none;
  white-space: nowrap;
}

.gn-star i {
  width: 6px;
  height: 6px;
  border: 1px solid rgba(255, 255, 255, 0.7);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.22);
  box-shadow: 0 0 6px rgba(190, 210, 255, 0.55);
  transition: transform 0.16s ease, background 0.16s ease, box-shadow 0.16s ease;
}

.gn-star.is-link:hover i,
.gn-star.is-link:focus-visible i {
  transform: scale(1.35);
  background: #ffffff;
  box-shadow:
    0 0 0 3px rgba(255, 255, 255, 0.12),
    0 0 12px rgba(210, 228, 255, 0.95);
}

.gn-star b {
  margin-top: 2px;
  font-size: 7.5px;
  font-weight: 600;
  line-height: 1.1;
}

.gn-star small {
  color: rgba(234, 241, 253, 0.45);
  font-size: 6.5px;
  line-height: 1.2;
}

.gn-star.is-link i {
  border-width: 1.5px;
  border-color: #ffffff;
  background: rgba(255, 255, 255, 0.48);
  box-shadow:
    0 0 0 3px rgba(255, 255, 255, 0.1),
    0 0 9px rgba(200, 220, 255, 0.9);
}

.gn-star.is-link:hover b,
.gn-star.is-link:focus-visible b {
  color: #ffffff;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.gn-star.is-link:focus-visible {
  outline: none;
}

.gn-note {
  max-width: 460px;
  margin: 0;
  color: var(--text-soft);
  font-size: 11px;
  line-height: 1.55;
}

.gn-hint {
  margin: 0;
  color: var(--text-dim);
  font-size: 10px;
  line-height: 1.5;
}

.galaxy-canvas {
  position: absolute;
  inset: 0;
  display: block;
  cursor: grab;
  touch-action: none;
}

.galaxy-viz.is-panning .galaxy-canvas {
  cursor: grabbing;
}

.galaxy-hotspots {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.galaxy-spot {
  position: absolute;
  left: 0;
  top: 0;
  width: 0;
  height: 0;
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  text-decoration: none;
  pointer-events: auto;
  cursor: pointer;
}

.galaxy-spot::before {
  content: "";
  position: absolute;
  left: -14px;
  top: -14px;
  width: 28px;
  height: 28px;
  border-radius: 50%;
}

.galaxy-spot.has-label::after {
  content: attr(data-label);
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  padding: 3px 7px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 999px;
  background: rgba(8, 11, 19, 0.72);
  color: rgba(238, 243, 252, 0.94);
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0;
  line-height: 1.2;
  white-space: nowrap;
  pointer-events: none;
}

.galaxy-spot.has-label:hover::after,
.galaxy-spot.has-label:focus-visible::after {
  opacity: 0;
}

.galaxy-spot-dot {
  position: absolute;
  left: 0;
  top: 0;
  width: 12px;
  height: 12px;
  transform: translate(-50%, -50%);
  border: 1.5px solid rgba(255, 255, 255, 0.85);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.22);
  box-shadow: 0 0 12px rgba(190, 210, 255, 0.7);
  transition: transform 0.16s ease, background 0.16s ease, box-shadow 0.16s ease;
}

.galaxy-viz.has-hover .galaxy-spot {
  opacity: 0.38;
}

.galaxy-viz.has-hover .galaxy-spot.is-hovered {
  opacity: 1;
}

.galaxy-spot.is-hovered .galaxy-spot-dot {
  transform: translate(-50%, -50%) scale(1.3);
  background: #ffffff;
  box-shadow:
    0 0 0 4px rgba(255, 255, 255, 0.12),
    0 0 20px rgba(210, 228, 255, 0.95);
}

.galaxy-spot-tip {
  position: absolute;
  left: 14px;
  top: 50%;
  width: min(250px, calc(100vw - 48px));
  transform: translate(4px, -50%);
  display: grid;
  gap: 4px;
  padding: 10px 12px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 12px;
  background: rgba(10, 13, 22, 0.94);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  color: #eaf1fd;
  text-align: left;
  opacity: 0;
  visibility: hidden;
  transform: translate(4px, -50%);
  transition: opacity 0.18s ease, transform 0.18s ease, visibility 0.18s ease;
}

.galaxy-spot-tip strong {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0;
}

.galaxy-spot-tip span {
  color: rgba(231, 237, 248, 0.72);
  font-size: 11px;
  line-height: 1.55;
}

.galaxy-spot-tip em {
  color: rgba(190, 214, 255, 0.92);
  font-size: 10px;
  font-style: normal;
  letter-spacing: 0.07em;
  text-transform: uppercase;
}

.galaxy-spot:hover .galaxy-spot-tip,
.galaxy-spot:focus-visible .galaxy-spot-tip {
  opacity: 1;
  visibility: visible;
  transform: translate(0, -50%);
}

.galaxy-spot:hover .galaxy-spot-dot,
.galaxy-spot:focus-visible .galaxy-spot-dot {
  background: rgba(255, 255, 255, 0.75);
}

.galaxy-spot.is-link .galaxy-spot-dot {
  background: rgba(255, 255, 255, 0.34);
  box-shadow:
    0 0 0 3px rgba(255, 255, 255, 0.1),
    0 0 16px rgba(190, 210, 255, 0.85);
}

.galaxy-spot.is-link:hover .galaxy-spot-dot,
.galaxy-spot.is-link:focus-visible .galaxy-spot-dot {
  background: #ffffff;
  box-shadow:
    0 0 0 4px rgba(255, 255, 255, 0.16),
    0 0 20px rgba(200, 220, 255, 0.95);
}

.galaxy-spot:focus-visible {
  outline: none;
}

.galaxy-spot:focus-visible .galaxy-spot-dot {
  outline: 2px solid rgba(198, 220, 255, 0.75);
  outline-offset: 4px;
}

.galaxy-viz.is-labels-hidden .galaxy-spot {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.galaxy-viz.is-labels-hidden .galaxy-view-scale {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.galaxy-viz.is-labels-hidden + .galaxy-neighborhood {
  display: none;
}

.galaxy-controls {
  position: absolute;
  left: 12px;
  bottom: 12px;
  z-index: 3;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  max-width: calc(100% - 24px);
  padding: 4px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  background: rgba(10, 13, 22, 0.5);
  -webkit-backdrop-filter: blur(12px) saturate(1.05);
  backdrop-filter: blur(12px) saturate(1.05);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.28);
}

.galaxy-ctl {
  display: grid;
  place-items: center;
  height: 28px;
  padding: 0 9px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  background: transparent;
  color: rgba(234, 241, 253, 0.85);
  font: inherit;
  font-size: 10.5px;
  cursor: pointer;
}

.galaxy-ctl:hover,
.galaxy-ctl:focus-visible {
  border-color: rgba(255, 255, 255, 0.32);
  color: #ffffff;
}

.galaxy-ctl-play {
  width: 28px;
  padding: 0;
}

.galaxy-ctl-play svg {
  width: 14px;
  height: 14px;
  fill: currentColor;
}

.galaxy-ctl-play .g-pause {
  display: block;
}

.galaxy-ctl-play .g-play {
  display: none;
}

.galaxy-viz.is-paused .galaxy-ctl-play .g-pause {
  display: none;
}

.galaxy-viz.is-paused .galaxy-ctl-play .g-play {
  display: block;
}

.galaxy-speed {
  display: flex;
  gap: 2px;
  padding: 2px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
}

.galaxy-speed button {
  height: 22px;
  min-width: 30px;
  padding: 0 5px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: rgba(234, 241, 253, 0.7);
  font: inherit;
  font-size: 10px;
  cursor: pointer;
}

.galaxy-speed button:hover,
.galaxy-speed button:focus-visible {
  color: #ffffff;
}

.galaxy-speed button.is-active {
  background: rgba(255, 255, 255, 0.14);
  color: #ffffff;
}

.galaxy-zoom {
  display: flex;
  gap: 2px;
  padding: 2px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
}

.galaxy-zoom button {
  height: 22px;
  min-width: 26px;
  padding: 0 5px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: rgba(234, 241, 253, 0.78);
  font: inherit;
  font-size: 11px;
  cursor: pointer;
}

.galaxy-zoom button:hover,
.galaxy-zoom button:focus-visible {
  background: rgba(255, 255, 255, 0.1);
  color: #ffffff;
}

.galaxy-caption {
  margin: -12px 0 0;
  color: var(--text-dim);
  font-size: 10px;
  letter-spacing: 0;
}

/* Interactive "future collision" panel (native <details>). */
.galaxy-collision {
  margin-top: 16px;
  padding: 14px 16px;
  border: 1px solid color-mix(in srgb, var(--accent) 28%, var(--line));
  border-radius: 14px;
  background:
    linear-gradient(120deg, color-mix(in srgb, var(--accent) 7%, transparent), transparent 70%),
    var(--surface);
}

.galaxy-collision summary {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 3px 14px;
  align-items: baseline;
  cursor: pointer;
  list-style: none;
}

.galaxy-collision summary::-webkit-details-marker {
  display: none;
}

.galaxy-collision summary::after {
  content: "+";
  grid-row: 1 / span 2;
  grid-column: 2;
  align-self: center;
  width: 24px;
  height: 24px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 50%;
  color: var(--text-dim);
  font-size: 14px;
}

.galaxy-collision[open] summary::after {
  content: "−";
}

.galaxy-collision-kicker {
  grid-column: 1;
  color: var(--text-dim);
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.07em;
  text-transform: uppercase;
}

.galaxy-collision summary strong {
  grid-column: 1;
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
  line-height: 1.35;
}

.galaxy-collision-when {
  grid-column: 1;
  color: var(--accent);
  font-size: 10px;
  letter-spacing: 0.07em;
}

.galaxy-collision-body {
  display: grid;
  gap: 10px;
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.galaxy-collision-body p {
  margin: 0;
  color: var(--text-soft);
  font-size: 12.5px;
  line-height: 1.7;
}

.galaxy-collision-timeline {
  --collision-progress: 0%;
  display: grid;
  gap: 0;
  margin-top: 4px;
  padding: 12px 12px 10px;
  border: 1px solid color-mix(in srgb, var(--accent) 18%, var(--line));
  border-radius: 12px;
  background: color-mix(in srgb, var(--accent) 4%, transparent);
}

.galaxy-collision-timeline-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  color: var(--text-dim);
  font-size: 8.5px;
  font-weight: 600;
  letter-spacing: 0.07em;
  text-transform: uppercase;
}

.galaxy-collision-date {
  color: var(--accent);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0;
  text-align: right;
  text-transform: none;
}

.galaxy-collision-scale {
  position: relative;
  height: 34px;
}

.galaxy-collision-rail {
  position: absolute;
  top: 14px;
  right: 0;
  left: 0;
  height: 6px;
  overflow: hidden;
  border-radius: 999px;
  background: color-mix(in srgb, var(--text-dim) 20%, transparent);
}

.galaxy-collision-fill {
  position: absolute;
  inset: 0 auto 0 0;
  width: var(--collision-progress);
  border-radius: inherit;
  background: linear-gradient(90deg, #8fb8e8, #c9a8e8);
  transition: width 0.12s linear;
}

.galaxy-collision-marker {
  position: absolute;
  top: 50%;
  left: var(--collision-at);
  width: 2px;
  height: 6px;
  transform: translate(-50%, -50%);
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.45);
}

.galaxy-collision-range {
  position: absolute;
  inset: 0;
  z-index: 2;
  width: 100%;
  height: 34px;
  margin: 0;
  border-radius: 8px;
  background: transparent;
  cursor: ew-resize;
  -webkit-appearance: none;
  appearance: none;
}

.galaxy-collision-range::-webkit-slider-runnable-track {
  height: 34px;
  background: transparent;
}

.galaxy-collision-range::-webkit-slider-thumb {
  width: 18px;
  height: 18px;
  margin-top: 8px;
  border: 2px solid color-mix(in srgb, var(--accent) 62%, #ffffff);
  border-radius: 50%;
  background: #f3f6ff;
  box-shadow:
    0 0 0 4px color-mix(in srgb, var(--accent) 18%, transparent),
    0 0 14px color-mix(in srgb, var(--accent) 60%, transparent);
  -webkit-appearance: none;
  appearance: none;
}

.galaxy-collision-range::-moz-range-track {
  height: 34px;
  background: transparent;
}

.galaxy-collision-range::-moz-range-thumb {
  width: 15px;
  height: 15px;
  border: 2px solid color-mix(in srgb, var(--accent) 62%, #ffffff);
  border-radius: 50%;
  background: #f3f6ff;
  box-shadow:
    0 0 0 4px color-mix(in srgb, var(--accent) 18%, transparent),
    0 0 14px color-mix(in srgb, var(--accent) 60%, transparent);
}

.galaxy-collision-range:focus-visible {
  outline: 2px solid color-mix(in srgb, var(--accent) 74%, #ffffff);
  outline-offset: 3px;
}

.galaxy-collision-labels {
  position: relative;
  height: 35px;
  color: var(--text-dim);
  font-size: 9px;
  letter-spacing: 0;
}

.galaxy-collision-labels button {
  position: absolute;
  top: 0;
  left: var(--collision-at);
  display: grid;
  gap: 1px;
  min-height: 32px;
  padding: 2px 3px;
  border: 0;
  border-radius: 5px;
  background: transparent;
  color: inherit;
  font: inherit;
  line-height: 1.25;
  text-align: center;
  white-space: nowrap;
  cursor: pointer;
  transform: translateX(-50%);
}

.galaxy-collision-labels button:first-child {
  text-align: left;
  transform: none;
}

.galaxy-collision-labels button:last-child {
  text-align: right;
  transform: translateX(-100%);
}

.galaxy-collision-labels button:hover,
.galaxy-collision-labels button:focus-visible {
  background: color-mix(in srgb, var(--accent) 10%, transparent);
  color: var(--text);
}

.galaxy-collision-labels button:focus-visible {
  outline: 1px solid color-mix(in srgb, var(--accent) 65%, transparent);
  outline-offset: 1px;
}

.galaxy-collision-labels small {
  color: color-mix(in srgb, var(--accent) 76%, var(--text-dim));
  font-size: 7.5px;
  letter-spacing: 0;
}

.galaxy-collision-readout {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 7px;
  align-items: baseline;
  min-height: 20px;
  margin: 5px 0 0;
  padding-left: 9px;
  border-left: 2px solid color-mix(in srgb, var(--accent) 65%, transparent);
}

.galaxy-collision-readout strong {
  color: var(--text);
  font-size: 10.5px;
  font-weight: 600;
  white-space: nowrap;
}

.galaxy-collision-readout span {
  color: var(--text-soft);
  font-size: 10.5px;
  line-height: 1.45;
}

.galaxy-collision-scale-note {
  margin: 4px 0 0;
  color: var(--text-dim);
  font-size: 8px;
  letter-spacing: 0;
}

@media (max-width: 700px) {
  .galaxy-viz {
    height: clamp(300px, 56vh, 460px);
    border-radius: 14px;
  }

  .galaxy-controls {
    left: 8px;
    bottom: 8px;
    gap: 4px;
    max-width: calc(100% - 16px);
  }

  .galaxy-neighborhood {
    grid-template-columns: 1fr;
    gap: 12px;
    padding: 12px;
  }

  .gn-map {
    width: 200px;
    height: 200px;
    justify-self: center;
  }

  .galaxy-ctl {
    height: 28px;
    padding: 0 8px;
  }

  .galaxy-collision-timeline {
    padding-inline: 9px;
  }

  .galaxy-collision-labels {
    font-size: 8px;
  }

  .galaxy-collision-labels small {
    font-size: 7px;
  }

  .galaxy-collision-readout {
    grid-template-columns: 1fr;
    gap: 2px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .galaxy-spot-tip {
    transition: none;
  }
}
