/* ggnomz — calm scroll chapters: soft reveals, floating nav, ambient stickers */

html {
  scroll-behavior: smooth;
}

/* Decorations (header glows, hidden badge tooltips) may reach past the screen edge; they must never
   widen the page, or phones scroll sideways and things fixed to the right edge go off-screen.
   Both are needed: on html it only sets the window, and only then does body's own clip trim the
   content. Clip, unlike hidden, keeps the sticky header working. */
html,
body {
  overflow-x: clip;
}

body > header,
body > main,
body > footer {
  position: relative;
  z-index: 1;
}

/* --- Ambient sky (injected by scroll-motion.js) --- */
.motion-sky {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
}

.motion-sticker {
  position: absolute;
  left: var(--motion-x, 50%);
  top: var(--motion-y, 20%);
  font-size: clamp(18px, 2.2vw, 26px);
  line-height: 1;
  opacity: 0.22;
  filter: drop-shadow(0 2px 8px rgba(14, 6, 40, 0.2));
  animation: motion-sticker-float var(--motion-dur, 14s) ease-in-out infinite;
  animation-delay: var(--motion-delay, 0s);
  will-change: transform;
}

html[data-theme="light"] .motion-sticker {
  opacity: 0.16;
}

@keyframes motion-sticker-float {
  0%,
  100% {
    transform: translate3d(0, 0, 0) rotate(-6deg);
  }
  50% {
    transform: translate3d(0, -14px, 0) rotate(8deg);
  }
}

/* Header float + alignment: see header-nav.css (loaded after this file) */

/* --- Scroll chapters: more air between beats --- */
main section,
main > .panel,
main > article.panel {
  scroll-margin-top: 96px;
}

main > section + section,
main > .panel + section,
main > section + .panel,
main > section + .grid,
main > .panel + .grid {
  margin-top: clamp(28px, 5vw, 52px);
}

main .hero {
  margin-bottom: clamp(8px, 2vw, 20px);
}

main .section-title {
  margin-top: clamp(20px, 3vw, 36px);
  margin-bottom: clamp(12px, 2vw, 18px);
}

/* --- Reveal --- */
.motion-reveal {
  opacity: 0;
  transform: translate3d(0, 22px, 0);
  transition:
    opacity 0.75s cubic-bezier(0.22, 1, 0.36, 1),
    transform 0.75s cubic-bezier(0.22, 1, 0.36, 1);
  transition-delay: calc(var(--motion-i, 0) * 70ms);
  will-change: opacity, transform;
}

.motion-reveal--hero {
  transform: translate3d(0, 14px, 0);
  transition-duration: 0.9s;
}

.motion-reveal--in {
  opacity: 1;
  transform: translate3d(0, 0, 0);
}

/* Stagger children inside a revealed group */
.motion-stagger.motion-reveal {
  transition-delay: calc(var(--motion-i, 0) * 85ms + 40ms);
}

/* --- Calm always-on loops until in view --- */
html.motion-scroll-ready .featured-player-panel::before,
html.motion-scroll-ready .featured-player-panel::after {
  animation-duration: 9s, 16s;
}

html.motion-scroll-ready .featured-player-panel:not(.motion-ambient-on)::before,
html.motion-scroll-ready .featured-player-panel:not(.motion-ambient-on)::after {
  animation-play-state: paused;
  opacity: 0.42;
}

html.motion-scroll-ready .featured-player-panel:not(.motion-ambient-on) .featured-player-sparkle {
  animation-play-state: paused;
  opacity: 0.15;
}

html.motion-scroll-ready .queue-globe-spin {
  animation-duration: 180s;
}

html.motion-scroll-ready .panel.panel--queue-globe:not(.motion-ambient-on) .queue-globe-spin {
  animation-play-state: paused;
}

/* Softer tile hover site-wide */
html.motion-scroll-ready a.tile {
  transition:
    transform 0.35s cubic-bezier(0.22, 1, 0.36, 1),
    box-shadow 0.35s ease;
}

html.motion-scroll-ready a.tile:hover {
  transform: translateY(-3px);
}

/* Feed tilt only after launch (class on html) */
html:not(.motion-feed-live) [data-nomnom-feed-full] [data-clip-slot] {
  transform: none !important;
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  .motion-sky {
    display: none;
  }

  .motion-reveal,
  .motion-reveal--hero,
  .motion-stagger.motion-reveal {
    opacity: 1;
    transform: none;
    transition: none;
  }

  .header,
  .header .header-inner,
  .header.container {
    transition: none;
  }
}
