/**
 * site-animations.css
 * Suite de Animaciones Motion Nativas (iOS / Android Material You & Apple HIG)
 * Instituto de Compuinglés de Oriente (ICO)
 * 
 * - Físicas de resorte elásticas y curvas cinemáticas Apple / Google
 * - Respuesta táctil háptica simulada (Tap / Press Feedback con scale elástico)
 * - Efecto onda expansiva Material You (Ripple Effect)
 * - Revelado escalonado en cascada (Staggered Scroll Reveal)
 * - Micro-interacciones en formularios, botones flotantes y tarjetas
 * - Soporte completo de accesibilidad (prefers-reduced-motion) y aceleración por GPU (60-120fps)
 */

/* ==========================================================================
   1. VARIABLES DE DISEÑO CINEMÁTICO (APPLE FLUID & ANDROID MATERIAL MOTION)
   ========================================================================== */
:root {
    /* Curvas de aceleración nativas de iOS (Apple HIG) y Android (Material Design 3) */
    --ease-ios-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
    --ease-ios-smooth: cubic-bezier(0.16, 1, 0.3, 1);
    --ease-ios-decelerate: cubic-bezier(0.05, 0.7, 0.1, 1);
    --ease-android-standard: cubic-bezier(0.2, 0, 0, 1);
    --ease-android-bounce: cubic-bezier(0.175, 0.885, 0.32, 1.275);
    
    /* Tiempos de micro-interacción */
    --duration-tap: 120ms;
    --duration-release: 280ms;
    --duration-motion: 360ms;
    --duration-enter: 480ms;
    --duration-exit: 220ms;
}

/* ==========================================================================
   2. CONFIGURACIÓN BASE DEL SISTEMA NATIVO
   ========================================================================== */
/* Desactivar el recuadro gris por defecto de navegadores móviles para una experiencia 100% limpia */
*, *::before, *::after {
    -webkit-tap-highlight-color: transparent;
}

html {
    scroll-behavior: smooth;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Momentum scroll fluido en iOS Safari */
body {
    -webkit-overflow-scrolling: touch;
}

/* ==========================================================================
   3. RESPUESTA TÁCTIL TIPO APLICACIÓN NATIVA (PRESS & TAP FEEDBACK)
   ========================================================================== */
/* Botones, enlaces tipo botón, chips, tarjetas y elementos accionables */
.native-press,
.btn,
button:not(.ico-live-toast__close),
input[type="submit"],
input[type="button"],
.program-card,
.plantel-card,
.benefit-card,
.feature-card,
.filter-btn,
.tab-btn,
.chip-btn,
.floating-social a,
.cta-button {
    transition: transform var(--duration-release) var(--ease-ios-spring),
                box-shadow var(--duration-release) var(--ease-ios-smooth),
                filter var(--duration-release) ease,
                background-color var(--duration-release) ease;
    will-change: transform;
    transform: translateZ(0); /* Forzar capa GPU */
}

/* Estado presionado / active (Simulación de física háptica táctil) */
.native-press:active,
.btn:active,
button:not(.ico-live-toast__close):active,
input[type="submit"]:active,
input[type="button"]:active,
.filter-btn:active,
.tab-btn:active,
.chip-btn:active,
.floating-social a:active,
.cta-button:active,
.is-pressed {
    transform: scale(0.962) translateZ(0) !important;
    filter: brightness(0.95);
    transition: transform var(--duration-tap) var(--ease-ios-smooth),
                filter var(--duration-tap) ease !important;
}

/* Tarjetas grandes: compresión táctil más sutil y elegante */
.program-card:active,
.plantel-card:active,
.benefit-card:active,
.feature-card:active,
.card-press:active {
    transform: scale(0.985) translateZ(0) !important;
    filter: brightness(0.98);
    transition: transform var(--duration-tap) var(--ease-ios-smooth) !important;
}

/* Elevación refinada en escritorio con cursor fino (iPadOS / macOS hover) */
@media (hover: hover) and (pointer: fine) {
    .btn:hover,
    .cta-button:hover,
    .floating-social a:hover {
        transform: translateY(-2px) translateZ(0);
        box-shadow: 0 10px 24px -6px rgba(0, 122, 165, 0.35);
    }

    .program-card:hover,
    .plantel-card:hover,
    .benefit-card:hover,
    .hover-lift:hover {
        transform: translateY(-6px) translateZ(0);
        box-shadow: 0 20px 32px -12px rgba(19, 53, 87, 0.15), 0 8px 16px -6px rgba(19, 53, 87, 0.08);
    }
}

/* ==========================================================================
   4. EFECTO ONDA EXPANSIVA MATERIAL YOU / ANDROID (RIPPLE EFFECT)
   ========================================================================== */
.ripple-container {
    position: relative;
    overflow: hidden;
}

.native-ripple {
    position: absolute;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(255, 255, 255, 0.45) 0%, rgba(255, 255, 255, 0.15) 70%, transparent 100%);
    pointer-events: none;
    transform: scale(0);
    animation: nativeRippleAnim 0.55s var(--ease-android-standard) forwards;
    will-change: transform, opacity;
}

