/* ============================================================
   SW Fire & Angels Foundation — animations.css
   Comprehensive motion design · OKLCH · Spring easing
   ============================================================ */

/* ── 1. Scroll progress bar ────────────────────────────────── */
#scroll-progress {
  position: fixed;
  inset-block-start: 0;
  inset-inline-start: 0;
  height: 3px;
  width: 0%;
  background: linear-gradient(90deg,
    var(--fire-core),
    var(--fire-bright),
    var(--fire-amber),
    var(--fire-gold),
    var(--fire-amber),
    var(--fire-bright)
  );
  background-size: 300% 100%;
  z-index: 1200;
  transition: width 60ms linear;
  animation: progressShimmer 3s linear infinite;
  box-shadow: 0 0 8px var(--fire-bright), 0 0 16px oklch(61% 0.22 40 / .4);
}

/* ── 2. Core keyframes ─────────────────────────────────────── */

@keyframes progressShimmer {
  0%   { background-position: 0% 50%; }
  100% { background-position: 300% 50%; }
}

@keyframes bodyReveal {
  from { opacity: 0; }
  to   { opacity: 1; }
}

@keyframes fadeSlideDown {
  from { opacity: 0; translate: 0 -24px; }
  to   { opacity: 1; translate: 0 0; }
}

@keyframes fadeSlideUp {
  from { opacity: 0; translate: 0 40px; }
  to   { opacity: 1; translate: 0 0; }
}

@keyframes fadeSlideLeft {
  from { opacity: 0; translate: 30px 0; }
  to   { opacity: 1; translate: 0 0; }
}

@keyframes fadeSlideRight {
  from { opacity: 0; translate: -30px 0; }
  to   { opacity: 1; translate: 0 0; }
}

@keyframes scaleSpring {
  from { opacity: 0; scale: 0.82; }
  to   { opacity: 1; scale: 1; }
}

@keyframes clipRevealUp {
  from { clip-path: inset(100% 0 0 0 round 4px); }
  to   { clip-path: inset(0% 0 0 0 round 4px); }
}

@keyframes float {
  0%, 100% { translate: 0 0px; }
  33%       { translate: 8px -22px; }
  66%       { translate: -6px -14px; }
}

@keyframes floatReverse {
  0%, 100% { translate: 0 0px; }
  33%       { translate: -10px -18px; }
  66%       { translate: 6px -26px; }
}

@keyframes orbDrift {
  0%, 100% { translate: 0 0; scale: 1; opacity: 0.6; }
  25%       { translate: 30px -40px; scale: 1.1; opacity: 0.8; }
  50%       { translate: -20px -60px; scale: 0.95; opacity: 0.5; }
  75%       { translate: 40px -30px; scale: 1.05; opacity: 0.7; }
}

@keyframes glowBreath {
  0%, 100% { opacity: 0.3; filter: blur(50px); scale: 1; }
  50%       { opacity: 0.65; filter: blur(30px); scale: 1.08; }
}

@keyframes firePulse {
  0%, 100% {
    box-shadow: 0 0 20px oklch(61% 0.22 40 / .25), var(--shadow-lg);
    border-color: oklch(61% 0.22 40 / .35);
  }
  50% {
    box-shadow: 0 0 60px oklch(61% 0.22 40 / .55),
                0 0 120px oklch(50% 0.22 33 / .2),
                var(--shadow-xl);
    border-color: var(--fire-bright);
  }
}

@keyframes pulseRing {
  0%   { scale: 1;   opacity: 1; }
  100% { scale: 2.6; opacity: 0; }
}

@keyframes shimmerSlide {
  from { background-position: -250% 0; }
  to   { background-position:  250% 0; }
}

@keyframes fireGradientCycle {
  0%   { background-position: 0%   50%; }
  50%  { background-position: 100% 50%; }
  100% { background-position: 0%   50%; }
}

@keyframes scrollBounce {
  0%, 100% { translate: 0 0; opacity: 1; }
  50%       { translate: 0 8px; opacity: .5; }
}

@keyframes rippleOut {
  from { scale: 0; opacity: 0.5; }
  to   { scale: 4;  opacity: 0; }
}

@keyframes cursorBlink {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0; }
}

