/* ==========================================================================
   Relato guiado por el scroll: una consulta, de principio a fin
   ========================================================================== */

/* ---------- Relato: una consulta, de principio a fin ---------- */

.story__head {
  max-width: 640px;
}

.story__layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
}

.story__stage {
  position: sticky;
  top: calc(var(--header-h) + 8px);
  z-index: 2;
  display: grid;
  place-items: center;
  height: min(54vh, 460px);
  padding-bottom: 30px;
  background: linear-gradient(180deg, var(--cream-50) 88%, rgba(246, 245, 240, 0));
}

.story__steps {
  padding: 4vh 0 10vh;
}

.story__step {
  min-height: 52vh;
  padding: 1.5rem 0;
  opacity: 0.35;
  transition: opacity 0.5s ease;
}

.story__step.is-active,
html:not(.js) .story__step {
  opacity: 1;
}

@media (min-width: 960px) {
  .story__layout {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: clamp(3rem, 6vw, 7rem);
  }

  .story__stage {
    grid-column: 2;
    grid-row: 1;
    top: calc(var(--header-h) + 5vh);
    height: min(calc(100vh - var(--header-h) - 10vh), 700px);
    background: none;
  }

  .story__steps {
    grid-column: 1;
    grid-row: 1;
    padding: 10vh 0 20vh;
  }

  .story__step {
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-height: 68vh;
    padding: 0;
  }
}

.story__time {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1rem;
  font-size: var(--fs-xs);
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.story__time span {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border: 1px solid var(--line-light-strong);
  border-radius: 50%;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0;
  color: var(--ink-900);
  transition: background-color 0.4s ease, border-color 0.4s ease;
}

.story__step.is-active .story__time span {
  border-color: var(--amber-500);
  background: var(--amber-500);
}

.story__title {
  font-size: clamp(1.5rem, 1.1rem + 1.6vw, 2.375rem);
  letter-spacing: -0.035em;
}

.story__text {
  max-width: 30rem;
  margin-top: 0.85rem;
  font-size: var(--fs-md);
  color: var(--text-muted);
}

/* Dispositivo */

.device {
  --pad: 10px;
  position: relative;
  width: min(100%, 320px);
  height: 100%;
  padding: var(--pad);
  border-radius: 40px;
  background: var(--ink-900);
  box-shadow:
    inset 0 0 0 1px rgba(246, 245, 240, 0.08),
    0 50px 90px -40px rgba(10, 18, 33, 0.6),
    0 0 0 8px rgba(15, 26, 44, 0.04);
  transition:
    width 0.9s var(--ease-in-out),
    border-radius 0.9s var(--ease-in-out);
}

/* En el paso final el teléfono se transforma en el panel del negocio. */
.device[data-state="5"] {
  width: min(100%, 470px);
  border-radius: 26px;
}

.device__screen {
  position: absolute;
  inset: var(--pad);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-radius: 30px;
  background: var(--ink-850);
  opacity: 0;
  visibility: hidden;
  transform: scale(0.97);
  transition:
    opacity 0.6s ease,
    transform 0.6s var(--ease-out),
    visibility 0s linear 0.6s,
    border-radius 0.9s var(--ease-in-out);
}

.device[data-state="1"] .device__screen--chat,
.device[data-state="2"] .device__screen--chat,
.device[data-state="3"] .device__screen--chat,
.device[data-state="4"] .device__screen--lock,
.device[data-state="5"] .device__screen--panel {
  opacity: 1;
  visibility: visible;
  transform: none;
  transition-delay: 0s;
}

.device[data-state="5"] .device__screen {
  border-radius: 18px;
}

.device__progress {
  position: absolute;
  left: 50%;
  bottom: -26px;
  display: flex;
  gap: 6px;
  transform: translateX(-50%);
}

.device__progress span {
  width: 20px;
  height: 3px;
  border-radius: 3px;
  background: var(--line-light-strong);
  transition: background-color 0.4s ease;
}

.device[data-state="1"] .device__progress span:nth-child(-n + 1),
.device[data-state="2"] .device__progress span:nth-child(-n + 2),
.device[data-state="3"] .device__progress span:nth-child(-n + 3),
.device[data-state="4"] .device__progress span:nth-child(-n + 4),
.device[data-state="5"] .device__progress span {
  background: var(--amber-500);
}

/* Pantalla de chat */

.device__bar {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 1.1rem 1rem 0.8rem;
  border-bottom: 1px solid var(--line-dark);
}

.device__avatar img {
  width: 34px;
  height: 34px;
  border-radius: 50%;
}

.device__who {
  display: grid;
  line-height: 1.3;
}

.device__who strong {
  font-size: 0.875rem;
  color: var(--text-on-dark);
}

.device__status {
  font-size: 0.6875rem;
  color: var(--text-on-dark-muted);
}

.device__status-typing {
  display: none;
  color: var(--amber-300);
}

.device[data-state="2"] .device__status-online {
  display: none;
}

.device[data-state="2"] .device__status-typing {
  display: inline;
}

.device__tag {
  margin-left: auto;
  padding: 0.15rem 0.55rem;
  border: 1px solid var(--line-dark-strong);
  border-radius: var(--radius-pill);
  font-size: 0.625rem;
  font-weight: 500;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-on-dark-muted);
}

