/* momentos.css — la sección central: sub-nav pegajosa, pila de seis paneles
 * que se encaballan y el teléfono con la conversación que crece al scroll.
 *
 * Cómo se coordina sin JS: cada panel publica su avance como línea de tiempo
 * con nombre (--m1 … --m6). El panel de abajo se hunde con la entrada del
 * siguiente, y cada burbuja del teléfono aparece con la entrada de su panel.
 * `timeline-scope` en la sección es lo que deja que el teléfono, que vive en
 * otra columna, lea esas líneas de tiempo.
 */

.momentos {
  padding: 40px 0 120px;
  timeline-scope: --m1, --m2, --m3, --m4, --m5, --m6;
}

/* ── Sub-nav pegajosa ────────────────────────────────────────────────────── */

.subnav {
  position: sticky;
  top: 0;
  z-index: 45;
  background: rgb(251 251 253 / 0.96);
  border-bottom: 1px solid var(--linea);
  transition: box-shadow 250ms;
}
.subnav.is-pegada { box-shadow: 0 8px 24px -18px rgb(28 29 34 / 0.4); }

.subnav__fila {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 64px;
}
.subnav__lista {
  display: flex;
  gap: 2px;
  margin: 0;
  padding: 0;
  list-style: none;
  overflow-x: auto;
  scrollbar-width: none;
  height: 100%;
}
.subnav__lista::-webkit-scrollbar { display: none; }
.subnav__lista a {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 100%;
  padding: 0 12px;
  white-space: nowrap;
  color: var(--tinta-3);
  font-weight: 600;
  font-size: 0.93rem;
  transition: color 200ms;
}
.subnav__lista a::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--c); opacity: 0.45; transition: opacity 200ms; }
.subnav__lista a::after {
  content: "";
  position: absolute;
  left: 12px; right: 12px; bottom: -1px;
  height: 2px;
  background: var(--c);
  transform: scaleX(0);
  transform-origin: 0 50%;
  transition: transform 260ms cubic-bezier(0.22, 1, 0.36, 1);
}
.subnav__lista a.is-activa { color: var(--tinta); }
.subnav__lista a.is-activa::before { opacity: 1; }
.subnav__lista a.is-activa::after { transform: scaleX(1); }
.subnav__fila .boton { margin-left: auto; min-height: 40px; padding-inline: 16px; font-size: 0.93rem; flex: 0 0 auto; }

/* ── Escena ──────────────────────────────────────────────────────────────── */

.momentos__intro { padding: 72px 0 40px; }

.escena {
  display: grid;
  grid-template-columns: minmax(0, 7fr) minmax(0, 5fr);
  gap: 40px;
  align-items: start;
}

.pila { display: grid; gap: 40px; }

.panel {
  --i: 0;
  position: sticky;
  top: calc(64px + 24px + var(--i) * 16px);
  border-radius: var(--r-tarjeta);
  background: var(--superficie);
  border: 1px solid var(--linea);
  border-top: 6px solid var(--c);
  box-shadow: 0 24px 50px -30px rgb(28 29 34 / 0.35);
  padding: 26px 28px 28px;
  transform-origin: 50% 0;
  transform: scale(calc(1 - var(--hundido) * 0.045)) translateY(calc(var(--hundido) * -6px));
  will-change: transform;
}
.panel:nth-child(1) { --i: 0; view-timeline: --m1 block; }
.panel:nth-child(2) { --i: 1; view-timeline: --m2 block; }
.panel:nth-child(3) { --i: 2; view-timeline: --m3 block; }
.panel:nth-child(4) { --i: 3; view-timeline: --m4 block; }
.panel:nth-child(5) { --i: 4; view-timeline: --m5 block; }
.panel:nth-child(6) { --i: 5; view-timeline: --m6 block; }

/* Cuánto se ha hundido cada panel: un escalón por cada panel que lo tapa. */
@property --hundido { syntax: "<number>"; inherits: false; initial-value: 0; }

@keyframes hunde-1 { from { --hundido: 0; } to { --hundido: 1; } }
@keyframes hunde-2 { from { --hundido: 1; } to { --hundido: 2; } }
@keyframes hunde-3 { from { --hundido: 2; } to { --hundido: 3; } }
@keyframes hunde-4 { from { --hundido: 3; } to { --hundido: 4; } }
@keyframes hunde-5 { from { --hundido: 4; } to { --hundido: 5; } }

@supports (animation-timeline: view()) {
  .panel { animation-timing-function: linear; animation-fill-mode: forwards; animation-range: entry 0% entry 100%; }
  .panel:nth-child(1) { animation-name: hunde-1, hunde-2, hunde-3, hunde-4, hunde-5; animation-timeline: --m2, --m3, --m4, --m5, --m6; }
  .panel:nth-child(2) { animation-name: hunde-1, hunde-2, hunde-3, hunde-4; animation-timeline: --m3, --m4, --m5, --m6; }
  .panel:nth-child(3) { animation-name: hunde-1, hunde-2, hunde-3; animation-timeline: --m4, --m5, --m6; }
  .panel:nth-child(4) { animation-name: hunde-1, hunde-2; animation-timeline: --m5, --m6; }
  .panel:nth-child(5) { animation-name: hunde-1; animation-timeline: --m6; }
}

