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

/* Fade-in con observer */
.fade-in {
  opacity: 0;
  transform: translateY(28px);
  transition: opacity 0.65s cubic-bezier(0.22, 1, 0.36, 1),
              transform 0.65s cubic-bezier(0.22, 1, 0.36, 1);
}
.fade-in.visible { opacity: 1; transform: translateY(0); }

/* Stagger — servicios */
.services-grid .fade-in:nth-child(1) { transition-delay: 0s; }
.services-grid .fade-in:nth-child(2) { transition-delay: 0.08s; }
.services-grid .fade-in:nth-child(3) { transition-delay: 0.16s; }
.services-grid .fade-in:nth-child(4) { transition-delay: 0.24s; }

/* Stagger — portafolio */
.portfolio-grid .fade-in:nth-child(1) { transition-delay: 0s; }
.portfolio-grid .fade-in:nth-child(2) { transition-delay: 0.07s; }
.portfolio-grid .fade-in:nth-child(3) { transition-delay: 0.14s; }
.portfolio-grid .fade-in:nth-child(4) { transition-delay: 0.21s; }
.portfolio-grid .fade-in:nth-child(5) { transition-delay: 0.28s; }
.portfolio-grid .fade-in:nth-child(6) { transition-delay: 0.35s; }
.portfolio-grid .fade-in:nth-child(7) { transition-delay: 0.42s; }
.portfolio-grid .fade-in:nth-child(8) { transition-delay: 0.49s; }

/* Float (cards destacadas) */
@keyframes float {
  0%, 100% { transform: translateY(0); }
  50%       { transform: translateY(-6px); }
}

/* Shimmer (disponible para badges/elementos futuros) */
@keyframes shimmer {
  0%   { background-position: -200% center; }
  100% { background-position:  200% center; }
}

/* ==================== STATS COUNTER ANIMATION ==================== */

.stat__number {
  display: block;         /* bloque: no cambia el ancho del padre al contar */
  text-align: center;
  opacity: 0;
  transform: translateY(16px) scale(0.75);
  transition: opacity 0.55s cubic-bezier(0.34, 1.56, 0.64, 1),
              transform 0.55s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.stat__number.stat--pop {
  opacity: 1;
  transform: translateY(0) scale(1);
}

/* Stagger entre los tres stats */
.stat:nth-child(1) .stat__number { transition-delay: 0s; }
.stat:nth-child(2) .stat__number { transition-delay: 0.14s; }
.stat:nth-child(3) .stat__number { transition-delay: 0.28s; }

/* "SaaS" — flip adicional al pop */
.stat__number--text {
  transform: translateY(16px) scale(0.75) rotateX(45deg);
  transform-origin: center bottom;
}
.stat__number--text.stat--pop {
  transform: translateY(0) scale(1) rotateX(0deg);
}

/* Slot machine (años de exp) — span interno que se desliza verticalmente */
.stat__slot-inner {
  display: block;
  will-change: transform, opacity;
}

/* ==================== CELEBRACION AL LLEGAR AL VALOR FINAL ==================== */

@keyframes stat-celebrate {
  0%   { transform: scale(1); }
  22%  { transform: scale(1.25); color: var(--primary); }
  45%  { transform: scale(0.92); }
  68%  { transform: scale(1.08); }
  100% { transform: scale(1); }
}

@keyframes ring-out {
  0%   { transform: translate(-50%, -50%) scale(0.2); opacity: 0.85; }
  100% { transform: translate(-50%, -50%) scale(2.2); opacity: 0; }
}

.stat--done {
  animation: stat-celebrate 0.65s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

/* Anillo expansivo — se agrega via JS y se elimina solo */
.stat__ring {
  position: absolute;
  top: 30%; left: 50%;
  transform: translate(-50%, -50%) scale(0.2);
  width: 54px; height: 54px;
  border: 2px solid var(--primary);
  border-radius: 50%;
  animation: ring-out 0.75s ease-out forwards;
  pointer-events: none;
  z-index: 10;
}