.device__chat {
  display: flex;
  flex: 1;
  flex-direction: column;
  justify-content: flex-end;
  gap: 0.5rem;
  min-height: 0;
  padding: 0.9rem;
  overflow: hidden; /* como en un chat real, lo más viejo queda arriba, fuera de vista */
}

.msg {
  max-width: 86%;
  padding: 0.55rem 0.8rem 0.4rem;
  border-radius: 15px;
  font-size: 0.8125rem;
  line-height: 1.42;
  color: var(--text-on-dark);
}

.msg time {
  display: block;
  margin-top: 0.1rem;
  font-size: 0.625rem;
  text-align: right;
  color: var(--text-on-dark-muted);
}

.msg--in {
  align-self: flex-start;
  border-bottom-left-radius: 5px;
  background: rgba(246, 245, 240, 0.08);
}

.msg--out {
  align-self: flex-end;
  border-bottom-right-radius: 5px;
  background: var(--amber-500);
  color: var(--ink-900);
}

.msg--out time {
  color: rgba(15, 26, 44, 0.62);
}

.device__event {
  align-self: center;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.35rem 0.75rem;
  border: 1px solid rgba(244, 165, 36, 0.3);
  border-radius: var(--radius-pill);
  background: rgba(244, 165, 36, 0.1);
  font-size: 0.6875rem;
  font-weight: 500;
  color: var(--amber-300);
}

.device__event .icon {
  width: 13px;
  height: 13px;
}

/* Aparición de los elementos según el estado. */
.device [data-from="3"],
.device [data-only="2"] {
  display: none;
}

.device[data-state="3"] [data-from="3"] {
  display: block;
  animation: msg-in 0.5s var(--ease-out) both;
}

.device[data-state="3"] .device__event {
  display: inline-flex;
}

.device[data-state="3"] [data-delay="2"] { animation-delay: 0.7s; }
.device[data-state="3"] [data-delay="3"] { animation-delay: 1.3s; }
.device[data-state="3"] [data-delay="4"] { animation-delay: 1.8s; }

.device[data-state="2"] [data-only="2"] {
  display: block;
  animation: msg-in 0.5s var(--ease-out) both;
}

@keyframes msg-in {
  from {
    opacity: 0;
    transform: translate3d(0, 10px, 0) scale(0.98);
  }
}

/* Análisis de la IA */
.device__ai {
  position: relative;
  overflow: hidden;
  padding: 0.85rem;
  border: 1px solid rgba(244, 165, 36, 0.35);
  border-radius: 14px;
  background: rgba(10, 18, 33, 0.7);
}

.device__ai::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, transparent, rgba(244, 165, 36, 0.14) 50%, transparent);
  transform: translateY(-100%);
  animation: ai-scan 1.8s var(--ease-in-out) infinite;
}

.device__ai-title {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin-bottom: 0.6rem;
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--amber-300);
}

.device__ai-title .icon {
  width: 14px;
  height: 14px;
}

.device__ai ul {
  display: grid;
  gap: 0.35rem;
  padding: 0;
  list-style: none;
}

.device__ai li {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  font-size: 0.75rem;
  animation: msg-in 0.4s var(--ease-out) both;
}

