/* ==========================================================================
   SCENE 04: "EL NEGOCIO ALREDEDOR DEL SISTEMA"
   iPhone con Core Logic como centro de gravedad + 4 satélites operativos
   (Ventas / Estadísticas / Gastos / Compromisos). Columna editorial a la
   izquierda que convive con la escena; tres estados de scroll: problema →
   sistema → control.
   ========================================================================== */

.cls {
  position: relative;
  background: #060604;
  z-index: 3;
}

/* ---------- Stage (sticky scrub) ---------- */
.cls__wrap {
  position: relative;
  height: clamp(780px, 175svh, 1550px);
}
.cls__stage {
  position: sticky;
  top: 0;
  height: 100svh;
  min-height: 640px;
  display: grid;
  grid-template-columns: minmax(230px, 30%) 1fr;
  align-items: center;
  gap: clamp(20px, 3vw, 40px);
  padding: 0 clamp(24px, 5vw, 64px);
  overflow: hidden;
}

/* ---------- Intro editorial (columna izquierda) ---------- */
.cls__intro {
  position: relative;
  z-index: 6;
  max-width: 40ch;
  text-align: left;
}
.cls__title {
  margin: 0;
  font-family: var(--font-clash, 'Clash Display', sans-serif);
  text-transform: uppercase;
  font-weight: 500;
  font-size: clamp(1.9rem, 1.3rem + 2.6vw, 3.1rem);
  line-height: 1;
  letter-spacing: -.02em;
  color: rgba(243, 238, 230, .82);
}
.cls__title-mark {
  display: block;
  margin-bottom: 6px;
  color: #F3EEE6;
}
.cls__title-control {
  color: #00B37A;
}
.cls__sub {
  margin: 26px 0 0 0;
  max-width: 34ch;
  font-family: var(--font-cabinet, 'Cabinet Grotesk', sans-serif);
  font-size: clamp(.95rem, .89rem + .2vw, 1.05rem);
  line-height: 1.65;
  color: rgba(243, 238, 230, .55);
}
.cls__value {
  margin: 10px 0 0 0;
  max-width: 30ch;
  font-family: var(--font-cabinet, 'Cabinet Grotesk', sans-serif);
  font-weight: 500;
  font-size: clamp(1rem, .93rem + .25vw, 1.14rem);
  line-height: 1.42;
  letter-spacing: -.008em;
  color: #F3EEE6;
}

/* ---------- Escena (columna derecha) ---------- */
.cls__scene {
  position: relative;
  width: 100%;
  height: min(86svh, 760px);
}

.cls__glow {
  position: absolute;
  left: 58%;
  top: 62%;
  width: 30%;
  aspect-ratio: 1 / 1;
  transform: translate(-50%, -50%);
  background: radial-gradient(closest-side, rgba(243, 238, 230, .05), rgba(243, 238, 230, 0) 70%);
  filter: blur(22px);
  z-index: 1;
  pointer-events: none;
}

/* ---------- iPhone ----------
   .cls__phone solo centra (left/top/transform); GSAP anima .cls__phone-anim,
   un hijo sin transform propio, para no pisar el translate(-50%,-50%) del centrado. */
.cls__phone {
  position: absolute;
  left: 58%;
  top: 50%;
  width: clamp(240px, 24vw, 322px);
  aspect-ratio: 9 / 19.2;
  transform: translate(-50%, -50%);
  z-index: 5;
}
.cls__phone::after {
  content: '';
  position: absolute;
  left: 50%;
  bottom: -4%;
  width: 74%;
  height: 10%;
  background: radial-gradient(closest-side, rgba(0, 0, 0, .5), rgba(0, 0, 0, 0) 75%);
  transform: translateX(-50%);
  filter: blur(10px);
  z-index: -1;
  pointer-events: none;
}
.cls__phone-anim {
  width: 100%;
  height: 100%;
  filter:
    drop-shadow(0 18px 22px rgba(0, 0, 0, .38))
    drop-shadow(0 60px 70px rgba(0, 0, 0, .32));
}
/* Chasis: solo fondo/forma del bisel. No clipea contenido — la máscara
   real del display vive en .cls__phone-screen, una caja independiente. */