.panel__cabeza { display: flex; align-items: baseline; gap: 14px; flex-wrap: wrap; }
.panel__num { color: var(--c); font-weight: 800; font-size: 0.95rem; }
.panel__cuando {
  margin-top: 8px;
  color: var(--tinta-2);
  font-size: 1.02rem;
}
.panel__cuando b { color: var(--tinta); }

.panel__captura {
  margin: 20px 0 0;
  border-radius: 12px;
  overflow: clip;
  border: 1px solid var(--linea);
  background: var(--superficie-2);
}
.panel__captura img { width: 100%; }

.panel__dato {
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px dashed var(--linea-fuerte);
  color: var(--tinta-2);
  font-size: 0.95rem;
}
.panel__dato b { color: var(--c); }

/* ── El teléfono ─────────────────────────────────────────────────────────── */

.telefono {
  position: sticky;
  top: calc(64px + 24px);
  margin: 0 auto;
  width: min(100%, 360px);
  height: min(700px, calc(100svh - 64px - 48px));
  border-radius: 40px;
  background: #101114;
  padding: 12px;
  box-shadow: 0 40px 80px -40px rgb(28 29 34 / 0.6), inset 0 0 0 2px #2a2c33;
}
.telefono__pantalla {
  height: 100%;
  border-radius: 30px;
  background: #efeae2;
  overflow: clip;
  display: flex;
  flex-direction: column;
}
.chat__cabeza {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 26px 16px 12px;
  background: #075e54;
  color: white;
}
.chat__avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: var(--acaba);
  display: grid;
  place-items: center;
  font-weight: 800;
  color: #063d36;
}
.chat__cabeza strong { display: block; font-size: 0.95rem; }
.chat__cabeza small { display: block; opacity: 0.8; font-size: 0.75rem; }

.chat {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  gap: 0;
  padding: 12px 12px 16px;
  overflow: clip;
}

.chat__fecha {
  align-self: center;
  margin-top: 10px;
  padding: 3px 10px;
  border-radius: 8px;
  background: rgb(255 255 255 / 0.85);
  color: var(--tinta-2);
  font-size: 0.72rem;
  font-weight: 600;
}
.chat__msj {
  position: relative;
  margin-top: 8px;
  max-width: 88%;
  padding: 8px 10px 6px;
  border-radius: 10px;
  background: white;
  font-size: 0.84rem;
  line-height: 1.35;
  box-shadow: 0 1px 1px rgb(0 0 0 / 0.08);
}
.chat__msj--sale { align-self: flex-end; background: #dcf8c6; border-bottom-right-radius: 2px; }
.chat__msj--entra { align-self: flex-start; border-bottom-left-radius: 2px; }
.chat__msj small {
  display: block;
  margin-bottom: 3px;
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--c, var(--acento));
}
.chat__msj time { display: block; margin-top: 3px; text-align: right; font-size: 0.66rem; color: var(--tinta-3); }
.chat__msj a { color: #0b57d0; text-decoration: underline; }

/* Cada burbuja crece con la entrada de su panel. Los hijos empiezan sin alto
 * para que el chat no reserve espacio a lo que todavía no ha pasado. */
@keyframes llega {
  from { opacity: 0; max-height: 0; margin-top: 0; padding-top: 0; padding-bottom: 0; translate: 0 10px; }
  30%  { opacity: 0; }
  to   { opacity: 1; max-height: 260px; translate: none; }
}
@supports (animation-timeline: view()) {
  .chat [data-m] { animation: llega linear both; overflow: clip; }
  .chat [data-m="1"] { animation-timeline: --m1; animation-range: entry 35% entry 95%; }
  .chat [data-m="2"] { animation-timeline: --m2; animation-range: entry 35% entry 95%; }
  .chat [data-m="3"] { animation-timeline: --m3; animation-range: entry 35% entry 95%; }
  .chat [data-m="4"] { animation-timeline: --m4; animation-range: entry 35% entry 95%; }
  .chat [data-m="5"] { animation-timeline: --m5; animation-range: entry 35% entry 95%; }
  .chat [data-m="6"] { animation-timeline: --m6; animation-range: entry 35% entry 95%; }
  .chat [data-m][data-tarde] { animation-range: entry 70% entry 130%; }
}

.chat__pie {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px 14px;
  background: #f0f0f0;
}
.chat__pie span {
  flex: 1;
  height: 34px;
  border-radius: 17px;
  background: white;
  color: var(--tinta-3);
  font-size: 0.8rem;
  display: flex;
  align-items: center;
  padding: 0 14px;
}
.chat__pie i { width: 34px; height: 34px; border-radius: 50%; background: #075e54; display: grid; place-items: center; }
.chat__pie svg { width: 16px; height: 16px; fill: white; }

/* ── Móvil: los paneles van uno tras otro y el teléfono se esconde ──────── */

@media (max-width: 900px) {
  .subnav__fila .boton { display: none; }
  .escena { grid-template-columns: 1fr; }
  .panel { position: static; transform: none !important; animation: none !important; padding: 20px 18px 22px; }
  .pila { gap: 20px; }
  .telefono { display: none; }
  .momentos__intro { padding-top: 48px; }
}

@media (prefers-reduced-motion: reduce) {
  .panel { animation: none !important; transform: none !important; }
  .chat [data-m] { animation: none !important; opacity: 1 !important; max-height: none !important; }
}
