/* MrPops spatial scroll system — progressive enhancement, no external runtime. */
:root {
  --scroll-y: 0;
  --scroll-progress: 0;
  --pointer-x: 0;
  --pointer-y: 0;
  --fx-cyan: 45, 231, 255;
  --fx-magenta: 235, 55, 204;
}

html { background: #02050b; }
body {
  overflow-x: clip;
  isolation: isolate;
}

#fx-3d-space {
  position: fixed;
  inset: 0;
  z-index: -2;
  pointer-events: none;
  overflow: hidden;
  perspective: 720px;
  background:
    radial-gradient(circle at calc(48% + var(--pointer-x) * 4%), calc(30% + var(--pointer-y) * 3%), rgba(var(--fx-cyan), .09), transparent 30%),
    radial-gradient(circle at 76% 62%, rgba(var(--fx-magenta), .075), transparent 34%);
}

#fx-3d-space::before {
  content: "";
  position: absolute;
  left: -35%;
  right: -35%;
  bottom: -43%;
  height: 90%;
  opacity: .44;
  background-image:
    linear-gradient(rgba(var(--fx-cyan), .14) 1px, transparent 1px),
    linear-gradient(90deg, rgba(var(--fx-cyan), .12) 1px, transparent 1px);
  background-size: 68px 68px;
  mask-image: linear-gradient(to top, #000 25%, transparent 88%);
  transform-origin: 50% 100%;
  transform: rotateX(67deg) translate3d(0, calc(var(--scroll-y) * -0.045px), 0);
  will-change: transform;
}

#fx-3d-space::after {
  content: "";
  position: absolute;
  inset: -20%;
  opacity: .34;
  background-image:
    radial-gradient(circle, rgba(255,255,255,.7) 0 1px, transparent 1.5px),
    radial-gradient(circle, rgba(var(--fx-cyan),.85) 0 1px, transparent 1.5px);
  background-position: 0 0, 37px 91px;
  background-size: 123px 157px, 179px 211px;
  transform: translate3d(0, calc(var(--scroll-y) * -0.075px), 0) scale(1.08);
  will-change: transform;
}

#fx-3d-space .fx-portal {
  position: absolute;
  inset: -5%;
  opacity: 0;
  background: url("portal-mrpops.webp") 50% 42% / cover no-repeat;
  filter: saturate(1.18) contrast(1.08);
  transform: translate3d(0, calc(var(--scroll-y) * -0.032px), -30px) scale(1.07);
  transform-origin: 50% 45%;
  mask-image: radial-gradient(ellipse 72% 70% at 50% 44%, #000 0 38%, rgba(0,0,0,.72) 58%, transparent 86%);
  transition: opacity .8s ease;
  will-change: transform;
}

html[data-motion="portal"] #fx-3d-space .fx-portal { opacity: .30; }

main {
  position: relative;
  perspective: 1500px;
  perspective-origin: 50% 42vh;
  transform-style: preserve-3d;
}

.motion-section {
  --depth: 0;
  --tilt-x: 0deg;
  --tilt-y: 0deg;
  --drift-x: 0px;
  --drift-y: 0px;
  --section-scale: 1;
  --section-opacity: 1;
  --section-blur: 0px;
  --section-brightness: 1;
  position: relative;
  transform-origin: 50% 50%;
  transform-style: preserve-3d;
  backface-visibility: hidden;
  will-change: transform, opacity;
  transform: translate3d(var(--drift-x), var(--drift-y), calc(var(--depth) * 1px)) rotateX(var(--tilt-x)) rotateY(var(--tilt-y)) scale(var(--section-scale));
  opacity: var(--section-opacity);
}

html[data-motion="cinema"] .motion-section::after {
  border-color: rgba(var(--fx-magenta), calc(.04 + var(--section-energy, 0) * .10));
  box-shadow: -34px 50px 110px rgba(var(--fx-magenta), .055), 34px 50px 110px rgba(var(--fx-cyan), .055);
}

html[data-motion="deck"] main { perspective: 1050px; }
html[data-motion="deck"] .motion-section::after {
  background: linear-gradient(155deg, rgba(var(--fx-cyan), .045), transparent 48%, rgba(var(--fx-magenta), .04));
  box-shadow: 0 70px 150px rgba(0,0,0,.52), 0 0 55px rgba(var(--fx-cyan), .04);
}

