.ambient-space {
  position: fixed;
  inset: 0;
  z-index: 0;
  isolation: isolate;
  overflow: hidden;
  pointer-events: none;
  background:
    radial-gradient(ellipse 48% 37% at 77% 72%, #421b5965, transparent 80%),
    radial-gradient(ellipse 48% 51% at 52% 42%, #172b4a78, transparent 83%),
    radial-gradient(ellipse 49% 30% at 22% 24%, #38164f65, transparent 80%),
    #05040a;
}

.ambient-scene {
  --earth-size: min(54cqi, 54cqb, 17rem);
  position: relative;
  container-type: size;
  isolation: isolate;
  z-index: -1;
  min-width: 0;
  block-size: clamp(14rem, 37vw, 27rem);
  pointer-events: none;
}

.ambient-stars {
  position: absolute;
  inset: -8rem;
  width: calc(100% + 16rem);
  height: calc(100% + 16rem);
  animation: ambient-drift var(--drift-duration) ease-in-out var(--drift-phase) infinite alternate;
}

.ambient-stars.far {
  --drift-x: -2.8rem;
  --drift-y: 1.4rem;
  --drift-angle: -1.3deg;
  --drift-duration: 105s;
  --drift-phase: -30s;
}

.ambient-stars.near {
  --drift-x: 4.2rem;
  --drift-y: -2.4rem;
  --drift-angle: 2deg;
  --drift-duration: 81s;
  --drift-phase: -40s;
}

@keyframes ambient-drift {
  from { transform: translate(0, 0) rotate(0deg); }
  to { transform: translate(var(--drift-x), var(--drift-y)) rotate(var(--drift-angle)); }
}

.ambient-earth {
  position: absolute;
  z-index: 2;
  left: 50%;
  top: 50%;
  translate: -50% -50%;
  width: var(--earth-size);
  background: radial-gradient(circle at 66% 29%, #365775, #121e34 47%, #080b16 70%);
  border-radius: 50%;
  box-shadow: 1rem -1rem 3rem -.5rem #4c82e848;
}

.ambient-planet { aspect-ratio: 1; }
.ambient-planet canvas { display: block; width: 100%; height: 100%; }
.ambient-planet:not([data-rendered]) canvas { visibility: hidden; }

.ambient-earth[data-rendered] { background: none; box-shadow: none; }
.ambient-earth canvas { filter: drop-shadow(.45rem -.4rem 1.1rem #629fef72); }

.ambient-nibiru {
  position: absolute;
  z-index: 1;
  top: calc(50% - var(--earth-size) * .63);
  left: calc(50% + var(--earth-size) * .41);
  translate: -50% -50%;
  width: calc(var(--earth-size) * .26);
  background: radial-gradient(circle at 29% 24%, #6f3397, #291141 56%, #100817 76%);
  border-radius: 50%;
  box-shadow: 0 0 1.7rem #a846dd4a;
  animation: ambient-flyby 240s linear -10s infinite;
}

.ambient-nibiru[data-rendered] { background: none; box-shadow: none; }
.ambient-nibiru canvas { filter: drop-shadow(0 0 .7rem #c04bf884); }

@keyframes ambient-flyby {
  0% { transform: translate(0, 0); opacity: 0; }
  4% { transform: translate(0, 0); opacity: 1; }
  80% { transform: translate(calc(-100vw - 100%), -12vh); opacity: 1; }
  81%, 100% { transform: translate(calc(-100vw - 100%), -12vh); opacity: 0; }
}

.ambient-space::after {
  content: '';
  position: absolute;
  z-index: 3;
  inset: 0;
  background:
    radial-gradient(ellipse at 54% 54%, transparent 29%, #0402079c 100%),
    linear-gradient(90deg, #05030b44, transparent 50%, #06040a2c);
}

@media (prefers-reduced-motion: reduce) {
  .ambient-stars, .ambient-nibiru { animation: none; }
}