.cls__phone-frame {
  position: relative;
  width: 100%;
  height: 100%;
  border-radius: 15% / 7.2%;
  background: linear-gradient(165deg, #3c3c3c 0%, #1c1c1c 13%, #0a0a0a 50%, #181818 87%, #363636 100%);
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, .07),
    inset 0 0 14px rgba(0, 0, 0, .65),
    0 0 0 1px rgba(0, 0, 0, .55),
    0 0 0 2.5px rgba(255, 255, 255, .035);
}
/* Brillo del metal: pinta antes que .cls__phone-screen en el DOM y sin
   z-index propio, así queda siempre debajo de ella (solo visible en el
   bisel) y nunca cruza el display. */
.cls__phone-frame::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: linear-gradient(115deg, rgba(255, 255, 255, .09) 0%, rgba(255, 255, 255, 0) 16%);
  opacity: .55;
  pointer-events: none;
}
/* Única máscara real del display: top/bottom fijan el alto (en vez de
   aspect-ratio) para minimizar bisel superior e inferior. Las 5 capturas
   de la secuencia se ajustan dentro vía object-fit: cover — deben
   exportarse todas desde el mismo viewport/aspect ratio. */
.cls__phone-screen {
  position: absolute;
  left: 50%;
  top: 1.9%;
  bottom: 1.7%;
  transform: translateX(-50%);
  width: 93.2%;
  border-radius: 10% / 4.9%;
  overflow: hidden;
  background: #050505;
  /* Micro-gap oscuro + filo metálico entre vidrio y bisel: separa visualmente
     pantalla / vidrio / marco en vez de fundirlos en un solo bloque. */
  box-shadow:
    inset 0 0 0 1px rgba(0, 0, 0, .9),
    inset 0 0 0 2px rgba(255, 255, 255, .035);
}
.cls__phone-shot {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  transform: translateY(7px);
  transition: opacity .4s ease, transform .4s ease;
  z-index: 1;
}
.cls__phone-shot.is-active {
  opacity: 1;
  transform: translateY(0);
  z-index: 2;
}
.cls__phone-shot.is-leaving {
  opacity: 0;
  transform: translateY(-7px);
  z-index: 1;
}
.cls__phone-glass {
  position: absolute;
  inset: 0;
  background:
    linear-gradient(115deg, rgba(255, 255, 255, .07) 0%, rgba(255, 255, 255, 0) 20%),
    radial-gradient(120% 55% at 50% -8%, rgba(255, 255, 255, .05), rgba(255, 255, 255, 0) 55%),
    radial-gradient(140% 80% at 50% 112%, rgba(0, 0, 0, .2), rgba(0, 0, 0, 0) 60%);
  pointer-events: none;
}
.cls__phone-notch {
  position: absolute;
  top: 2.8%;
  left: 50%;
  transform: translateX(-50%);
  width: 29%;
  aspect-ratio: 3.3 / 1;
  min-width: 44px;
  background: linear-gradient(165deg, #0d0d0d 0%, #000 55%, #0c0c0c 100%);
  border-radius: 999px;
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, .06),
    inset 0 1px 1px rgba(255, 255, 255, .08),
    0 1px 2px rgba(0, 0, 0, .5);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding-right: 13%;
}
.cls__phone-cam {
  position: relative;
  width: 17%;
  aspect-ratio: 1;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #3a3a42, #050505 68%);
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, .05),
    inset 0 0 2px rgba(255, 255, 255, .12);
}
.cls__phone-cam::after {
  content: '';
  position: absolute;
  top: 24%;
  left: 24%;
  width: 24%;
  height: 24%;
  border-radius: 50%;
  background: rgba(255, 255, 255, .3);
  filter: blur(.4px);
}

/* ---------- Satélites ----------
   .cls__sat: SOLO posicionamiento + tamaño; GSAP anima x/y/rotate/scale/opacity
   sobre este elemento durante el scroll (entrada/scatter/asentamiento).
   .cls__sat-inner: la card visual COMPLETA (fondo, borde, sombra, radius,
   ícono + label) — es el objetivo real de la interacción (hover/proximidad
   en desktop, scroll/tap en mobile, por rAF), así nunca compite con la
   tween de scroll del padre. */