/* Variante de onda para fondos claros o botones blancos */
.native-ripple--dark {
    background: radial-gradient(circle, rgba(0, 122, 165, 0.25) 0%, rgba(0, 122, 165, 0.08) 70%, transparent 100%);
}

@keyframes nativeRippleAnim {
    0% {
        transform: scale(0);
        opacity: 0.8;
    }
    100% {
        transform: scale(3.2);
        opacity: 0;
    }
}

/* ==========================================================================
   5. REVELADO SUAVE AL SCROLL (SCROLL REVEAL CON FÍSICAS DE RESORTE)
   ========================================================================== */
.reveal-on-scroll {
    opacity: 0;
    transform: translateY(28px) scale(0.98);
    transition: opacity 0.65s var(--ease-ios-smooth),
                transform 0.65s var(--ease-ios-smooth);
    will-change: opacity, transform;
}

.reveal-on-scroll.is-visible {
    opacity: 1;
    transform: translateY(0) scale(1);
}

/* Variaciones de dirección de revelado */
.reveal-from-left {
    opacity: 0;
    transform: translateX(-32px);
    transition: opacity 0.65s var(--ease-ios-smooth),
                transform 0.65s var(--ease-ios-smooth);
    will-change: opacity, transform;
}
.reveal-from-left.is-visible {
    opacity: 1;
    transform: translateX(0);
}

.reveal-from-right {
    opacity: 0;
    transform: translateX(32px);
    transition: opacity 0.65s var(--ease-ios-smooth),
                transform 0.65s var(--ease-ios-smooth);
    will-change: opacity, transform;
}
.reveal-from-right.is-visible {
    opacity: 1;
    transform: translateX(0);
}

.reveal-scale {
    opacity: 0;
    transform: scale(0.92);
    transition: opacity 0.65s var(--ease-ios-spring),
                transform 0.65s var(--ease-ios-spring);
    will-change: opacity, transform;
}
.reveal-scale.is-visible {
    opacity: 1;
    transform: scale(1);
}

/* Retardos escalonados en cascada tipo lista nativa (Staggered Animation) */
.delay-50  { transition-delay: 50ms; }
.delay-100 { transition-delay: 100ms; }
.delay-150 { transition-delay: 150ms; }
.delay-200 { transition-delay: 200ms; }
.delay-250 { transition-delay: 250ms; }
.delay-300 { transition-delay: 300ms; }
.delay-350 { transition-delay: 350ms; }
.delay-400 { transition-delay: 400ms; }
.delay-500 { transition-delay: 500ms; }

/* ==========================================================================
   6. MICRO-INTERACCIONES EN FORMULARIOS NATIVOS (FOCUS RINGS & FLOAT)
   ========================================================================== */
input[type="text"],
input[type="email"],
input[type="tel"],
input[type="number"],
select,
textarea {
    transition: border-color 0.22s ease,
                box-shadow 0.22s var(--ease-ios-smooth),
                transform 0.22s var(--ease-ios-smooth),
                background-color 0.22s ease;
}

input[type="text"]:focus,
input[type="email"]:focus,
input[type="tel"]:focus,
input[type="number"]:focus,
select:focus,
textarea:focus {
    transform: translateY(-1.5px);
    border-color: #007AA5 !important;
    box-shadow: 0 0 0 3.5px rgba(0, 122, 165, 0.22) !important;
    outline: none !important;
}

/* ==========================================================================
   7. MODALES Y HOJAS INFERIORES NATIVAS (IOS/ANDROID BOTTOM SHEETS)
   ========================================================================== */
