/* =========================================================
   FLEXTUC — motion.css
   Capa de animaciones. Solo transform/opacity (baratas en móvil).
   Todo vive dentro de prefers-reduced-motion: no-preference.
   Si este archivo no carga, el sitio queda exactamente como antes.
   ========================================================= */

:root {
    --mo-ease: cubic-bezier(.2, .7, .2, 1);
    --mo-ease-out: cubic-bezier(.16, 1, .3, 1);
}

@media (prefers-reduced-motion: no-preference) {

    /* ---------- 1. Transición suave entre páginas (Chrome/Edge/Safari recientes) ---------- */
    @view-transition { navigation: auto; }
    ::view-transition-old(root) { animation: mo-fade-out .16s ease both; }
    ::view-transition-new(root) { animation: mo-fade-in .26s ease both; }
    @keyframes mo-fade-out { to { opacity: 0; } }
    @keyframes mo-fade-in  { from { opacity: 0; } }

    /* ---------- 2. Reveal al hacer scroll (las clases las pone motion.js) ---------- */
    html.mo .mo-reveal {
        opacity: 0;
        transform: translate3d(0, 22px, 0);
    }
    html.mo .mo-reveal.mo-in {
        opacity: 1;
        transform: none;
        transition:
            opacity .7s var(--mo-ease-out) var(--mo-delay, 0ms),
            transform .7s var(--mo-ease-out) var(--mo-delay, 0ms);
    }
    html.mo .mo-reveal.mo-fade { transform: none; }

    /* ---------- 3. Slider de la home: Ken Burns + texto escalonado ---------- */
    .slider-slide.active img {
        animation: mo-kenburns 9s ease-out both;
    }
    @keyframes mo-kenburns {
        from { transform: scale(1.09); }
        to   { transform: scale(1); }
    }
    .slider-slide.active .slider-overlay > * {
        animation: mo-rise .8s var(--mo-ease-out) both;
    }
    .slider-slide.active .slider-overlay > :nth-child(1) { animation-delay: .15s; }
    .slider-slide.active .slider-overlay > :nth-child(2) { animation-delay: .30s; }
    .slider-slide.active .slider-overlay > :nth-child(3) { animation-delay: .45s; }
    @keyframes mo-rise {
        from { opacity: 0; transform: translate3d(0, 26px, 0); }
        to   { opacity: 1; transform: none; }
    }

    /* Hero de reemplazo (cuando no hay slider cargado) */
    .hero h1, .hero p, .hero .hero-actions {
        animation: mo-rise .8s var(--mo-ease-out) both;
    }
    .hero p { animation-delay: .12s; }
    .hero .hero-actions { animation-delay: .26s; }

    /* ---------- 4. Botones: respuesta al toque/click ---------- */
    .btn { transition: transform .15s var(--mo-ease), background-color .2s, color .2s, box-shadow .2s, opacity .2s; }
    .btn:active { transform: scale(.97); }

    /* Agregar al carrito: estados */
    .add-to-cart.mo-loading { opacity: .75; pointer-events: none; }
    .add-to-cart.mo-done {
        background: #16a34a !important;
        border-color: #16a34a !important;
        color: #fff !important;
        animation: mo-pop .45s var(--mo-ease-out);
    }
    @keyframes mo-pop {
        0%   { transform: scale(.94); }
        55%  { transform: scale(1.04); }
        100% { transform: scale(1); }
    }

    /* Punto que vuela hacia el carrito */
    .mo-fly {
        position: fixed;
        z-index: 10000;
        left: 0; top: 0;
        width: 46px; height: 46px;
        border-radius: 50%;
        background-color: var(--primary, #be1e5b);
        background-size: cover;
        background-position: center;
        box-shadow: 0 6px 18px rgba(0, 0, 0, .28);
        pointer-events: none;
        will-change: transform, opacity;
    }

    /* Contador del carrito "late" al cambiar */
    #cartCount.mo-bump { animation: mo-bump .5s var(--mo-ease-out); }
    @keyframes mo-bump {
        0%   { transform: scale(1); }
        35%  { transform: scale(1.6); }
        100% { transform: scale(1); }
    }

    /* Toast más fluido */
    .toast { animation: mo-toast-in .45s var(--mo-ease-out); }
    @keyframes mo-toast-in {
        from { opacity: 0; transform: translate3d(24px, -8px, 0) scale(.96); }
        to   { opacity: 1; transform: none; }
    }

    /* ---------- 5. Ficha de producto: zoom en la imagen principal ---------- */
    @media (hover: hover) and (pointer: fine) {
        .gallery-main.mo-zoomable { cursor: zoom-in; }
        .gallery-main.mo-zoomable #galeriaPrincipal {
            transition: transform .35s var(--mo-ease-out);
            will-change: transform;
        }
        .gallery-main.mo-zoomable.mo-zooming #galeriaPrincipal { transform: scale(1.8); }
    }

    /* Miniaturas */
    .gallery-thumbs .thumb { transition: opacity .2s, border-color .2s, transform .2s var(--mo-ease); }
    .gallery-thumbs .thumb:hover { transform: translateY(-2px); }
}

