/* ==========================================================================
   Versión B: la misma web con más movimiento ligado al scroll.
   Solo se carga en version-b.html. b.js calcula el avance del scroll y lo
   pasa a CSS como variables (--p, --lp, --q...).
   Sin JavaScript o con «reducir movimiento», todo se ve estático y completo:
   las animaciones solo se activan con .is-live / html.motion.
   ========================================================================== */

/* ---------- Barra de progreso de la página ---------- */
.page-progress { position: fixed; top: 0; left: 0; right: 0; height: 3px; z-index: 350; background: var(--accent); transform-origin: left; transform: scaleX(var(--page, 0)); pointer-events: none; }

/* ---------- Portada con recorrido (estado base: estático) ---------- */
.cine { position: relative; background: var(--paper); }
.cine__stage { position: relative; padding-top: calc(var(--header-h) + clamp(32px, 6vw, 80px)); padding-bottom: clamp(56px, 8vw, 96px); }
.cine__night, .cine__tiles, .cine__end, .cine__rail, .cine__hint { display: none; }
.cine__intro .wrap { display: grid; gap: 24px; }
.cine__title { font-size: clamp(2.6rem, 6vw, 5.4rem); font-weight: 750; letter-spacing: -0.04em; line-height: .98; max-width: 13ch; }
.cine__title em { font-style: normal; color: var(--accent); }
.cine__sub { font-size: clamp(1.1rem, 1.6vw, 1.3rem); color: var(--ink-soft); max-width: 44ch; }
.cine .hero__ctas { margin-top: 8px; }
.cine__device { display: flex; justify-content: center; margin-top: 56px; }
.cine__float { position: relative; }
.cine .phone { width: 300px; }
.cine:not(.is-live) .screen[data-on="0"] { opacity: 1; transform: none; }
.cine__copy { width: 100%; max-width: var(--maxw); margin: 48px auto 0; padding-inline: var(--gutter); }
.cine__caps { list-style: none; padding: 0; display: grid; gap: 28px; margin-top: 16px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 240px), 1fr)); }
.cap__n { font-family: var(--f-mono); font-size: .8125rem; color: var(--accent); }
.cap h3 { font-size: clamp(1.35rem, 2vw, 1.7rem); font-weight: 700; margin-top: 8px; }
.cap p { color: var(--ink-soft); margin-top: 8px; }
.cap .cap__note { font-size: .9375rem; border-left: 2px solid var(--line); padding-left: 12px; }
.cine__notif { display: none; }