@keyframes badgeBreathe {
  0%, 100% { box-shadow: 0 0 0 0 oklch(61% 0.22 40 / .0); }
  50%       { box-shadow: 0 0 0 6px oklch(61% 0.22 40 / .15); }
}

@keyframes shine {
  0%   { background-position: -200% 0; opacity: 0; }
  10%  { opacity: 1; }
  90%  { opacity: 1; }
  100% { background-position: 200% 0; opacity: 0; }
}

@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

@keyframes lineGrow {
  from { scale: 0 1; }
  to   { scale: 1 1; }
}

@keyframes counterPop {
  0%   { scale: 1; }
  40%  { scale: 1.18; }
  70%  { scale: 0.95; }
  100% { scale: 1; }
}

/* Body always visible — no flash-of-black */

/* ── 4. Hero word fire animation ───────────────────────────── */
.hero__word {
  background-size: 250% 250%;
  animation: fireGradientCycle 4.5s ease infinite;
}

/* ── 5. Hero scroll arrow ──────────────────────────────────── */
.hero__scroll-arrow {
  animation: scrollBounce 1.8s ease-in-out infinite !important;
}

/* ── 6. Page hero — richer gradient backdrop ───────────────── */
.page-hero {
  position: relative;
  overflow: hidden;
}

.page-hero::before {
  content: '';
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse 500px 350px at 80% 40%,
      oklch(61% 0.22 40 / .07) 0%, transparent 100%),
    radial-gradient(ellipse 350px 250px at 15% 70%,
      oklch(50% 0.22 33 / .09) 0%, transparent 100%);
  pointer-events: none;
  z-index: 0;
  animation: glowBreath 9s ease-in-out infinite;
}

.page-hero .container { position: relative; z-index: 1; }

.page-hero .badge {
  animation: fadeSlideDown 0.6s var(--ease-out) 0.1s both;
  display: inline-flex;
  margin-block-end: var(--sp-4);
}
.page-hero h1 {
  animation: fadeSlideUp 0.75s var(--ease-out) 0.25s both;
}
.page-hero p {
  animation: fadeSlideUp 0.75s var(--ease-out) 0.4s both;
}

/* ── 7. Ambient section backgrounds ────────────────────────── */
/* Raised sections */
.section--raised {
  position: relative;
  overflow: hidden;
}
.section--raised::before {
  content: '';
  position: absolute;
  width: 700px; height: 700px;
  border-radius: 50%;
  background: radial-gradient(circle,
    oklch(50% 0.22 33 / .055) 0%, transparent 70%);
  inset-block-start: -250px;
  inset-inline-end: -200px;
  pointer-events: none;
  z-index: 0;
  animation: orbDrift 14s ease-in-out infinite;
}
.section--raised::after {
  content: '';
  position: absolute;
  width: 500px; height: 500px;
  border-radius: 50%;
  background: radial-gradient(circle,
    oklch(72% 0.20 55 / .04) 0%, transparent 70%);
  inset-block-end: -180px;
  inset-inline-start: -150px;
  pointer-events: none;
  z-index: 0;
  animation: orbDrift 18s ease-in-out infinite reverse 2s;
}
.section--raised > .container { position: relative; z-index: 1; }

/* Mission section (also bg-surface) */
.mission {
  position: relative;
  overflow: hidden;
}
.mission::after {
  content: '';
  position: absolute;
  width: 600px; height: 400px;
  border-radius: 50%;
  background: radial-gradient(ellipse,
    oklch(61% 0.22 40 / .06) 0%, transparent 70%);
  inset-block-start: 50%;
  inset-inline-start: 50%;
  translate: -50% -50%;
  pointer-events: none;
  z-index: 0;
  animation: glowBreath 8s ease-in-out infinite 1s;
}
.mission > .container { position: relative; z-index: 1; }

/* Community section */
.community {
  position: relative;
  overflow: hidden;
}
.community::before {
  content: '';
  position: absolute;
  width: 800px; height: 600px;
  border-radius: 50%;
  background: radial-gradient(ellipse,
    oklch(33% 0.18 30 / .10) 0%, transparent 70%);
  inset-block-start: 50%;
  inset-inline-start: 50%;
  translate: -50% -50%;
  pointer-events: none;
  z-index: 0;
  animation: glowBreath 12s ease-in-out infinite 3s;
}
.community > .container { position: relative; z-index: 1; }

