/* ============================================================
   Colección Historia UNMSM v2.0 · Animaciones
   Listas para usar. Importar después de los tokens.
   ============================================================ */

/* ---------- Keyframes ---------- */

@keyframes chu-fade-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}

@keyframes chu-card-enter {
  from { opacity: 0; transform: scale(0.98); }
  to   { opacity: 1; transform: scale(1); }
}

@keyframes chu-modal-open {
  from { opacity: 0; transform: scale(0.9); }
  to   { opacity: 1; transform: scale(1); }
}

@keyframes chu-modal-close {
  from { opacity: 1; transform: scale(1); }
  to   { opacity: 0; transform: scale(0.95); }
}

@keyframes chu-toast-in {
  from { opacity: 0; transform: translate(-50%, -16px); }
  to   { opacity: 1; transform: translate(-50%, 0); }
}

@keyframes chu-toast-out {
  from { opacity: 1; transform: translate(-50%, 0); }
  to   { opacity: 0; transform: translate(-50%, -8px); }
}

@keyframes chu-crossfade {
  0%   { opacity: 1; }
  50%  { opacity: 0; }
  100% { opacity: 1; }
}

@keyframes chu-shake {
  0%, 100% { transform: translateX(0); }
  25%      { transform: translateX(-4px); }
  75%      { transform: translateX(4px); }
}

@keyframes chu-spin {
  to { transform: rotate(360deg); }
}

/* ---------- Aplicación por componente ---------- */

/* Cards: stagger fade-in (delay calculado inline por React) */
.chu-card {
  animation: chu-card-enter 0.2s ease-out both;
  transition: transform 0.2s ease-out, box-shadow 0.2s ease-out;
}
.chu-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
}

/* Modal */
.chu-modal-backdrop {
  animation: chu-fade-in 0.18s ease-out both;
}
.chu-modal-container {
  animation: chu-modal-open 0.25s cubic-bezier(0.2, 0.9, 0.4, 1.1) both;
}
.chu-modal-closing .chu-modal-container {
  animation: chu-modal-close 0.2s ease-in both;
}

/* Toast */
.chu-toast {
  animation: chu-toast-in 0.3s cubic-bezier(0.2, 0.8, 0.4, 1) both;
}
.chu-toast.leaving {
  animation: chu-toast-out 0.2s ease-in both;
}

/* Crossfade al cambiar de tomo/sección (en el header de resultados) */
.chu-results-header {
  animation: chu-crossfade 0.15s ease;
}

/* Botones (hover + active) */
.chu-btn {
  transition: background 0.15s ease, color 0.15s ease, transform 0.15s ease;
}
.chu-btn:hover  { transform: scale(1.04); }
.chu-btn:active { transform: scale(0.98); }

/* Image hover dentro de cards: leve zoom + reducir sepia */
.chu-card-thumb img {
  transition: transform 0.3s ease, filter 0.3s ease;
}
.chu-card:hover .chu-card-thumb img {
  transform: scale(1.04);
  filter: sepia(0.06) saturate(1.0);
}

/* Error shake (en form admin al fallar validación) */
.chu-field.error input,
.chu-field.error textarea,
.chu-field.error select {
  animation: chu-shake 0.32s ease;
}

/* Spinner de carga */
.chu-spinner {
  display: inline-block;
  width: 40px; height: 40px;
  border: 3px solid #E0E0E0;
  border-top-color: #8B0000;
  border-radius: 50%;
  animation: chu-spin 0.9s linear infinite;
}

/* Sidebar drawer mobile */
.chu-sidebar {
  transition: transform 0.2s ease;
}

/* ---------- Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001s !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001s !important;
    scroll-behavior: auto !important;
  }
  .chu-card:hover            { transform: none !important; }
  .chu-btn:hover, .chu-btn:active { transform: none !important; }
  .chu-card:hover .chu-card-thumb img { transform: none !important; }
}