/* Pantallas del teléfono */
.cine .screen > .sw-wa { position: absolute; left: 16px; right: 16px; bottom: 18px; margin: 0; box-shadow: 0 10px 24px -10px rgba(16, 60, 38, .6); transition: transform .3s var(--ease); }
.cine .scr-inner { display: flex; flex-direction: column; gap: 10px; }
.sw-map { display: flex; gap: 10px; align-items: center; padding: 10px; border-radius: 14px; background: #fff; border: 1px solid #E2E3DC; font-size: 12px; margin-bottom: 70px; }
.sw-map i { width: 48px; height: 48px; flex: none; border-radius: 10px; background: linear-gradient(90deg, transparent 46%, #fff 46% 54%, transparent 54%), linear-gradient(0deg, transparent 40%, #fff 40% 50%, transparent 50%), #CBD8C6; position: relative; }
.sw-map i::after { content: ""; position: absolute; left: 50%; top: 42%; width: 12px; height: 12px; margin: -6px; border-radius: 50% 50% 50% 0; transform: rotate(-45deg); background: #2F6B4F; }
.tap { position: absolute; inset: 0; border-radius: inherit; pointer-events: none; }
.typing { display: inline-flex; gap: 4px; align-self: flex-start; padding: 12px 14px; border-radius: 16px; border-bottom-left-radius: 5px; background: #fff; border: 1px solid #E2E3DC; }
.typing i { width: 6px; height: 6px; border-radius: 50%; background: #9AA0AA; animation: dot 1s infinite ease-in-out; }
.typing i:nth-child(2) { animation-delay: .15s; }
.typing i:nth-child(3) { animation-delay: .3s; }
@keyframes dot { 0%, 60%, 100% { transform: none; opacity: .5; } 30% { transform: translateY(-3px); opacity: 1; } }
.res-count b + b { display: none; }
.cine .tick svg { width: 22px; height: 22px; fill: none; stroke: #fff; stroke-width: 2.6; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- Portada con recorrido: modo animado ---------- */
.cine.is-live { height: 760vh; }
.is-live .cine__stage { position: sticky; top: 0; height: 100vh; height: 100dvh; overflow: hidden; padding: 0; }
.is-live .cine__night { display: block; position: absolute; inset: 0; background: var(--night); opacity: var(--lp, 0); }

/* Negocios flotando alrededor del titular */
.is-live .cine__tiles { display: block; position: absolute; inset: 0; pointer-events: none; }
.tile {
  position: absolute; left: calc(var(--x) * 1%); top: calc(var(--y) * 1%);
  transform: translate(-50%, -50%) translate(calc(var(--dx) * var(--lp, 0) * 1px), calc(var(--dy) * var(--lp, 0) * 1px))
    translate(calc(var(--mx, 0) * (10px + var(--f) * 4px)), calc(var(--my, 0) * (10px + var(--f) * 4px))) scale(calc(1 + var(--lp, 0) * .2));
  transition: transform .5s cubic-bezier(.22, 1, .36, 1);
  opacity: calc(1 - var(--lp, 0) * 1.3);
  display: inline-flex; align-items: center; gap: .55em; white-space: nowrap;
  padding: .6em 1.05em; border-radius: 999px; background: var(--surface); border: 1px solid var(--line);
  font-weight: 600; font-size: .95rem;
  box-shadow: 0 16px 36px -22px color-mix(in srgb, var(--ink) 50%, transparent);
  animation: bob 6s ease-in-out infinite, tileIn .9s var(--ease) both;
  animation-delay: calc(var(--f) * -.8s), calc(var(--f) * 70ms + 300ms);
}
.tile::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); }
.tile:nth-child(3n+2)::before { background: var(--ok); }
.tile:nth-child(3n)::before { background: var(--warn); }
@keyframes bob { 50% { translate: 0 -10px; } }
@keyframes tileIn { from { opacity: 0; scale: .8; } }

.is-live .cine__intro { position: absolute; inset: 0; display: flex; align-items: center; padding-top: var(--header-h); opacity: calc(1 - var(--lp, 0)); transform: translateY(calc(var(--lp, 0) * -80px)) scale(calc(1 - var(--lp, 0) * .05)); transform-origin: left center; }
.is-live .cine__intro .wrap > * { max-width: 620px; }
.is-live .cine__intro.is-past { visibility: hidden; }
.is-live .cine__hint { display: flex; align-items: center; gap: 12px; font-family: var(--f-mono); font-size: .75rem; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-soft); margin-top: 12px; }
.cine__hint span { width: 2px; height: 34px; border-radius: 2px; background: var(--line); position: relative; overflow: hidden; }
.cine__hint span::after { content: ""; position: absolute; left: 0; right: 0; top: 0; height: 40%; background: var(--accent); animation: hint 1.8s var(--ease) infinite; }
@keyframes hint { from { transform: translateY(-100%); } to { transform: translateY(260%); } }

/* Palabras del titular */
.cine__title .w { display: inline-block; }
html.motion .cine__title .w { animation: wordIn 1s var(--ease) both; animation-delay: calc(var(--wi) * 55ms + 120ms); }
@keyframes wordIn { from { opacity: 0; transform: translateY(.45em) rotate(3deg); filter: blur(8px); } }
html.motion .is-live .cine__sub, html.motion .is-live .cine__intro .hero__ctas, html.motion .is-live .cine__hint { animation: rise .9s var(--ease) both; animation-delay: .7s; }
html.motion .is-live .cine__intro .hero__ctas { animation-delay: .82s; }
html.motion .is-live .cine__hint { animation-delay: 1.1s; }

/* Teléfono: entra desde abajo, se inclina con el scroll y se aparta al final */
.is-live .cine__device {
  position: absolute; left: 50%; top: calc(50% + var(--header-h) / 2); margin: 0; display: block;
  --px: clamp(160px, 20vw, 330px);
  transform: translate(-50%, -50%) translate(var(--px), calc((1 - var(--enter, 0)) * 85vh)) rotate(calc((1 - var(--enter, 0)) * -14deg));
  opacity: min(1, calc(var(--enter, 0) * 3));
  pointer-events: none;
}
.is-live .cine__float { transform: translateX(calc(var(--exit, 0) * 8vw)) scale(calc(1 - var(--exit, 0) * .12)); opacity: calc(1 - var(--exit, 0) * .7); }
.is-live .phone { zoom: var(--pz, 1); transform: perspective(1400px) rotateY(calc((var(--p, 0) - .5) * -18deg)) rotateX(calc((var(--p, 0) - .5) * 6deg)); box-shadow: 0 60px 90px -50px rgba(40, 52, 44, .45); }
@media (max-height: 860px) { .is-live { --pz: .9; } }
@media (max-height: 760px) { .is-live { --pz: .8; } }
@media (max-height: 660px) { .is-live { --pz: .68; } }

/* Contenido del teléfono ligado al scroll */
.is-live .screen { opacity: 0; }
.is-live .screen.is-on { opacity: 1; transform: none; }
.is-live .scr-inner { transform: translateY(calc(var(--lp, 0) * -170px)); }
.is-live .cine__wa.is-on { transform: scale(1.04); }
.is-live .tap { box-shadow: 0 0 0 calc(var(--lp, 0) * 16px) rgba(31, 122, 77, calc(.55 - var(--lp, 0) * .55)); }
.is-live .bubble:not(.is-on), .is-live .typing:not(.is-on) { display: none; }
.is-live .bubble.is-on, .is-live .typing.is-on { animation: pop .45s var(--ease) both; }
.is-live .bubble--me.is-on { transform-origin: right bottom; }
.is-live .bubble--them.is-on { transform-origin: left bottom; }
@keyframes pop { from { opacity: 0; transform: translateY(10px) scale(.92); } }
.is-live .res-days span, .is-live .res-times span { transition: background-color .3s, color .3s, border-color .3s, transform .3s var(--ease); }
.is-live .res-days .sel, .is-live .res-times .sel { transform: scale(1.06); }
.is-live .res-count b { display: none; }
.is-live .res-count b.is-on { display: inline; animation: pop .35s var(--ease); }
.is-live .res-cta { transition: transform .2s var(--ease), background-color .2s; }
.is-live .res-cta.is-pressed { transform: scale(.94); background: #245640; }
.is-live .screen.is-on .ok-card { animation: pop .6s var(--ease) both; }
.is-live .tick__path { stroke-dasharray: 24; stroke-dashoffset: calc((1 - var(--lp, 0)) * 24); }

/* Aviso que le llega al negocio */
.is-live .cine__notif {
  display: flex; gap: 12px; align-items: center; position: absolute; right: calc(100% - 40px); bottom: 16%;
  width: 270px; padding: 14px 16px; border-radius: var(--r-panel);
  background: var(--surface); color: var(--ink); border: 1px solid var(--line);
  box-shadow: 0 24px 50px -26px rgba(40, 52, 44, .4);
  opacity: var(--lp, 0); transform: translateX(calc((1 - var(--lp, 0)) * 60px)) scale(calc(.9 + var(--lp, 0) * .1));
}
.cine__notif b { display: block; font-family: var(--f-display); font-size: 1rem; letter-spacing: -.01em; }
.cine__notif span { font-size: .875rem; color: var(--ink-soft); }
.cine__notif-icon { width: 38px; height: 38px; flex: none; border-radius: 10px; display: grid; place-items: center; background: var(--accent); color: var(--accent-ink); }

/* Textos de cada paso */
.is-live .cine__copy { position: absolute; inset: 0; margin: 0; max-width: none; padding: 0; pointer-events: none; color: var(--night-ink); }
.is-live .cine__copy > * { position: absolute; left: max(var(--gutter), calc((100vw - var(--maxw)) / 2 + var(--gutter))); width: min(460px, 40vw); }
.is-live .cine__label { top: calc(var(--header-h) + 40px); color: var(--night-soft); }
.is-live .cine__label, .is-live .cine__rail { opacity: clamp(0, min(calc((var(--p, 0) - .15) * 20), calc((.93 - var(--p, 0)) * 20)), 1); }
.is-live .cine__caps { display: block; top: 50%; margin: 0; }
.is-live .cap {
  position: absolute; left: 0; right: 0; top: 0;
  opacity: clamp(0, min(calc(var(--lp, 0) * 7), calc((1 - var(--lp, 0)) * 7)), 1);
  transform: translateY(calc(-50% + (.5 - var(--lp, 0)) * 70px));
}
.is-live .cap__n { font-size: clamp(3.5rem, 7vw, 6rem); font-family: var(--f-display); font-weight: 800; line-height: 1; letter-spacing: -.05em; color: transparent; -webkit-text-stroke: 1.5px var(--accent); display: block; }
.is-live .cap h3 { font-size: clamp(1.9rem, 3.4vw, 3rem); margin-top: 18px; }
.is-live .cap p { color: var(--night-soft); font-size: 1.0625rem; }
.is-live .cap .cap__note { border-color: var(--night-line); font-size: .9375rem; }
.is-live .cine__rail { display: flex; gap: 8px; top: calc(var(--header-h) + 72px); width: min(320px, 40vw); }
.cine__rail span { flex: 1; height: 3px; border-radius: 3px; background: var(--night-line); position: relative; overflow: hidden; }
.cine__rail span::after { content: ""; position: absolute; inset: 0; background: var(--accent); transform-origin: left; transform: scaleX(var(--lp, 0)); }

/* Cierre del recorrido */
.is-live .cine__end {
  display: grid; gap: 28px; position: absolute; top: 50%;
  left: max(var(--gutter), calc((100vw - var(--maxw)) / 2 + var(--gutter))); width: min(560px, 46vw);
  color: var(--night-ink); opacity: var(--lp, 0); transform: translateY(calc(-50% + (1 - var(--lp, 0)) * 50px));
}
.is-live .cine__end.is-before { visibility: hidden; }
.cine__end-title { font-family: var(--f-display); font-size: clamp(2.4rem, 5vw, 4.4rem); font-weight: 750; letter-spacing: -.035em; line-height: 1; text-wrap: balance; }
.cine__ghost { color: var(--night-ink); border-color: color-mix(in srgb, var(--night-ink) 35%, transparent); }
.cine__ghost:hover { border-color: var(--night-ink); }

/* Móvil: teléfono arriba, texto abajo */
@media (max-width: 860px) {
  .is-live .cine__tiles { display: none; }
  .is-live .cine__intro { align-items: center; }
  .is-live .cine__device { top: calc(var(--header-h) + 12px); --px: 0px; transform: translate(-50%, 0) translateY(calc((1 - var(--enter, 0)) * 90vh)) rotate(calc((1 - var(--enter, 0)) * -10deg)); }
  .is-live { --pz: .64; }
  .is-live .cine__float { transform: scale(calc(1 - var(--exit, 0) * .1)); opacity: calc(1 - var(--exit, 0) * .85); }
  .is-live .cine__copy > * { left: var(--gutter); right: var(--gutter); width: auto; }
  .is-live .cine__label { top: auto; bottom: calc(26px + env(safe-area-inset-bottom, 0px)); }
  .is-live .cine__caps { top: auto; bottom: calc(76px + env(safe-area-inset-bottom, 0px)); }
  .is-live .cap { top: auto; bottom: 0; transform: translateY(calc((.5 - var(--lp, 0)) * 40px)); }
  .is-live .cap__n { font-size: 2.4rem; }
  .is-live .cap h3 { font-size: 1.55rem; margin-top: 6px; }
  .is-live .cap p { font-size: .975rem; margin-top: 6px; }
  .is-live .cine__rail { bottom: auto; top: calc(var(--header-h) + 6px); left: 50%; right: auto; width: 160px; transform: translateX(-50%); z-index: 3; }
  .is-live .cine__label { display: none; }
  .is-live .cine__notif { right: auto; left: 50%; bottom: -36px; width: 260px; transform: translateX(-50%) translateY(calc((1 - var(--lp, 0)) * 40px)); }
  .is-live .cine__end { left: var(--gutter); right: var(--gutter); width: auto; top: auto; bottom: calc(76px + env(safe-area-inset-bottom, 0px)); transform: translateY(calc((1 - var(--lp, 0)) * 40px)); }
  .is-live .cine__end .hero__ctas { flex-direction: column; align-items: stretch; }
  .is-live .cine__end .btn { justify-content: center; }
}
@media (max-width: 860px) and (max-height: 760px) { .is-live { --pz: .54; } }
@media (max-width: 860px) and (max-height: 660px) { .is-live { --pz: .44; } }

/* La sección siguiente sube por encima del recorrido */
.is-b #problemas { position: relative; z-index: 2; background: var(--paper); border-radius: 32px 32px 0 0; margin-top: -32px; }

/* ---------- Problemas: frase que se ilumina y tarjetas que se apilan ---------- */
.scrub-words .sw { transition: opacity .15s linear; }
html.motion .scrub-words .sw { opacity: clamp(.16, calc(var(--q, 0) * var(--n) - var(--i) + .2), 1); }
html.motion .is-b .problems__list { grid-template-columns: minmax(0, 1fr); max-width: 860px; margin-inline: auto; gap: 28px; }
html.motion .is-b .problem {
  position: sticky; top: calc(var(--header-h) + 32px + var(--k, 0) * 20px);
  padding: clamp(26px, 4vw, 44px); min-height: 220px; align-content: center;
  border: 1px solid var(--line); border-radius: 22px; background: var(--surface);
  box-shadow: 0 30px 60px -40px color-mix(in srgb, var(--ink) 45%, transparent);
  transform: scale(calc(1 - var(--cover, 0) * .06)); transform-origin: center top;
  filter: brightness(calc(1 - var(--cover, 0) * .06));
}
html.motion .is-b .problem h3 { font-size: clamp(1.5rem, 2.6vw, 2.2rem); }
html.motion .is-b .problem .icon { width: 34px; height: 34px; }

/* ---------- Cinta de tipos de negocio ---------- */
.marquee { padding-block: clamp(48px, 7vw, 96px); overflow: hidden; display: grid; gap: 10px; }
.marquee__row { display: flex; width: max-content; will-change: transform; }
.marquee__set { display: flex; flex: none; }
.marquee__set span { font-family: var(--f-display); font-weight: 750; font-size: clamp(2.6rem, 7vw, 6rem); letter-spacing: -.04em; line-height: 1.1; white-space: nowrap; padding-right: .5em; display: inline-flex; align-items: center; gap: .5em; }
.marquee__set span::after { content: ""; width: .28em; height: .28em; border-radius: 50%; background: var(--accent); }
.marquee__row--out span { color: transparent; -webkit-text-stroke: 1.5px color-mix(in srgb, var(--ink) 40%, transparent); }
.marquee__row--out span::after { background: color-mix(in srgb, var(--ink) 30%, transparent); }
.marquee__label { display: flex; justify-content: center; margin-bottom: 14px; }

/* ---------- Servicios: desplazamiento horizontal en escritorio ---------- */
html.hs-on .hs__sticky { position: sticky; top: var(--header-h); height: calc(100vh - var(--header-h)); height: calc(100dvh - var(--header-h)); display: flex; flex-direction: column; justify-content: center; gap: 36px; }
html.hs-on .is-b #servicios { overflow-x: clip; }
html.hs-on .hs .services__grid { margin: 0; display: flex; gap: 20px; width: max-content; transform: translate3d(var(--tx, 0px), 0, 0); will-change: transform; }
html.hs-on .hs .svc { width: min(460px, 36vw); min-height: min(300px, 40vh); flex: none; }
html.hs-on .hs .svc:nth-child(1) { width: min(560px, 44vw); }
.hs__count { font-family: var(--f-mono); font-size: .8125rem; color: var(--ink-soft); display: none; }
html.hs-on .hs__count { display: block; }

/* ---------- Titulares que suben palabra a palabra ---------- */
.hw { display: inline-block; overflow: clip; vertical-align: top; padding-bottom: .1em; margin-bottom: -.1em; }
.hw > span { display: inline-block; }
html.motion .reveal .hw > span { transform: translateY(105%); transition: transform 1s var(--ease); transition-delay: calc(var(--wi) * 45ms + 60ms); }
html.motion .reveal.is-in .hw > span { transform: none; }

/* ---------- Luz que sigue al puntero en tarjetas ---------- */
.spot { position: relative; isolation: isolate; }
.spot::after { content: ""; position: absolute; inset: 0; border-radius: inherit; pointer-events: none; z-index: -1; opacity: 0; transition: opacity .3s; background: radial-gradient(420px circle at var(--mx, 50%) var(--my, 50%), color-mix(in srgb, var(--accent) 14%, transparent), transparent 62%); }
.spot:hover::after { opacity: 1; }

/* ---------- Cómo trabajamos: pasos que entran en cadena ---------- */
html.motion .is-b .step { opacity: 0; transform: translateY(24px); transition: opacity .7s var(--ease), transform .7s var(--ease); transition-delay: calc(var(--si, 0) * 120ms); }
html.motion .is-b .step.is-in { opacity: 1; transform: none; }

/* ---------- Marca gigante en el pie ---------- */
.bigmark { overflow: hidden; padding-inline: var(--gutter); margin-top: 32px; max-width: 1200px; margin-inline: auto; }
.bigmark span { display: block; font-family: var(--f-display); font-weight: 800; letter-spacing: -.06em; line-height: .8; font-size: clamp(2.5rem, 8vw, 6.5rem); color: var(--accent); white-space: nowrap; }
html.motion .bigmark span { transform: translateY(calc((1 - var(--q, 1)) * 60%)); opacity: calc(.2 + var(--q, 1) * .8); }



/* Cabecera oscura mientras el recorrido está sobre fondo oscuro */
html.on-night .header.is-scrolled { background: color-mix(in srgb, var(--night) 82%, transparent); box-shadow: 0 1px 0 var(--night-line); }
html.on-night .header .brand, html.on-night .header .nav a:not(.btn) { color: var(--night-ink); }
html.on-night .header .nav a:not(.btn):hover { background: color-mix(in srgb, var(--night-ink) 10%, transparent); }
html.on-night .header .btn--primary[aria-disabled="true"] { color: var(--night-soft); border-color: var(--night-line); }
html.on-night .menu-btn { background: var(--night-2); border-color: var(--night-line); color: var(--night-ink); }
@media (max-width: 960px) { html.on-night .header .nav a:not(.btn) { color: var(--ink); } }

/* ---------- Más animaciones ---------- */
/* Botones magnéticos: vuelven a su sitio con suavidad */
html.motion .btn--primary, html.motion .theme-btn { transition: translate .35s cubic-bezier(.22, 1, .36, 1), transform .18s var(--ease), background-color .2s, color .2s, border-color .2s; }

/* Opciones de proyecto en cadena */
html.motion .is-b #plans > * { opacity: 0; translate: 0 36px; transition: opacity .8s var(--ease), translate .8s var(--ease); transition-delay: calc(var(--pi, 0) * 130ms); }
html.motion .is-b #plans.is-in > * { opacity: 1; translate: 0 0; }

/* Ejemplos: suavizar el movimiento de profundidad */
html.motion .is-b .demo { transition: opacity .8s var(--ease), transform .8s var(--ease), translate .2s linear; }

/* Preguntas frecuentes: se abren deslizando (navegadores compatibles) */
html.motion .is-b { interpolate-size: allow-keywords; }
html.motion .is-b .faq__list details::details-content { block-size: 0; overflow: clip; opacity: 0; transition: block-size .45s var(--ease), opacity .35s, content-visibility .45s allow-discrete; }
html.motion .is-b .faq__list details[open]::details-content { block-size: auto; opacity: 1; }
html.motion .is-b .faq__list summary { transition: color .2s, padding-left .3s var(--ease); }
html.motion .is-b .faq__list summary:hover { color: var(--accent); padding-left: 6px; }

/* Campos del formulario que se iluminan al escribir */
html.motion .is-b .field input, html.motion .is-b .field textarea { transition: border-color .2s, box-shadow .25s var(--ease); }
html.motion .is-b .field input:focus, html.motion .is-b .field textarea:focus { box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 18%, transparent); }

@media (prefers-reduced-motion: reduce) {
  .tile, .typing i, .cine__hint span::after { animation: none; }
}
