/* ==========================================================================
   hero-phone.css  -  Celular 3D del hero (CSS 3D puro: sin librerias, sin canvas)

   Capas, de afuera hacia adentro:
     .ph-stage   escena: perspectiva, brillo de fondo y sombra en el piso
     .ph-tilt    inclinacion con cursor y scroll          (JS escribe su transform)
     .ph-float   levitacion suave                         (CSS)
     .ph         cuerpo del telefono; su pose cambia con el chat (JS)

   Solo se animan transform y opacity. Nada de filter, backdrop-filter ni
   box-shadow animados. Todo se mide en em: el telefono escala solo.
   El telefono es siempre oscuro (como un aparato real), en tema claro y oscuro.
   ========================================================================== */

.ph-stage {
  --ph-ease: cubic-bezier(.22, .7, .2, 1);
  position: relative; display: grid; justify-items: center;
  padding-block: 1.5em 3.2em;
  margin-block: -3em; /* invade el padding del hero: el telefono cabe en el primer vistazo */
  /* ancho ~ 280px en escritorio; baja en pantallas bajas para que quepa en el primer vistazo */
  font-size: clamp(11px, min(.9vw + 5px, 1.5vh), 13px);
  perspective: 1500px;
  overflow: clip;
  pointer-events: none;
  user-select: none;
}

/* resplandor de fondo (degradado estatico, se pinta una sola vez) */
.ph-glow {
  position: absolute; inset-inline: 0; margin-inline: auto; top: 50%;
  width: min(34em, 100%); aspect-ratio: 1; transform: translateY(-50%);
  background: radial-gradient(closest-side, color-mix(in srgb, var(--accent) 38%, transparent), transparent);
  opacity: .5;
}
:root[data-theme="light"] .ph-glow { opacity: .32; }

/* sombra en el piso */
.ph-shadow {
  position: absolute; inset-inline: 0; margin-inline: auto; bottom: 1em;
  width: 17em; height: 2.4em;
  background: radial-gradient(closest-side, rgba(0, 0, 0, .55), rgba(0, 0, 0, 0));
  will-change: transform;
}
:root[data-theme="light"] .ph-shadow { background: radial-gradient(closest-side, rgba(20, 26, 36, .32), rgba(20, 26, 36, 0)); }

.ph-tilt, .ph-float { transform-style: preserve-3d; }
.ph-tilt { will-change: transform; }
.ph-float { animation: ph-float 7s ease-in-out infinite; }
@keyframes ph-float {
  0%, 100% { transform: translate3d(0, 0, 0); }
  50%      { transform: translate3d(0, -.7em, 0); }
}

/* ---------- cuerpo ---------- */
.ph {
  --c-bg: #0b1014; --c-in: #1f272c; --c-out: #055c4c;
  --c-tx: #e9edef; --c-mute: #8696a0; --c-link: #53bdeb;
  position: relative; width: 22em; aspect-ratio: 22 / 45;
  transform-style: preserve-3d;
  transform: rotateY(-3deg) rotateX(1deg);          /* pose final: de frente */
  transition: transform 1.5s var(--ph-ease);
  will-change: transform;
  font-family: inherit; color: var(--c-tx);
}
.is-out .ph { transition-duration: 2.2s; }

