:root {
  color-scheme: dark;
  --ink: #f2eee6;
  --deep-space: #03070f;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
}

body {
  background: radial-gradient(circle at 70% 45%, #13202a, var(--deep-space) 60%);
  color: var(--ink);
  font-family: "DM Sans", "Segoe UI", sans-serif;
}

button {
  font: inherit;
}

::selection {
  color: var(--deep-space);
  background: #ddd2bc;
}

.universe {
  position: relative;
  width: 100%;
  height: 100svh;
  min-height: 20rem;
  overflow: hidden;
  isolation: isolate;
  touch-action: none;
}

@media (hover: hover) and (pointer: fine) {
  .universe,
  .motion-toggle {
    cursor: url("./cursor.svg?v=2") 4 5, auto;
  }
}

.universe canvas {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
}

#stardust-title {
  z-index: 2;
  pointer-events: none;
}

.universe__vignette {
  position: absolute;
  inset: 0;
  z-index: 1;
  background:
    linear-gradient(90deg, rgba(2, 5, 11, 0.6), rgba(2, 5, 11, 0.12) 52%, transparent 78%),
    linear-gradient(0deg, rgba(2, 5, 11, 0.45), transparent 36%),
    radial-gradient(ellipse at 68% 47%, transparent 22%, rgba(2, 5, 11, 0.48) 100%);
  pointer-events: none;
}

.cursor-well {
  position: absolute;
  z-index: 3;
  top: 0;
  left: 0;
  width: 76px;
  height: 76px;
  opacity: 0;
  transform: translate3d(calc(var(--well-x, -150px) - 30px), calc(var(--well-y, -150px) - 29px), 0);
  transition: opacity 160ms ease;
  pointer-events: none;
}

.universe.well-active .cursor-well {
  opacity: 1;
}

.cursor-well::before,
.cursor-well::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50%;
}

.cursor-well::before {
  background: radial-gradient(circle,
    rgba(2, 6, 16, 0.3) 0 11px,
    rgba(36, 126, 215, 0.28) 19px,
    rgba(73, 168, 255, 0.11) 27px,
    transparent 36px);
  filter: blur(3px);
}

.cursor-well::after {
  background: conic-gradient(
    transparent 0deg 45deg,
    rgba(54, 153, 240, 0.42) 80deg,
    transparent 125deg 170deg,
    rgba(204, 235, 255, 0.72) 215deg,
    rgba(48, 143, 240, 0.24) 250deg,
    transparent 305deg 360deg);
  mask: radial-gradient(circle, transparent 0 16px, #000 21px, transparent 27px);
  animation: well-orbit 3.6s linear infinite;
}

.cursor-well.is-feeding::before {
  background: radial-gradient(circle,
    rgba(2, 6, 16, 0.38) 0 10px,
    rgba(44, 149, 249, 0.42) 20px,
    rgba(103, 193, 255, 0.2) 30px,
    transparent 38px);
}

.cursor-well.is-feeding::after {
  filter: brightness(1.6);
}

.universe.is-paused .cursor-well::after {
  animation-play-state: paused;
}

@keyframes well-orbit {
  to { transform: rotate(360deg); }
}

.universe h1 {
  position: absolute;
  z-index: 2;
  top: 50%;
  left: clamp(1.5rem, 5.8vw, 7rem);
  max-width: calc(100% - 3rem);
  margin: 0;
  font-size: clamp(3.3rem, 8.4vw, 8.2rem);
  font-weight: 300;
  letter-spacing: 0.105em;
  line-height: 1;
  text-shadow: 0 8px 36px rgba(0, 0, 0, 0.46);
  transform: translate3d(var(--title-x, 0px), calc(-50% + var(--title-y, 0px)), 0);
  transition: transform 650ms cubic-bezier(0.18, 0.8, 0.24, 1);
  user-select: none;
  pointer-events: none;
}

.universe.canvas-ready h1 {
  color: transparent;
  text-shadow: none;
}

.guide,
.motion-toggle {
  position: absolute;
  z-index: 2;
  bottom: clamp(1.3rem, 3vw, 2.5rem);
  margin: 0;
  color: rgba(242, 238, 230, 0.78);
  font-size: 0.65rem;
  font-weight: 500;
  letter-spacing: 0.15em;
  text-transform: uppercase;
}

.guide {
  left: clamp(1.3rem, 3vw, 2.5rem);
  max-width: calc(100% - 13rem);
  line-height: 1.6;
  pointer-events: none;
}

.guide .separator {
  margin-inline: 0.65rem;
  opacity: 0.5;
}

.motion-toggle {
  right: clamp(1.3rem, 3vw, 2.5rem);
  min-width: 8.5rem;
  min-height: 2.75rem;
  padding: 0.65rem 1rem;
  border: 1px solid rgba(242, 238, 230, 0.42);
  border-radius: 999px;
  background: rgba(5, 11, 20, 0.22);
  backdrop-filter: blur(8px);
  cursor: inherit;
  transition: border-color 200ms ease, background-color 200ms ease, color 200ms ease;
}

.motion-toggle:hover {
  border-color: rgba(242, 238, 230, 0.85);
  background: rgba(15, 26, 39, 0.6);
  color: var(--ink);
}

.motion-toggle:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 4px;
}

.motion-toggle:disabled {
  cursor: default;
  opacity: 0.62;
}

@media (max-width: 700px) {
  .universe__vignette {
    background:
      linear-gradient(0deg, rgba(2, 5, 11, 0.78), transparent 54%),
      radial-gradient(ellipse at 55% 37%, transparent 16%, rgba(2, 5, 11, 0.35) 100%);
  }

  .universe h1 {
    top: 77%;
    left: 50%;
    width: max-content;
    max-width: calc(100% - 2rem);
    font-size: clamp(2.65rem, 11.2vw, 5rem);
    letter-spacing: 0.095em;
    transform: translate3d(calc(-50% + var(--title-x, 0px)), calc(-50% + var(--title-y, 0px)), 0);
  }

  .guide {
    max-width: 11rem;
    line-height: 1.6;
  }

  .guide__gravity,
  .guide__hold {
    display: none;
  }

  .motion-toggle {
    min-width: 7.7rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .cursor-well {
    display: none;
  }

  .universe h1,
  .motion-toggle {
    transition: none;
  }

  .guide {
    display: none;
  }

}
