/*
 * SPN POLDA SULUT — Premium Motion System v4.3
 * Kept separate from the main design system for easy maintenance.
 * Motion is progressive enhancement: the site remains fully usable without JS.
 */

/* Reading progress: visually subtle, no content displacement. */
.reading-progress {
  position: fixed;
  z-index: 110;
  top: 0;
  left: 0;
  width: 100%;
  height: 3px;
  background: transparent;
  pointer-events: none;
}
.reading-progress__fill {
  display: block;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, #b58e4c, #e0c68c);
  box-shadow: 0 0 10px rgba(198,166,103,.2);
  transform: scaleX(0);
  transform-origin: left center;
  will-change: transform;
}

/* Respect touch devices and keyboard focus. */
.desktop-nav a::after {
  content: '';
  position: absolute;
  bottom: 24px;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--gold);
  transform: scaleX(0);
  transform-origin: left center;
  transition: transform .28s cubic-bezier(.22,1,.36,1);
}
.desktop-nav a:hover::after,
.desktop-nav a:focus-visible::after,
.desktop-nav a[aria-current="page"]::after { transform: scaleX(1); }

@media (prefers-reduced-motion: no-preference) {
  /* Intro: image moves almost imperceptibly behind the static text. */
  .hero {
    background-image: none !important;
    background-color: var(--navy);
    overflow: hidden;
  }
  .hero::before {
    content: '';
    position: absolute;
    inset: -2%;
    z-index: -2;
    background: var(--hero) center 45% / cover no-repeat;
    transform: scale(1);
    transform-origin: center;
    animation: spn-hero-drift 22s ease-in-out infinite alternate;
    will-change: transform;
    pointer-events: none;
  }
  @keyframes spn-hero-drift {
    from { transform: scale(1); }
    to { transform: scale(1.065); }
  }

  /* First content on screen: sequential entrance only once, never looping. */
  .hero .hero-tag,
  .hero h1,
  .hero .hero-content > p,
  .hero .hero-actions,
  .hero .hero-side-mark {
    opacity: 0;
    animation: spn-hero-enter .85s cubic-bezier(.22,1,.36,1) forwards;
  }
  .hero .hero-tag { animation-delay: .06s; }
  .hero h1 { animation-delay: .17s; }
  .hero .hero-content > p { animation-delay: .29s; }
  .hero .hero-actions { animation-delay: .41s; }
  .hero .hero-side-mark { animation-delay: .58s; }
  @keyframes spn-hero-enter {
    from { opacity: 0; transform: translateY(24px); }
    to { opacity: 1; transform: translateY(0); }
  }

  /* Page title entrance. */
  .page-hero .container,
  .article-header .article-width {
    animation: spn-page-enter .75s cubic-bezier(.22,1,.36,1) both;
  }
  @keyframes spn-page-enter {
    from { opacity: 0; transform: translateY(15px); }
    to { opacity: 1; transform: translateY(0); }
  }

  /* Scroll reveal is activated by JS; without JS everything stays visible. */
  html.motion-enhanced .motion-item {
    opacity: 0;
    transform: translate3d(0, 28px, 0);
    transition:
      opacity .75s cubic-bezier(.22,1,.36,1),
      transform .75s cubic-bezier(.22,1,.36,1);
    transition-delay: var(--motion-delay, 0ms);
  }
  html.motion-enhanced .motion-item[data-motion="left"] { transform: translate3d(-30px, 0, 0); }
  html.motion-enhanced .motion-item[data-motion="right"] { transform: translate3d(30px, 0, 0); }
  html.motion-enhanced .motion-item.is-in-view { opacity: 1; transform: translate3d(0, 0, 0); }
  html.motion-enhanced .motion-item .eyebrow::before {
    transform-origin: left;
    transform: scaleX(.3);
    transition: transform .8s cubic-bezier(.22,1,.36,1) .25s;
  }
  html.motion-enhanced .motion-item.is-in-view .eyebrow::before { transform: scaleX(1); }

  /* Lightweight feedback for cards, images and links. */
  .program-card,
  .facility-card,
  .article-card,
  .quote-card,
  .education-photo,
  .community-collage img {
    transition:
      box-shadow .35s cubic-bezier(.22,1,.36,1),
      transform .35s cubic-bezier(.22,1,.36,1),
      border-color .35s ease;
  }
  .article-card:hover,
  .article-card:focus-within,
  .quote-card:hover,
  .quote-card:focus-within,
  .facility-card:hover,
  .facility-card:focus-within {
    transform: translateY(-5px);
    box-shadow: 0 18px 40px rgba(10,30,56,.11);
  }
  html.motion-enhanced .quote-card.motion-item.is-in-view:hover,
  html.motion-enhanced .facility-card.motion-item.is-in-view:hover,
  html.motion-enhanced .article-card.motion-item.is-in-view:hover {
    transform: translateY(-5px);
  }
  .program-card:hover,
  .program-card:focus-visible { transform: translateY(-4px); box-shadow: 0 20px 40px rgba(10,30,56,.18); }
  html.motion-enhanced .program-card.motion-item.is-in-view:hover,
  html.motion-enhanced .program-card.motion-item.is-in-view:focus-visible { transform: translateY(-4px); }
  .intro-photo img,
  .leader-photo > img,
  .education-photo img { transition: transform .8s cubic-bezier(.22,1,.36,1); }
  .intro-photo:hover img,
  .leader-photo:hover > img,
  .education-photo:hover img { transform: scale(1.035); }
  .community-collage { overflow: hidden; }
  .community-collage img:hover { transform: scale(1.035); }
  .btn svg,
  .text-link svg,
  .program-link svg { transition: transform .25s cubic-bezier(.22,1,.36,1); }
  .btn:hover svg,
  .text-link:hover svg,
  .program-card:hover .program-link svg { transform: translateX(4px); }
  .mobile-nav:not([hidden]) { animation: spn-menu-enter .22s ease-out both; }
  @keyframes spn-menu-enter {
    from { opacity: 0; transform: translateY(-8px); }
    to { opacity: 1; transform: translateY(0); }
  }

  /* One understated pulse every six seconds on the official WA contact link. */
  .floating-wa::after {
    content: '';
    position: absolute;
    inset: -3px;
    border-radius: inherit;
    border: 1px solid rgba(36,142,100,.4);
    pointer-events: none;
    animation: spn-contact-ring 6s ease-out infinite;
  }
  @keyframes spn-contact-ring {
    0%, 55%, 100% { transform: scale(1); opacity: 0; }
    60% { opacity: .65; }
    76% { transform: scale(1.24); opacity: 0; }
  }
}

/* Motion and decorative effects should never block reduced-motion users. */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  html.motion-enhanced .motion-item { opacity: 1 !important; transform: none !important; }
  .hero::before, .floating-wa::after { animation: none !important; }
  .reading-progress__fill { transition: none !important; }
}

/* Directional reveals must never create sideways scrolling on phones. */
html, body { overflow-x: clip; }
@media (max-width: 760px) and (prefers-reduced-motion: no-preference) {
  html.motion-enhanced .motion-item[data-motion="left"],
  html.motion-enhanced .motion-item[data-motion="right"] {
    transform: translate3d(0, 22px, 0);
  }
  /* Hero text still animates, but a continuous large bitmap animation is
     avoided on mobile devices to preserve battery and scrolling fluidity. */
  .hero::before { animation: none; transform: scale(1.01); will-change: auto; }
}