/* Testimonials */
.testimonials {
  position: relative;
  overflow: hidden;
}
.testimonials::before {
  content: '';
  position: absolute;
  width: 500px; height: 500px;
  border-radius: 50%;
  background: radial-gradient(circle,
    oklch(72% 0.20 55 / .05) 0%, transparent 70%);
  inset-block-start: 0;
  inset-inline-end: 0;
  pointer-events: none;
  z-index: 0;
  animation: float 10s ease-in-out infinite;
}
.testimonials > .container { position: relative; z-index: 1; }

/* Fundraising box ambient */
.fundraising {
  background: var(--bg-raised);
  border: 1px solid var(--border-dim);
  border-radius: var(--radius-xl);
  padding: var(--sp-12);
  text-align: center;
  position: relative;
  overflow: hidden;
  animation: firePulse 4s ease-in-out infinite;
}
.fundraising::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at 50% 100%,
    oklch(33% 0.18 30 / .18) 0%, transparent 65%);
  pointer-events: none;
  z-index: 0;
  animation: glowBreath 5s ease-in-out infinite;
}
.fundraising > * { position: relative; z-index: 1; }

/* ── 8. Card 3D tilt + shine effect ────────────────────────── */
.card {
  position: relative;
  transform-style: preserve-3d;
  transition:
    transform    0.18s ease-out,
    box-shadow   0.18s ease-out,
    border-color var(--dur-base) var(--ease-out);
}

/* Shine overlay */
.card-shine {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: linear-gradient(
    105deg,
    transparent   30%,
    oklch(100% 0 0 / .10) 50%,
    transparent   70%
  );
  background-size: 250% 100%;
  opacity: 0;
  pointer-events: none;
  z-index: 3;
  transition: opacity 0.2s;
}
.card:hover .card-shine {
  opacity: 1;
  animation: shine 0.65s ease forwards;
}

/* Tilt-specific glow */
.card:hover {
  border-color: var(--fire-bright);
}

/* ── 9. Featured image pulse border ────────────────────────── */
.featured-item.today,
.transform-card.now {
  animation: firePulse 3.5s ease-in-out infinite;
}

/* ── 10. Scroll-reveal variants ─────────────────────────────── */
.reveal {
  opacity: 0;
  translate: 0 40px;
  transition:
    opacity   0.65s var(--ease-out),
    translate 0.65s var(--ease-out);
}
.reveal.visible {
  opacity: 1;
  translate: 0 0;
}

/* Directional variants */
.reveal--left {
  translate: -40px 0 !important;
}
.reveal--left.visible {
  translate: 0 0 !important;
}

.reveal--right {
  translate: 40px 0 !important;
}
.reveal--right.visible {
  translate: 0 0 !important;
}

.reveal--scale {
  scale: 0.88 !important;
  opacity: 0 !important;
  translate: 0 0 !important;
  transition:
    opacity 0.65s var(--ease-out),
    scale   0.65s var(--ease-spring) !important;
}
.reveal--scale.visible {
  opacity: 1 !important;
  scale: 1 !important;
}

/* Stagger children — nth-child delays */
.stagger-children > *:nth-child(1) { transition-delay:   0ms; }
.stagger-children > *:nth-child(2) { transition-delay:  90ms; }
.stagger-children > *:nth-child(3) { transition-delay: 180ms; }
.stagger-children > *:nth-child(4) { transition-delay: 270ms; }
.stagger-children > *:nth-child(5) { transition-delay: 360ms; }
.stagger-children > *:nth-child(6) { transition-delay: 450ms; }
.stagger-children > *:nth-child(7) { transition-delay: 540ms; }
.stagger-children > *:nth-child(8) { transition-delay: 630ms; }

/* ── 11. Stat pulse ring ────────────────────────────────────── */
.hero-stat {
  position: relative;
}
.pulse-ring {
  position: absolute;
  inset: -10px;
  border: 2px solid var(--fire-bright);
  border-radius: 50%;
  pointer-events: none;
  animation: pulseRing 1.1s var(--ease-out) forwards;
}

