:root {
  color-scheme: dark;
  --ink: rgba(247, 250, 255, 0.94);
  --ink-soft: rgba(226, 235, 247, 0.7);
  --ink-faint: rgba(226, 235, 247, 0.48);
  --panel-ink: rgba(18, 22, 27, 0.88);
  --silver: #dbe2ea;
  --blue: #8bc7ff;
  --gold: #fff0bd;
  --black: #030508;
  --mx: 0;
  --my: 0;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  min-height: 100%;
  margin: 0;
  overflow: hidden;
  background: var(--black);
}

body {
  color: var(--ink);
}

a {
  color: inherit;
}

.moon-page {
  position: relative;
  isolation: isolate;
  width: 100vw;
  height: 100svh;
  min-height: 620px;
  overflow: hidden;
  background: #020407;
}

.moon-page::before,
.moon-page::after {
  position: absolute;
  inset: 0;
  z-index: 18;
  pointer-events: none;
  content: "";
}

.moon-page::before {
  background:
    radial-gradient(circle at 57% 19%, transparent 0 11%, rgba(113, 185, 255, 0.08) 15%, transparent 24%),
    radial-gradient(ellipse at 50% 73%, transparent 0 40%, rgba(0, 0, 0, 0.32) 75%, rgba(0, 0, 0, 0.78) 100%),
    linear-gradient(90deg, rgba(0, 0, 0, 0.38), transparent 18% 78%, rgba(0, 0, 0, 0.44));
}

.moon-page::after {
  background:
    linear-gradient(180deg, transparent 0 42%, rgba(255, 255, 255, 0.035) 46%, transparent 51%),
    radial-gradient(circle at 19.5% 52%, rgba(255, 247, 220, 0.18), transparent 7%),
    radial-gradient(ellipse at 82% 75%, rgba(255, 238, 194, 0.16), transparent 17%);
  mix-blend-mode: screen;
  opacity: 0.82;
}

.layer {
  transform:
    translate3d(calc(var(--mx) * var(--depth-x, 0px)), calc(var(--my) * var(--depth-y, 0px)), 0)
    scale(var(--layer-scale, 1));
  transition: transform 850ms cubic-bezier(0.2, 0.7, 0.18, 1);
  will-change: transform;
}

.moon-backdrop {
  --depth-x: -11px;
  --depth-y: -7px;
  --layer-scale: 1.035;
  position: absolute;
  inset: -2.4%;
  z-index: 0;
  background-image: url("assets/moon/moon-landscape.png");
  background-position: center center;
  background-size: cover;
  filter: saturate(1.04) contrast(1.05);
}

.earth-halo {
  --depth-x: -18px;
  --depth-y: -10px;
  position: absolute;
  left: 42%;
  top: 3%;
  z-index: 2;
  width: min(32vw, 520px);
  aspect-ratio: 1;
  border-radius: 50%;
  background:
    radial-gradient(circle, rgba(161, 214, 255, 0.22), rgba(116, 177, 232, 0.08) 45%, transparent 69%);
  mix-blend-mode: screen;
  opacity: 0.74;
  animation: earth-breathe 6.5s ease-in-out infinite alternate;
}

.horizon-scan {
  position: absolute;
  left: -18%;
  right: -18%;
  top: 47%;
  z-index: 4;
  height: 1px;
  pointer-events: none;
  background: linear-gradient(90deg, transparent, rgba(192, 224, 255, 0.54), transparent);
  filter: blur(0.3px);
  opacity: 0;
  animation: horizon-scan 8.5s ease-in-out infinite;
}

.saucer-flight {
  --depth-x: -9px;
  --depth-y: -5px;
  position: absolute;
  left: 0;
  top: 0;
  z-index: 27;
  width: clamp(42px, 4.8vw, 86px);
  height: clamp(18px, 2vw, 36px);
  color: inherit;
  cursor: pointer;
  outline: none;
  pointer-events: auto;
  text-decoration: none;
  opacity: 0;
  transform:
    translate3d(112vw, 15vh, 0)
    scale(0.46);
  animation: saucer-flight 28s 3.8s cubic-bezier(0.4, 0, 0.2, 1) infinite;
  will-change: opacity, transform, filter;
}

.saucer-flight::before {
  position: absolute;
  inset: -18px -22px;
  border-radius: 999px;
  content: "";
}

.flying-saucer {
  position: relative;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  filter:
    drop-shadow(0 0 8px rgba(151, 206, 255, 0.18))
    drop-shadow(0 2px 3px rgba(0, 0, 0, 0.5));
}

.saucer-flight:focus-visible .flying-saucer {
  outline: 1px solid rgba(181, 226, 255, 0.76);
  outline-offset: 5px;
}

