/* ============================================
   VISION INFANTIL SANA - ANIMACIONES
   ============================================ */

/* FADE IN ANIMATIONS */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

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

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

@keyframes fadeInRight {
    from {
        opacity: 0;
        transform: translateX(30px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

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

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

@keyframes pulse {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.05);
    }
}

/* GLOW ANIMATIONS */
@keyframes glow {
    0%, 100% {
        box-shadow: 0 0 20px rgba(59, 130, 246, 0.3);
    }
    50% {
        box-shadow: 0 0 40px rgba(59, 130, 246, 0.6);
    }
}

@keyframes glowText {
    0%, 100% {
        text-shadow: 0 0 20px rgba(59, 130, 246, 0.5);
    }
    50% {
        text-shadow: 0 0 40px rgba(59, 130, 246, 0.8);
    }
}

/* GRADIENT ANIMATIONS */
@keyframes gradientShift {
    0% {
        background-position: 0% 50%;
    }
    50% {
        background-position: 100% 50%;
    }
    100% {
        background-position: 0% 50%;
    }
}

/* ROTATION ANIMATIONS */
@keyframes rotate {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}

@keyframes rotateReverse {
    from {
        transform: rotate(360deg);
    }
    to {
        transform: rotate(0deg);
    }
}

/* BOUNCE ANIMATIONS */
@keyframes bounce {
    0%, 100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(-10px);
    }
}

@keyframes bounceIn {
    0% {
        opacity: 0;
        transform: scale(0.3);
    }
    50% {
        opacity: 1;
        transform: scale(1.05);
    }
    70% {
        transform: scale(0.9);
    }
    100% {
        transform: scale(1);
    }
}