/* Counter pop when it finishes */
.hero-stat__num.popped {
  animation: counterPop 0.5s var(--ease-spring) both;
}

/* ── 12. Section fire-line divider ──────────────────────────── */
.fire-line {
  height: 1px;
  border: none;
  background: linear-gradient(90deg,
    transparent 0%,
    oklch(50% 0.22 33 / .6) 20%,
    oklch(61% 0.22 40)       35%,
    oklch(72% 0.20 55)       50%,
    oklch(61% 0.22 40)       65%,
    oklch(50% 0.22 33 / .6) 80%,
    transparent 100%
  );
  background-size: 200% 100%;
  animation: shimmerSlide 2.8s linear infinite;
  margin-block: var(--sp-10);
  opacity: 0.55;
}

/* ── 13. Button ripple ──────────────────────────────────────── */
.btn {
  overflow: hidden;
}

.ripple {
  position: absolute;
  border-radius: 50%;
  background: oklch(100% 0 0 / .28);
  transform: scale(0);
  animation: rippleOut 0.65s ease-out forwards;
  pointer-events: none;
}

/* ── 14. Typewriter cursor ──────────────────────────────────── */
.tw-cursor {
  display: inline-block;
  width: 2px;
  height: 1em;
  background: var(--fire-amber);
  margin-inline-start: 2px;
  vertical-align: text-bottom;
  border-radius: 1px;
  animation: cursorBlink 0.9s step-end infinite;
}

/* ── 15. Badge pulse ────────────────────────────────────────── */
.badge {
  animation: badgeBreathe 3s ease-in-out infinite;
}

/* ── 16. Progress bar tip glow ──────────────────────────────── */
.progress-tip {
  position: absolute;
  inset-block: -3px;
  inset-inline-end: -4px;
  width: 10px; height: 10px;
  border-radius: 50%;
  background: var(--fire-gold);
  box-shadow: 0 0 10px var(--fire-gold), 0 0 22px var(--fire-amber);
  animation: glowBreath 1.8s ease-in-out infinite;
  pointer-events: none;
}

/* ── 17. Timeline dot pulse ─────────────────────────────────── */
.timeline-item.visible .timeline-dot::after {
  content: '';
  position: absolute;
  inset: -8px;
  border-radius: 50%;
  border: 2px solid var(--fire-bright);
  animation: pulseRing 2s ease-out infinite;
  pointer-events: none;
}
.timeline-dot { position: relative; }

/* ── 18. Nav tab animated underline slide ───────────────────── */
.nav-bar .nav-tab {
  position: relative;
}
.nav-bar .nav-tab::before {
  content: '';
  position: absolute;
  inset-block-end: -1px;
  inset-inline-start: 50%;
  translate: -50% 0;
  height: 2px;
  width: 0%;
  background: var(--fire-amber);
  border-radius: 2px;
  transition: width 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  z-index: 1;
}
.nav-bar .nav-tab:hover::before { width: 60%; }
.nav-bar .nav-tab.active::before { width: 100%; }
/* hide the border-based underline since we're using ::before now */
.nav-bar .nav-tab.active { border-block-end-color: transparent; }

/* ── 19. Card grid stagger (via JS --stagger-i custom prop) ─── */
.card,
.blog-card,
.video-card,
.bio-card,
.giving-card {
  transition-delay: calc(var(--stagger-i, 0) * 90ms);
}

/* ── 20. Form input glow on focus ───────────────────────────── */
.field input:focus,
.field select:focus,
.field textarea:focus {
  box-shadow: 0 0 0 4px oklch(61% 0.22 40 / .18);
}

/* ── 21. Mobile nav stagger ─────────────────────────────────── */
.nav-mobile .nav-tab {
  opacity: 0;
  translate: -20px 0;
  transition: opacity 0.25s var(--ease-out), translate 0.25s var(--ease-out);
}
.nav-mobile.open .nav-tab {
  opacity: 1;
  translate: 0 0;
}
.nav-mobile.open .nav-tab:nth-child(1) { transition-delay:  30ms; }
.nav-mobile.open .nav-tab:nth-child(2) { transition-delay:  70ms; }
.nav-mobile.open .nav-tab:nth-child(3) { transition-delay: 110ms; }
.nav-mobile.open .nav-tab:nth-child(4) { transition-delay: 150ms; }
.nav-mobile.open .nav-tab:nth-child(5) { transition-delay: 190ms; }
.nav-mobile.open .nav-tab:nth-child(6) { transition-delay: 230ms; }
.nav-mobile.open .nav-tab:nth-child(7) { transition-delay: 270ms; }
.nav-mobile.open .nav-tab:nth-child(8) { transition-delay: 310ms; }
.nav-mobile.open .nav-tab:nth-child(9) { transition-delay: 350ms; }