.saucer-rim,
.saucer-dome,
.saucer-glow {
  position: absolute;
  left: 50%;
  display: block;
  content: "";
  transform: translateX(-50%);
}

.saucer-rim {
  bottom: 18%;
  width: 100%;
  height: 36%;
  border-radius: 50%;
  background:
    radial-gradient(ellipse at 50% 65%, rgba(255, 255, 255, 0.34), transparent 23%),
    linear-gradient(180deg, rgba(218, 226, 232, 0.88), rgba(72, 86, 96, 0.9) 52%, rgba(17, 23, 29, 0.92));
  box-shadow:
    inset 0 1px 2px rgba(255, 255, 255, 0.42),
    inset 0 -2px 4px rgba(0, 0, 0, 0.55);
}

.saucer-dome {
  bottom: 34%;
  width: 42%;
  height: 46%;
  border-radius: 50% 50% 44% 44%;
  background:
    radial-gradient(ellipse at 38% 18%, rgba(255, 255, 255, 0.7), transparent 24%),
    linear-gradient(145deg, rgba(197, 225, 246, 0.8), rgba(75, 102, 119, 0.76) 60%, rgba(17, 24, 31, 0.82));
  opacity: 0.88;
}

.saucer-glow {
  bottom: 7%;
  width: 54%;
  height: 6%;
  border-radius: 999px;
  background: rgba(178, 222, 255, 0.58);
  box-shadow: 0 0 8px rgba(149, 213, 255, 0.42);
  opacity: 0.52;
}

.earth-return {
  --depth-x: -16px;
  --depth-y: -9px;
  position: absolute;
  left: 43.6%;
  top: -1%;
  z-index: 26;
  display: block;
  width: min(30vw, 430px);
  aspect-ratio: 1;
  border-radius: 50%;
  color: rgba(184, 224, 255, 0.86);
  text-decoration: none;
  outline: none;
  transition: transform 850ms cubic-bezier(0.2, 0.7, 0.18, 1);
}

.earth-return span,
.earth-return::before,
.earth-return::after {
  position: absolute;
  inset: 0;
  display: block;
  border-radius: inherit;
  content: "";
  pointer-events: none;
}

.earth-return span,
.earth-return::after {
  display: none;
}

.earth-return::before {
  inset: 9%;
  border: 1px solid rgba(180, 224, 255, 0);
  opacity: 0;
  transition: border-color 180ms ease, opacity 180ms ease;
}

.earth-return:focus-visible::before {
  border-color: rgba(176, 224, 255, 0.58);
  opacity: 1;
}

.moon-link {
  position: absolute;
  z-index: 24;
  display: grid;
  place-items: center;
  color: var(--panel-ink);
  text-align: center;
  text-decoration: none;
  outline: none;
  isolation: isolate;
  pointer-events: auto;
  transform-origin: center;
}

.moon-link::before,
.moon-link::after,
.link-glass,
.link-signal {
  position: absolute;
  inset: 0;
  pointer-events: none;
  content: "";
}

.link-glass {
  display: none;
}

.moon-link::before {
  display: none;
}

.moon-link::after {
  display: none;
}

.link-label {
  position: relative;
  z-index: 2;
  max-width: min(16ch, 90%);
  padding: 0.3em;
  font-size: clamp(0.55rem, 0.34rem + 0.54vw, 0.88rem);
  font-weight: 800;
  line-height: 1.4;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  transform: translate(var(--label-x, 0), var(--label-y, 0)) scaleX(0.92);
}

.link-signal {
  display: none;
}

.link-signal::before,
.link-signal::after {
  position: absolute;
  left: 50%;
  width: 8px;
  height: 8px;
  border-top: 1px solid currentColor;
  border-right: 1px solid currentColor;
  opacity: 0.72;
  content: "";
}

.link-signal::before {
  top: -4px;
  transform: translateX(-50%) rotate(-45deg);
}

.link-signal::after {
  top: -4px;
  transform: translateX(-50%) rotate(135deg);
}

.moon-link:is(:hover, :focus-visible),
.moon-page.is-signaling .moon-link {
  color: rgba(6, 9, 13, 0.96);
}

.moon-link:is(:hover, :focus-visible)::before {
  display: none;
}

.moon-link:is(:hover, :focus-visible)::after {
  display: none;
}

.moon-link:is(:hover, :focus-visible) .link-glass {
  display: none;
}

.relay-link {
  --depth-x: -11px;
  --depth-y: -7px;
  --label-x: 0%;
  --label-y: 0%;
  left: var(--relay-left, 16.8%);
  top: var(--relay-top, 41%);
  width: var(--relay-width, clamp(96px, 9.2vw, 170px));
  height: var(--relay-height, clamp(150px, 22.2vh, 226px));
  border-radius: 3px;
}

