/* ==========================================================================
   Biencel — inicio: celular 3D + historia con scroll
   El 3D es CSS puro (preserve-3d): sin librerías, liviano en móvil.
   motion.js solo escribe variables (--p, --tx, --ty) y el paso activo.
   ========================================================================== */

/* ---------- Hero ---------- */
.h3d {
  --p: 0;            /* avance del scroll dentro del hero, 0 → 1 */
  --tx: 0; --ty: 0;  /* inclinación por puntero, -1 → 1 */
  position: relative; overflow: hidden; background: var(--bg);
  padding-top: clamp(36px, 5vw, 64px);
}
.h3d__copy { display: grid; justify-items: center; text-align: center; position: relative; z-index: 2; }
.h3d__text { justify-items: center; gap: 20px; }
.h3d__sub { text-wrap: balance; }
.h3d__title { display: grid; font-size: clamp(46px, min(7vw, 9.5vh), 96px); line-height: .98; letter-spacing: -.05em; font-weight: 600; }
.h3d__line { display: block; white-space: nowrap; }
.h3d__line--blue { color: var(--blue-600); }
.h3d__price { color: var(--promo-500); }
.h3d__sub { font-size: clamp(18px, 1.7vw, 22px); color: var(--text-2); max-width: 34ch; }
.h3d__ctas { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 12px 28px; }
.h3d__legal { position: relative; z-index: 2; text-align: center; font-size: 12.5px; color: var(--text-3); padding-bottom: 28px; }

/* Entrada del titular: línea por línea, sube y se enfoca */
.js .h3d__line, .js .h3d__sub, .js .h3d__ctas, .js .h3d .hero-pill {
  opacity: 0; transform: translateY(28px); filter: blur(10px);
  animation: riseIn 1s var(--ease-out) forwards;
}
.js .h3d .hero-pill { animation-delay: .05s; }
.js .h3d__line:nth-child(1) { animation-delay: .12s; }
.js .h3d__line:nth-child(2) { animation-delay: .22s; }
.js .h3d__line:nth-child(3) { animation-delay: .32s; }
.js .h3d__sub { animation-delay: .46s; }
.js .h3d__ctas { animation-delay: .56s; }
@keyframes riseIn { to { opacity: 1; transform: none; filter: blur(0); } }

/* Escenario */
.h3d__stage {
  position: relative; height: clamp(520px, 62vw, 760px); margin-top: clamp(-8px, -1vw, 0px);
  perspective: 1600px; perspective-origin: 50% 30%;
  display: grid; place-items: start center;
}
.h3d__shadow {
  position: absolute; left: 50%; bottom: 6%; width: min(420px, 70vw); height: 60px; translate: -50% 0;
  border-radius: 50%; background: radial-gradient(closest-side, rgba(0, 0, 0, .22), transparent);
  filter: blur(8px); transform: scale(calc(.9 + var(--p) * .2)); opacity: calc(.9 - var(--p) * .4);
}
.h3d__rig {
  position: relative; transform-style: preserve-3d; margin-top: clamp(28px, 5vw, 56px);
  /* scroll: de inclinado a de frente; puntero: un poco extra */
  transform:
    translateY(calc(var(--p) * -40px))
    rotateX(calc(16deg - var(--p) * 16deg + var(--ty) * -6deg))
    rotateY(calc(-24deg + var(--p) * 24deg + var(--tx) * 10deg))
    rotateZ(calc(4deg - var(--p) * 4deg));
  transition: transform .5s var(--ease-out);
  animation: rigIn 1.6s cubic-bezier(.16, 1, .3, 1) .25s both;
}
@keyframes rigIn {
  from { opacity: 0; transform: translateY(160px) rotateX(48deg) rotateY(-50deg) rotateZ(10deg) scale(.86); }
}

/* ---------- Celular 3D ---------- */
.phone {
  --w: min(300px, 64vw); --h: calc(var(--w) * 2.05); --rad: calc(var(--w) * .17);
  position: relative; width: var(--w); height: var(--h); transform-style: preserve-3d;
  animation: idle 8s ease-in-out infinite;
}
.phone--sm { --w: min(270px, 56vw); }
@keyframes idle { 0%, 100% { translate: 0 0; } 50% { translate: 0 -10px; } }