/* ── 22. Story image reveal ─────────────────────────────────── */
.story-image {
  overflow: hidden;
}
.story-image img {
  transition: transform 0.8s var(--ease-out);
}
.story-image:hover img {
  transform: scale(1.04);
}
.story-image::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(
    135deg,
    oklch(61% 0.22 40 / .12) 0%,
    transparent 60%
  );
  opacity: 0;
  transition: opacity 0.4s var(--ease-out);
  pointer-events: none;
}
.story-image:hover::after { opacity: 1; }

/* ── 23. Blog/bios card hover lift ─────────────────────────── */
.blog-card:hover,
.bio-card:hover,
.video-card:hover {
  transform: translateY(-8px) !important;
  box-shadow: var(--shadow-xl), var(--glow-fire) !important;
  border-color: var(--fire-bright) !important;
}

/* ── 24. Section header reveal decoration ───────────────────── */
.section-header::after {
  content: '';
  display: block;
  width: 60px;
  height: 3px;
  background: linear-gradient(90deg, var(--fire-core), var(--fire-amber));
  border-radius: 2px;
  margin: var(--sp-5) auto 0;
  animation: lineGrow 0.6s var(--ease-spring) both;
}

/* ── 25. Giving card / Donate card ─────────────────────────── */
.giving-card {
  transition:
    transform    0.35s var(--ease-out),
    box-shadow   0.35s var(--ease-out),
    border-color 0.2s  var(--ease-out);
}
.giving-card:hover {
  transform: translateY(-6px);
  box-shadow: var(--shadow-xl), var(--glow-fire);
  border-color: var(--fire-bright);
}

/* ── 26. Amount chip bounce on select ───────────────────────── */
.amount-chip {
  transition:
    transform    0.3s var(--ease-spring),
    background   0.15s var(--ease-out),
    border-color 0.15s var(--ease-out),
    color        0.15s var(--ease-out);
}
.amount-chip:hover {
  transform: translateY(-2px) scale(1.05);
}
.amount-chip.active {
  animation: counterPop 0.4s var(--ease-spring) both;
}

/* ── 27. Donor letter modal animation ───────────────────────── */
#donorLetterModal {
  opacity: 0;
  transition: opacity 0.3s var(--ease-out);
}
#donorLetterModal.open {
  opacity: 1;
}
#donorLetterModal .modal-inner {
  transform: translateY(32px) scale(0.96);
  transition:
    transform 0.4s var(--ease-spring),
    opacity   0.3s var(--ease-out);
  opacity: 0;
}
#donorLetterModal.open .modal-inner {
  transform: translateY(0) scale(1);
  opacity: 1;
}

/* ── 28. Footer social pill hover ───────────────────────────── */
.social-pill {
  transition:
    transform    0.25s var(--ease-spring),
    background   0.2s  var(--ease-out),
    border-color 0.2s  var(--ease-out);
}
.social-pill:hover {
  transform: translateY(-3px) scale(1.06);
  background: oklch(61% 0.22 40 / .15);
  border-color: var(--fire-bright);
}

/* ── 29. Scroll-to-top button ───────────────────────────────── */
.scroll-top:hover {
  animation: float 1s ease-in-out infinite;
}

/* ── 30. Prefers-reduced-motion ─────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }

  .reveal,
  .reveal--left,
  .reveal--right,
  .reveal--scale {
    opacity: 1 !important;
    translate: 0 0 !important;
    scale: 1 !important;
  }

  .section--raised::before,
  .section--raised::after,
  .hero__word,
  .fundraising,
  .featured-item.today,
  .transform-card.now {
    animation: none !important;
  }
}