.relay-link .link-glass,
.relay-link::after {
  border-radius: 3px;
}

.relay-link .link-label {
  max-width: 8.3ch;
  font-size: clamp(0.52rem, 0.28rem + 0.5vw, 0.78rem);
  line-height: 1.52;
  letter-spacing: 0.24em;
}

.relay-link .link-signal {
  bottom: 14%;
}

.plaque-link {
  --depth-x: -11px;
  --depth-y: -7px;
  --label-x: 0%;
  --label-y: 0%;
  left: var(--plaque-left, 67.8%);
  top: var(--plaque-top, 66.8%);
  right: auto;
  bottom: auto;
  width: var(--plaque-width, clamp(250px, 28vw, 480px));
  height: var(--plaque-height, clamp(72px, 12.4vh, 120px));
  border-radius: 12px;
  transform:
    translate3d(calc(var(--mx) * var(--depth-x, 0px)), calc(var(--my) * var(--depth-y, 0px)), 0)
    rotate(5.6deg)
    skewX(-7deg);
}

.plaque-link .link-glass,
.plaque-link::after {
  border-radius: 12px;
}

.plaque-link .link-label {
  font-size: clamp(0.62rem, 0.34rem + 0.62vw, 0.94rem);
  letter-spacing: 0.34em;
}

.signal-arc {
  position: absolute;
  z-index: 6;
  pointer-events: none;
  border: 1px solid rgba(146, 210, 255, 0.18);
  border-left: 0;
  border-bottom: 0;
  border-radius: 50%;
  opacity: 0;
  mix-blend-mode: screen;
  transform-origin: center;
}

.signal-arc-a {
  --depth-x: -5px;
  --depth-y: -3px;
  --arc-rotation: -27deg;
  left: 16%;
  top: 24%;
  width: 25vw;
  aspect-ratio: 1.8;
  transform: rotate(var(--arc-rotation));
  animation: signal-wake 7.4s ease-in-out infinite;
}

.signal-arc-b {
  --depth-x: 4px;
  --depth-y: 2px;
  --arc-rotation: 18deg;
  right: 16%;
  bottom: 31%;
  width: 22vw;
  aspect-ratio: 2.2;
  transform: rotate(var(--arc-rotation));
  animation: signal-wake 9s 1.8s ease-in-out infinite;
}

.moon-page.is-signaling .signal-arc {
  opacity: 0.9;
  animation-duration: 2.1s;
}

#moon-canvas {
  position: absolute;
  inset: 0;
  z-index: 20;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

@keyframes earth-breathe {
  from {
    opacity: 0.52;
    transform: scale(0.96);
  }
  to {
    opacity: 0.82;
    transform: scale(1.04);
  }
}

@keyframes horizon-scan {
  0%,
  76%,
  100% {
    opacity: 0;
    transform: translateX(-18%) scaleX(0.42);
  }
  84% {
    opacity: 0.62;
  }
  94% {
    opacity: 0;
    transform: translateX(18%) scaleX(0.88);
  }
}

@keyframes signal-wake {
  0%,
  70%,
  100% {
    opacity: 0;
    transform: rotate(var(--arc-rotation, 0deg)) scale(0.82);
  }
  82% {
    opacity: 0.58;
  }
  96% {
    opacity: 0;
    transform: rotate(var(--arc-rotation, 0deg)) scale(1.16);
  }
}

@keyframes saucer-flight {
  0% {
    opacity: 0;
    filter: blur(0.2px);
    transform: translate3d(112vw, 15vh, 0) scale(0.46) rotate(-2deg);
  }
  7% {
    opacity: 0.92;
  }
  24% {
    opacity: 0.94;
    filter: blur(0.15px);
    transform: translate3d(70vw, 17vh, 0) scale(0.42) rotate(-1deg);
  }
  34%,
  48% {
    opacity: 0;
    filter: blur(0.8px);
    transform: translate3d(53vw, 18vh, 0) scale(0.34) rotate(1deg);
  }
  55% {
    opacity: 0.82;
    filter: blur(0.5px);
    transform: translate3d(38vw, 19vh, 0) scale(0.27) rotate(3deg);
  }
  76% {
    opacity: 0.42;
    filter: blur(0.85px);
    transform: translate3d(12vw, 8vh, 0) scale(0.14) rotate(4deg);
  }
  88%,
  100% {
    opacity: 0;
    filter: blur(1.4px);
    transform: translate3d(-14vw, 2vh, 0) scale(0.06) rotate(5deg);
  }
}