html[data-motion="portal"] .motion-section {
  transform-origin: 50% 36%;
}
html[data-motion="portal"] .motion-section::after {
  border-radius: 50%;
  border-color: rgba(var(--fx-cyan), calc(.06 + var(--section-energy, 0) * .18));
  box-shadow: inset 0 0 90px rgba(var(--fx-cyan), .045), 0 0 85px rgba(var(--fx-magenta), .055);
}

html[data-motion="portal"] .motion-section .section-top,
html[data-motion="portal"] .motion-section .hero-copy {
  text-shadow: 0 0 28px rgba(var(--fx-cyan), calc(var(--section-energy, 0) * .16));
}

.motion-section::after {
  content: "";
  position: absolute;
  z-index: -1;
  left: 4%;
  right: 4%;
  top: 8%;
  height: 84%;
  border-radius: 48px;
  border: 1px solid rgba(var(--fx-cyan), calc(.035 + var(--section-energy, 0) * .08));
  background: linear-gradient(125deg, rgba(var(--fx-cyan), .025), transparent 42%, rgba(var(--fx-magenta), .025));
  box-shadow: 0 55px 120px rgba(0, 0, 0, .36), 0 0 70px rgba(var(--fx-cyan), .025);
  transform: translateZ(-42px) scale(.965);
  pointer-events: none;
}

.motion-section > * {
  transform-style: preserve-3d;
}

.motion-section .section-top,
.motion-section .hero-copy {
  transform: translateZ(42px);
}

.motion-section .release,
.motion-section .upcoming,
.motion-section .listen,
.motion-section .artist-art {
  transform: translate3d(0, var(--item-y, 0px), var(--item-z, 0px)) rotateX(var(--item-rx, 0deg));
  transition: border-color .35s ease, box-shadow .35s ease;
  will-change: transform;
  backface-visibility: hidden;
}

.motion-section .release:hover,
.motion-section .upcoming:hover,
.motion-section .listen:hover {
  border-color: rgba(var(--fx-cyan), .42);
  box-shadow: 0 24px 70px rgba(0,0,0,.42), 0 0 34px rgba(var(--fx-cyan), .09);
}

#scroll-orbit {
  position: fixed;
  z-index: 30;
  top: 50%;
  right: 20px;
  width: 2px;
  height: min(38vh, 330px);
  border-radius: 999px;
  background: rgba(255,255,255,.09);
  transform: translateY(-50%);
  pointer-events: none;
}

#scroll-orbit span {
  display: block;
  width: 100%;
  height: calc(var(--scroll-progress) * 100%);
  border-radius: inherit;
  background: linear-gradient(to bottom, rgb(var(--fx-cyan)), rgb(var(--fx-magenta)));
  box-shadow: 0 0 18px rgba(var(--fx-cyan), .72);
}

#scroll-orbit::after {
  content: "";
  position: absolute;
  left: 50%;
  top: calc(var(--scroll-progress) * 100%);
  width: 9px;
  height: 9px;
  border: 1px solid rgba(255,255,255,.8);
  border-radius: 50%;
  background: rgb(var(--fx-cyan));
  box-shadow: 0 0 20px rgba(var(--fx-cyan), .9);
  transform: translate(-50%, -50%);
}

@media (max-width: 760px) {
  main { perspective: 1050px; }
  .motion-section::after { left: -2%; right: -2%; border-radius: 30px; }
  #scroll-orbit { right: 8px; height: 22vh; opacity: .62; }
  #fx-3d-space::before { opacity: .28; background-size: 48px 48px; }
  html[data-motion="portal"] #fx-3d-space .fx-portal { opacity: .22; background-position: 50% 32%; }
}

@media (prefers-reduced-motion: reduce) {
  #fx-3d-space::before,
  #fx-3d-space::after,
  #fx-3d-space .fx-portal,
  .motion-section,
  .motion-section .release,
  .motion-section .upcoming,
  .motion-section .listen,
  .motion-section .artist-art {
    transform: none !important;
    opacity: 1 !important;
    filter: none !important;
  }
  #scroll-orbit { display: none; }
}