.device__ai li:nth-child(2) { animation-delay: 0.25s; }
.device__ai li:nth-child(3) { animation-delay: 0.5s; }
.device__ai li:nth-child(4) { animation-delay: 0.75s; }

.device__ai li span {
  color: var(--text-on-dark-muted);
}

.device__ai li strong {
  font-weight: 600;
  color: var(--text-on-dark);
}

@keyframes ai-scan {
  to {
    transform: translateY(100%);
  }
}

/* Pantalla bloqueada con el recordatorio */
.device__screen--lock {
  align-items: center;
  padding: 3.5rem 1rem 1rem;
  background:
    radial-gradient(260px circle at 50% 110%, rgba(244, 165, 36, 0.35), transparent 70%),
    linear-gradient(180deg, #1b2a45, var(--ink-950));
  color: var(--text-on-dark);
}

.device__clock {
  font-size: 3.75rem;
  font-weight: 300;
  line-height: 1;
  letter-spacing: -0.04em;
}

.device__date {
  margin-top: 0.4rem;
  font-size: 0.8125rem;
  color: var(--text-on-dark-muted);
}

.device__notice {
  width: 100%;
  margin-top: 2.25rem;
  padding: 0.9rem;
  border: 1px solid rgba(246, 245, 240, 0.12);
  border-radius: 18px;
  background: rgba(246, 245, 240, 0.1);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
}

.device[data-state="4"] .device__notice {
  animation: notice-in 0.7s 0.25s var(--ease-out) both;
}

.device__notice-app {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.6875rem;
  color: var(--text-on-dark-muted);
}

.device__notice-app img {
  border-radius: 5px;
}

.device__notice-text {
  margin-top: 0.5rem;
  font-size: 0.8125rem;
  line-height: 1.45;
}

.device__notice-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.45rem;
  margin-top: 0.75rem;
}

.device__notice-actions span {
  padding: 0.45rem;
  border-radius: 10px;
  background: rgba(246, 245, 240, 0.12);
  font-size: 0.75rem;
  font-weight: 600;
  text-align: center;
}

.device__notice-actions span:first-child {
  background: var(--amber-500);
  color: var(--ink-900);
}

@keyframes notice-in {
  from {
    opacity: 0;
    transform: translate3d(0, -24px, 0) scale(0.96);
  }
}

/* Panel del negocio */
.device__screen--panel {
  padding: 1.25rem;
  background: var(--white);
  color: var(--ink-900);
}

.panel__top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding-bottom: 0.9rem;
  border-bottom: 1px solid var(--line-light);
  font-size: 0.9375rem;
}

.panel__live {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.6875rem;
  color: var(--text-muted);
}

.panel__live span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #2fb36d;
  box-shadow: 0 0 0 3px rgba(47, 179, 109, 0.18);
}

.panel__list {
  display: grid;
  min-height: 0;
  overflow: hidden;
  gap: 0.35rem;
  margin-top: 0.75rem;
  padding: 0;
  list-style: none;
}

.panel__list li {
  display: grid;
  grid-template-columns: 3rem minmax(0, 1fr) auto;
  align-items: center;
  gap: 0.6rem;
  padding: 0.65rem 0.7rem;
  border-radius: 10px;
  font-size: 0.75rem;
}

.panel__list time {
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.panel__list span {
  color: var(--text);
}

.panel__list em {
  font-style: normal;
  font-size: 0.6875rem;
  font-weight: 600;
  color: #23905a;
}

.panel__list em.is-muted {
  color: var(--text-muted);
}

.panel__list .is-new {
  background: rgba(244, 165, 36, 0.14);
  box-shadow: inset 3px 0 0 var(--amber-500);
}

.panel__list .is-new em {
  color: var(--amber-700);
}

.device[data-state="5"] .panel__list .is-new {
  animation: msg-in 0.6s 0.6s var(--ease-out) both;
}

.panel__flag {
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
  margin-top: auto;
  padding: 0.8rem 0.9rem;
  border: 1px dashed var(--line-light-strong);
  border-radius: 12px;
  font-size: 0.75rem;
  line-height: 1.4;
  color: var(--text-muted);
}

.panel__flag strong {
  display: block;
  color: var(--ink-900);
}

.panel__flag .icon {
  width: 18px;
  height: 18px;
  color: var(--amber-600);
}