.phone__edge, .phone__back, .phone__face { position: absolute; inset: 0; border-radius: var(--rad); }
/* Capas apiladas = grosor del equipo cuando gira */
.phone__edge { transform: translateZ(calc(var(--z) * -1.5px)); background: linear-gradient(90deg, #3a3a3f, #1c1c1f 12%, #2c2c30 50%, #1c1c1f 88%, #3a3a3f); }
.phone__back {
  transform: translateZ(-13px) rotateY(180deg); backface-visibility: hidden;
  background: linear-gradient(140deg, #2b2b30, #121214 60%, #222226);
}
.phone__cam { position: absolute; top: 5%; left: 7%; width: 38%; aspect-ratio: 1; border-radius: 26%; background: #18181b; box-shadow: inset 0 0 0 2px #333; }
.phone__face {
  background: #0d0d0f; padding: calc(var(--w) * .035); backface-visibility: hidden;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, .06) inset, 0 50px 80px -20px rgba(0, 0, 0, .35);
}
.phone__screen {
  position: relative; height: 100%; overflow: hidden; border-radius: calc(var(--rad) * .8);
  background: #fff; color: var(--text);
  padding: calc(var(--w) * .16) calc(var(--w) * .07) calc(var(--w) * .07);
  display: flex; flex-direction: column; gap: calc(var(--w) * .045);
  font-size: calc(var(--w) * .047);
}
.phone__island { position: absolute; top: calc(var(--w) * .035); left: 50%; translate: -50% 0; width: 32%; height: calc(var(--w) * .085); border-radius: 99px; background: #0d0d0f; }
.phone__glare {
  position: absolute; inset: 0; border-radius: var(--rad); pointer-events: none;
  background: linear-gradient(115deg, rgba(255, 255, 255, .22) 0%, transparent 32%, transparent 70%, rgba(255, 255, 255, .06));
  mix-blend-mode: soft-light;
}

/* ---------- Interfaz dentro del celular ---------- */
.ui-status { position: absolute; top: calc(var(--w) * .045); left: calc(var(--w) * .1); right: calc(var(--w) * .08); display: flex; justify-content: space-between; align-items: center; font-weight: 600; font-size: calc(var(--w) * .046); }
.ui-status__icons { display: inline-flex; align-items: flex-end; gap: 2px; }
.ui-status__icons i { width: 3px; background: var(--text); border-radius: 1px; }
.ui-status__icons i:nth-child(1) { height: 4px; } .ui-status__icons i:nth-child(2) { height: 6px; }
.ui-status__icons i:nth-child(3) { height: 8px; } .ui-status__icons i:nth-child(4) { height: 10px; }
.ui-status__icons b { width: 20px; height: 10px; margin-left: 5px; border-radius: 3px; border: 1.5px solid var(--text); background: linear-gradient(90deg, var(--text) 75%, transparent 75%); background-clip: content-box; padding: 1px; }
.ui-head { display: flex; justify-content: space-between; align-items: center; }
.ui-head img { height: calc(var(--w) * .07); width: auto; }
.ui-pill { display: inline-flex; align-items: center; gap: 5px; padding: 3px 8px; border-radius: 99px; background: #E6F8F1; color: #0A7D58; font-weight: 600; font-size: .82em; }
.ui-pill i { width: 6px; height: 6px; border-radius: 50%; background: #14C48A; }

.ui-ring { position: relative; width: 84%; aspect-ratio: 1; margin: 2% auto 0; display: grid; place-items: center; }
.ui-ring svg { position: absolute; inset: 0; transform: rotate(-90deg); overflow: visible; }
.ui-ring__track { fill: none; stroke: #F0F0F3; stroke-width: 14; }
.ui-ring__arc { fill: none; stroke-width: 14; stroke-linecap: round; }
.ui-ring__arc--base { stroke: #C9D8F5; stroke-dasharray: var(--base) 100; }
.ui-ring__arc--extra { stroke: var(--blue-600); stroke-dasharray: var(--extra) 100; stroke-dashoffset: calc(var(--base) * -1); }
.js .h3d .ui-ring__arc--base { animation: ringIn 1.2s var(--ease-out) 1.2s both; }
.js .h3d .ui-ring__arc--extra { animation: ringIn 1.4s var(--ease-out) 1.7s both; }
@keyframes ringIn { from { stroke-dasharray: 0 100; } }
.ui-ring__label { display: grid; justify-items: center; line-height: 1; }
.ui-ring__label strong { font-size: calc(var(--w) * .27); font-weight: 600; letter-spacing: -.06em; }
.ui-ring__label span { margin-top: 4px; color: var(--text-3); font-weight: 500; font-size: .9em; }
.ui-legend { display: flex; justify-content: center; gap: 12px; color: var(--text-3); font-size: .82em; }
.ui-legend span { display: inline-flex; align-items: center; gap: 5px; }
.ui-legend i { width: 10px; height: 4px; border-radius: 2px; background: #C9D8F5; }
.ui-legend i.is-extra { background: var(--blue-600); }
.ui-card { display: flex; justify-content: space-between; align-items: center; padding: 10px 12px; border-radius: 16px; background: #F5F5F7; margin-top: auto; }
.ui-card small { display: block; color: var(--text-3); font-size: .85em; }
.ui-card strong { font-size: 1.9em; font-weight: 600; letter-spacing: -.04em; color: var(--promo-500); line-height: 1.05; }
.ui-card__go { display: grid; place-items: center; width: 2.2em; height: 2.2em; border-radius: 50%; background: var(--promo-500); color: #fff; }
.ui-card__go .i { width: 1em; height: 1em; }
.ui-apps { display: flex; justify-content: space-between; }
.ui-apps i { display: grid; place-items: center; width: 2.3em; height: 2.3em; border-radius: 30%; background: #F5F5F7; color: var(--text); }
.ui-apps .i { width: 1.15em; height: 1.15em; }

/* Etiquetas que flotan alrededor, cada una a otra profundidad */
.float-tag {
  position: absolute; display: inline-flex; align-items: center; gap: 8px; white-space: nowrap;
  padding: 10px 16px 10px 12px; border-radius: 99px; font-size: 14px; font-weight: 500;
  background: rgba(255, 255, 255, .9); color: var(--text);
  box-shadow: 0 1px 0 rgba(0, 0, 0, .04), 0 18px 40px rgba(0, 0, 0, .1), 0 0 0 1px rgba(0, 0, 0, .05);
  -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
  animation: tagIn .9s var(--ease-out) both, bob 6s ease-in-out infinite;
}
.float-tag .i { width: 18px; height: 18px; color: var(--blue-600); }
.float-tag--1 { left: -62%; top: 14%; transform: translateZ(110px); animation-delay: 1.3s, -1s; }
.float-tag--1 .i { color: var(--promo-500); }
.float-tag--2 { right: -58%; top: 30%; transform: translateZ(70px); animation-delay: 1.45s, -3s; }
.float-tag--3 { left: -54%; top: 60%; transform: translateZ(60px); animation-delay: 1.6s, -2s; }
.float-tag--4 { right: -60%; top: 72%; transform: translateZ(130px); animation-delay: 1.75s, -4s; }
.float-tag--4 .i { color: var(--mint-400); }
@keyframes tagIn { from { opacity: 0; scale: .7; } }
@keyframes bob { 0%, 100% { translate: 0 0; } 50% { translate: 0 -8px; } }

/* ---------- Historia con scroll ---------- */
.story { --sp: 0; position: relative; height: 420vh; background: var(--bg-alt); }
.story__sticky { position: sticky; top: 0; height: 100vh; height: 100dvh; display: grid; align-items: center; overflow: hidden; }
.story__grid { display: grid; grid-template-columns: 1fr 1fr; gap: clamp(32px, 6vw, 96px); align-items: center; }
.story__copy { display: grid; gap: 22px; align-content: center; }
.story__steps { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.story__step { display: flex; gap: 16px; padding: 14px 0; opacity: .32; transition: opacity .5s var(--ease-out); }
.story__step h3 { font-size: clamp(20px, 2vw, 24px); }
.story__step p { color: var(--text-2); max-height: 0; overflow: hidden; opacity: 0; transition: max-height .6s var(--ease-out), opacity .4s, margin .6s; }
.story__step.is-active { opacity: 1; }
.story__step.is-active p { max-height: 8em; opacity: 1; margin-top: 6px; }
.story__n { font-variant-numeric: tabular-nums; font-weight: 600; color: var(--blue-600); font-size: 15px; padding-top: 4px; }
.story__bar { height: 3px; border-radius: 3px; background: rgba(0, 0, 0, .08); overflow: hidden; max-width: 360px; }
.story__bar i { display: block; height: 100%; background: var(--text); transform-origin: left; transform: scaleX(var(--sp)); }

.story__stage { perspective: 1400px; display: grid; place-items: center; }
.story__rig {
  transform-style: preserve-3d;
  transform: rotateY(calc(-18deg + var(--sp) * 36deg)) rotateX(calc(6deg - var(--sp) * 6deg));
  transition: transform .4s var(--ease-out);
}
.scr { position: absolute; inset: calc(var(--w) * .16) calc(var(--w) * .07) calc(var(--w) * .07); display: flex; flex-direction: column; gap: calc(var(--w) * .04); opacity: 0; transform: translateY(14px) scale(.98); transition: opacity .45s var(--ease-out), transform .55s var(--ease-out); }
.scr.is-on { opacity: 1; transform: none; }
.scr__app { font-weight: 600; font-size: 1.15em; letter-spacing: -.02em; }
.scr__hint { color: var(--text-3); font-size: .85em; text-align: center; margin-top: auto; }
.scr__ok { display: inline-flex; align-items: center; justify-content: center; gap: 6px; font-weight: 600; color: #0A7D58; }
.scr__ok i { width: 8px; height: 8px; border-radius: 50%; background: #14C48A; }
.sms { max-width: 78%; padding: 8px 12px; border-radius: 18px; line-height: 1.3; }
.sms--out { align-self: flex-end; background: var(--blue-600); color: #fff; border-bottom-right-radius: 6px; }
.sms--in { align-self: flex-start; background: #ECECF0; border-bottom-left-radius: 6px; }
.sms__dots { display: inline-flex; gap: 3px; }
.sms__dots i { width: 6px; height: 6px; border-radius: 50%; background: #9A9AA0; animation: dot 1.2s infinite; }
.sms__dots i:nth-child(2) { animation-delay: .15s; } .sms__dots i:nth-child(3) { animation-delay: .3s; }
@keyframes dot { 0%, 60%, 100% { opacity: .3; } 30% { opacity: 1; } }
.scr.is-on .sms--late { animation: smsIn .5s var(--ease-out) .9s both; }
@keyframes smsIn { from { opacity: 0; transform: translateY(8px) scale(.96); } }
.qr { position: relative; width: 78%; aspect-ratio: 1; margin: 6% auto 0; padding: 8%; border-radius: 18px; background: #fff; box-shadow: 0 0 0 1px var(--line), 0 10px 26px rgba(0, 0, 0, .06); overflow: hidden; }
.qr svg { width: 100%; height: 100%; }
.qr__scan { position: absolute; left: 0; right: 0; top: 0; height: 22%; background: linear-gradient(180deg, transparent, rgba(11, 92, 230, .18)); border-bottom: 2px solid var(--blue-600); animation: qrScan 2.2s ease-in-out infinite; }
@keyframes qrScan { 0%, 100% { transform: translateY(-20%); } 50% { transform: translateY(380%); } }
.ui-ring--story .ui-ring__arc--base { stroke-dasharray: calc(var(--base) * min(1, var(--fill, 0) * 2)) 100; }
.ui-ring--story .ui-ring__arc--extra { stroke-dasharray: calc(var(--extra) * max(0, var(--fill, 0) * 2 - 1)) 100; }
.countries { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.countries li { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 14px; background: #F5F5F7; font-weight: 500; }
.countries b { display: grid; place-items: center; width: 2.1em; height: 2.1em; border-radius: 50%; background: var(--text); color: #fff; font-size: .8em; }
.countries span { margin-left: auto; color: #0A7D58; font-size: .85em; }
.ui-apps--grid { margin-top: 4px; }

/* ---------- Móvil ---------- */
@media (max-width: 920px) {
  .h3d__stage { height: calc(min(300px, 64vw) * 2.05 + 120px); }
  .float-tag { font-size: 12.5px; padding: 8px 12px 8px 10px; }
  .float-tag .i { width: 15px; height: 15px; }
  .float-tag--1 { left: -22%; top: 22%; }
  .float-tag--2 { right: -20%; top: 34%; }
  .float-tag--3 { left: -20%; top: 60%; }
  .float-tag--4 { right: -22%; top: 80%; }

  .story { height: 400vh; }
  .story__grid { grid-template-columns: 1fr; gap: 12px; align-content: center; height: 100%; padding-block: calc(var(--header-h) + 8px) 88px; }
  .story__stage { order: -1; }
  .phone--sm { --w: min(178px, 44vw, 22dvh); }
  .story__copy { gap: 10px; }
  .story__copy .eyebrow, .story__copy .h2 { display: none; }
  .story__step { display: none; padding: 0; }
  .story__step.is-active { display: flex; animation: stepIn .5s var(--ease-out); }
  .story__bar { margin-inline: auto; width: 60%; }
  @keyframes stepIn { from { opacity: 0; transform: translateY(10px); } }
}
@media (max-width: 420px) {
  .h3d__title { font-size: clamp(40px, 12.4vw, 54px); }
  .float-tag--3, .float-tag--4 { display: none; }
}

/* ---------- Reducir movimiento ---------- */
@media (prefers-reduced-motion: reduce) {
  .h3d__rig, .story__rig { transform: none !important; animation: none; }
  .phone, .float-tag { animation: none; }
  .js .h3d__line, .js .h3d__sub, .js .h3d__ctas, .js .h3d .hero-pill { opacity: 1; transform: none; filter: none; animation: none; }
  .story { height: auto; }
  .story__sticky { position: static; height: auto; padding-block: var(--section-y); }
  .story__step { opacity: 1; display: flex; }
  .story__step p { max-height: none; opacity: 1; }
  .story__stage, .story__bar { display: none; }
}

/* Filas de información dentro de la pantalla */
.ui-row { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 8px 2px; border-bottom: 1px solid #EFEFF2; font-size: .9em; }
.ui-row span { display: inline-flex; align-items: center; gap: 6px; color: var(--text-2); }
.ui-row .i { width: 1.1em; height: 1.1em; color: var(--blue-600); }
.ui-row b { font-weight: 600; }
.scr .ui-row { margin-top: auto; }