@media (max-width: 760px) {
  .moon-page {
    min-height: 100svh;
  }

  .moon-backdrop {
    inset: -1.2%;
    background-image: url("assets/moon/moon-landscape-mobile.png");
    background-position: 42% center;
  }

  .earth-halo {
    left: 17%;
    top: 8.5%;
    width: 72vw;
  }

  .earth-return {
    left: 15.5%;
    top: 8.5%;
    width: 72vw;
  }

  .saucer-flight {
    width: clamp(38px, 13vw, 58px);
    height: clamp(16px, 5vw, 26px);
    animation-name: saucer-flight-mobile;
  }

  .relay-link {
    --depth-x: -11px;
    --depth-y: -7px;
    --label-x: 0%;
    --label-y: 0%;
  }

  .plaque-link {
    --depth-x: -11px;
    --depth-y: -7px;
    --label-x: 0%;
    --label-y: 0%;
    transform:
      translate3d(calc(var(--mx) * var(--depth-x, 0px)), calc(var(--my) * var(--depth-y, 0px)), 0)
      rotate(6deg)
      skewX(-8deg);
  }

  .link-label {
    font-size: clamp(0.52rem, 1.7vw, 0.68rem);
    letter-spacing: 0.18em;
  }

  .relay-link .link-label {
    max-width: 7.4ch;
    font-size: clamp(0.48rem, 1.55vw, 0.62rem);
    line-height: 1.5;
  }

  .plaque-link .link-label {
    font-size: clamp(0.54rem, 1.9vw, 0.72rem);
    letter-spacing: 0.23em;
  }

  .signal-arc-a {
    left: 14%;
    top: 52%;
    width: 58vw;
  }

  .signal-arc-b {
    right: 10%;
    bottom: 21%;
    width: 54vw;
  }
}

@keyframes saucer-flight-mobile {
  0% {
    opacity: 0;
    filter: blur(0.2px);
    transform: translate3d(116vw, 19vh, 0) scale(0.42) rotate(-2deg);
  }
  8% {
    opacity: 0.88;
  }
  26% {
    opacity: 0.9;
    transform: translate3d(78vw, 22vh, 0) scale(0.38) rotate(-1deg);
  }
  35%,
  49% {
    opacity: 0;
    filter: blur(0.75px);
    transform: translate3d(50vw, 23vh, 0) scale(0.3) rotate(1deg);
  }
  57% {
    opacity: 0.76;
    filter: blur(0.55px);
    transform: translate3d(28vw, 24vh, 0) scale(0.23) rotate(2deg);
  }
  80% {
    opacity: 0.38;
    filter: blur(0.9px);
    transform: translate3d(4vw, 12vh, 0) scale(0.11) rotate(4deg);
  }
  90%,
  100% {
    opacity: 0;
    filter: blur(1.3px);
    transform: translate3d(-18vw, 7vh, 0) scale(0.05) rotate(5deg);
  }
}

@media (min-aspect-ratio: 21 / 9) {
  .earth-return {
    left: 44%;
    top: -19%;
    width: min(27vw, 470px);
  }

  .saucer-flight {
    animation-name: saucer-flight-wide;
  }

  .relay-link {
    --label-x: 0%;
    --label-y: 0%;
  }

  .relay-link .link-label {
    font-size: clamp(0.68rem, 0.62vw, 0.95rem);
    letter-spacing: 0.22em;
  }

  .plaque-link {
    --label-x: 0%;
    --label-y: 0%;
  }
}

@keyframes saucer-flight-wide {
  0% {
    opacity: 0;
    filter: blur(0.2px);
    transform: translate3d(112vw, 10vh, 0) scale(0.42) rotate(-2deg);
  }
  7% {
    opacity: 0.9;
  }
  25% {
    opacity: 0.9;
    transform: translate3d(72vw, 11vh, 0) scale(0.36) rotate(-1deg);
  }
  34%,
  48% {
    opacity: 0;
    filter: blur(0.75px);
    transform: translate3d(56vw, 12vh, 0) scale(0.3) rotate(1deg);
  }
  55% {
    opacity: 0.78;
    filter: blur(0.55px);
    transform: translate3d(42vw, 13vh, 0) scale(0.24) rotate(2deg);
  }
  76% {
    opacity: 0.36;
    filter: blur(0.95px);
    transform: translate3d(14vw, 6vh, 0) scale(0.12) rotate(4deg);
  }
  88%,
  100% {
    opacity: 0;
    filter: blur(1.35px);
    transform: translate3d(-14vw, 1.5vh, 0) scale(0.05) rotate(5deg);
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }

  .layer,
  .plaque-link,
  .saucer-flight {
    transform: none !important;
  }

  .saucer-flight {
    display: none;
  }
}