@media (max-width: 768px) {
    .native-bottom-sheet {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        background: #ffffff;
        border-radius: 24px 24px 0 0;
        box-shadow: 0 -12px 36px rgba(19, 53, 87, 0.25);
        transform: translateY(100%);
        transition: transform 0.42s var(--ease-ios-smooth);
        padding-bottom: max(16px, env(safe-area-inset-bottom));
        z-index: 99990;
    }

    .native-bottom-sheet.is-open {
        transform: translateY(0);
    }

    .native-bottom-sheet__handle {
        width: 38px;
        height: 4.5px;
        background: rgba(19, 53, 87, 0.2);
        border-radius: 999px;
        margin: 10px auto 14px;
    }
}

/* ==========================================================================
   8. PULSO DISCRETO DE LLAMADA A LA ACCIÓN (FAB / WHATSAPP / CTA)
   ========================================================================== */
@keyframes nativePulseGlow {
    0% {
        box-shadow: 0 0 0 0 rgba(37, 211, 102, 0.55);
    }
    70% {
        box-shadow: 0 0 0 14px rgba(37, 211, 102, 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(37, 211, 102, 0);
    }
}

.native-pulse-whatsapp {
    animation: nativePulseGlow 2.4s infinite cubic-bezier(0.24, 0, 0.38, 1);
}

/* Micro-rebote de celebración en iconos de check o insignias de éxito */
@keyframes nativeBadgePop {
    0% { transform: scale(0.6); opacity: 0; }
    70% { transform: scale(1.15); }
    100% { transform: scale(1); opacity: 1; }
}

.native-badge-pop {
    animation: nativeBadgePop 0.45s var(--ease-ios-spring) forwards;
}

/* ==========================================================================
   9. EFECTO DE ESCRITURA EN VIVO / TYPEWRITER Y TRAZADOS A MANO
   ========================================================================== */
.typewriter-cursor {
    display: inline-block;
    width: 2px;
    height: 1.1em;
    vertical-align: -0.15em;
    background-color: currentColor;
    margin-left: 2px;
    animation: typewriterBlink 0.9s infinite ease-in-out;
}

@keyframes typewriterBlink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0; }
}

.char-reveal {
    display: inline-block;
    opacity: 0;
    transform: translateY(6px);
    transition: opacity 0.25s ease, transform 0.25s ease;
}
.char-reveal.is-typed {
    opacity: 1;
    transform: translateY(0);
}

.handwritten-highlight {
    position: relative;
    display: inline-block;
    white-space: nowrap;
}

.handwritten-highlight svg.handwritten-stroke {
    position: absolute;
    left: 0;
    bottom: -6px;
    width: 100%;
    height: 12px;
    pointer-events: none;
    overflow: visible;
}

.handwritten-highlight svg.handwritten-stroke path {
    stroke-dasharray: 400;
    stroke-dashoffset: 400;
    transition: stroke-dashoffset 1.1s cubic-bezier(0.4, 0, 0.2, 1);
}

.handwritten-highlight.is-visible svg.handwritten-stroke path,
.is-visible .handwritten-highlight svg.handwritten-stroke path {
    stroke-dashoffset: 0;
}

.handwritten-circle {
    position: relative;
    display: inline-block;
}

.handwritten-circle svg.handwritten-circle-svg {
    position: absolute;
    top: -6px;
    left: -8px;
    width: calc(100% + 16px);
    height: calc(100% + 12px);
    pointer-events: none;
}

.handwritten-circle svg.handwritten-circle-svg path {
    stroke-dasharray: 600;
    stroke-dashoffset: 600;
    transition: stroke-dashoffset 1.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.handwritten-circle.is-visible svg.handwritten-circle-svg path,
.is-visible .handwritten-circle svg.handwritten-circle-svg path {
    stroke-dashoffset: 0;
}

/* ==========================================================================
   10. ACCESIBILIDAD (PREFERS-REDUCED-MOTION)
   ========================================================================== */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
    .reveal-on-scroll,
    .reveal-from-left,
    .reveal-from-right,
    .reveal-scale {
        opacity: 1 !important;
        transform: none !important;
        transition: none !important;
    }
    .native-ripple,
    .typewriter-cursor {
        display: none !important;
    }
    .handwritten-highlight svg.handwritten-stroke path,
    .handwritten-circle svg.handwritten-circle-svg path {
        stroke-dashoffset: 0 !important;
        transition: none !important;
    }
}
