/**
 * animations.css — Sistema de animaciones y movimiento
 * AVN Networks v1.0.0
 *
 * Estrategia: CSS-first, 0 dependencias externas.
 * JS solo activa clases (.in-view, .is-open, etc.)
 * Respeta prefers-reduced-motion en TODAS las animaciones.
 */

/* ============================================================
   KEYFRAMES GLOBALES
   ============================================================ */

/* Fade in hacia arriba — entry animation para secciones */
@keyframes avn-fade-up {
    from { opacity: 0; transform: translateY(32px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* Fade in — overlay, modal */
@keyframes avn-fade-in {
    from { opacity: 0; }
    to   { opacity: 1; }
}

/* Scale in — badges, tags, iconos */
@keyframes avn-scale-in {
    from { opacity: 0; transform: scale(.85); }
    to   { opacity: 1; transform: scale(1); }
}

/* Slide desde izquierda */
@keyframes avn-slide-left {
    from { opacity: 0; transform: translateX(-40px); }
    to   { opacity: 1; transform: translateX(0); }
}

/* Slide desde derecha */
@keyframes avn-slide-right {
    from { opacity: 0; transform: translateX(40px); }
    to   { opacity: 1; transform: translateX(0); }
}

/* Pulso suave — para badges de estado o CTA */
@keyframes avn-pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(0,217,255,.4); }
    50%       { box-shadow: 0 0 0 12px rgba(0,217,255,0); }
}

/* Grid de fondo hero — pulso de opacidad */
@keyframes avn-grid-pulse {
    0%, 100% { opacity: .3; }
    50%       { opacity: .55; }
}

/* Gradiente animado — para hero title o accents */
@keyframes avn-gradient-shift {
    0%   { background-position: 0% 50%; }
    50%  { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

/* Typewriter cursor */
@keyframes avn-blink {
    0%, 100% { opacity: 1; }
    50%       { opacity: 0; }
}

/* Floating suave — para ilustraciones/iconos en hero */
@keyframes avn-float {
    0%, 100% { transform: translateY(0); }
    50%       { transform: translateY(-10px); }
}

/* Spin lento — para iconos de loading o decorativos */
@keyframes avn-spin-slow {
    to { transform: rotate(360deg); }
}

/* Shimmer — skeleton loading */
@keyframes avn-shimmer {
    0%   { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}

/* Contador — tick hacia arriba */
@keyframes avn-count-in {
    from { opacity: 0; transform: translateY(16px) scale(.9); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* ============================================================
   CLASES DE ENTRADA — activadas por IntersectionObserver
   Los elementos empiezan invisible y aparecen al entrar al viewport.
   ============================================================ */

/* Estado inicial — elemento invisible esperando entrar */
[data-animate] {
    opacity: 0;
    transform: translateY(28px);
    transition:
        opacity .6s cubic-bezier(.4,0,.2,1),
        transform .6s cubic-bezier(.4,0,.2,1);
}

/* Variantes de dirección */
[data-animate="left"]  { transform: translateX(-28px); }
[data-animate="right"] { transform: translateX(28px); }
[data-animate="scale"] { transform: scale(.9); opacity: 0; }
[data-animate="fade"]  { transform: none; opacity: 0; }

/* Estado activo — el Observer agrega .in-view */
[data-animate].in-view {
    opacity: 1;
    transform: none;
}

/* Delays escalonados para grids (cascade) */
[data-delay="1"] { transition-delay: .1s; }
[data-delay="2"] { transition-delay: .2s; }
[data-delay="3"] { transition-delay: .3s; }
[data-delay="4"] { transition-delay: .4s; }
[data-delay="5"] { transition-delay: .5s; }
[data-delay="6"] { transition-delay: .6s; }

/* ============================================================
   CLASES DE ANIMACION DIRECTA (no necesitan JS)
   ============================================================ */

.avn-animate-fade-up {
    animation: avn-fade-up .7s cubic-bezier(.4,0,.2,1) both;
}

.avn-animate-fade-in {
    animation: avn-fade-in .5s ease both;
}

.avn-animate-scale-in {
    animation: avn-scale-in .4s cubic-bezier(.34,1.56,.64,1) both;
}

.avn-animate-float {
    animation: avn-float 4s ease-in-out infinite;
}

.avn-animate-pulse-cta {
    animation: avn-pulse 2.5s cubic-bezier(.4,0,.6,1) infinite;
}

/* ============================================================
   GRADIENTE ANIMADO — Para texto highlight o fondos
   ============================================================ */
.avn-gradient-text {
    background: linear-gradient(
        270deg,
        var(--avn-accent, #00d9ff),
        var(--avn-accent-2, #a855f7),
        #fff,
        var(--avn-accent, #00d9ff)
    );
    background-size: 300% 300%;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    animation: avn-gradient-shift 6s ease infinite;
}

/* ============================================================
   HERO GRID BACKGROUND (usado en .avn-hero__bg::before)
   ============================================================ */
.avn-bg-grid {
    background-image: radial-gradient(rgba(0,217,255,.15) 1px, transparent 1px);
    background-size: 40px 40px;
    animation: avn-grid-pulse 8s ease-in-out infinite;
}

/* ============================================================
   CARDS — HOVER LIFT
   ============================================================ */
.avn-card {
    transition:
        transform .25s cubic-bezier(.4,0,.2,1),
        box-shadow .25s ease,
        border-color .25s ease;
}

.avn-card:hover {
    transform: translateY(-6px);
    box-shadow: 0 20px 48px rgba(0,0,0,.35), 0 0 0 1px rgba(0,217,255,.15);
    border-color: rgba(0,217,255,.2);
}

/* ============================================================
   BOTONES — ESTADOS
   ============================================================ */
.btn-primary {
    position: relative;
    overflow: hidden;
    transition: transform .2s ease, box-shadow .2s ease, opacity .2s;
}

.btn-primary::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,.15), transparent);
    transform: translateX(-100%);
    transition: transform .4s ease;
}

.btn-primary:hover::after { transform: translateX(100%); }
.btn-primary:hover { transform: translateY(-2px); box-shadow: 0 8px 24px rgba(0,217,255,.3); }
.btn-primary:active { transform: translateY(0); }

.btn-secondary {
    transition: background .2s ease, color .2s ease, border-color .2s ease, transform .2s;
}
.btn-secondary:hover { transform: translateY(-2px); }

/* ============================================================
   SKELETON LOADING — Para blog preview dinámico
   ============================================================ */
.avn-skeleton {
    background: linear-gradient(90deg, #1a1a1a 25%, #242424 50%, #1a1a1a 75%);
    background-size: 200% 100%;
    animation: avn-shimmer 1.5s infinite;
    border-radius: 6px;
}

/* ============================================================
   STATS COUNTER — Animación de entrada
   ============================================================ */
.avn-stat-number {
    animation: avn-count-in .6s cubic-bezier(.34,1.56,.64,1) both;
}

/* ============================================================
   TYPEWRITER — Para subtítulo del hero
   ============================================================ */
.avn-typewriter-cursor {
    display: inline-block;
    width: 2px;
    height: 1.1em;
    background: var(--avn-accent, #00d9ff);
    margin-left: 2px;
    vertical-align: middle;
    animation: avn-blink .9s step-end infinite;
}

/* ============================================================
   TRANSICION DE PAGINA — Fade entre pages con Polylang
   ============================================================ */
.avn-page-transition {
    animation: avn-fade-in .4s ease;
}

/* ============================================================
   RESPETO POR prefers-reduced-motion — OBLIGATORIO
   Desactiva TODAS las animaciones para usuarios que lo solicitan.
   ============================================================ */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: .01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: .01ms !important;
    }

    [data-animate] {
        opacity: 1 !important;
        transform: none !important;
        transition: none !important;
    }

    .avn-gradient-text {
        animation: none;
        background: var(--avn-accent);
        background-clip: text;
        -webkit-background-clip: text;
    }
}
