/* ==========================================
   ANIMATIONS.CSS - EJE LEGAL
   Animaciones y transiciones para el sitio
========================================== */

/* ------------------------------
   KEYFRAMES - Definiciones de animaciones
------------------------------ */

/* Fade In - Aparecer gradualmente */
@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

/* Fade In Up - Aparecer desde abajo */
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(30px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Slide Left - Deslizar desde la izquierda */
@keyframes slideLeft {
  from {
    opacity: 0;
    transform: translateX(-50px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

/* Slide Right - Deslizar desde la derecha */
@keyframes slideRight {
  from {
    opacity: 0;
    transform: translateX(50px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

/* Scale In - Crecer desde el centro */
@keyframes scaleIn {
  from {
    opacity: 0;
    transform: scale(0.9);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

/* Bounce In - Rebotar al aparecer */
@keyframes bounceIn {
  0% {
    opacity: 0;
    transform: scale(0.3);
  }
  50% {
    transform: scale(1.05);
  }
  70% {
    transform: scale(0.9);
  }
  100% {
    opacity: 1;
    transform: scale(1);
  }
}

/* Pulse - Pulsar continuamente */
@keyframes pulse {
  0% {
    box-shadow: 0 0 0 0 rgba(52, 152, 219, 0.4);
  }
  70% {
    box-shadow: 0 0 0 15px rgba(52, 152, 219, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(52, 152, 219, 0);
  }
}

/* Shake - Sacudir (para errores) */
@keyframes shake {
  0%, 100% {
    transform: translateX(0);
  }
  10%, 30%, 50%, 70%, 90% {
    transform: translateX(-5px);
  }
  20%, 40%, 60%, 80% {
    transform: translateX(5px);
  }
}

/* Rotate - Rotar continuamente */
@keyframes rotate {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

/* Float - Flotar arriba y abajo */
@keyframes float {
  0%, 100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-10px);
  }
}

/* Gradient Animation - Animación de gradiente */
@keyframes gradientShift {
  0% {
    background-position: 0% 50%;
  }
  50% {
    background-position: 100% 50%;
  }
  100% {
    background-position: 0% 50%;
  }
}

/* ------------------------------
   CLASES DE ANIMACIÓN
------------------------------ */

/* CLASE BASE para todos los elementos que se animan al aparecer */
.animated-element {
  opacity: 0;
  will-change: opacity, transform;
}

/* Clases que definen el tipo de animación */
.animate-fade-in {
  animation: fadeIn 0.8s ease-out forwards;
}

.animate-fade-in-up {
  animation: fadeInUp 0.8s ease-out forwards;
}

.animate-slide-left {
  animation: slideLeft 0.8s ease-out forwards;
}

.animate-slide-right {
  animation: slideRight 0.8s ease-out forwards;
}

.animate-scale-in {
  animation: scaleIn 0.6s ease-out forwards;
}

.animate-bounce-in {
  animation: bounceIn 0.8s ease-out forwards;
}

/* ESTADO FINAL ACTIVADO POR JAVASCRIPT */
.is-visible {
  opacity: 1 !important;
  transform: none !important;
}

/* ------------------------------
   DELAYS - Retrasos escalonados
------------------------------ */

.delay-1 {
  animation-delay: 0.2s;
}

.delay-2 {
  animation-delay: 0.4s;
}

.delay-3 {
  animation-delay: 0.6s;
}

.delay-4 {
  animation-delay: 0.8s;
}

.delay-5 {
  animation-delay: 1s;
}

/* ------------------------------
   ANIMACIONES CONTINUAS
------------------------------ */

/* Pulse continuo */
.animate-pulse {
  animation: pulse 2s infinite;
}

/* Float continuo */
.animate-float {
  animation: float 3s ease-in-out infinite;
}

/* Rotate continuo (para loaders) */
.animate-rotate {
  animation: rotate 1s linear infinite;
}

/* Gradiente animado */
.animate-gradient {
  background-size: 200% 200%;
  animation: gradientShift 3s ease infinite;
}

/* ------------------------------
   ESTADOS INTERACTIVOS
------------------------------ */

/* Hover - Elevación suave */
.hover-lift {
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.hover-lift:hover {
  transform: translateY(-5px);
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15);
}

/* Hover - Escalar */
.hover-scale {
  transition: transform 0.3s ease;
}

.hover-scale:hover {
  transform: scale(1.05);
}

/* Hover - Brillo */
.hover-glow {
  transition: box-shadow 0.3s ease;
}

.hover-glow:hover {
  box-shadow: 0 0 20px rgba(52, 152, 219, 0.5);
}

/* ------------------------------
   ESTADOS DE VISIBILIDAD
------------------------------ */

/* Oculto inicialmente */
.hidden {
  opacity: 0;
  visibility: hidden;
}

/* Visible */
.visible {
  opacity: 1;
  visibility: visible;
}

/* ------------------------------
   ANIMACIONES DE CARGA
------------------------------ */

/* Spinner de carga */
.spinner {
  border: 3px solid rgba(52, 152, 219, 0.2);
  border-top: 3px solid #3498db;
  border-radius: 50%;
  width: 40px;
  height: 40px;
  animation: rotate 1s linear infinite;
}

/* Dots loader */
.dots-loader {
  display: flex;
  gap: 5px;
}

.dots-loader span {
  width: 8px;
  height: 8px;
  background: #3498db;
  border-radius: 50%;
  animation: bounce 1.4s infinite ease-in-out both;
}

.dots-loader span:nth-child(1) {
  animation-delay: -0.32s;
}

.dots-loader span:nth-child(2) {
  animation-delay: -0.16s;
}

@keyframes bounce {
  0%, 80%, 100% {
    transform: scale(0);
  }
  40% {
    transform: scale(1);
  }
}

/* ------------------------------
   ANIMACIONES DE TEXTO
------------------------------ */

/* Typing effect */
.typing-effect {
  overflow: hidden;
  border-right: 2px solid #3498db;
  white-space: nowrap;
  animation: typing 3.5s steps(40, end), blink-caret 0.75s step-end infinite;
}

@keyframes typing {
  from {
    width: 0;
  }
  to {
    width: 100%;
  }
}

@keyframes blink-caret {
  from, to {
    border-color: transparent;
  }
  50% {
    border-color: #3498db;
  }
}

/* Underline animation */
.underline-animate {
  position: relative;
  display: inline-block;
}

.underline-animate::after {
  content: '';
  position: absolute;
  width: 0;
  height: 2px;
  bottom: 0;
  left: 0;
  background: #3498db;
  transition: width 0.3s ease;
}

.underline-animate:hover::after {
  width: 100%;
}

/* ------------------------------
   ANIMACIONES DE FEEDBACK
------------------------------ */

/* Success shake */
.success-shake {
  animation: shake 0.5s ease;
}

/* Error shake */
.error-shake {
  animation: shake 0.5s ease;
  border-color: #e74c3c !important;
}

/* Success fade */
.success-fade {
  animation: fadeIn 0.5s ease, fadeOut 0.5s ease 2.5s forwards;
}

@keyframes fadeOut {
  from {
    opacity: 1;
  }
  to {
    opacity: 0;
  }
}

/* ------------------------------
   TRANSICIONES SUAVES
------------------------------ */

/* Transición estándar */
.transition {
  transition: all 0.3s ease;
}

/* Transición lenta */
.transition-slow {
  transition: all 0.6s ease;
}

/* Transición rápida */
.transition-fast {
  transition: all 0.15s ease;
}

/* ------------------------------
   ANIMACIONES RESPONSIVE
------------------------------ */

/* Reducir animaciones en mobile */
@media (max-width: 768px) {
  .animated-element {
    animation-duration: 0.5s;
    transition-duration: 0.5s;
  }
  
  /* Reducir delays en mobile */
  .delay-1 { animation-delay: 0.1s; }
  .delay-2 { animation-delay: 0.2s; }
  .delay-3 { animation-delay: 0.3s; }
  .delay-4 { animation-delay: 0.4s; }
  .delay-5 { animation-delay: 0.5s; }
}

/* Respetar preferencias de movimiento reducido */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ------------------------------
   UTILIDADES ADICIONALES
------------------------------ */

/* Parallax suave */
.parallax {
  will-change: transform;
  transition: transform 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

/* Hardware acceleration */
.gpu-accelerated {
  transform: translateZ(0);
  backface-visibility: hidden;
  perspective: 1000px;
}

/* Smooth transitions para imágenes */
img {
  transition: opacity 0.3s ease, transform 0.3s ease;
}

img:hover {
  opacity: 0.9;
}

/* ------------------------------
   FIN DE ANIMATIONS.CSS
------------------------------ */