/* ==============================================================
   ESCENA 3D v1 · el CSS de los componentes de impacto
   Va junto con escena3d.js. Los colores salen de las variables de
   marca que ya define la web:
     --vv-primario  --vv-secundario  --vv-fondo  --vv-texto
   ============================================================== */

/* --- 1) PANTALLA DE CARGA -------------------------------------
   HTML (primer hijo del body):
   <div class="vv-intro" data-carga="1900">
     <div class="e3d-marca">
       <img src="img/logo.png" alt="">
       <p class="e3d-nombre">Nombre del negocio</p>
     </div>
     <div class="e3d-barra"><span></span></div>
     <p class="e3d-pie"><b class="e3d-cifra">0</b>%</p>
   </div>
   El data-carga son milisegundos: el kit lo deja en 1900 y el techo
   duro son 2400 (lo pone el JS). Más que eso y el visitante se va.  */
.vv-intro[data-carga] {
  position: fixed; inset: 0; z-index: 9999;
  display: grid; place-content: center; justify-items: center; gap: clamp(20px, 4vh, 34px);
  background: var(--vv-fondo, #0c0c0e);
  animation: none;                       /* acá manda el JS, no el iris de vivo.css */
  transition: opacity .55s ease, clip-path .8s cubic-bezier(.76, 0, .24, 1);
  clip-path: inset(0 0 0 0);
  padding: 24px;
}
.vv-intro[data-carga].e3d-fuera { clip-path: inset(0 0 100% 0); opacity: 0; pointer-events: none; }
.vv-intro .e3d-marca { display: grid; justify-items: center; gap: 14px; text-align: center; }
.vv-intro .e3d-marca img {
  max-width: min(46vw, 220px); max-height: 24vh; width: auto; height: auto;
  animation: e3dEntra .9s cubic-bezier(.2, .9, .3, 1.05) both;
}
.vv-intro .e3d-nombre {
  margin: 0; color: var(--vv-texto, #fff);
  font-size: clamp(15px, 2.4vw, 20px); letter-spacing: .16em; text-transform: uppercase;
  opacity: .82; animation: e3dEntra .9s cubic-bezier(.2, .9, .3, 1.05) .12s both;
}
.vv-intro .e3d-barra {
  width: min(70vw, 300px); height: 2px; border-radius: 2px;
  background: color-mix(in srgb, var(--vv-texto, #fff) 18%, transparent);
  overflow: hidden;
}
.vv-intro .e3d-barra span {
  display: block; width: 0; height: 100%;
  background: var(--vv-primario, #fff);
}
.vv-intro .e3d-pie {
  margin: 0; color: var(--vv-texto, #fff); opacity: .5;
  font-variant-numeric: tabular-nums; font-size: 13px; letter-spacing: .08em;
}
@keyframes e3dEntra {
  from { opacity: 0; transform: translateY(14px) scale(.96); }
  to   { opacity: 1; transform: none; }
}
/* Mientras carga no se scrollea: si no, se ve media web moviéndose detrás. */
html.e3d-cargando, html.e3d-cargando body { overflow: hidden; }
/* Sin JavaScript la cortina no se puede ir: mejor que no exista. */
html.vv-quieto .vv-intro[data-carga] { display: none; }

/* --- 2) ESCENA 3D POR CAPAS ------------------------------------
   <div data-e3d="capas" data-fuerza="14" class="e3d-capas">
     <div class="e3d-capa" style="--z:0"><img src="img/fondo.jpg" alt=""></div>
     <div class="e3d-capa" style="--z:3"><img src="img/producto.png" alt=""></div>
   </div>
   El --z de cada capa es su profundidad: 0 al fondo, más alto = más
   cerca de la cámara y más se despega al mover el puntero.           */
.e3d-capas {
  position: relative; overflow: clip;
  perspective: 1200px; transform-style: preserve-3d;
  transform: rotateX(var(--rx, 0deg)) rotateY(var(--ry, 0deg));
  transition: transform .3s ease-out;
  isolation: isolate;
}
.e3d-capa {
  position: absolute; inset: 0;
  display: grid; place-items: center;
  will-change: transform;
}
.e3d-capa img { max-width: 100%; height: auto; display: block; }
/* La capa que trae la foto de fondo va a sangre y tapa todo el bloque. */
.e3d-capa.e3d-fondo { inset: -6%; }
.e3d-capa.e3d-fondo img { width: 100%; height: 100%; object-fit: cover; }
/* Sin movimiento: se ven todas las capas quietas y encimadas, se entiende igual. */
.e3d-capas.e3d-plano .e3d-capa { transform: none !important; }

/* --- 3) COMPARADOR ANTES / DESPUÉS -----------------------------
   <div data-comparar="50" class="e3d-comparar">
     <img class="e3d-antes"   src="img/antes.jpg"   alt="Antes">
     <img class="e3d-despues" src="img/despues.jpg" alt="Después">
     <span class="e3d-etiqueta e3d-izq">Antes</span>
     <span class="e3d-etiqueta e3d-der">Después</span>
   </div>
   Las dos fotos tienen que tener EL MISMO encuadre y el mismo tamaño,
   si no el efecto no se entiende.                                    */
.e3d-comparar {
  position: relative; overflow: clip; touch-action: pan-y;
  aspect-ratio: 16 / 10; width: 100%; border-radius: 14px;
  cursor: ew-resize; user-select: none; -webkit-user-select: none;
}
.e3d-comparar img {
  position: absolute; inset: 0;
  width: 100%; height: 100%; object-fit: cover; display: block;
  pointer-events: none;
}
.e3d-comparar .e3d-despues { clip-path: inset(0 0 0 var(--corte, 50%)); }
.e3d-comparar .e3d-tirador {
  position: absolute; top: 0; bottom: 0; left: var(--corte, 50%);
  width: 44px; margin-left: -22px; padding: 0;
  background: none; border: 0; cursor: ew-resize;
  display: grid; place-items: center;
}
.e3d-comparar .e3d-tirador::before {
  content: ""; position: absolute; top: 0; bottom: 0; left: 21px;
  width: 2px; background: #fff; box-shadow: 0 0 14px rgba(0, 0, 0, .45);
}
.e3d-comparar .e3d-tirador::after {
  content: "‹ ›"; position: relative;
  width: 44px; height: 44px; border-radius: 50%;
  background: #fff; color: #111;
  display: grid; place-items: center;
  font-size: 17px; letter-spacing: 2px;
  box-shadow: 0 6px 22px rgba(0, 0, 0, .32);
}
.e3d-comparar .e3d-tirador:focus-visible { outline: 3px solid var(--vv-primario, #fff); outline-offset: 4px; }
.e3d-comparar .e3d-etiqueta {
  position: absolute; bottom: 14px; z-index: 2;
  padding: 7px 15px; border-radius: 999px;
  background: rgba(12, 12, 14, .72); color: #fff;
  font-size: 12px; letter-spacing: .12em; text-transform: uppercase;
  white-space: nowrap; pointer-events: none;
}
.e3d-comparar .e3d-izq { left: 14px; }
.e3d-comparar .e3d-der { right: 14px; }

/* --- 4) PARTÍCULAS --------------------------------------------
   <div class="e3d-fondo-vivo" data-particulas="60" data-color="#c9a227"></div>
   Va SIEMPRE dentro de una sección con position:relative y detrás del
   contenido. Nunca encima del texto.                                  */
.e3d-lienzo {
  position: absolute; inset: 0; width: 100%; height: 100%;
  pointer-events: none; z-index: 0;
}
.e3d-fondo-vivo { position: absolute; inset: 0; overflow: clip; pointer-events: none; z-index: 0; }

/* --- 4b) MODELO 3D DEL RUBRO ----------------------------------
   <div class="e3d-modelo" data-e3d="modelo" data-modelo="capilar"></div>
   Ocupa el bloque entero. Va detrás o al lado del texto, nunca encima. */
.e3d-modelo {
  position: relative; overflow: clip;
  width: 100%; min-height: clamp(300px, 52vh, 520px);
  touch-action: pan-y; cursor: grab;
}
.e3d-modelo:active { cursor: grabbing; }
.e3d-lienzo-modelo { z-index: 0; }

/* --- 5) FOCO DE LUZ -------------------------------------------
   <section data-spot class="e3d-spot"> … </section>                   */
.e3d-spot { position: relative; isolation: isolate; }
.e3d-spot::before {
  content: ""; position: absolute; inset: 0; z-index: 0; pointer-events: none;
  background: radial-gradient(420px circle at var(--mx, 50%) var(--my, 50%),
    color-mix(in srgb, var(--vv-primario, #fff) 16%, transparent), transparent 62%);
  transition: opacity .4s ease;
}
.e3d-spot > * { position: relative; z-index: 1; }

/* --- 6) ANILLO 3D DE TARJETAS ---------------------------------
   <div data-e3d="orbita" data-radio="360" class="e3d-orbita">
     <article class="e3d-carta">…</article> × 5 a 8
   </div>                                                              */
.e3d-orbita {
  --giro: 0deg;
  position: relative; overflow: clip;
  height: clamp(320px, 46vh, 460px);
  perspective: 1400px;
}
/* El anillo lo crea el JS y envuelve a las cartas: el giro va acá, para no
   pisar el transform individual de cada una (que es la que la pone en su lugar
   del círculo). */
.e3d-orbita .e3d-anillo {
  position: absolute; inset: 0;
  transform-style: preserve-3d;
  transform: rotateY(var(--giro));
}
.e3d-orbita .e3d-carta {
  position: absolute;
  top: calc(50% - 95px);
  left: calc(50% - min(32vw, 130px));
  width: min(64vw, 260px); min-height: 190px;
  backface-visibility: hidden;
  border-radius: 16px; padding: 22px;
  background: color-mix(in srgb, var(--vv-texto, #fff) 7%, transparent);
  border: 1px solid color-mix(in srgb, var(--vv-texto, #fff) 14%, transparent);
}
/* Sin movimiento (o si el sistema pide reducirlo): el anillo se desarma en una
   grilla común y se lee igual. */
.e3d-orbita.e3d-plano { height: auto; perspective: none; }
.e3d-orbita.e3d-plano .e3d-anillo {
  position: static; transform: none;
  display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px;
}
.e3d-orbita.e3d-plano .e3d-carta {
  position: static; transform: none !important; width: auto; top: auto; left: auto;
}

/* --- 7) PILA DE TARJETAS QUE SE APILAN ------------------------
   <div class="e3d-pila" data-e3d="pila">
     <article class="e3d-ficha">…</article> × 3 a 6
   </div>
   Cada ficha se pega arriba y la siguiente le pasa por encima. El JS
   solo escribe --p (0 a 1) por ficha; la matemática vive acá.        */
.e3d-pila { display: grid; gap: clamp(18px, 3vw, 34px); }
.e3d-pila .e3d-ficha {
  position: sticky;
  top: calc(90px + var(--i, 0) * 14px);
  border-radius: 20px;
  padding: clamp(24px, 4vw, 48px);
  background: var(--vv-fondo, #14161a);
  border: 1px solid color-mix(in srgb, var(--vv-texto, #fff) 12%, transparent);
  box-shadow: 0 18px 50px rgba(0, 0, 0, .18);
  transform: scale(calc(1 - var(--p, 0) * 0.06)) translateY(calc(var(--p, 0) * -10px));
  filter: brightness(calc(1 - var(--p, 0) * 0.18));
  transform-origin: 50% 0;
  will-change: transform;
}
.e3d-pila.e3d-plano .e3d-ficha { position: static; transform: none; filter: none; }

/* El modelo 3D usado como FONDO del hero: ocupa todo y va detrás del texto. */
.e3d-modelo.e3d-modelo-fondo {
  position: absolute; inset: 0; min-height: 0; z-index: 0;
}

/* --- 8) REALCE 3D AL PASAR EL PUNTERO -------------------------
   <article class="e3d-realce"> … </article>
   La tarjeta se inclina hacia el puntero, se levanta y se agranda un
   toque, con un brillo que sigue al mouse. Se nota, y es lo que hace
   que una lista de servicios se sienta viva.                          */
/* 🚨 El realce NO usa `transform`: usa `scale`, `translate` y `rotate`, que son propiedades
   sueltas y se COMPONEN con el transform que ya tenga el elemento. Con `transform` no
   funcionaba en las tarjetas del anillo 3D — su transform inline (el que las ubica en el
   círculo) lo pisaba y la tarjeta no reaccionaba, aunque el brillo sí apareciera. */
.e3d-realce {
  position: relative;
  transition: scale .25s cubic-bezier(.2, .9, .3, 1.05),
              translate .25s cubic-bezier(.2, .9, .3, 1.05),
              rotate .25s ease, box-shadow .25s ease, border-color .25s ease;
  will-change: scale, translate;
}
.e3d-realce:hover, .e3d-realce:focus-within {
  scale: 1.045;
  translate: 0 -8px;
  rotate: y var(--ry, 0deg);
  box-shadow: 0 26px 60px rgba(0, 0, 0, .22);
  border-color: color-mix(in srgb, var(--vv-primario, #888) 55%, transparent);
  z-index: 2;
}
/* el brillo que sigue al puntero */
.e3d-realce::after {
  content: ""; position: absolute; inset: 0; border-radius: inherit;
  pointer-events: none; opacity: 0; transition: opacity .25s ease;
  background: radial-gradient(220px circle at var(--lx, 50%) var(--ly, 50%),
    color-mix(in srgb, var(--vv-primario, #fff) 22%, transparent), transparent 70%);
}
.e3d-realce:hover::after { opacity: 1; }
.e3d-realce:active { transform: translateY(-2px) scale(1.01); }
/* En celular no hay puntero: el realce lo da el toque. */
@media (hover: none) {
  .e3d-realce:hover { transform: none; box-shadow: none; }
  .e3d-realce:active { transform: scale(.985); }
}

/* --- Micro-interacciones: todo lo clicable responde al tocarlo ----- */
.e3d-toque { transition: transform .18s cubic-bezier(.2,.9,.3,1.05), box-shadow .18s ease; }
.e3d-toque:hover { transform: translateY(-3px); }
.e3d-toque:active { transform: translateY(0) scale(.985); }

@media (prefers-reduced-motion: reduce) {
  .e3d-capa, .e3d-capas, .e3d-toque { transition: none !important; animation: none !important; }
}
