/* ==========================================================================
   KINDWEAVE | Charity and Non-profit HTML Template
   File: assets/css/animations.css (all motion lives here)

   01. Scroll reveal        elements fade in as they enter the screen
   02. Hero entrance        the opening sequence on the home page
   03. Stitch drawing       the dashed thread that draws itself
   04. Looping motion       floating card, pulsing dot, marquee, 404
   05. Filter animation     cause cards when a filter is chosen
   06. Reduced motion       switches everything off for visitors who ask

   HOW TO USE SCROLL REVEAL IN THE HTML
   Add data-reveal to any element:
     data-reveal            fades up
     data-reveal="left"     slides in from the left
     data-reveal="right"    slides in from the right
     data-reveal="zoom"     grows in
   Add data-delay="1" up to data-delay="5" to stagger items in a row.
   ========================================================================== */


/* ==========================================================================
   01. SCROLL REVEAL
   The ".js" class is added to <html> by a tiny script in the <head>.
   If JavaScript is off, nothing is hidden and the page still works.
   ========================================================================== */
.js [data-reveal] {
  opacity: 0;
  transform: translateY(28px);
  transition: opacity 0.8s var(--ease), transform 0.8s var(--ease);
  will-change: opacity, transform;
}

.js [data-reveal="left"]  { transform: translateX(-36px); }
.js [data-reveal="right"] { transform: translateX(36px); }
.js [data-reveal="zoom"]  { transform: scale(0.92); }

/* main.js adds .is-visible when the element enters the screen */
.js [data-reveal].is-visible {
  opacity: 1;
  transform: none;
}

.js [data-delay="1"] { transition-delay: 0.1s; }
.js [data-delay="2"] { transition-delay: 0.2s; }
.js [data-delay="3"] { transition-delay: 0.3s; }
.js [data-delay="4"] { transition-delay: 0.4s; }
.js [data-delay="5"] { transition-delay: 0.5s; }


/* ==========================================================================
   02. HERO ENTRANCE
   Runs once when the home page loads. Each item starts a little later
   than the one before it. Change the --d value in the HTML to retime.
   ========================================================================== */
@keyframes rise-in {
  from { opacity: 0; transform: translateY(30px); }
  to   { opacity: 1; transform: none; }
}

@keyframes pop-in {
  from { opacity: 0; transform: scale(0.8); }
  to   { opacity: 1; transform: none; }
}

@keyframes arch-in {
  from { opacity: 0; clip-path: inset(100% 0 0 0 round 999px 999px 28px 28px); }
  to   { opacity: 1; clip-path: inset(0 0 0 0 round 999px 999px 28px 28px); }
}

.hero [data-hero] {
  animation: rise-in 0.9s var(--ease) both;
  animation-delay: var(--d, 0s);
}

.hero [data-hero="pop"] {
  animation-name: pop-in;
}

.hero [data-hero="arch"] {
  animation-name: arch-in;
  animation-duration: 1.2s;
}

/* Page banner title on inner pages */
.page-banner h1,
.page-banner .breadcrumb {
  animation: rise-in 0.8s var(--ease) both;
}

.page-banner .breadcrumb {
  animation-delay: 0.15s;
}


/* ==========================================================================
   03. STITCH DRAWING
   The dashed thread is revealed by a mask that grows along the path.
   ========================================================================== */
@keyframes stitch-draw {
  to { stroke-dashoffset: 0; }
}

.stitch-reveal {
  fill: none;
  stroke: #fff;
  stroke-width: 10;
  stroke-dasharray: 1;
  stroke-dashoffset: 1;
  animation: stitch-draw 2.4s 0.5s ease-in-out forwards;
}


/* ==========================================================================
   04. LOOPING MOTION
   ========================================================================== */

/* Floating card in the hero */
@keyframes float {
  0%, 100% { translate: 0 0; }
  50%      { translate: 0 -10px; }
}

.hero-card {
  animation: rise-in 0.9s var(--ease) both, float 5s 1.6s ease-in-out infinite;
  animation-delay: var(--d, 0s), 1.6s;
}

/* Pulsing dot */
@keyframes pulse {
  0%   { box-shadow: 0 0 0 0 rgba(31, 166, 122, 0.55); }
  100% { box-shadow: 0 0 0 12px rgba(31, 166, 122, 0); }
}

.live-dot {
  animation: pulse 1.8s ease-out infinite;
}

/* Partner logos scrolling sideways. Change 32s to make it faster or slower. */
@keyframes marquee {
  to { transform: translateX(calc(-50% - 28px)); }
}

.marquee__track {
  animation: marquee 32s linear infinite;
}

.marquee:hover .marquee__track {
  animation-play-state: paused;
}

/* The zero on the 404 page */
@keyframes wobble {
  0%, 100% { transform: rotate(-8deg); }
  50%      { transform: rotate(8deg); }
}

.error-page__code span {
  animation: wobble 3s ease-in-out infinite;
}

/* Heart icon in donate buttons beats on hover */
@keyframes beat {
  0%, 100% { transform: scale(1); }
  30%      { transform: scale(1.3); }
  60%      { transform: scale(0.95); }
}

.btn:hover .icon--heart {
  animation: beat 0.7s var(--ease);
}


/* ==========================================================================
   05. FILTER ANIMATION
   ========================================================================== */
@keyframes filter-in {
  from { opacity: 0; transform: scale(0.94); }
  to   { opacity: 1; transform: none; }
}

.is-filtered-in {
  animation: filter-in 0.5s var(--ease) both;
}


/* ==========================================================================
   06. REDUCED MOTION
   Visitors who switch on "reduce motion" on their device get a still page.
   ========================================================================== */
@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-delay: 0s !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    transition-delay: 0s !important;
  }

  .js [data-reveal] {
    opacity: 1;
    transform: none;
  }

  .marquee__track {
    animation: none;
  }
}
