/* Kit de movimiento de Cas Web Design · v1 (2026-10-27)
   Los estados iniciales solo existen con html.mov, que pone el script del <head> (y que se quita solo si el kit
   no carga en 2.5 s o si el visitante pide menos movimiento). Sin JS, todo se ve completo.
   Solo se animan transform y opacity. */

@view-transition { navigation: auto; }
::view-transition-old(root), ::view-transition-new(root) { animation-duration: .32s; }

:root { --mov-dur: .7s; --mov-ease: cubic-bezier(.2, .75, .2, 1); --mov-paso: 70ms; }

/* 1. Entrada del hero: líneas del titular, foto que se asienta y CTA al final */
[data-mov~="hero"] .mov-linea { display: block; }
.mov [data-mov~="hero"] .mov-linea { opacity: .01; transform: translateY(.55em); }
.mov [data-mov~="hero"] [data-mov-cta] { opacity: .01; transform: translateY(14px); }
.mov [data-mov~="hero"] [data-mov-foto] { transform: scale(1.06); }
.mov [data-mov~="hero"].mov-in .mov-linea,
.mov [data-mov~="hero"].mov-in [data-mov-cta],
.mov [data-mov~="hero"].mov-in [data-mov-foto] {
  opacity: 1; transform: none;
  transition: opacity .55s var(--mov-ease), transform .9s var(--mov-ease);
  transition-delay: calc(var(--i, 0) * 90ms);
}

/* 2. Revelar al hacer scroll (y escalonado en tarjetas) */
.mov [data-mov~="revelar"], .mov [data-mov~="escalonado"] > * {
  opacity: 0; transform: translateY(26px);
  transition: opacity var(--mov-dur) var(--mov-ease), transform var(--mov-dur) var(--mov-ease);
  transition-delay: calc(var(--i, 0) * var(--mov-paso));
}
.mov [data-mov~="revelar"].mov-in, .mov [data-mov~="escalonado"].mov-in > * { opacity: 1; transform: none; }

/* 3. Imagen con parallax suave: CSS nativo donde se puede; GSAP ScrollTrigger donde no */
[data-mov~="parallax"] { overflow: hidden; }
[data-mov~="parallax"] > img, [data-mov~="parallax"] > picture > img { transform: scale(1.12); will-change: transform; }
@supports (animation-timeline: view()) {
  .mov [data-mov~="parallax"] > img, .mov [data-mov~="parallax"] > picture > img {
    animation: mov-parallax linear both; animation-timeline: view(); animation-range: cover;
  }
}
@keyframes mov-parallax { from { transform: scale(1.12) translateY(-5%); } to { transform: scale(1.12) translateY(5%); } }

/* 4. Cinta que se mueve sola; se pausa con el dedo, el ratón o el foco */
[data-mov~="cinta"] { overflow-x: auto; scrollbar-width: none; }
.mov [data-mov~="cinta"] { overflow: hidden; }
[data-mov~="cinta"] > .mov-pista { display: flex; width: max-content; gap: var(--cinta-gap, 16px); }
.mov [data-mov~="cinta"] > .mov-pista { animation: mov-cinta var(--cinta-dur, 40s) linear infinite; }
.mov [data-mov~="cinta"]:hover > .mov-pista, .mov [data-mov~="cinta"]:focus-within > .mov-pista,
.mov [data-mov~="cinta"].mov-pausa > .mov-pista { animation-play-state: paused; }
@keyframes mov-cinta { to { transform: translateX(calc(-50% - var(--cinta-gap, 16px) / 2)); } }

/* 5. Pestañas o filtros con transición */
[data-mov~="pestanas"] [role="tabpanel"][hidden] { display: none; }
.mov [data-mov~="pestanas"] [role="tabpanel"].mov-entra { animation: mov-panel .4s var(--mov-ease) both; }
@keyframes mov-panel { from { opacity: 0; transform: translateY(10px); } }

/* 6. Antes y después con deslizador */
[data-mov~="antes-despues"] { position: relative; overflow: hidden; touch-action: pan-y; }
[data-mov~="antes-despues"] .mov-despues { position: absolute; inset: 0; clip-path: inset(0 0 0 var(--corte, 50%)); }
[data-mov~="antes-despues"] input[type="range"] { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: ew-resize; margin: 0; }
[data-mov~="antes-despues"] .mov-linea-corte { position: absolute; top: 0; bottom: 0; left: var(--corte, 50%); width: 3px; background: #fff; transform: translateX(-50%); pointer-events: none; }

/* 7. Botón de WhatsApp fijo que aparece después del hero */
[data-mov~="wa-fijo"] { position: fixed; right: 16px; bottom: calc(16px + env(safe-area-inset-bottom)); z-index: 60; }
.mov [data-mov~="wa-fijo"] { opacity: 0; transform: translateY(24px) scale(.9); pointer-events: none; transition: opacity .35s var(--mov-ease), transform .35s var(--mov-ease); }
.mov [data-mov~="wa-fijo"].mov-in { opacity: 1; transform: none; pointer-events: auto; }

/* 8. Contadores: solo números reales; el número final ya está en el HTML */
[data-mov~="contador"] { font-variant-numeric: tabular-nums; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
  [data-mov~="parallax"] > img, [data-mov~="parallax"] > picture > img { transform: none; }
}
