/* ==========================================================================
   ANIMACIONES & TRANSICIONES
   ========================================================================== */

/* ── Entrada al hacer scroll ──────────────────────────── */
.fade-in {
  opacity: 0;
  transform: translateY(26px);
  transition: opacity 0.7s var(--ease), transform 0.7s var(--ease);
}
.fade-in.visible { opacity: 1; transform: none; }

/* Variantes direccionales */
.fade-in--left  { transform: translateX(-26px); }
.fade-in--right { transform: translateX(26px); }

/* Escalonado genérico — funciona en cualquier grid */
.stagger > *:nth-child(1) { transition-delay: 0.00s; }
.stagger > *:nth-child(2) { transition-delay: 0.07s; }
.stagger > *:nth-child(3) { transition-delay: 0.14s; }
.stagger > *:nth-child(4) { transition-delay: 0.21s; }
.stagger > *:nth-child(5) { transition-delay: 0.28s; }
.stagger > *:nth-child(6) { transition-delay: 0.35s; }
.stagger > *:nth-child(7) { transition-delay: 0.42s; }
.stagger > *:nth-child(8) { transition-delay: 0.49s; }
.stagger > *:nth-child(n+9) { transition-delay: 0.56s; }

/* El portafolio se re-renderiza al filtrar: sin retardo acumulado largo */
.portfolio-grid > *:nth-child(1) { transition-delay: 0.00s; }
.portfolio-grid > *:nth-child(2) { transition-delay: 0.05s; }
.portfolio-grid > *:nth-child(3) { transition-delay: 0.10s; }
.portfolio-grid > *:nth-child(4) { transition-delay: 0.15s; }
.portfolio-grid > *:nth-child(5) { transition-delay: 0.20s; }
.portfolio-grid > *:nth-child(6) { transition-delay: 0.25s; }
.portfolio-grid > *:nth-child(n+7) { transition-delay: 0.30s; }

/* ── Indicadores del hero ─────────────────────────────── */
.stat__number {
  display: block;
  opacity: 0;
  transform: translateY(14px) scale(0.8);
  transition: opacity 0.55s var(--ease-back), transform 0.55s var(--ease-back);
}
.stat__number.stat--pop { opacity: 1; transform: none; }

.stat:nth-child(1) .stat__number { transition-delay: 0.00s; }
.stat:nth-child(2) .stat__number { transition-delay: 0.11s; }
.stat:nth-child(3) .stat__number { transition-delay: 0.22s; }
.stat:nth-child(4) .stat__number { transition-delay: 0.33s; }

/* Contenedor del efecto de rodillo */
.stat__slot-inner { display: block; will-change: transform, opacity; }

/* Celebración al alcanzar el valor final */
@keyframes stat-celebrate {
  0%   { transform: scale(1); }
  22%  { transform: scale(1.22); color: var(--primary); }
  46%  { transform: scale(0.94); }
  70%  { transform: scale(1.07); }
  100% { transform: scale(1); }
}
.stat--done { animation: stat-celebrate 0.65s var(--ease-back); }

@keyframes ring-out {
  from { transform: translate(-50%, -50%) scale(0.2); opacity: 0.8; }
  to   { transform: translate(-50%, -50%) scale(2.3); opacity: 0; }
}
.stat__ring {
  position: absolute;
  top: 32%; left: 50%;
  width: 54px; height: 54px;
  border: 2px solid var(--primary);
  border-radius: 50%;
  transform: translate(-50%, -50%) scale(0.2);
  animation: ring-out 0.78s ease-out forwards;
  pointer-events: none;
  z-index: 10;
}

/* ── Utilidades de animación ──────────────────────────── */
@keyframes spin { to { transform: rotate(360deg); } }
.spinner { animation: spin 0.9s linear infinite; }

/* ── Accesibilidad: movimiento reducido ───────────────── */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }

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

  .fade-in { opacity: 1; transform: none; }
  .stat__number { opacity: 1; transform: none; }
  .tech-stack__inner { animation: none; }
  .hero__scroll span::after { animation: none; }
}
