/* =========================================================
   MOVIMIENTO (02/11) — estilos del motor de components/motion.js
   El estado «oculto antes de entrar» existe SOLO con html.has-motion (lo pone motion.js). Sin JavaScript, sin soporte,
   con «reducir movimiento» del sistema o con el interruptor «Reducir animaciones» del pie (html.reduce-motion), todo se
   ve quieto y completo. Al imprimir, también.
   Solo se mueven opacity y las propiedades de transformación sueltas (translate, scale, rotate) más filter en las fotos
   grandes de la compu: nada cambia el tamaño ni el lugar de las cajas (CLS 0). Va en su propia capa, la última.
   ========================================================= */
@layer motion {
  :root {
    --motion-dur: 800ms;                        /* 700–850 ms: el video de referencia está acelerado */
    --motion-ease: cubic-bezier(0.16, 1, 0.3, 1);
    --motion-step: 100ms;                       /* cascada entre hermanos (hasta 6 escalones) */
    --motion-x: 96px;                           /* distancia lateral en la compu */
    --motion-y: 40px;
    --motion-tilt: -2.5deg;
    --motion-steps: 5;                          /* tope de escalones de la cascada (6 escalones: 0 a 5) */
  }

  html.has-motion [data-motion] {
    transition: opacity var(--motion-dur) var(--motion-ease), translate var(--motion-dur) var(--motion-ease),
      scale var(--motion-dur) var(--motion-ease), rotate var(--motion-dur) var(--motion-ease), filter var(--motion-dur) var(--motion-ease);
    transition-delay: calc(min(var(--motion-i, 0), var(--motion-steps)) * var(--motion-step));
  }
  html.has-motion [data-motion]:not(.is-in) { opacity: 0; }
  html.has-motion [data-motion="left"]:not(.is-in) { translate: calc(var(--motion-x) * -1) 0; }
  html.has-motion [data-motion="right"]:not(.is-in) { translate: var(--motion-x) 0; }
  html.has-motion [data-motion="up"]:not(.is-in) { translate: 0 var(--motion-y); }
  html.has-motion [data-motion="zoom"]:not(.is-in) { scale: 0.96; }
  /* «stack»: la foto sube desde abajo y se apoya encima de la otra, corrida (el collage del video). */
  html.has-motion [data-motion="stack"]:not(.is-in) { translate: 0 calc(var(--motion-y) * 1.8); scale: 0.97; }
  /* Desenfoque y giro solo en la compu (pantalla ancha y mouse). */
  @media (min-width: 768px) and (pointer: fine) {
    html.has-motion [data-motion-blur]:not(.is-in) { filter: blur(6px); }
    html.has-motion [data-motion-tilt]:not(.is-in) { rotate: var(--motion-tilt); }
    html.has-motion [data-motion-tilt="right"]:not(.is-in) { rotate: calc(var(--motion-tilt) * -1); }
  }
  html.has-motion [data-motion].is-animating { will-change: translate, opacity; }
  html.has-motion [data-motion].motion-now { transition: none; }

  /* Celular y pantallas con dedo (02/11, pasada móvil): se resigna movimiento a cambio de estabilidad. Sin entradas
     laterales: todo aparece con un fundido y una subida corta (14 px), en 500 ms, con cascadas de 60 ms y hasta 3
     escalones. Sin desenfoque, giros ni parallax (esos solo existen con mouse y pantalla ancha) y sin will-change
     permanente. En las filas que se deslizan con el dedo, las tarjetas solo se funden. */
  @media (max-width: 767px), (pointer: coarse) {
    :root { --motion-dur: 500ms; --motion-step: 60ms; --motion-steps: 2; --motion-y: 14px; }
    html.has-motion :is([data-motion="left"], [data-motion="right"], [data-motion="up"], [data-motion="stack"]):not(.is-in) { translate: 0 var(--motion-y); scale: none; }
    html.has-motion [data-motion="zoom"]:not(.is-in) { scale: none; translate: 0 var(--motion-y); }
    html.has-motion :is([data-scroll-track], .reels__row) > [data-motion]:not(.is-in) { translate: none; }
    html.has-motion [data-motion].is-animating { will-change: auto; }
  }

  /* Las filas de productos que entran con el motor no usan además el subir de base.css. */
  html.has-motion [data-motion-group] > .card[data-motion] { animation: none; }

  /* Etiqueta comercial de la tarjeta: un «pop» chico un instante después de que entra la tarjeta. */
  @media (prefers-reduced-motion: no-preference) {
    html:not(.reduce-motion) .card__badge { animation: badge-pop 200ms var(--motion-ease) 250ms both; }
    html.has-motion .card[data-motion]:not(.is-in) .card__badge { animation: none; opacity: 0; }
    html.has-motion .card[data-motion].is-in .card__badge { animation: badge-pop 200ms var(--motion-ease) calc(var(--motion-i, 0) * var(--motion-step) + 380ms) both; }
  }

  /* «Reducir animaciones» del pie: lo mismo que pide el sistema con «reducir movimiento». */
  html.reduce-motion { scroll-behavior: auto; }
  html.reduce-motion *, html.reduce-motion *::before, html.reduce-motion *::after {
    animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important;
  }
  html.reduce-motion .product-grid > .card { animation: none; }
  html.reduce-motion::view-transition-group(*), html.reduce-motion::view-transition-old(*), html.reduce-motion::view-transition-new(*) { animation: none !important; }

  @media print {
    html.has-motion [data-motion] { opacity: 1 !important; translate: none !important; scale: none !important; rotate: none !important; filter: none !important; }
  }
}
@keyframes badge-pop { from { opacity: 0; scale: 0.9; } to { opacity: 1; scale: 1; } }

/* Botón redondo «Volver arriba» (02/11): aparece después de bajar un poco (motion.js); no tapa el aviso de cookies, el
   botón de WhatsApp ni la barra de compra del celular. */
.to-top { position: fixed; z-index: 53; right: 16px; bottom: calc(16px + var(--cookie-h, 0px) + env(safe-area-inset-bottom)); display: grid; place-items: center;
  width: 46px; height: 46px; border: 1px solid var(--line-strong); border-radius: 50%; background: rgb(255 255 255 / 94%); color: var(--ink);
  box-shadow: 0 10px 24px -14px rgb(29 29 27 / 45%); transition: background-color var(--fast) var(--ease), color var(--fast) var(--ease); }
.to-top .icon { width: 18px; height: 18px; rotate: -90deg; }
.to-top:hover { background: var(--ink); color: #fff; }
body:has(.wa-float) .to-top { bottom: calc(80px + var(--cookie-h, 0px) + env(safe-area-inset-bottom)); }
body:has(.buybar.is-visible) .to-top { display: none; }
@media (max-width: 767px), (pointer: coarse) { .to-top { display: none; } }
.to-top__mark { position: absolute; top: 0; left: 0; width: 1px; height: 140vh; pointer-events: none; }

/* Interruptor del pie: el estado también se ve (además de role="switch" y aria-checked para los lectores de pantalla). */
.motion-toggle[aria-checked="true"]::after { content: " · activado"; }
