/* The map takes the space between the existing header and footer. */
.solar-home {
  --map-chrome: 158px;
  min-height: 100vh;
  min-height: 100svh;
  isolation: isolate;
  background:
    radial-gradient(ellipse at 14% 72%, #181d39 0, transparent 53%),
    radial-gradient(ellipse at 82% 24%, #21172f 0, transparent 54%),
    #070912;
}

.galactic-sky {
  position: fixed;
  inset: 0;
  z-index: -1;
  width: 100%;
  height: 100%;
  max-width: none;
  object-fit: cover;
  opacity: .66;
  pointer-events: none;
}

@media (max-aspect-ratio: 4/5) {
  .galactic-sky {
    inset: auto;
    top: 50%;
    left: 50%;
    width: 100vh;
    width: 100lvh;
    height: 100vw;
    transform: translate(-50%, -50%) rotate(-90deg);
  }
}

.solar-home.cosmic-ready {
  overflow: auto;
}

.solar-home .site-header,
.solar-home footer {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
}

.solar-home.cosmic-ready footer {
  position: static;
}

.solar-home .site-header nav,
.solar-home footer .coordinate {
  grid-column: 2;
}

.solar-home .header-contact,
.solar-home footer > a {
  grid-column: 3;
  justify-self: end;
}

.solar-home footer > a {
  padding-block: 8px;
}

.solar-stage {
  position: relative;
  isolation: isolate;
  height: calc(100vh - var(--map-chrome));
  height: calc(100svh - var(--map-chrome));
}

.solar-system {
  position: absolute;
  inset: 0;
  overflow: hidden;
}

.star-field {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: -1;
}

.solar-sun {
  position: absolute;
  top: var(--sun-y, 50%);
  left: 50%;
  width: var(--sun-size);
  aspect-ratio: 1;
  transform: translate(-50%, -50%);
  pointer-events: none;
  z-index: 500;
}

.solar-sun::before {
  content: "";
  position: absolute;
  inset: -64%;
  border-radius: 50%;
  background: radial-gradient(circle, #ffbf572b 6%, #ffab3518 31%, #ef812b09 48%, transparent 68%);
}

.solar-sun img {
  display: block;
  width: 127%;
  max-width: none;
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  filter: brightness(1.22);
}

.solar-body {
  --diameter: 44px;
  --target: 52px;
  --art-height: var(--diameter);
  --photo-width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  width: var(--target);
  text-align: center;
  background: transparent;
  -webkit-tap-highlight-color: transparent;
}

.solar-system[data-ready] .solar-body {
  position: absolute;
  top: 0;
  left: 0;
  margin-left: calc(var(--target) / -2);
  margin-top: calc(var(--art-height) / -2);
  will-change: transform;
}

.solar-body:not(a) {
  pointer-events: none;
}

.planet-art {
  flex: none;
  position: relative;
  display: grid;
  place-items: center;
  width: 100%;
  height: var(--art-height);
}

.solar-body[href] .planet-art::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: var(--target);
  height: var(--target);
  transform: translate(-50%, -50%);
}

.planet-disc {
  position: relative;
  display: block;
  width: var(--diameter);
  height: var(--diameter);
  border-radius: 50%;
}

.planet-disc img {
  position: absolute;
  top: 50%;
  left: 50%;
  display: block;
  width: var(--photo-width);
  max-width: none;
  height: auto;
  transform: translate(-50%, -50%);
  user-select: none;
  pointer-events: none;
}

.planet-disc::before {
  content: "";
  position: absolute;
  z-index: 1;
  inset: 1%;
  border-radius: inherit;
  pointer-events: none;
  background: linear-gradient(90deg, transparent 22%, #080b1606 52%, #080b165e 84%, #080b1680);
  transform: rotate(var(--night-angle, 0deg));
}

/* Image bounds include the physical rings around the two ice/gas giants. */
[data-planet="saturn"] {
  --art-height: calc(var(--diameter) * 1.7);
  --photo-width: 360%;
  --ring-width: 3.55;
  --ring-height: 1;
  --ring-tilt: 24deg;
}
[data-planet="uranus"] {
  --photo-width: 104%;
  --ring-width: 0.74;
  --ring-height: 2.25;
  --ring-tilt: 11deg;
}

:is([data-planet="saturn"], [data-planet="uranus"]) .planet-art::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: calc(var(--diameter) * var(--ring-width));
  height: calc(var(--diameter) * var(--ring-height));
  border-radius: 50%;
  transform: translate(-50%, -50%) rotate(var(--ring-tilt));
}

.planet-caption {
  position: relative;
  z-index: 2;
  flex: none;
  width: max-content;
  max-width: min(150px, 40vw);
  margin-top: 1px;
  padding: 0 2px 3px;
  color: #eeedf5;
  font-size: clamp(13px, 1.1vw, 16px);
  line-height: 1.15;
  letter-spacing: -.015em;
  text-shadow: 0 1px 3px #070912, 0 0 7px #070912;
  text-wrap: balance;
}

.solar-body[href] .planet-disc::after {
  content: "";
  position: absolute;
  inset: -5px;
  border: 1px solid #ded9ffba;
  border-radius: 50%;
  box-shadow: 0 0 16px #b8aff02b;
  pointer-events: none;
  z-index: 2;
  opacity: 0;
  transition: opacity 140ms ease;
}

@media (hover: hover) and (pointer: fine) {
  .solar-body[href]:hover .planet-disc::after { opacity: 1; }
  .solar-body[href]:hover .planet-caption { text-decoration: underline; text-underline-offset: 3px; }
}

.solar-body[href]:focus-visible {
  outline: none;
}

.solar-body[href]:focus-visible .planet-disc::after { opacity: 1; }
.solar-body[href]:focus-visible .planet-caption { text-decoration: underline; text-underline-offset: 3px; }

/* Hash links still lead to the HTML sections if orbital motion is unavailable. */
.solar-system:not([data-ready]) {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 168px));
  align-content: center;
  justify-content: center;
  justify-items: center;
  gap: 32px 20px;
}

.solar-system:not([data-ready]) :is(.star-field, .solar-sun, .solar-body:not(a)) { display: none; }

@media (max-width: 760px) {
  .solar-home { --map-chrome: 146px; }
  .planet-caption { font-size: 13px; }
}

@media (max-height: 520px) and (orientation: landscape) {
  .solar-home { --map-chrome: 94px; }
  .solar-home .site-header { height: 54px; }
  .solar-home footer, .solar-home.cosmic-ready footer { height: 40px; }
  .planet-caption { font-size: 12px; }
}