/* =========================================================
   v2 — HOME: hero vivo + detalles
   ========================================================= */
@media (prefers-reduced-motion: no-preference) {

    /* ---------- Hero: luces ambientales que se desplazan lento ---------- */
    .hero { position: relative; overflow: hidden; isolation: isolate; }
    .hero .container { position: relative; z-index: 2; }

    .hero::before,
    .hero::after {
        content: "";
        position: absolute;
        z-index: 0;
        border-radius: 50%;
        pointer-events: none;
        will-change: transform;
        transition: translate .9s var(--mo-ease-out);
        translate: calc(var(--mx, 0) * 26px) calc(var(--my, 0) * 18px);
    }
    /* luz dorada, arriba a la izquierda */
    .hero::before {
        width: 620px; height: 620px;
        left: -180px; top: -300px;
        background: radial-gradient(circle at center, rgba(224, 170, 70, .30), rgba(224, 170, 70, 0) 66%);
        animation: mo-drift-a 17s ease-in-out infinite alternate;
    }
    /* luz rosa de marca, abajo a la derecha */
    .hero::after {
        width: 560px; height: 560px;
        right: -160px; bottom: -330px;
        background: radial-gradient(circle at center, rgba(197, 23, 83, .34), rgba(197, 23, 83, 0) 66%);
        animation: mo-drift-b 21s ease-in-out infinite alternate;
        translate: calc(var(--mx, 0) * -34px) calc(var(--my, 0) * -22px);
    }
    @keyframes mo-drift-a {
        from { transform: translate3d(0, 0, 0) scale(1); }
        to   { transform: translate3d(120px, 50px, 0) scale(1.18); }
    }
    @keyframes mo-drift-b {
        from { transform: translate3d(0, 0, 0) scale(1.1); }
        to   { transform: translate3d(-130px, -40px, 0) scale(.92); }
    }

    /* ---------- Partículas doradas (las crea motion.js) ---------- */
    .mo-particles {
        position: absolute; inset: 0;
        z-index: 1;
        overflow: hidden;
        pointer-events: none;
    }
    .mo-particles i {
        position: absolute;
        bottom: -12px;
        width: var(--s, 3px); height: var(--s, 3px);
        border-radius: 50%;
        background: radial-gradient(circle, #fff2c9 0%, #e9b955 60%, rgba(233, 185, 85, 0) 100%);
        opacity: 0;
        will-change: transform, opacity;
        animation: mo-float var(--d, 12s) linear var(--dl, 0s) infinite;
    }
    @keyframes mo-float {
        0%   { transform: translate3d(0, 0, 0) scale(.6); opacity: 0; }
        12%  { opacity: .85; }
        85%  { opacity: .55; }
        100% { transform: translate3d(var(--x, 20px), calc(var(--h, 300px) * -1), 0) scale(1.15); opacity: 0; }
    }

    /* Se pausa todo cuando el hero no está en pantalla (ahorra batería) */
    .hero.mo-paused::before,
    .hero.mo-paused::after,
    .hero.mo-paused .mo-particles i,
    .hero.mo-paused .btn-gold::after { animation-play-state: paused; }

    /* ---------- Título palabra por palabra ---------- */
    .hero h1.mo-split { animation: none; }
    .hero h1 .mo-w {
        display: inline-block;
        opacity: 0;
        transform: translate3d(0, .55em, 0);
        animation: mo-word .6s var(--mo-ease-out) forwards;
        animation-delay: calc(var(--i, 0) * 45ms + 40ms);
    }
    @keyframes mo-word {
        from { opacity: 0; transform: translate3d(0, .55em, 0); }
        to   { opacity: 1; transform: none; }
    }

    /* ---------- Botón principal: brillo que barre cada tanto ---------- */
    .hero .btn-gold { position: relative; overflow: hidden; isolation: isolate; }
    .hero .btn-gold::after {
        content: "";
        position: absolute;
        top: 0; bottom: 0; left: 0;
        width: 45%;
        background: linear-gradient(100deg, rgba(255, 255, 255, 0) 0%, rgba(255, 255, 255, .55) 50%, rgba(255, 255, 255, 0) 100%);
        transform: translateX(-130%) skewX(-18deg);
        animation: mo-shine 5.5s ease-in-out 1.6s infinite;
        pointer-events: none;
    }
    @keyframes mo-shine {
        0%, 62% { transform: translateX(-130%) skewX(-18deg); }
        100%    { transform: translateX(330%) skewX(-18deg); }
    }

    /* ---------- Franja de marcas: bordes difuminados ---------- */
    .brands-slider {
        -webkit-mask-image: linear-gradient(90deg, transparent 0, #000 9%, #000 91%, transparent 100%);
                mask-image: linear-gradient(90deg, transparent 0, #000 9%, #000 91%, transparent 100%);
    }
}

/* En pantallas chicas: orbes más chicos para no tapar texto */
@media (max-width: 640px) and (prefers-reduced-motion: no-preference) {
    .hero::before { width: 380px; height: 380px; left: -140px; top: -190px; }
    .hero::after  { width: 360px; height: 360px; right: -140px; bottom: -200px; }
}
