/* ============================================================
   Subscale — Animations
   Keyframes, scroll-reveal states, and motion utilities.
   ============================================================ */

/* ---------- Keyframes ---------- */
@keyframes spin { to { transform: rotate(360deg); } }

@keyframes pulse-dot {
  0%, 100% { box-shadow: 0 0 0 0 rgba(34, 211, 154, 0.45); }
  50% { box-shadow: 0 0 0 6px rgba(34, 211, 154, 0); }
}

@keyframes loader-bounce {
  0%, 100% { transform: scaleY(0.4); opacity: 0.6; }
  50% { transform: scaleY(1); opacity: 1; }
}

@keyframes float-y {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-12px); }
}

@keyframes draw-line {
  from { stroke-dashoffset: var(--len, 900); }
  to { stroke-dashoffset: 0; }
}

@keyframes rise-bar {
  from { transform: scaleY(0); }
  to { transform: scaleY(1); }
}

@keyframes shimmer {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}

/* ---------- Scroll Reveal ---------- */
[data-reveal] {
  opacity: 0;
  transform: translateY(22px);
  transition: opacity 0.5s var(--ease), transform 0.5s var(--ease);
  will-change: opacity, transform;
}
[data-reveal].is-visible {
  opacity: 1;
  transform: translateY(0);
}

/* Stagger children inside grids when revealed */
.cards [data-reveal].is-visible,
.timeline [data-reveal].is-visible { transition-delay: var(--reveal-delay, 0s); }

/* ---------- Chart line draw ---------- */
.chart__line {
  stroke-dasharray: 900;
  stroke-dashoffset: 900;
}
.chart.is-drawn .chart__line {
  animation: draw-line 1.2s var(--ease) forwards;
}
.chart__area, .chart__pin, .chart__base { opacity: 0; transition: opacity 0.6s var(--ease) 0.6s; }
.chart.is-drawn .chart__area,
.chart.is-drawn .chart__pin,
.chart.is-drawn .chart__base { opacity: 1; }

/* ---------- Conversion bars fill ---------- */
.convbar__fill.is-filled { width: var(--w); transition: width 1.2s var(--ease); }

/* ---------- Sparkline bars in results ---------- */
.stat__spark span { transform: scaleY(0); }
.stat.is-visible .stat__spark span { animation: rise-bar 0.7s var(--ease) forwards; }
.stat.is-visible .stat__spark span:nth-child(1) { animation-delay: 0.05s; }
.stat.is-visible .stat__spark span:nth-child(2) { animation-delay: 0.12s; }
.stat.is-visible .stat__spark span:nth-child(3) { animation-delay: 0.19s; }
.stat.is-visible .stat__spark span:nth-child(4) { animation-delay: 0.26s; }
.stat.is-visible .stat__spark span:nth-child(5) { animation-delay: 0.33s; }
.stat.is-visible .stat__spark span:nth-child(6) { animation-delay: 0.40s; }

/* ---------- Shimmer skeleton (loader fallback) ---------- */
.shimmer {
  background: linear-gradient(90deg, rgba(255,255,255,0.04) 25%, rgba(255,255,255,0.1) 37%, rgba(255,255,255,0.04) 63%);
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite;
}

/* ---------- Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
  [data-reveal] { opacity: 1 !important; transform: none !important; }
  .chart__line { stroke-dashoffset: 0 !important; }
  .chart__area, .chart__pin, .chart__base { opacity: 1 !important; }
  .float-chip { animation: none !important; }
}