/* SLIDE ANIMATIONS */
@keyframes slideInFromRight {
    from {
        opacity: 0;
        transform: translateX(100%);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes slideInFromLeft {
    from {
        opacity: 0;
        transform: translateX(-100%);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* TYPING ANIMATION */
@keyframes typing {
    from {
        width: 0;
    }
    to {
        width: 100%;
    }
}

@keyframes blink {
    50% {
        border-color: transparent;
    }
}

/* SHIMMER ANIMATION */
@keyframes shimmer {
    0% {
        background-position: -1000px 0;
    }
    100% {
        background-position: 1000px 0;
    }
}

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

/* WAVE ANIMATION */
@keyframes wave {
    0%, 100% {
        transform: rotate(0deg);
    }
    25% {
        transform: rotate(10deg);
    }
    75% {
        transform: rotate(-10deg);
    }
}

/* PROGRESS ANIMATION */
@keyframes progressFill {
    from {
        width: 0%;
    }
}

/* PARTICLE ANIMATION */
@keyframes particle {
    0% {
        opacity: 1;
        transform: translate(0, 0) scale(1);
    }
    100% {
        opacity: 0;
        transform: translate(var(--tx), var(--ty)) scale(0);
    }
}

/* ============================================
   CLASES DE ANIMACION
   ============================================ */

/* Fade Animations */
.animate-fade-in {
    animation: fadeIn 0.6s ease-out forwards;
}

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

.animate-fade-in-down {
    animation: fadeInDown 0.6s ease-out forwards;
}

.animate-fade-in-left {
    animation: fadeInLeft 0.6s ease-out forwards;
}

.animate-fade-in-right {
    animation: fadeInRight 0.6s ease-out forwards;
}

/* Scale Animations */
.animate-scale-in {
    animation: scaleIn 0.5s ease-out forwards;
}

.animate-pulse {
    animation: pulse 2s ease-in-out infinite;
}

/* Glow Animations */
.animate-glow {
    animation: glow 2s ease-in-out infinite;
}

.animate-glow-text {
    animation: glowText 2s ease-in-out infinite;
}

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

/* Rotation Animations */
.animate-rotate {
    animation: rotate 3s linear infinite;
}

.animate-rotate-reverse {
    animation: rotateReverse 3s linear infinite;
}

/* Bounce Animations */
.animate-bounce {
    animation: bounce 1s ease-in-out infinite;
}

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

/* Slide Animations */
.animate-slide-in-right {
    animation: slideInFromRight 0.6s ease-out forwards;
}

.animate-slide-in-left {
    animation: slideInFromLeft 0.6s ease-out forwards;
}

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

/* Wave Animation */
.animate-wave {
    animation: wave 1s ease-in-out infinite;
}

/* Shimmer Effect */
.animate-shimmer {
    background: linear-gradient(
        90deg,
        rgba(255, 255, 255, 0) 0%,
        rgba(255, 255, 255, 0.1) 50%,
        rgba(255, 255, 255, 0) 100%
    );
    background-size: 200% 100%;
    animation: shimmer 2s infinite;
}

/* ============================================
   DELAYS PARA ANIMACIONES EN CASCADA
   ============================================ */

.delay-100 { animation-delay: 0.1s; }
.delay-200 { animation-delay: 0.2s; }
.delay-300 { animation-delay: 0.3s; }
.delay-400 { animation-delay: 0.4s; }
.delay-500 { animation-delay: 0.5s; }
.delay-600 { animation-delay: 0.6s; }
.delay-700 { animation-delay: 0.7s; }
.delay-800 { animation-delay: 0.8s; }
.delay-900 { animation-delay: 0.9s; }
.delay-1000 { animation-delay: 1s; }

/* ============================================
   ANIMACIONES ESPECIFICAS DEL PROYECTO
   ============================================ */

/* Hero Title Animation */
.hero-title .title-line {
    opacity: 0;
    animation: fadeInUp 0.8s ease-out forwards;
}

.hero-title .title-line:nth-child(1) { animation-delay: 0.2s; }
.hero-title .title-line:nth-child(2) { animation-delay: 0.4s; }
.hero-title .title-line:nth-child(3) { animation-delay: 0.6s; }

/* Stat Cards Animation */
.stat-card {
    opacity: 0;
    animation: scaleIn 0.6s ease-out forwards;
}

.stat-card:nth-child(1) { animation-delay: 0.1s; }
.stat-card:nth-child(2) { animation-delay: 0.2s; }
.stat-card:nth-child(3) { animation-delay: 0.3s; }
.stat-card:nth-child(4) { animation-delay: 0.4s; }

/* Navigation Animation on Scroll */
.smart-nav.scrolled {
    animation: fadeInDown 0.3s ease-out;
}

/* Progress Bar Fill */
.progress-fill, .comp-fill, .coverage-fill, .bar-fill, .diag-fill {
    animation: progressFill 1.5s ease-out forwards;
}

/* Card Hover Effects */
.overview-card, .ai-card, .module-card, .optimax-card, .impact-card {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.overview-card:hover, .ai-card:hover, .module-card:hover, .optimax-card:hover {
    transform: translateY(-8px) scale(1.02);
}

/* Button Hover Animations */
.btn-primary, .btn-secondary, .btn-primary-large, .btn-secondary-large {
    position: relative;
    overflow: hidden;
    transition: all 0.3s ease;
}

.btn-primary::before, .btn-primary-large::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    transform: translate(-50%, -50%);
    transition: width 0.6s, height 0.6s;
}

.btn-primary:hover::before, .btn-primary-large:hover::before {
    width: 300px;
    height: 300px;
}

/* Logo Icon Rotation on Hover */
.logo-icon {
    transition: transform 0.3s ease;
}

.brand-logo:hover .logo-icon {
    transform: rotate(10deg) scale(1.1);
}

/* Scroll Indicator Animation */
.scroll-indicator {
    animation: bounce 2s ease-in-out infinite;
}

/* Map Region Pulse on Hover */
.region:hover {
    animation: pulse 0.5s ease-in-out;
}

/* Timeline Entry Animation */
.timeline-entry {
    opacity: 0;
    transform: translateX(-30px);
    transition: all 0.5s ease-out;
}

.timeline-entry.visible {
    opacity: 1;
    transform: translateX(0);
}

/* Diagram Animation */
.diagram-card {
    opacity: 0;
    animation: fadeIn 0.8s ease-out forwards;
}

.diagram-card:nth-child(1) { animation-delay: 0.1s; }
.diagram-card:nth-child(2) { animation-delay: 0.2s; }
.diagram-card:nth-child(3) { animation-delay: 0.3s; }
.diagram-card:nth-child(4) { animation-delay: 0.4s; }

/* Counter Animation - se activa via JavaScript */
.counter {
    display: inline-block;
}

/* Section Reveal Animation */
section {
    opacity: 0;
    transform: translateY(30px);
    transition: opacity 0.8s ease-out, transform 0.8s ease-out;
}

section.visible {
    opacity: 1;
    transform: translateY(0);
}

/* ============================================
   ANIMACIONES DE CARGA
   ============================================ */

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid rgba(59, 130, 246, 0.1);
    border-top: 4px solid var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

/* ============================================
   ANIMACIONES DE TEXTO
   ============================================ */

.typewriter {
    overflow: hidden;
    border-right: 2px solid var(--primary);
    white-space: nowrap;
    animation: typing 3.5s steps(40, end), blink 0.75s step-end infinite;
}

/* ============================================
   TRANSICIONES SUAVES
   ============================================ */

.smooth-transition {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ============================================
   PERFORMANCE OPTIMIZATION
   ============================================ */

/* Usar will-change para animaciones frecuentes */
.nav-link, .btn-primary, .btn-secondary, .overview-card, .ai-card {
    will-change: transform;
}

/* Preferir transform y opacity sobre otras propiedades */
* {
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
    -webkit-perspective: 1000;
    perspective: 1000;
}
