/* Site-wide motion, paced like a retro game's title screen. */
:where(header, main, footer, #detail) :is(a, button):focus-visible,
#motion-toggle:focus-visible {
  outline: 2px solid #f57584;
  outline-offset: 4px;
}

@media (prefers-reduced-motion: no-preference) {
  #world {
    animation: world-drift 22s ease-in-out infinite alternate;
  }

  #storm-scene::after {
    content: "";
    position: absolute;
    inset: 0;
    background:
      radial-gradient(ellipse at 74% 72%, #c03e2740, transparent 28%),
      radial-gradient(ellipse at 35% 98%, #96a9bc38, transparent 53%);
    animation: storm-haze 9s ease-in-out infinite alternate;
  }

  .strip, .running-head {
    animation: signal-glow 6s ease-in-out infinite;
  }

  .wordmark span {
    display: inline-block;
    animation: emblem-orbit 8s linear infinite;
  }

  .book-cover h1 {
    animation: title-rise 1s cubic-bezier(.16, 1, .3, 1) backwards,
      signal-glow 7s 1s ease-in-out infinite;
  }

  .game-emblem {
    animation: emblem-orbit 8s linear infinite;
  }

  .cover-open {
    animation: start-beacon 3s ease-in-out infinite;
  }

  body.chapter-mode .active-chapter {
    transform-origin: center top;
    animation: page-turn .55s cubic-bezier(.2, .75, .25, 1) backwards;
  }

  .active-chapter :is(.running-head, .cover-edition, .cover-subtitle, .cover-foot,
      .heading, .contents-intro, .chapter-artwork, .page-end, .chapter-home),
  .active-chapter.book-page > :is(h2, p, .eyebrow),
  .active-chapter.closing > div,
  .active-chapter :is(.chapter-list li, .product) {
    animation: menu-reveal .45s var(--reveal-delay, .08s) ease-out backwards;
  }

  .active-chapter .running-head {
    animation: menu-reveal .45s ease-out backwards, signal-glow 6s ease-in-out infinite;
  }

  .cover-subtitle, .contents-intro, .chapter-artwork {
    --reveal-delay: .16s;
  }

  .chapter-list li:nth-child(2), .product:nth-child(2) {
    --reveal-delay: .16s;
  }

  .chapter-list li:nth-child(3), .product:nth-child(3) {
    --reveal-delay: .24s;
  }

  .chapter-list li:nth-child(4), .page-end, .chapter-home, .cover-foot {
    --reveal-delay: .32s;
  }

  .chapter-artwork .art-pedestal {
    animation: artifact-hover 6s ease-in-out infinite;
  }

  .chapter-artwork .art-pedestal img {
    animation: artifact-rotation 18s linear infinite, artifact-light 5s ease-in-out infinite;
  }

  .product-art {
    position: relative;
    overflow: hidden;
  }

  .product-art::after {
    content: "";
    position: absolute;
    pointer-events: none;
    inset: 0;
    background: linear-gradient(180deg, transparent 36%, #ee23452b 49%, #ff23474a 50%, transparent 55%);
    animation: card-scan 5s linear infinite;
  }

  .product:nth-child(2) .product-art::after { animation-delay: -1.6s; }
  .product:nth-child(3) .product-art::after { animation-delay: -3.2s; }

  :where(header, main, footer, #detail) :is(a, button),
  #motion-toggle {
    transition: translate .18s ease-out, filter .18s ease-out, border-color .18s ease-out;
  }

  body:not(.atmosphere-paused) :where(header, main, footer, #detail)
    :is(a, button):is(:hover, :focus-visible) {
    translate: 0 -2px;
    filter: brightness(1.3);
  }

  body:not(.atmosphere-paused) :where(header, main, footer, #detail) :is(a, button):active {
    translate: 0 1px;
  }

  #detail[open] {
    animation: menu-reveal .25s ease-out backwards;
  }

  #detail[open]::backdrop {
    animation: backdrop-in .25s ease-out backwards;
  }
}

@keyframes world-drift {
  from { transform: scale(1.025) translateX(-.35%); }
  to { transform: scale(1.065) translateX(.8%); }
}

@keyframes storm-haze {
  from { opacity: .22; transform: translateX(-3%); }
  to { opacity: .83; transform: translateX(3%); }
}

@keyframes signal-glow {
  0%, 100% { filter: brightness(1); }
  50% { filter: brightness(1.22); }
}

@keyframes title-rise {
  from { opacity: .35; transform: translateY(14px) skewY(-3deg) scale(.98); }
  to { opacity: 1; transform: translateY(0) skewY(-3deg) scale(1); }
}

@keyframes emblem-orbit {
  0% { transform: rotateY(0) translateY(0); }
  50% { transform: rotateY(180deg) translateY(-4px); }
  100% { transform: rotateY(360deg) translateY(0); }
}

@keyframes start-beacon {
  0%, 100% { filter: drop-shadow(0 0 2px #a70f36); }
  50% { filter: drop-shadow(0 0 11px #df255a); }
}

@keyframes page-turn {
  from { opacity: .5; transform: perspective(1100px) rotateX(-4deg) translateY(12px); }
  to { opacity: 1; transform: perspective(1100px) rotateX(0) translateY(0); }
}

@keyframes menu-reveal {
  from { opacity: .35; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes artifact-hover {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-9px); }
}

@keyframes artifact-light {
  0%, 100% { filter: drop-shadow(0 12px 20px #000a); }
  50% { filter: drop-shadow(0 8px 16px #b10e3b88); }
}

@keyframes card-scan {
  from { transform: translateY(-115%); }
  to { transform: translateY(115%); }
}

@keyframes backdrop-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* Stop motion without leaving a new chapter half revealed. */
body.atmosphere-paused,
body.atmosphere-paused *,
body.atmosphere-paused *::before,
body.atmosphere-paused *::after,
body.atmosphere-paused #detail::backdrop {
  animation: none !important;
  transition: none !important;
}
