/* =============================================================================
   efectos.css — Movimiento, fondo vivo y capas flotantes
   Todo lo que se oculta para animar depende de html.anim (que tema.js solo
   agrega si la persona no pidió movimiento reducido). Sin JS, todo se ve.
   ============================================================================= */

/* ---------- Fondo: shader WebGL y respaldo CSS ---------- */
#escena { position: fixed; inset: 0; z-index: -3; display: block; width: 100%; height: 100%; opacity: 0; transition: opacity 1.4s var(--ease); pointer-events: none; }
#escena.lista { opacity: 1; }
[data-theme="light"] #escena.lista { opacity: .5; }

.fondo-respaldo { position: fixed; inset: 0; z-index: -3; display: none; overflow: hidden; pointer-events: none; }
.sin-webgl .fondo-respaldo { display: block; }
.fondo-respaldo span { position: absolute; width: 62vmax; height: 62vmax; border-radius: 50%; filter: blur(5.625rem); opacity: .32; animation: flotar 24s ease-in-out infinite alternate; }
.fondo-respaldo span:nth-child(1) { top: -22%; left: -14%; background: var(--acento-a); }
.fondo-respaldo span:nth-child(2) { right: -18%; bottom: -26%; background: var(--acento-b); animation-duration: 30s; }
.fondo-respaldo span:nth-child(3) { top: 34%; left: 42%; width: 40vmax; height: 40vmax; background: var(--arena); opacity: .16; animation-duration: 36s; }
[data-theme="light"] .fondo-respaldo span { opacity: .18; }

/* Parallax del hero atado al scroll de la página (compositor, sin JS). Usa transform;
   la entrada usa scale/opacity y el mouse usa translate, así que no se pisan. */
@supports (animation-timeline: scroll()) {
  @media (prefers-reduced-motion: no-preference) {
    .hv { animation-timeline: scroll(root); animation-range: 0 100vh; animation-timing-function: linear; animation-fill-mode: both; }
    .hv-atras { animation-name: subeAtras; }
    .hv-frente { animation-name: subeFrente; }
    .hv-tel { animation-name: subeTel; }
    .hv-chip-1 { animation-name: subeChip1; }
    .hv-chip-2 { animation-name: subeChip2; }
  }
}
@keyframes subeAtras { to { transform: translateY(-16%); } }
@keyframes subeFrente { to { transform: translateY(-7%); } }
@keyframes subeTel { to { transform: translateY(-38%); } }
@keyframes subeChip1 { to { transform: translateY(-110%); } }
@keyframes subeChip2 { to { transform: translateY(-55%); } }

