/* ============================================================
   Motion — animaciones compartidas del sitio y de las demos.
   Solo anima transform, opacity y clip-path (lo más ligero para el navegador).
   Sin JavaScript todo se ve; con "reducir movimiento" no se anima nada.
   ============================================================ */
:root { --ease-out: cubic-bezier(0.16, 1, 0.3, 1); --ease-soft: cubic-bezier(0.22, 0.61, 0.36, 1); }

/* Transición suave entre páginas (navegadores compatibles) */
@view-transition { navigation: auto; }
::view-transition-old(root), ::view-transition-new(root) { animation-duration: 0.3s; }

/* ---------- Entradas al hacer scroll ---------- */
.js .reveal, .js [data-reveal] {
  opacity: 0; transform: translateY(26px);
  transition: opacity 0.85s var(--ease-soft) var(--d, 0ms), transform 1s var(--ease-out) var(--d, 0ms), clip-path 1.15s var(--ease-out) var(--d, 0ms), filter 0.85s var(--ease-soft) var(--d, 0ms);
}
.js [data-reveal='left'] { transform: translateX(-40px); }
.js [data-reveal='right'] { transform: translateX(40px); }
/* En pantallas angostas, un desplazamiento lateral ensancharía la página */
@media (max-width: 1023px) { .js [data-reveal='left'], .js [data-reveal='right'] { transform: translateY(26px); } }
.js [data-reveal='zoom'] { transform: scale(0.93); }
.js [data-reveal='blur'] { transform: translateY(14px); filter: blur(10px); }
.js [data-reveal='fade'] { transform: none; }
.js [data-reveal='mask'] { opacity: 1; transform: none; clip-path: inset(0 0 100% 0); }
.js [data-reveal='mask-x'] { opacity: 1; transform: none; clip-path: inset(0 100% 0 0); }
.js .reveal.in, .js [data-reveal].in { opacity: 1; transform: none; filter: none; }
.js [data-reveal='mask'].in, .js [data-reveal='mask-x'].in { clip-path: inset(0 0 0 0); }

/* ---------- Texto que sube palabra por palabra ---------- */
.split-w { display: inline-block; overflow: hidden; vertical-align: top; padding: 0.1em 0.03em 0.16em; margin: -0.1em -0.03em -0.16em; }
.split-i { display: inline-block; transition: transform 1s var(--ease-out); transition-delay: calc(var(--i, 0) * 36ms + var(--d, 0ms)); }
.js [data-split]:not(.in) .split-i { transform: translateY(118%); }

/* ---------- Títulos del héroe: solo CSS, para no retrasar el primer pintado ---------- */
.hl { display: block; overflow: hidden; padding-bottom: 0.14em; margin-bottom: -0.14em; }
.hl > span { display: block; animation: hlUp 1.1s var(--ease-out) both; }
.hd-1 > span { animation-delay: 0.08s; }
.hd-2 > span { animation-delay: 0.16s; }
.hd-3 > span { animation-delay: 0.24s; }
@keyframes hlUp { from { transform: translateY(106%); } to { transform: none; } }
.rise { animation: riseIn 1s var(--ease-out) both; }
.rise-1 { animation-delay: 0.14s; }
.rise-2 { animation-delay: 0.24s; }
.rise-3 { animation-delay: 0.34s; }
.rise-4 { animation-delay: 0.44s; }
@keyframes riseIn { from { transform: translateY(20px); } to { transform: none; } }
.curtain { animation: curtainIn 1.4s var(--ease-out) both; }
@keyframes curtainIn { from { clip-path: inset(12% 8% 12% 8%); transform: scale(1.06); } to { clip-path: inset(0 0 0 0); transform: none; } }

/* ---------- Palabra que rota ---------- */
.rotator { display: inline-grid; vertical-align: bottom; overflow: hidden; padding-bottom: 0.14em; margin-bottom: -0.14em; }
.rotator > * { grid-area: 1 / 1; justify-self: start; white-space: nowrap; opacity: 0; visibility: hidden; transform: translateY(70%); transition: opacity 0.45s ease, transform 0.8s var(--ease-out), visibility 0s linear 0.8s; }
.rotator > .is-on { opacity: 1; visibility: visible; transform: none; transition-delay: 0s; }
.rotator > .is-out { opacity: 0; visibility: visible; transform: translateY(-70%); transition-delay: 0s; }

