/* ============================================================
   ANIMATIONS — Micro-animaciones y transiciones
   ============================================================ */

/* ---- ENTRADA DE PÁGINA ---- */
@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

@keyframes slideUp {
  from { opacity: 0; transform: translateY(20px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes slideDown {
  from { opacity: 0; transform: translateY(-20px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes slideRight {
  from { opacity: 0; transform: translateX(-20px); }
  to   { opacity: 1; transform: translateX(0); }
}

@keyframes scaleIn {
  from { opacity: 0; transform: scale(0.9); }
  to   { opacity: 1; transform: scale(1); }
}

@keyframes popIn {
  0%   { opacity: 0; transform: scale(0.5); }
  70%  { transform: scale(1.05); }
  100% { opacity: 1; transform: scale(1); }
}

/* ---- XP PULSE ---- */
@keyframes xpPulse {
  0%   { transform: scale(1); }
  50%  { transform: scale(1.2); }
  100% { transform: scale(1); }
}

/* ---- CORRECT ANSWER ---- */
@keyframes correctPulse {
  0%   { box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.4); }
  70%  { box-shadow: 0 0 0 10px rgba(34, 197, 94, 0); }
  100% { box-shadow: 0 0 0 0 rgba(34, 197, 94, 0); }
}

/* ---- WRONG SHAKE ---- */
@keyframes wrongShake {
  0%, 100% { transform: translateX(0); }
  20%  { transform: translateX(-8px); }
  40%  { transform: translateX(8px); }
  60%  { transform: translateX(-4px); }
  80%  { transform: translateX(4px); }
}

/* ---- PROGRESS ANIMATION ---- */
@keyframes progressGrow {
  from { width: 0; }
}

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

.spinner {
  width: 20px;
  height: 20px;
  border: 2px solid var(--border-default);
  border-top-color: var(--role-rector);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

/* ---- GLOW PULSE ---- */
@keyframes glowPulse {
  0%, 100% { opacity: 0.5; }
  50%  { opacity: 1; }
}

/* ---- FLOATING ---- */
@keyframes float {
  0%, 100% { transform: translateY(0); }
  50%  { transform: translateY(-8px); }
}

/* ---- CONFETTI (para celebración) ---- */
@keyframes confettiFall {
  0%   { transform: translateY(-100px) rotate(0deg); opacity: 1; }
  100% { transform: translateY(100vh) rotate(720deg); opacity: 0; }
}

/* ---- UTILITY CLASSES DE ANIMACIÓN ---- */
.animate-fadeIn       { animation: fadeIn var(--transition-base) ease forwards; }
.animate-slideUp      { animation: slideUp var(--transition-base) ease forwards; }
.animate-slideDown    { animation: slideDown var(--transition-base) ease forwards; }
.animate-slideRight   { animation: slideRight var(--transition-base) ease forwards; }
.animate-scaleIn      { animation: scaleIn var(--transition-spring) forwards; }
.animate-popIn        { animation: popIn var(--transition-spring) forwards; }
.animate-spin         { animation: spin 0.7s linear infinite; }
.animate-float        { animation: float 3s ease-in-out infinite; }
.animate-xpPulse      { animation: xpPulse 0.4s var(--transition-spring); }
.animate-correct      { animation: correctPulse 0.6s ease; }
.animate-wrong        { animation: wrongShake 0.5s ease; }

/* ---- DELAYS ---- */
.delay-1 { animation-delay: 50ms; }
.delay-2 { animation-delay: 100ms; }
.delay-3 { animation-delay: 150ms; }
.delay-4 { animation-delay: 200ms; }

/* ---- STAGGER CHILDREN ---- */
.stagger > * {
  opacity: 0;
  animation: slideUp var(--transition-base) ease forwards;
}
.stagger > *:nth-child(1) { animation-delay: 0ms; }
.stagger > *:nth-child(2) { animation-delay: 60ms; }
.stagger > *:nth-child(3) { animation-delay: 120ms; }
.stagger > *:nth-child(4) { animation-delay: 180ms; }
.stagger > *:nth-child(5) { animation-delay: 240ms; }
.stagger > *:nth-child(6) { animation-delay: 300ms; }

/* ---- HOVER LIFT ---- */
.hover-lift {
  transition: transform var(--transition-base), box-shadow var(--transition-base);
}
.hover-lift:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-lg);
}

/* ---- PULSE RING (para indicar interactividad) ---- */
.pulse-ring {
  position: relative;
}
.pulse-ring::after {
  content: '';
  position: absolute;
  inset: -4px;
  border-radius: inherit;
  border: 2px solid currentColor;
  opacity: 0;
  animation: correctPulse 2s ease-in-out infinite;
}

/* ---- SHIMMER (loading skeleton) ---- */
@keyframes shimmer {
  0%   { background-position: -1000px 0; }
  100% { background-position: 1000px 0; }
}

.skeleton {
  background: linear-gradient(
    90deg,
    var(--bg-surface-2) 25%,
    var(--bg-surface-3) 37%,
    var(--bg-surface-2) 63%
  );
  background-size: 2000px 100%;
  animation: shimmer 1.5s linear infinite;
  border-radius: var(--radius-sm);
}

/* ---- TRANSITIONS PARA REDUCED MOTION ---- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
