/**
 * Animaciones globales del tema OZ — entrada de bloques al hacer scroll
 * + microinteracciones de botones. Profesional y sutil.
 *
 * Diseño:
 *  - Los bloques empiezan ocultos SOLO cuando el JS añade `.oz-anim` al <html>
 *    (clase `oz-anim-ready`). Así, sin JS, nada queda invisible (fallback seguro).
 *  - El IntersectionObserver añade `.oz-in` al entrar en viewport → dispara la
 *    transición de entrada (una sola vez).
 *  - Se respeta `prefers-reduced-motion`.
 */

/* ───────────────────────────────────────────────────────────
   1) ENTRADA DE BLOQUES AL HACER SCROLL
   El estado "oculto inicial" solo aplica cuando <html> tiene
   `.oz-anim-ready` (lo pone el JS). Sin JS → visible normal.
   ─────────────────────────────────────────────────────────── */
.oz-anim-ready .oz-anim {
    opacity: 0;
    transform: translateY(24px);
    /* Curva suave tipo "ease-out" premium; duración corta para no entorpecer. */
    transition:
        opacity 0.62s cubic-bezier(0.22, 1, 0.36, 1),
        transform 0.62s cubic-bezier(0.22, 1, 0.36, 1);
    transition-delay: var(--oz-anim-delay, 0ms);
    will-change: opacity, transform;
}

.oz-anim-ready .oz-anim.oz-in {
    opacity: 1;
    transform: none;
}

/* Una vez visible, soltar will-change para no consumir memoria de compositing. */
.oz-anim-ready .oz-anim.oz-anim-done {
    will-change: auto;
}

/* Variantes de dirección (el JS las puede asignar por tipo de bloque) */
.oz-anim-ready .oz-anim--left  { transform: translateX(-28px); }
.oz-anim-ready .oz-anim--right { transform: translateX(28px); }
.oz-anim-ready .oz-anim--zoom  { transform: scale(0.96); }
.oz-anim-ready .oz-anim--left.oz-in,
.oz-anim-ready .oz-anim--right.oz-in,
.oz-anim-ready .oz-anim--zoom.oz-in { transform: none; }

/* ───────────────────────────────────────────────────────────
   1b) MAQUETADOR — secciones de EXACTAMENTE 2 columnas:
   la columna 1 entra desde la izquierda y la 2 desde la derecha.

   No depende de que el JS marque las columnas: reutiliza el `.oz-in`
   que el observer ya pone sobre la `.oz-pb-section` al entrar al viewport.
   La detección de "2 columnas" usa `:nth-last-child(... of .oz-pb-col)`,
   que cuenta SOLO columnas y es inmune a los <style> que el builder a veces
   intercala en el grid (alto/ancho/alineación fija de columna).
   Fallback seguro: sin `.oz-anim-ready` (JS caído) las columnas quedan en su
   sitio normal; en navegadores sin `:has()`/`of` simplemente no se anima.
   ─────────────────────────────────────────────────────────── */
.oz-anim-ready .oz-pb-section .oz-pb-grid > .oz-pb-col:first-child:nth-last-child(2 of .oz-pb-col),
.oz-anim-ready .oz-pb-section .oz-pb-grid > .oz-pb-col:last-child:nth-child(2 of .oz-pb-col) {
    opacity: 0;
    transition:
        opacity 0.62s cubic-bezier(0.22, 1, 0.36, 1),
        transform 0.62s cubic-bezier(0.22, 1, 0.36, 1);
    will-change: opacity, transform;
}

/* Columna 1 (primera de 2) → desde la izquierda */
.oz-anim-ready .oz-pb-section .oz-pb-grid > .oz-pb-col:first-child:nth-last-child(2 of .oz-pb-col) {
    transform: translateX(-40px);
}

/* Columna 2 (última de 2) → desde la derecha */
.oz-anim-ready .oz-pb-section .oz-pb-grid > .oz-pb-col:last-child:nth-child(2 of .oz-pb-col) {
    transform: translateX(40px);
}

/* Cuando la sección entra (el observer añade `.oz-in`), revelar ambas. */
.oz-anim-ready .oz-pb-section.oz-in .oz-pb-grid > .oz-pb-col:first-child:nth-last-child(2 of .oz-pb-col),
.oz-anim-ready .oz-pb-section.oz-in .oz-pb-grid > .oz-pb-col:last-child:nth-child(2 of .oz-pb-col) {
    opacity: 1;
    transform: none;
}