/* ---------- Marquesina infinita ---------- */
.marquee { display: flex; overflow: hidden; -webkit-mask-image: linear-gradient(90deg, transparent, #000 7%, #000 93%, transparent); mask-image: linear-gradient(90deg, transparent, #000 7%, #000 93%, transparent); }
.marquee-track { display: flex; flex: none; align-items: center; gap: var(--mq-gap, 2.75rem); padding-right: var(--mq-gap, 2.75rem); min-width: 100%; animation: mq var(--mq-t, 36s) linear infinite; }
.marquee:hover .marquee-track { animation-play-state: paused; }
.marquee-rev .marquee-track { animation-direction: reverse; }
@keyframes mq { to { transform: translateX(-100%); } }

/* ---------- Texto que se enciende con el scroll ---------- */
.scrub-w { opacity: 0.5; transition: opacity 0.3s ease; }
.scrub-w.on { opacity: 1; }

/* ---------- Inclinación 3D y brillo que sigue al cursor ---------- */
[data-tilt] { transition: transform 0.6s var(--ease-out); }
.spot { position: relative; }
.spot::after {
  content: ''; position: absolute; inset: 0; border-radius: inherit; pointer-events: none; opacity: 0; transition: opacity 0.35s ease;
  background: radial-gradient(340px circle at var(--mx, 50%) var(--my, 50%), var(--spot-color, rgba(255, 255, 255, 0.09)), transparent 65%);
}
.spot:hover::after { opacity: 1; }
[data-magnetic] { transition: transform 0.5s var(--ease-out); }

/* ---------- Barra de progreso de lectura ---------- */
.scroll-bar { position: fixed; inset: 0 0 auto 0; height: 2px; z-index: 90; transform: scaleX(0); transform-origin: 0 50%; background: var(--scroll-bar, currentColor); pointer-events: none; }

/* ---------- Línea que se llena con el scroll ---------- */
.fill-track { position: relative; overflow: hidden; }
.fill-line { position: absolute; inset: 0; transform-origin: 50% 0; transform: scaleY(var(--p, 0)); }

/* ---------- Galería horizontal: se desliza en celular, se fija al bajar en escritorio ---------- */
.hs-track { display: flex; overflow-x: auto; scroll-snap-type: x mandatory; -webkit-overflow-scrolling: touch; scrollbar-width: none; }
.hs-track::-webkit-scrollbar { display: none; }
.hs-track > * { flex: none; scroll-snap-align: start; }
.hs-on .hs-pin { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; justify-content: center; overflow: hidden; }
.hs-on .hs-track { overflow: visible; scroll-snap-type: none; width: max-content; will-change: transform; }

/* ---------- Comparador antes / después ---------- */
.compare { position: relative; overflow: hidden; --pos: 50%; }
.compare-after { position: absolute; inset: 0; clip-path: inset(0 0 0 var(--pos)); }
.compare-handle { position: absolute; top: 0; bottom: 0; left: var(--pos); width: 2px; margin-left: -1px; background: #fff; pointer-events: none; box-shadow: 0 0 18px rgba(0, 0, 0, 0.5); }
.compare-knob { position: absolute; top: 50%; left: 50%; width: 44px; height: 44px; margin: -22px 0 0 -22px; border-radius: 50%; background: #fff; color: #0b0f1a; display: flex; align-items: center; justify-content: center; box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45); }
.compare input[type='range'] { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: ew-resize; touch-action: pan-y; }
.compare input[type='range']:focus-visible ~ .compare-handle .compare-knob { outline: 3px solid #22d3ee; outline-offset: 2px; }

/* ---------- Captura larga que se recorre al pasar el cursor ---------- */
.shot-frame { position: relative; overflow: hidden; container-type: size; }
.shot-img { display: block; width: 100%; height: auto; transition: transform 1.2s var(--ease-out); }
.shot-frame:hover .shot-img.is-full, .shot-frame:focus-within .shot-img.is-full { transform: translateY(calc(-100% + 100cqh)); transition: transform 9s cubic-bezier(0.45, 0.05, 0.55, 0.95); }

/* ---------- Fuera de pantalla no se anima (ver data-live en motion.js) ---------- */
.live-off, .live-off * { animation-play-state: paused !important; }

/* ---------- Flotado y brillo continuos ---------- */
.float-a { animation: floatY 6.5s ease-in-out infinite; }
.float-b { animation: floatY 8s ease-in-out -2.5s infinite; }
.float-c { animation: floatY 5.5s ease-in-out -1s infinite; }
@keyframes floatY { 50% { transform: translateY(-12px); } }
.spin-slow { animation: spinSlow 22s linear infinite; }
@keyframes spinSlow { to { transform: rotate(360deg); } }
.draw path, .draw line, .draw circle, .draw rect { stroke-dasharray: 1; stroke-dashoffset: 1; }
.draw.in path, .draw.in line, .draw.in circle, .draw.in rect { animation: drawLine 2.2s var(--ease-soft) forwards; }
@keyframes drawLine { to { stroke-dashoffset: 0; } }

/* ---------- Etiqueta "Demo" y mapa bajo demanda (demos) ---------- */
.demo-pill { position: fixed; left: 14px; bottom: 14px; z-index: 80; display: flex; align-items: center; gap: 0.5rem; padding: 0.55rem 0.9rem; border-radius: 999px; background: rgba(8, 8, 10, 0.82); -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px); border: 1px solid rgba(255, 255, 255, 0.16); color: #d6d3d1; font: 500 11px/1.2 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; text-decoration: none; transition: transform 0.3s var(--ease-out), border-color 0.2s ease; }
.demo-pill:hover { transform: translateY(-2px); border-color: rgba(255, 255, 255, 0.4); }
.demo-pill b { color: #fff; font-weight: 600; }
.demo-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--pill, #22d3ee); box-shadow: 0 0 0 0 var(--pill, #22d3ee); animation: demoPulse 2.2s ease-out infinite; }
.demo-pill-teal { --pill: #2dd4bf; }
@keyframes demoPulse { 70% { box-shadow: 0 0 0 7px transparent; } 100% { box-shadow: 0 0 0 0 transparent; } }
@media (max-width: 640px) { .demo-more { display: none; } }

.map-facade { position: relative; display: flex; align-items: center; justify-content: center; min-height: 320px; overflow: hidden; background-color: var(--map-bg, #11161d); background-size: cover; background-position: center; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 600 400'%3E%3Cg fill='none' stroke='%23fff' stroke-opacity='.14'%3E%3Cpath stroke-width='10' d='M-10 300 180 240l140 40 300-90'/%3E%3Cpath stroke-width='7' d='M90-10 150 420M330-10l-30 420M500-10l40 420'/%3E%3Cpath stroke-width='4' d='M-10 90 620 40M-10 170l630-30M-10 370l630-60M230-10 210 420M420-10l-20 420'/%3E%3C/g%3E%3Cpath fill='none' stroke='%2360a5fa' stroke-opacity='.25' stroke-width='16' d='M-10 20c120 60 180 20 270 90s170 60 350 10'/%3E%3C/svg%3E"); }
.map-facade .map-pin { position: absolute; top: 38%; left: 50%; width: 22px; height: 22px; margin-left: -11px; border-radius: 50% 50% 50% 0; background: var(--pill, #22d3ee); transform: rotate(-45deg); box-shadow: 0 10px 20px rgba(0, 0, 0, 0.45); }
.map-facade .map-pin::after { content: ''; position: absolute; inset: 7px; border-radius: 50%; background: rgba(0, 0, 0, 0.55); }
.map-facade .map-btn { position: relative; margin-top: 4.5rem; padding: 0.7rem 1.2rem; border-radius: 999px; background: #fff; color: #111; font: 600 12px/1 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; cursor: pointer; transition: transform 0.25s var(--ease-out); }
.map-facade .map-btn:hover { transform: translateY(-2px); }
.map-frame { display: block; width: 100%; height: 100%; min-height: 320px; border: 0; }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto !important; }
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-delay: 0s !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; transition-delay: 0s !important; }
  .shot-frame:hover .shot-img.is-full { transform: none; }
}