/* grosor: capas con el mismo contorno apiladas en Z (respeta las esquinas redondeadas) */
.ph-slice {
  position: absolute; inset: 0; border-radius: 3.4em;
  background: linear-gradient(180deg, #4b4b55 0%, #2a2a31 16%, #1a1a1f 50%, #2a2a31 84%, #43434d 100%);
  transform: translateZ(calc(var(--z) * .3em));
}
/* botones laterales */
.ph-key { position: absolute; width: .24em; border-radius: .12em; background: linear-gradient(90deg, #44444d, #22222a); }
.k-act  { left: -.2em;  top: 6em;    height: 1.5em; }
.k-vol1 { left: -.2em;  top: 8.6em;  height: 2.8em; }
.k-vol2 { left: -.2em;  top: 12.2em; height: 2.8em; }
.k-pwr  { right: -.2em; top: 10em;   height: 5.2em; }

/* frente: marco + pantalla */
.ph-face {
  position: absolute; inset: 0; border-radius: 3.4em; overflow: hidden;
  transform: translateZ(.85em); backface-visibility: hidden;
  background: #020203; border: .2em solid #3b3b44;
  box-shadow: inset 0 0 0 .12em #0c0c0e;
}
.ph-screen {
  position: absolute; inset: .5em; border-radius: 2.9em; overflow: hidden;
  display: flex; flex-direction: column; background: var(--c-bg);
}
.ph-island {
  position: absolute; z-index: 5; top: .8em; left: 50%; width: 6em; height: 1.7em; margin-left: -3em;
  border-radius: 1em; background: #000;
}
.ph-glare {
  position: absolute; z-index: 6; inset: 0 -30%; pointer-events: none;
  background: linear-gradient(112deg, transparent 36%, rgba(255, 255, 255, .075) 46%, rgba(255, 255, 255, .02) 54%, transparent 64%);
  will-change: transform;
}

/* barra de estado */
.ph-status {
  display: flex; align-items: flex-end; justify-content: space-between;
  height: 3.2em; padding: 0 2em .5em; color: #fff;
}
.ph-status b { font-size: .74em; font-weight: 650; letter-spacing: .01em; }
.ph-sys { display: flex; align-items: center; gap: .45em; }
.ph-sig { display: flex; align-items: flex-end; gap: .12em; height: .75em; }
.ph-sig i { width: .16em; background: #fff; border-radius: .05em; }
.ph-sig i:nth-child(1) { height: 30%; } .ph-sig i:nth-child(2) { height: 55%; }
.ph-sig i:nth-child(3) { height: 80%; } .ph-sig i:nth-child(4) { height: 100%; }
.ph-bat { position: relative; width: 1.5em; height: .72em; border: .08em solid rgba(255, 255, 255, .6); border-radius: .22em; }
.ph-bat::before { content: ""; position: absolute; inset: .1em; right: .35em; border-radius: .1em; background: #fff; }

/* cabecera del chat */
.ph-head {
  display: flex; align-items: center; gap: .6em; height: 4em; padding: 0 .8em;
  background: #161d22; border-bottom: 1px solid rgba(255, 255, 255, .05);
}
.ph-head .icon { width: 1.25em; height: 1.25em; flex: none; color: var(--c-tx); }
.ph-ava {
  display: grid; place-items: center; flex: none; width: 2.5em; height: 2.5em; border-radius: 50%;
  background: linear-gradient(135deg, #2563eb, #7aa7ff); color: #fff;
}
.ph-ava .icon { width: 1.15em; height: 1.15em; color: #fff; }
.ph-who { display: grid; line-height: 1.2; min-width: 0; }
.ph-who b { font-size: .88em; font-weight: 650; }
.ph-who small { font-size: .64em; color: #4ade80; }
.ph-dots { margin-left: auto; display: grid; gap: .2em; padding-right: .3em; }
.ph-dots i { width: .2em; height: .2em; border-radius: 50%; background: var(--c-mute); }

/* conversacion */
.ph-chat {
  position: relative; flex: 1; min-height: 0; overflow: hidden;
  display: flex; flex-direction: column; gap: .6em; padding: .9em .75em;
  background: radial-gradient(120% 55% at 50% 0%, #121a20, #0a0e11);
  transition: opacity .6s ease;
}
.is-out .ph-chat { opacity: 0; }

.ph-msg {
  position: relative; max-width: 84%; margin: 0; padding: .5em .7em .4em;
  font-size: .86em; line-height: 1.35; border-radius: .9em; color: var(--c-tx);
  overflow-wrap: anywhere;
}
.ph-in-msg  { align-self: flex-start; background: var(--c-in); border-top-left-radius: .25em; transform-origin: left bottom; }
.ph-out-msg { align-self: flex-end;   background: var(--c-out); border-top-right-radius: .25em; transform-origin: right bottom; }
.ph-t { float: right; margin: .75em 0 -.1em .7em; font-size: .72em; line-height: 1; color: rgba(233, 237, 239, .55); }

/* "escribiendo..." comparte hueco con la respuesta: no hay saltos de layout */
.ph-slot { display: grid; }
.ph-slot > * { grid-area: 1 / 1; justify-self: start; align-self: start; }
.ph-typing {
  display: flex; gap: .28em; padding: .8em .9em; border-radius: .9em; border-top-left-radius: .25em;
  background: var(--c-in); transform-origin: left bottom;
}
.ph-typing i { width: .42em; height: .42em; border-radius: 50%; background: var(--c-mute); opacity: .5; }
.ph-typing.on i { animation: ph-dot 1.1s ease-in-out infinite; }
.ph-typing i:nth-child(2) { animation-delay: .15s; }
.ph-typing i:nth-child(3) { animation-delay: .3s; }
@keyframes ph-dot {
  0%, 60%, 100% { transform: translate3d(0, 0, 0); opacity: .45; }
  30%           { transform: translate3d(0, -.32em, 0); opacity: 1; }
}

/* ficha de producto */
.ph-card { width: 84%; padding: .25em; }
.ph-pic {
  position: relative; display: grid; place-items: center; height: 6.8em; overflow: hidden;
  border-radius: .7em .7em .35em .35em;
  background: radial-gradient(90% 80% at 50% 22%, #2c52a3 0%, #15274f 55%, #0c1630 100%);
}
.ph-pic::before {
  content: ""; position: absolute; width: 6.2em; height: 6.2em; border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, .09); background: radial-gradient(closest-side, rgba(122, 167, 255, .22), transparent);
}
.ph-pic svg { position: relative; width: 5.6em; height: auto; }
.ph-tag {
  position: absolute; left: .55em; top: .55em; display: flex; align-items: center; gap: .4em;
  padding: .25em .7em; border-radius: 2em; font-size: .68em; font-weight: 600;
  background: rgba(0, 0, 0, .45); color: #d7f7e5;
}
.ph-tag::before { content: ""; width: .55em; height: .55em; border-radius: 50%; background: #4ade80; }
.ph-info { display: grid; gap: .12em; padding: .55em .45em .35em; }
.ph-name  { font-weight: 650; }
.ph-price { font-weight: 600; color: #cfe0ff; }
.ph-desc  { font-size: .88em; line-height: 1.35; color: rgba(233, 237, 239, .66); }
.ph-act {
  display: flex; align-items: center; justify-content: center; gap: .45em;
  margin: .3em -.25em -.25em; padding: .65em; border-top: 1px solid rgba(255, 255, 255, .09);
  border-radius: 0 0 .9em .9em; font-weight: 600; color: var(--c-link);
  transition: background-color .2s ease, transform .2s ease;
}
.ph-act .icon { width: 1.15em; height: 1.15em; }
.ph-act.on { background: rgba(83, 189, 235, .18); transform: scale(.985); }

/* barra de mensaje */
.ph-input { position: relative; display: flex; align-items: center; gap: .5em; padding: .6em .7em 1.6em; background: #0d1317; }
.ph-field { flex: 1; display: flex; align-items: center; height: 2.9em; padding: 0 1em; border-radius: 1.5em; background: var(--c-in); color: var(--c-mute); font-size: .76em; }
.ph-send { flex: none; width: 2.5em; height: 2.5em; border-radius: 50%; background: #00a884; }
.ph-input::after {
  content: ""; position: absolute; left: 50%; bottom: .5em; width: 7em; height: .3em; margin-left: -3.5em;
  border-radius: .2em; background: rgba(255, 255, 255, .4);
}

/* ---------- entrada de mensajes (solo con JS y movimiento permitido) ----------
   Sin JS o con "reducir movimiento" se ve el chat completo y quieto. */
.ph-typing { opacity: 0; }
@media (scripting: enabled) and (prefers-reduced-motion: no-preference) {
  .ph { transform: rotateY(28deg) rotateX(10deg) rotateZ(-3deg); }   /* arranca ladeado */
  .ph-item {
    opacity: 0; transform: translate3d(0, .8em, 0) scale(.96);
    transition: opacity .35s ease, transform .5s var(--ph-ease);
  }
  .ph-item.on { opacity: 1; transform: none; }
  .ph-card.ph-item { transform: translate3d(0, 1.6em, 0) scale(.93); transition-duration: .45s, .7s; transition-timing-function: ease, cubic-bezier(.2, .9, .25, 1.12); }
  .ph-card.ph-item.on { transform: none; }
  .is-reset .ph-chat, .is-reset .ph-chat * { transition: none !important; }
}

/* fuera de pantalla o pestaña oculta: todo en pausa */
.ph-stage[data-paused], .ph-stage[data-paused] * { animation-play-state: paused !important; }

@media (prefers-reduced-motion: reduce) {
  .ph-float { animation: none; }
  .ph { transition: none; }
}

/* una columna: el telefono pasa debajo del texto */
@media (max-width: 900px) {
  .ph-stage { font-size: clamp(11px, 3.3vw, 13px); padding-block: .5em 2.8em; margin-block: 0 -1em; }
}