/* ---------- Intro de carga ---------- */
#preloader {
  position: fixed;
  inset: 0;
  z-index: 500;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 1.375rem;
  background: var(--bg);
  clip-path: inset(0 0 0 0);
  transition: clip-path 1s var(--ease);
}
#preloader.listo { clip-path: inset(0 0 100% 0); }
html:not(.js) #preloader, .sin-intro #preloader { display: none; }
.cargando { overflow: hidden; }
.pre-marca { display: flex; align-items: center; gap: .75rem; font-size: 1.05rem; font-weight: 700; letter-spacing: -.02em; }
.pre-marca b { font-family: var(--f-mono); font-size: .7rem; font-weight: 500; letter-spacing: .16em; text-transform: uppercase; color: var(--texto-3); margin-left: .375rem; }
.pre-contador { font-size: clamp(4.5rem, 15vw, 9.5rem); font-weight: 760; letter-spacing: -.07em; line-height: 1; font-variant-numeric: tabular-nums; }
.pre-contador i { font-style: normal; font-size: .3em; color: var(--texto-3); vertical-align: top; margin-left: .1em; }
.pre-linea { width: min(20rem, 70vw); height: .125rem; overflow: hidden; background: var(--borde-2); }
.pre-linea span { display: block; height: 100%; transform-origin: left; transform: scaleX(0); background: linear-gradient(90deg, #2E86C1, #1AAFD0, #D9B98A); }
.pre-nota { font-family: var(--f-mono); font-size: .7rem; letter-spacing: .14em; text-transform: uppercase; color: var(--texto-4); }

/* ---------- Entrada del hero ---------- */
.anim .hero-titulo .linea > span { transform: translateY(112%); transition: transform 1.15s var(--ease); }
.anim .hero-titulo .linea:nth-child(2) > span { transition-delay: .09s; }
.anim .hero-titulo .linea:nth-child(3) > span { transition-delay: .18s; }
.anim .hero-in { opacity: 0; transform: translateY(1.125rem); transition: opacity .9s var(--ease), transform .9s var(--ease); }
.anim .hero-sub { transition-delay: .32s; }
.anim .hero-ctas { transition-delay: .44s; }
.anim .hero-precio { transition-delay: .54s; }
.anim .hero-puente { transition-delay: .64s; }
.anim .hv { opacity: 0; scale: .9; filter: blur(.5rem); transition: opacity 1.3s var(--ease), scale 1.3s var(--ease), filter 1.3s var(--ease); }
.anim .hv-atras { transition-delay: .2s; }
.anim .hv-frente { transition-delay: .32s; }
/* La captura principal es el elemento de LCP: se pinta desde el inicio y solo escala. */
.anim:not(.hero-listo) .hv-frente { opacity: 1; filter: none; scale: .94; }
.anim .hv-tel { transition-delay: .5s; }
.anim .hv-chip-1 { transition-delay: .75s; }
.anim .hv-chip-2 { transition-delay: .9s; }
.anim .hero-stats { opacity: 0; transition: opacity 1s var(--ease) .7s; }
.hero-listo .hero-titulo .linea > span { transform: none; }
.hero-listo .hero-in { opacity: 1; transform: none; }
.hero-listo .hv { opacity: 1; scale: 1; filter: none; }
.hero-listo .hero-stats { opacity: 1; }

/* ---------- Revelado al hacer scroll ---------- */
.anim [data-revelar] { opacity: 0; transform: translateY(1.875rem); transition: opacity .95s var(--ease), transform .95s var(--ease); transition-delay: var(--retraso, 0s); }
.anim [data-revelar].visible { opacity: 1; transform: none; }

/* Títulos divididos en palabras */
.w { display: inline-block; overflow: hidden; vertical-align: top; padding: 0 .04em .14em 0; margin: 0 -.04em -.14em 0; }
.wi { display: inline-block; }
em .w { padding-right: .12em; margin-right: -.12em; }
.anim .dividido .wi { transform: translateY(108%); transition: transform 1.05s var(--ease); transition-delay: calc(var(--i, 0) * 42ms); }
.anim .dividido.visible .wi { transform: none; }

/* Catálogo: entrada escalonada */
.anim .tarjeta { opacity: 0; translate: 0 2.25rem; transition: opacity .8s var(--ease), translate .8s var(--ease), transform .5s var(--ease), border-color .35s; transition-delay: var(--retraso, 0s), var(--retraso, 0s), 0s, 0s; }
.anim .tarjeta.visible { opacity: 1; translate: 0 0; }

/* ---------- Cursor propio ---------- */
.con-cursor:not(.modal-abierto), .con-cursor:not(.modal-abierto) :is(a, button, summary, label, .comparador, input[type="range"]) { cursor: none; }
.con-cursor input, .con-cursor textarea { cursor: text; }
.cursor, .cursor-anillo { position: fixed; top: 0; left: 0; z-index: 600; pointer-events: none; border-radius: 50%; opacity: 0; transition: opacity .3s; }
.con-cursor:not(.modal-abierto) .cursor, .con-cursor:not(.modal-abierto) .cursor-anillo { opacity: 1; }
.cursor { width: .5rem; height: .5rem; margin: -.25rem 0 0 -.25rem; background: #fff; mix-blend-mode: difference; }
.cursor-anillo {
  display: grid;
  place-items: center;
  width: 2.5rem;
  height: 2.5rem;
  margin: -1.25rem 0 0 -1.25rem;
  border: 1px solid color-mix(in srgb, var(--texto) 45%, transparent);
  font-family: var(--f-mono);
  font-size: .625rem;
  font-weight: 500;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--bg);
  transition: width .35s var(--ease), height .35s var(--ease), margin .35s var(--ease), background-color .3s, border-color .3s, opacity .3s;
}
.cursor-anillo span { opacity: 0; transition: opacity .2s; white-space: nowrap; }
.cursor-anillo.activo { width: 5rem; height: 5rem; margin: -2.5rem 0 0 -2.5rem; background: var(--texto); border-color: transparent; }
.cursor-anillo.activo span { opacity: 1; }
.cursor-anillo.presionado { width: 1.875rem; height: 1.875rem; margin: -.9375rem 0 0 -.9375rem; }
.cursor-oculto .cursor, .cursor-oculto .cursor-anillo { opacity: 0 !important; }

/* ---------- Panel técnico (HUD) ---------- */
.hud { position: fixed; left: 1rem; bottom: 1rem; z-index: 60; font-family: var(--f-mono); font-size: .74rem; transition: opacity .45s var(--ease), translate .45s var(--ease); }
.hud.oculto { opacity: 0; translate: 0 .875rem; pointer-events: none; }
.hud-pastilla {
  display: inline-flex;
  align-items: center;
  gap: .5625rem;
  padding: .75em 1.05em;
  border-radius: 62.4375rem;
  letter-spacing: .04em;
  color: var(--texto-2);
  background: var(--vidrio);
  border: 1px solid var(--borde-2);
  box-shadow: var(--sombra);
  transition: border-color .3s, color .3s;
}
.hud-pastilla:hover { color: var(--texto); border-color: var(--acento-a); }
.hud[data-estado="abierto"] .hud-pastilla { display: none; }
.hud-cuerpo {
  width: min(18.75rem, calc(100vw - 2rem));
  padding: .875rem 1rem .625rem;
  border-radius: 1rem;
  background: var(--vidrio);
  border: 1px solid var(--borde-2);
  box-shadow: var(--sombra);
  animation: hudIn .45s var(--ease);
}
.hud-cab { display: flex; align-items: center; justify-content: space-between; margin-bottom: .5rem; font-size: .78rem; color: var(--texto); }
.hud-x { display: grid; place-items: center; width: 1.625rem; height: 1.625rem; border-radius: 50%; }
.hud-x:hover { background: color-mix(in srgb, var(--texto) 10%, transparent); }
.hud-x svg { width: .875rem; height: .875rem; }
.hud dl div { display: grid; grid-template-columns: 6.125rem 1fr; gap: .5rem; padding: .375rem 0; border-top: 1px dashed var(--borde-2); }
.hud dt { font-size: .64rem; letter-spacing: .1em; text-transform: uppercase; color: var(--texto-4); }
.hud dd { color: var(--texto); overflow-wrap: anywhere; }
.hud dd.cambio { animation: destello .6s var(--ease); }

/* ---------- Diálogos ---------- */
dialog { max-width: none; max-height: none; padding: 0; border: 0; color: inherit; background: transparent; }
dialog::backdrop { background: rgba(6, 6, 5, .78); }

.popup {
  position: relative;
  width: min(32.5rem, calc(100vw - 2rem));
  margin: auto;
  padding: clamp(1.75rem, 4vw, 2.75rem);
  overflow: hidden;
  border-radius: var(--radio-xl);
  border: 1px solid var(--borde-2);
  background: var(--card);
  box-shadow: var(--sombra);
}
.popup[open] { animation: popIn .55s var(--ease); }
.popup h2 { margin: .875rem 0 .75rem; font-size: clamp(2rem, 4.4vw, 2.9rem); font-weight: 720; letter-spacing: -.045em; line-height: 1; }
.popup > p { color: var(--texto-2); }
.popup-brillo { position: absolute; top: -45%; right: -25%; width: 23.75rem; height: 23.75rem; border-radius: 50%; background: radial-gradient(closest-side, color-mix(in srgb, var(--acento-a) 50%, transparent), transparent); filter: blur(1.25rem); pointer-events: none; }
.popup-cerrar { position: absolute; top: .875rem; right: .875rem; z-index: 2; }
.popup-acciones { display: flex; flex-wrap: wrap; gap: .625rem; margin-top: 1.625rem; }

.ficha {
  --caso-a: #2E86C1;
  --caso-b: #1AAFD0;
  width: min(73.75rem, calc(100vw - 1.5rem));
  height: min(51.25rem, calc(100svh - 1.5rem));
  margin: auto;
  overflow: hidden;
  border-radius: var(--radio-xl);
  border: 1px solid var(--borde-2);
  background: var(--card);
  box-shadow: var(--sombra);
}
.ficha[open] { animation: fichaIn .6s var(--ease); }
.ficha-in { position: relative; display: grid; grid-template-columns: 1.28fr .72fr; height: 100%; }
.ficha-cerrar { position: absolute; top: .875rem; right: .875rem; z-index: 5; }
.ficha-visual {
  position: relative;
  display: flex;
  min-height: 0;
  padding: clamp(1.125rem, 2.4vw, 2rem);
  background:
    radial-gradient(90% 70% at 0% 0%, color-mix(in srgb, var(--caso-a) 36%, transparent), transparent 60%),
    radial-gradient(80% 70% at 100% 100%, color-mix(in srgb, var(--caso-b) 30%, transparent), transparent 60%),
    var(--bg-2);
}
.ficha-nav { display: flex; flex: 1; flex-direction: column; min-height: 0; }
.ficha-scroll { position: relative; flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin; background: var(--card-2); }
.ficha-scroll img { width: 100%; height: auto; }
.ficha-tel { position: absolute; right: clamp(1.125rem, 2.4vw, 2rem); bottom: clamp(1.125rem, 2.4vw, 2rem); width: clamp(6.875rem, 12vw, 10rem); transform: rotate(3deg) translate(18%, 6%); }
.ficha-info { display: flex; flex-direction: column; gap: .875rem; min-height: 0; padding: clamp(1.5rem, 3vw, 2.5rem); padding-top: 4rem; overflow-y: auto; }
.ficha-meta { display: flex; flex-wrap: wrap; gap: .5rem; }
.ficha-info h2 { font-size: clamp(1.8rem, 3vw, 2.6rem); font-weight: 720; letter-spacing: -.045em; line-height: 1; }
.ficha-lugar { font-family: var(--f-mono); font-size: .74rem; letter-spacing: .1em; text-transform: uppercase; color: var(--texto-3); }
.ficha-lugar:empty { display: none; }
.ficha-resumen { color: var(--texto-2); }
.ficha-info h3 { margin-top: .375rem; font-family: var(--f-mono); font-size: .72rem; font-weight: 500; letter-spacing: .12em; text-transform: uppercase; color: var(--texto-3); }
.ficha-lista { display: grid; gap: .5625rem; }
.ficha-lista li { display: flex; gap: .625rem; font-size: .96rem; }
.ficha-lista li::before { content: ''; flex: none; width: .375rem; height: .375rem; margin-top: .62em; border-radius: 50%; background: var(--caso-a); box-shadow: 0 0 .625rem var(--caso-a); }
.ficha-stack { display: flex; flex-wrap: wrap; gap: .375rem; }
.ficha-acciones { display: flex; flex-wrap: wrap; gap: .625rem; margin-top: auto; padding-top: .625rem; }
.ficha-acciones .btn { flex: 1 1 auto; }
.ficha-nav-casos { display: flex; align-items: center; justify-content: space-between; gap: .75rem; padding-top: 1rem; border-top: 1px solid var(--borde); font-family: var(--f-mono); font-size: .78rem; color: var(--texto-3); }
.ficha.cambiando .ficha-scroll img, .ficha.cambiando .ficha-tel img { opacity: 0; }
.ficha-scroll img, .ficha-tel img { transition: opacity .35s; }

/* ---------- Avisos ---------- */
.toasts { position: fixed; right: 1rem; bottom: 1rem; z-index: 450; display: grid; justify-items: end; gap: .625rem; pointer-events: none; }
.toast {
  display: flex;
  align-items: center;
  gap: .625rem;
  max-width: min(22.5rem, calc(100vw - 2rem));
  padding: .75rem 1rem;
  border-radius: .875rem;
  font-size: .88rem;
  line-height: 1.4;
  background: var(--card);
  border: 1px solid var(--borde-2);
  box-shadow: var(--sombra);
  pointer-events: auto;
  animation: toastIn .5s var(--ease) both;
}
.toast.saliendo { animation: toastOut .4s var(--ease) both; }

/* ---------- Cambio de tema con View Transitions ---------- */
/* El nombre de transición solo se asigna mientras se filtra: así el cambio de tema
   revela la página entera con el círculo y no tarjeta por tarjeta. */
.vt-tema::view-transition-old(root), .vt-tema::view-transition-new(root) { animation: none; mix-blend-mode: normal; }
.vt-tema::view-transition-new(root) { animation: revelarTema .75s var(--ease); }
.vt-filtro .tarjeta { view-transition-name: var(--vtn); }
.vt-filtro::view-transition-group(*) { animation-duration: .6s; animation-timing-function: var(--ease); }

/* ---------- Pequeños efectos ---------- */
.pop { animation: pop .45s var(--ease); }
.cambio-vivo { animation: destello .7s var(--ease); }

/* ---------- Keyframes ---------- */
@keyframes marquee { to { transform: translateX(-50%); } }
@keyframes pulso { 0% { transform: scale(1); opacity: .55; } 70%, 100% { transform: scale(2.8); opacity: 0; } }
@keyframes gota { 0% { transform: translateY(-100%); } 60%, 100% { transform: translateY(100%); } }
@keyframes flotar { to { transform: translate(8vw, 6vh) scale(1.12); } }
@keyframes girarIco { to { transform: rotate(360deg); } }
@keyframes tipeo { 0%, 60%, 100% { transform: translateY(0); opacity: .5; } 30% { transform: translateY(-.25rem); opacity: 1; } }
@keyframes msgIn { from { opacity: 0; transform: translateY(.625rem) scale(.97); } }
@keyframes popIn { from { opacity: 0; transform: translateY(1.5rem) scale(.96); } }
@keyframes fichaIn { from { opacity: 0; transform: translateY(2.5rem) scale(.97); } }
@keyframes hudIn { from { opacity: 0; transform: translateY(.625rem); } }
@keyframes toastIn { from { opacity: 0; transform: translateY(.875rem) scale(.96); } }
@keyframes toastOut { to { opacity: 0; transform: translateY(.5rem) scale(.97); } }
@keyframes pop { 40% { transform: scale(1.25); } }
@keyframes destello { from { color: var(--acento-a); } }
@keyframes revelarTema { from { clip-path: circle(0 at var(--vt-x, 90%) var(--vt-y, 3%)); } to { clip-path: circle(150vmax at var(--vt-x, 90%) var(--vt-y, 3%)); } }

.msg, .escribiendo { animation: msgIn .4s var(--ease) both; }

/* ---------- Pantallas chicas ---------- */
@media (max-width: 640px) {
  .hud-txt { display: none; }
  .hud-pastilla { width: 2.5rem; height: 2.5rem; padding: 0; justify-content: center; }
}

@media (max-width: 900px) {
  .ficha { width: 100vw; height: 100svh; border-radius: 0; border: 0; }
  .ficha-in { grid-template-columns: 1fr; grid-template-rows: 44svh 1fr; }
  .ficha-tel { width: 5.75rem; }
  .ficha-info { padding-top: 1.375rem; }
  .hud { left: .75rem; bottom: .75rem; }
}

/* ---------- Movimiento reducido ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .15s !important; scroll-behavior: auto !important; }
  .marquee-pista, .cta-cinta { animation: none !important; }
  .hv { translate: none !important; }
}