.cls__sat {
  position: absolute;
  z-index: 4;
  width: clamp(120px, 12vw, 175px);
  perspective: 900px;
}
.cls__sat-inner {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: clamp(8px, 1.4vw, 14px);
  padding: clamp(12px, 1.8vw, 18px);
  border-radius: 18px;
  overflow: hidden;
  background: #0c0c0b;
  border: 1px solid rgba(243, 238, 230, .08);
  box-shadow: 0 14px 26px rgba(0, 0, 0, .3);
  will-change: transform;
}
.cls__sat-icon {
  position: relative;
  width: 58%;
  aspect-ratio: 1 / 1;
  flex-shrink: 0;
}
.cls__sat-icon img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
}
.cls__sat-label {
  display: block;
  font-family: var(--font-cabinet, 'Cabinet Grotesk', sans-serif);
  font-size: .68rem;
  font-weight: 500;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: rgba(243, 238, 230, .78);
}

.cls__sat--ventas {
  left: 1%;
  top: 15%;
  width: clamp(126px, 12.5vw, 182px);
}
.cls__sat--estadisticas {
  left: 6%;
  top: 63%;
  width: clamp(112px, 11vw, 160px);
}
.cls__sat--gastos {
  right: 0%;
  top: 12%;
  width: clamp(150px, 15.5vw, 224px);
  z-index: 5;
}
.cls__sat--compromisos {
  right: 5%;
  top: 61%;
  width: clamp(118px, 12vw, 168px);
}

/* ---------- Cierre (CTA, dentro de la columna editorial) ---------- */
.cls__close {
  margin-top: clamp(28px, 4vh, 44px);
  opacity: 0;
}
.cls__cta {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 44px;
  padding: 0 22px;
  border-radius: 999px;
  font-family: var(--font-cabinet, 'Cabinet Grotesk', sans-serif);
  font-weight: 500;
  font-size: .92rem;
  letter-spacing: -.005em;
  color: #070707;
  background: #F3EEE6;
  text-decoration: none;
  border: 1px solid transparent;
  transition: transform .24s ease, background-color .24s ease, box-shadow .24s ease;
}
.cls__cta-arrow {
  transition: transform .24s ease;
}
.cls__cta:hover {
  background: var(--accent-copper, #C9784C);
  color: #F3EEE6;
  transform: translateY(-2px);
  box-shadow: 0 10px 22px rgba(0, 0, 0, .28);
}
.cls__cta:hover .cls__cta-arrow { transform: translateX(4px); }
.cls__cta:active { transform: translateY(0); }
.cls__cta:focus-visible {
  outline: 2px solid var(--accent-copper, #C9784C);
  outline-offset: 3px;
}

/* ==========================================================================
   Responsive — 820px breakpoint del sitio
   ========================================================================== */
@media (max-width: 820px) {
  .cls__wrap { height: clamp(760px, 168svh, 1100px); }
  .cls__stage {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr;
    padding: clamp(56px, 9vh, 72px) 8vw clamp(24px, 4vh, 32px) 8vw;
    min-height: 660px;
    gap: clamp(16px, 3vh, 24px);
  }

  .cls__intro { max-width: none; text-align: center; }
  .cls__title { margin-left: auto; margin-right: auto; }
  .cls__sub { margin-left: auto; margin-right: auto; }
  .cls__close { text-align: center; }

  .cls__scene { width: 100%; height: 100%; min-height: 420px; }

  .cls__glow { left: 50%; width: 78%; }

  .cls__phone { left: 50%; width: clamp(180px, 46vw, 224px); }

  .cls__sat { width: clamp(90px, 25vw, 108px); }
  .cls__sat-inner { padding: clamp(10px, 3vw, 14px); gap: 6px; }
  .cls__sat-label { font-size: .62rem; }

  /* pares: ventas + gastos arriba, estadísticas + compromisos abajo */
  .cls__sat--ventas { left: 0%; top: 4%; }
  .cls__sat--gastos { right: 0%; top: 4%; }
  .cls__sat--estadisticas { left: 2%; bottom: 4%; top: auto; }
  .cls__sat--compromisos { right: 2%; bottom: 4%; top: auto; }
}

@media (prefers-reduced-motion: reduce) {
  .cls__phone, .cls__sat, .cls__close { transition: none; }
}
