/**
 * Motion system
 *
 * Progressive enhancement for scroll reveals, ambient movement and interactive
 * feedback. All motion is disabled when the visitor requests reduced motion.
 */

:root {
  --motion-ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --motion-ease-soft: cubic-bezier(0.22, 1, 0.36, 1);
}

/* Scroll reveals are hidden only after JavaScript confirms it is available. */
.motion-ready .motion-reveal {
  --motion-delay: 0ms;
  opacity: 0;
  transform: translate3d(0, 42px, 0);
  transition:
    opacity 0.85s var(--motion-ease-out) var(--motion-delay),
    transform 0.85s var(--motion-ease-out) var(--motion-delay);
  will-change: opacity, transform;
}

.motion-ready .motion-reveal--left {
  transform: translate3d(-48px, 0, 0);
}

.motion-ready .motion-reveal--right {
  transform: translate3d(48px, 0, 0);
}

.motion-ready .motion-reveal--scale {
  transform: scale(0.94);
}

.motion-ready .motion-reveal.is-visible,
.motion-ready .motion-reveal.visible {
  opacity: 1;
  transform: translate3d(0, 0, 0) scale(1);
  will-change: auto;
}

/* Hero content enters immediately, with a compact editorial sequence. */
.motion-ready .motion-intro {
  opacity: 0;
  transform: translate3d(0, 28px, 0);
  animation: motion-intro 0.95s var(--motion-ease-out) forwards;
  animation-delay: var(--motion-delay, 100ms);
}

@keyframes motion-intro {
  to {
    opacity: 1;
    transform: translate3d(0, 0, 0);
  }
}

/* Replays a short content sequence whenever the homepage slider changes. */
.hero-slide.motion-slide-active .hero-content > * {
  opacity: 0;
  transform: translate3d(0, 24px, 0);
  animation: motion-intro 0.8s var(--motion-ease-out) forwards;
}

.hero-slide.motion-slide-active .hero-content > *:nth-child(2) {
  animation-delay: 90ms;
}

.hero-slide.motion-slide-active .hero-content > *:nth-child(3) {
  animation-delay: 180ms;
}

.hero-slide.motion-slide-active .hero-content > *:nth-child(4) {
  animation-delay: 270ms;
}

/* Slow ambient movement for the circles already present in the design. */
.editorial-orbit,
.devotional-hero__orbit {
  animation: motion-orbit 18s ease-in-out infinite alternate;
  transform-origin: center;
  will-change: transform;
}

.editorial-orbit--small,
.devotional-hero__orbit--two {
  animation-duration: 13s;
  animation-direction: alternate-reverse;
}

@keyframes motion-orbit {
  0% {
    transform: translate3d(-8px, 5px, 0) rotate(-2deg);
  }
  50% {
    transform: translate3d(11px, -9px, 0) rotate(3deg);
  }
  100% {
    transform: translate3d(-2px, 12px, 0) rotate(7deg);
  }
}

.devotional-hero__pause {
  animation: motion-breathe 5.5s ease-in-out infinite;
  transform-origin: center;
}

@keyframes motion-breathe {
  0%,
  100% {
    transform: rotate(7deg) scale(1);
    box-shadow: 0 0 0 0 rgba(120, 200, 145, 0);
  }
  50% {
    transform: rotate(4deg) scale(1.035);
    box-shadow: 0 0 0 16px rgba(120, 200, 145, 0.045);
  }
}

.editorial-hero,
.devotional-hero,
body.is-front-page .hero-slide::after,
body.is-front-page #main > section:nth-of-type(3)::after {
  animation: motion-grid-drift 24s linear infinite;
}

@keyframes motion-grid-drift {
  to {
    background-position: 64px 64px;
  }
}

/* Decorative lines gently extend when their section enters. */
.editorial-kicker > span,
.devotional-kicker > span,
.editorial-section-divider,
.section-divider {
  transform-origin: left center;
  animation: motion-line 2.8s ease-in-out infinite alternate;
}

@keyframes motion-line {
  from {
    transform: scaleX(0.72);
    opacity: 0.62;
  }
  to {
    transform: scaleX(1);
    opacity: 1;
  }
}

/* Scroll parallax uses a CSS variable updated in one requestAnimationFrame. */
.motion-parallax {
  --motion-parallax-y: 0px;
  translate: 0 var(--motion-parallax-y);
  will-change: translate;
}

/* Interactive surfaces keep their geometry while feeling less static. */
.motion-card {
  transition:
    transform 0.42s var(--motion-ease-soft),
    box-shadow 0.42s var(--motion-ease-soft),
    border-color 0.3s ease,
    background-color 0.3s ease;
}

.motion-card img {
  transition:
    transform 0.75s var(--motion-ease-soft),
    filter 0.5s ease;
}

.motion-card:hover img {
  transform: scale(1.045);
}

.editorial-button,
.devotional-read,
.devotional-list__arrow,
.event-link,
.btn,
.btn-ghost,
.hero-cta {
  transition:
    transform 0.35s var(--motion-ease-soft),
    gap 0.35s var(--motion-ease-soft),
    color 0.25s ease,
    background-color 0.25s ease,
    border-color 0.25s ease,
    box-shadow 0.35s ease;
}

.devotional-list__item:hover .devotional-list__arrow,
.devotional-read:hover,
.event-link:hover {
  transform: translate3d(6px, -2px, 0);
}

/* A soft sheen crosses primary editorial cards on hover. */
.devotional-feature__card,
.editorial-blog__grid .card,
.editorial-value,
.editorial-contact__link {
  position: relative;
  isolation: isolate;
  overflow: hidden;
}

.devotional-feature__card::after,
.editorial-blog__grid .card::after,
.editorial-value::after,
.editorial-contact__link::after {
  position: absolute;
  inset: 0;
  z-index: 1;
  background: linear-gradient(
    115deg,
    transparent 28%,
    rgba(120, 200, 145, 0.09) 46%,
    transparent 64%
  );
  content: "";
  pointer-events: none;
  transform: translateX(-115%);
  transition: transform 0.9s var(--motion-ease-soft);
}

.devotional-feature__card:hover::after,
.editorial-blog__grid .card:hover::after,
.editorial-value:hover::after,
.editorial-contact__link:hover::after {
  transform: translateX(115%);
}

@media (max-width: 768px) {
  .motion-ready .motion-reveal,
  .motion-ready .motion-reveal--left,
  .motion-ready .motion-reveal--right {
    transform: translate3d(0, 28px, 0);
  }

  .editorial-orbit,
  .devotional-hero__orbit {
    animation-duration: 22s;
  }

  .motion-parallax {
    translate: none;
    will-change: auto;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto !important;
  }

  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }

  .motion-ready .motion-reveal,
  .motion-ready .motion-intro {
    opacity: 1 !important;
    transform: none !important;
  }

  .motion-parallax {
    translate: none !important;
  }
}