/* La propia sección de 2 columnas NO debe desplazarse en vertical: el
   movimiento lo hacen las columnas (izq./der.). Dejamos solo el fade de la
   sección para que no haya doble animación. Solo afecta a secciones con
   exactamente 2 columnas. */
.oz-anim-ready .oz-pb-section.oz-anim:has(.oz-pb-grid > .oz-pb-col:first-child:nth-last-child(2 of .oz-pb-col)) {
    transform: none;
}

/* ───────────────────────────────────────────────────────────
   2) MICROINTERACCIONES DE BOTONES (todo el sitio)
   Transición suave en hover + "press" sutil al hacer click.
   Se aplica de forma amplia a botones y .button sin pisar colores.
   ─────────────────────────────────────────────────────────── */
.oz-btn-anim,
a.button,
button.button,
.wp-element-button,
.add_to_cart_button,
.single_add_to_cart_button,
.ozc-product-card__btn,
.ozc-product-card__btn--primary,
.ozc-product-card__wa-btn,
.oz-wc-ficha-tecnica__btn,
.hero-btn,
.btn,
.btn--primary {
    transition:
        transform 0.18s cubic-bezier(0.34, 1.56, 0.64, 1),
        box-shadow 0.22s ease,
        background-color 0.22s ease,
        border-color 0.22s ease,
        color 0.22s ease !important;
}

/* Hover: leve elevación */
.oz-btn-anim:hover,
a.button:hover,
button.button:hover,
.wp-element-button:hover,
.add_to_cart_button:hover,
.single_add_to_cart_button:hover,
.ozc-product-card__btn:hover,
.ozc-product-card__btn--primary:hover,
.ozc-product-card__wa-btn:hover,
.oz-wc-ficha-tecnica__btn:hover,
.hero-btn:hover,
.btn:hover,
.btn--primary:hover {
    transform: translateY(-2px);
}

/* Active/press: vuelve a su sitio con un toque de escala (feedback táctil) */
.oz-btn-anim:active,
a.button:active,
button.button:active,
.wp-element-button:active,
.add_to_cart_button:active,
.single_add_to_cart_button:active,
.ozc-product-card__btn:active,
.ozc-product-card__btn--primary:active,
.ozc-product-card__wa-btn:active,
.oz-wc-ficha-tecnica__btn:active,
.hero-btn:active,
.btn:active,
.btn--primary:active {
    transform: translateY(0) scale(0.97);
}

/* Foco accesible: anillo suave (no quita el outline del navegador por completo) */
.oz-btn-anim:focus-visible,
a.button:focus-visible,
button.button:focus-visible,
.add_to_cart_button:focus-visible,
.single_add_to_cart_button:focus-visible,
.ozc-product-card__btn:focus-visible,
.hero-btn:focus-visible,
.btn:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px rgba(241, 90, 34, 0.28);
}

/* Las flechas de los sliders NO deben "subir" en hover (rompería su centrado
   vertical absoluto): solo permitimos cambio de color/sombra. */
.ozs__nav-btn,
.oz-shop-grid-btn {
    transition:
        background-color 0.2s ease,
        color 0.2s ease,
        box-shadow 0.2s ease !important;
}
.ozs__nav-btn:hover { transform: translateY(-50%) !important; }

/* ───────────────────────────────────────────────────────────
   3) ACCESIBILIDAD — usuarios con "reducir movimiento"
   Sin animaciones de entrada ni microinteracciones de movimiento.
   ─────────────────────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
    .oz-anim-ready .oz-anim,
    .oz-anim-ready .oz-anim.oz-in {
        opacity: 1 !important;
        transform: none !important;
        transition: none !important;
    }
    .oz-btn-anim,
    a.button,
    button.button,
    .add_to_cart_button,
    .single_add_to_cart_button,
    .hero-btn,
    .btn {
        transition: background-color 0.2s ease, color 0.2s ease !important;
    }
    .oz-btn-anim:hover,
    a.button:hover,
    button.button:hover,
    .add_to_cart_button:hover,
    .single_add_to_cart_button:hover,
    .hero-btn:hover,
    .btn:hover { transform: none !important; }
}
