/* Motion is decorative: content and cards remain visible without JavaScript. */

/* The most important CTA alone receives a small, reversible magnet. */
.hero-actions .primary-button:hover {
  transform: none;
}

@media (hover: hover) and (pointer: fine) and (prefers-reduced-motion: no-preference) {
  /* The image stays intact beneath a restrained, non-interactive highlight. */
  .world-feature-media {
    position: relative;
  }

  .world-feature-media::after,
  .world-card-art::after {
    content: '';
    position: absolute;
    inset: 0;
    z-index: 1;
    border-radius: inherit;
    pointer-events: none;
    background: radial-gradient(
      circle at var(--motion-x, 50%) var(--motion-y, 50%),
      rgba(255, 255, 255, .18) 0%,
      rgba(255, 255, 255, .06) 24%,
      transparent 58%
    );
    opacity: 0;
    transition: opacity .28s ease;
  }

  .world-feature:hover .world-feature-media::after,
  .world-feature:focus-visible .world-feature-media::after,
  .world-card:hover .world-card-art::after,
  .world-card:focus-visible .world-card-art::after {
    opacity: 1;
  }

  .world-card-art img,
  .world-feature-media img {
    transition: transform .48s cubic-bezier(.22, 1, .36, 1);
  }

  .world-card:hover .world-card-art img,
  .world-card:focus-visible .world-card-art img,
  .world-feature:hover .world-feature-media img,
  .world-feature:focus-visible .world-feature-media img {
    transform: scale(1.065);
  }

  /* The artwork stays in its original grid; the card responds in place. */
  .world-card.motion-pointer-active:hover,
  .world-card:focus-visible {
    transform: perspective(1100px) translateY(-9px)
      rotateX(var(--motion-tilt-x, 0deg)) rotateY(var(--motion-tilt-y, 0deg));
  }
  .world-feature.motion-pointer-active:hover,
  .world-feature:focus-visible {
    transform: perspective(1100px) translateY(-7px)
      rotateX(var(--motion-tilt-x, 0deg)) rotateY(var(--motion-tilt-y, 0deg));
  }

  .world-feature-action {
    transition: transform .24s ease;
  }

  .world-feature:hover .world-feature-action,
  .world-feature:focus-visible .world-feature-action {
    transform: translateX(6px);
  }

  /* Preserve the existing selected-card colour transitions on this arrow. */
  .world-card .world-card-top .world-arrow {
    transition: transform .24s ease, background .24s ease, color .24s ease, border-color .24s ease;
  }

  .world-card:hover .world-arrow,
  .world-card:focus-visible .world-arrow {
    transform: translate(4px, -4px);
  }

  .hero-actions .primary-button {
    translate:
      clamp(-9px, var(--magnet-x, 0px), 9px)
      clamp(-5px, var(--magnet-y, 0px), 5px);
    transition: translate .24s cubic-bezier(.22, 1, .36, 1),
      background .24s ease, box-shadow .24s ease;
  }

  .hero-actions .primary-button > span {
    transform: translate(
      clamp(-4px, var(--magnet-x, 0px), 4px),
      clamp(-3px, var(--magnet-y, 0px), 3px)
    );
    transition: transform .22s ease-out;
  }
}

@media (hover: none), (pointer: coarse) {
  .world-card:hover,
  .world-feature:hover {
    transform: none;
  }
  .world-card:hover:not([aria-expanded="true"]) {
    border-color: rgba(207, 217, 238, .88);
    box-shadow: 0 12px 35px rgba(57, 68, 119, .055);
  }
  .world-feature:hover:not([aria-current="true"]) {
    border-color: #e8ecf5;
    box-shadow: 0 5px 18px rgba(59, 70, 120, .035);
  }
}

@media (prefers-reduced-motion: no-preference) {
  /* A quiet floating object, inspired by the reference site's layered hero. */
  .visual-frame {
    animation: motion-frame-float 7.5s ease-in-out infinite;
  }

  @keyframes motion-frame-float {
    0%, 100% { translate: 0 0; }
    50% { translate: 0 -9px; }
  }

  /* Independent translate composes with each card's hover transform. */
  .worlds-grid > .world-card {
    translate: 0 var(--role-drift-y, 0px);
  }

  /* Independent translate composes with the existing float transform animation. */
  .hero::after {
    background-position: 0 clamp(-28px, var(--motion-grid-y, 0px), 28px);
  }

  .hero-visual {
    translate: 0 clamp(-32px, var(--motion-visual-y, 0px), 32px);
  }

  .floating-tag-one {
    translate: 0 clamp(-18px, var(--motion-tag-one, 0px), 18px);
  }

  .floating-tag-two {
    translate: 0 clamp(-14px, var(--motion-tag-two, 0px), 14px);
  }

  /* Only an open dialog animates; no closed or ordinary content is hidden. */
  .search-dialog[open] .search-shell,
  .toc-dialog[open] .toc-shell {
    animation: motion-dialog-enter .32s cubic-bezier(.22, 1, .36, 1);
  }

  @keyframes motion-dialog-enter {
    from {
      transform: translateY(6px);
    }
    to {
      transform: translateY(0);
    }
  }
}

@media (prefers-reduced-motion: reduce) {
  /* Explicitly neutralize every added animation and displacement. */
  .hero::after {
    background-position: 0 0;
  }

  .hero-visual,
  .floating-tag-one,
  .floating-tag-two {
    animation: none;
    translate: none;
  }

  .visual-frame {
    animation: none;
    translate: none;
  }

  .worlds-grid > .world-card {
    translate: none;
  }

  .hero-actions .primary-button {
    translate: none;
  }

  .hero-actions .primary-button > span,
  .world-feature-action,
  .world-card .world-arrow {
    transform: none;
    transition: none;
  }

  .search-dialog[open] .search-shell,
  .toc-dialog[open] .toc-shell {
    animation: none;
    opacity: 1;
    transform: none;
  }
}
