/* ─────────────────────────────────────────────
   BLOCO 6 — DEMO STEP-BY-STEP
   4 steps verticais à esquerda + mockup sticky à direita.
   Mockup muda conforme scroll passa por cada step.
   Linha vertical conectando steps.
   ───────────────────────────────────────────── */

.demo {
  position: relative;
  background: var(--bg);
  padding: clamp(24px, 3vw, 44px) 0 clamp(80px, 10vw, 140px);
  overflow-x: clip; /* clip não bloqueia sticky descendente, hidden bloqueia */
  isolation: isolate;
}

.demo__head {
  text-align: center;
  margin-bottom: clamp(48px, 6vw, 80px);
}

.demo__eyebrow {
  display: block;
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--purple);
  margin-bottom: 18px;
}

.demo__eyebrow::before {
  content: "● ";
  color: var(--purple);
}

.demo h2 {
  font-family: var(--font-display);
  font-size: clamp(34px, 4.4vw, 64px);
  font-weight: 380;
  font-variation-settings: "opsz" 144, "SOFT" 50;
  line-height: 1.04;
  letter-spacing: -0.025em;
  color: var(--text);
  max-width: 880px;
  margin: 0 auto 14px;
}

.demo h2 .serif-italic {
  background: linear-gradient(120deg, var(--purple) 0%, var(--terracota) 90%);
  -webkit-background-clip: text;
          background-clip: text;
  -webkit-text-fill-color: transparent;
}

.demo__sub {
  font-size: 17px;
  color: var(--text-2);
  max-width: 540px;
  margin: 0 auto;
  line-height: 1.5;
}

/* ─── Layout principal: steps esquerda + mockup sticky direita ─────── */

.demo__grid {
  display: grid;
  grid-template-columns: minmax(0, 0.92fr) minmax(0, 1fr);
  gap: clamp(40px, 6vw, 96px);
  align-items: start;
  position: relative;
}

/* Coluna esquerda — steps stack */
.demo__steps {
  display: flex;
  flex-direction: column;
  gap: clamp(80px, 10vw, 160px);
  position: relative;
  padding: clamp(20px, 4vw, 40px) 0 clamp(20px, 4vw, 40px) clamp(28px, 4vw, 48px);
}

/* Linha ECG vertical conectando steps — batimento cardíaco real */
.demo__ecg {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: 32px;
  transform: translateX(-15px);
  pointer-events: none;
  z-index: 0;
}

.demo__ecg svg {
  width: 100%;
  height: 100%;
  display: block;
  overflow: visible;
}

.demo__ecg .ecg-ghost,
.demo__ecg .ecg-line {
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.demo__ecg .ecg-ghost {
  stroke: rgba(124, 58, 237, 0.16);
}

.demo__ecg .ecg-line {
  stroke: url(#ecgGradient);
  filter: drop-shadow(0 0 6px rgba(124, 58, 237, 0.45));
  /* O JS atualiza --demo-progress (0-100) e o stroke aparece da pct correspondente */
  stroke-dasharray: var(--ecg-len, 1000);
  stroke-dashoffset: calc(var(--ecg-len, 1000) * (1 - var(--demo-progress-d, 0)));
  transition: stroke-dashoffset 240ms linear;
}

.demo-step {
  position: relative;
  scroll-margin-top: 120px;
}

.demo-step__pill {
  position: absolute;
  top: -2px;
  left: calc(-1 * clamp(28px, 4vw, 48px));
  transform: translateX(-50%);
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--bg);
  border: 2px solid rgba(124, 58, 237, 0.25);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 600;
  color: var(--purple);
  z-index: 2;
  transition: background 280ms var(--ease-out), border-color 280ms, color 280ms, box-shadow 280ms, transform 280ms;
}

.demo-step.is-active .demo-step__pill {
  background: var(--purple);
  border-color: var(--purple);
  color: var(--bg);
  transform: translateX(-50%) scale(1.1);
  box-shadow: 0 0 0 6px rgba(124, 58, 237, 0.15), 0 0 22px -2px rgba(124, 58, 237, 0.55);
}

.demo-step__num {
  display: block;
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--text-3);
  margin-bottom: 12px;
  transition: color 280ms;
}

.demo-step.is-active .demo-step__num {
  color: var(--purple);
}

.demo-step h3 {
  font-family: var(--font-display);
  font-size: clamp(24px, 2.6vw, 36px);
  font-weight: 400;
  font-variation-settings: "opsz" 100, "SOFT" 50;
  line-height: 1.1;
  letter-spacing: -0.02em;
  color: var(--text);
  margin: 0 0 16px;
}

.demo-step h3 em {
  font-style: italic;
  font-variation-settings: "opsz" 144, "SOFT" 100, "WONK" 1;
  background: linear-gradient(120deg, var(--purple) 0%, var(--terracota) 90%);
  -webkit-background-clip: text;
          background-clip: text;
  -webkit-text-fill-color: transparent;
}

.demo-step p {
  font-size: 15.5px;
  line-height: 1.55;
  color: var(--text-2);
  margin: 0;
  max-width: 420px;
}

/* Dots (mobile carousel indicator). Escondido no desktop. */
.demo__dots { display: none; }

/* ─── Coluna direita: mockup sticky ─────── */

.demo__mockup-wrap {
  position: sticky;
  top: 100px;
  height: clamp(440px, 56vh, 600px);
  display: flex;
  align-items: center;
  justify-content: center;
}

.demo__mockup {
  position: relative;
  width: 100%;
  height: 100%;
  background: linear-gradient(155deg, #f5f3ee 0%, #faf8f3 100%);
  border-radius: var(--radius-lg);
  border: 1px solid rgba(10, 10, 18, 0.08);
  overflow: hidden;
  box-shadow:
    0 1px 0 0 rgba(255, 255, 255, 0.6) inset,
    0 24px 60px -20px rgba(10, 10, 18, 0.18),
    0 4px 14px -4px rgba(10, 10, 18, 0.08);
}

.demo__scene {
  position: absolute;
  inset: 0;
  padding: clamp(20px, 3vw, 36px);
  display: flex;
  flex-direction: column;
  opacity: 0;
  transform: scale(0.96);
  transition: opacity 600ms var(--ease-out), transform 600ms var(--ease-out);
  pointer-events: none;
}

.demo__scene.is-active {
  opacity: 1;
  transform: scale(1);
  pointer-events: auto;
}

/* Cena 1 — PDF da prova */
.scene-pdf {
  align-items: center;
  justify-content: center;
}

.scene-pdf__card {
  width: 64%;
  max-width: 280px;
  aspect-ratio: 1 / 1.32;
  background: var(--surface);
  border-radius: 8px;
  box-shadow: 0 18px 40px -12px rgba(10, 10, 18, 0.25), 0 0 0 1px rgba(10, 10, 18, 0.06);
  position: relative;
  display: flex;
  flex-direction: column;
  padding: 18px 16px;
  transform-origin: center;
  animation: pdfFloat 4s ease-in-out infinite;
}

@keyframes pdfFloat {
  0%, 100% { transform: translateY(0) rotate(-1deg); }
  50%      { transform: translateY(-8px) rotate(1deg); }
}

.scene-pdf__head {
  display: flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--terracota);
  margin-bottom: 14px;
}

.scene-pdf__head::before {
  content: "📄";
  font-size: 14px;
}

.scene-pdf__title {
  font-family: var(--font-display);
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  margin-bottom: 4px;
}

.scene-pdf__inst {
  font-family: var(--font-mono);
  font-size: 9px;
  color: var(--text-3);
  margin-bottom: 14px;
  letter-spacing: 0.04em;
}

.scene-pdf__lines {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
}

.scene-pdf__lines .line {
  height: 5px;
  background: rgba(10, 10, 18, 0.08);
  border-radius: 999px;
}
.scene-pdf__lines .line:nth-child(1) { width: 100%; }
.scene-pdf__lines .line:nth-child(2) { width: 88%; }
.scene-pdf__lines .line:nth-child(3) { width: 95%; }
.scene-pdf__lines .line:nth-child(4) { width: 76%; }
.scene-pdf__lines .line:nth-child(5) { width: 92%; }
.scene-pdf__lines .line:nth-child(6) { width: 60%; }

.scene-pdf__stack {
  position: absolute;
  inset: 0;
  z-index: -1;
  background: var(--surface);
  border-radius: 8px;
  transform: rotate(-3deg) translate(-12px, 6px);
  box-shadow: 0 8px 20px -8px rgba(10, 10, 18, 0.15);
  opacity: 0.65;
}

/* Cena 2 — Sistema lê (texto + tags) */
.scene-read {
  gap: 18px;
}

.scene-read__head {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--purple);
}

.scene-read__head::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--purple);
  animation: pulsePurple 1.6s ease-out infinite;
}

.scene-read__quote {
  font-family: var(--font-display);
  font-size: clamp(15px, 1.4vw, 18px);
  line-height: 1.45;
  color: var(--text);
  font-weight: 400;
  font-variation-settings: "opsz" 100;
}

.scene-read .hl {
  background: linear-gradient(180deg, transparent 60%, rgba(124, 58, 237, 0.28) 60%);
  padding: 0 2px;
  animation: hlSweep 2.4s ease-in-out infinite;
}

@keyframes hlSweep {
  0%, 100% { background: linear-gradient(180deg, transparent 60%, rgba(124, 58, 237, 0.28) 60%); }
  50%      { background: linear-gradient(180deg, transparent 60%, rgba(226, 82, 45, 0.28) 60%); }
}

.scene-read__tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.scene-read__tag {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  color: var(--purple);
  background: rgba(124, 58, 237, 0.1);
  border: 1px solid rgba(124, 58, 237, 0.25);
  padding: 5px 10px;
  border-radius: 999px;
  opacity: 0;
  transform: translateY(8px);
  animation: tagIn 600ms var(--ease-out) forwards;
}

.scene-read.is-active .scene-read__tag:nth-child(1) { animation-delay: 200ms; }
.scene-read.is-active .scene-read__tag:nth-child(2) { animation-delay: 400ms; }
.scene-read.is-active .scene-read__tag:nth-child(3) { animation-delay: 600ms; }
.scene-read.is-active .scene-read__tag:nth-child(4) { animation-delay: 800ms; }

@keyframes tagIn {
  to { opacity: 1; transform: translateY(0); }
}

.scene-read__bottom {
  margin-top: auto;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-3);
  letter-spacing: 0.04em;
  display: flex;
  align-items: center;
  gap: 6px;
}

.scene-read__bottom::before {
  content: "•";
  color: var(--terracota);
  animation: pulse 1.4s ease-out infinite;
}

/* Cena 3 — Calendário preenchendo */
.scene-cal {
  gap: 14px;
}

.scene-cal__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.scene-cal__title {
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 500;
  color: var(--text);
}

.scene-cal__count {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--purple);
  letter-spacing: 0.04em;
}

.scene-cal__grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
  flex: 1;
  align-content: start;
}

.scene-cal__day {
  aspect-ratio: 1 / 1;
  border-radius: 6px;
  background: rgba(10, 10, 18, 0.04);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-3);
  position: relative;
  overflow: hidden;
}

.scene-cal__day.is-filled {
  background: rgba(124, 58, 237, 0.12);
  color: var(--purple);
}

.scene-cal__day.is-filled::after {
  content: "";
  position: absolute;
  bottom: 4px;
  left: 50%;
  transform: translateX(-50%);
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--purple);
}

.scene-cal__day.is-today {
  background: var(--ink);
  color: var(--bg);
  box-shadow: 0 0 0 2px var(--terracota);
}

.scene-cal__legend {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-3);
  letter-spacing: 0.04em;
  text-align: center;
}

/* Cena 4 — Tela "Hoje" */
.scene-hoje {
  gap: 12px;
}

.scene-hoje__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 4px;
}

.scene-hoje__day {
  font-family: var(--font-display);
  font-size: 24px;
  font-weight: 500;
  color: var(--text);
}

.scene-hoje__day b {
  color: var(--purple);
  font-weight: 600;
}

.scene-hoje__time {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-3);
  letter-spacing: 0.04em;
}

.scene-hoje__list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1;
}

.scene-hoje__list li {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  background: var(--surface);
  border: 1px solid rgba(10, 10, 18, 0.06);
  border-radius: 10px;
  font-size: 13px;
  color: var(--text-2);
  position: relative;
}

.scene-hoje__list li::before {
  content: "";
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 1.5px solid var(--text-3);
  flex-shrink: 0;
}

.scene-hoje__list li.done {
  color: var(--text);
}
.scene-hoje__list li.done::before {
  background: var(--pulse-green);
  border-color: var(--pulse-green);
  box-shadow: inset 0 0 0 2px white;
}

.scene-hoje__list li.active {
  border-color: rgba(124, 58, 237, 0.3);
  background: rgba(124, 58, 237, 0.05);
  color: var(--text);
}
.scene-hoje__list li.active::before {
  background: var(--purple);
  border-color: var(--purple);
  animation: pulsePurple 1.8s ease-out infinite;
}

.scene-hoje__list li .lbl { flex: 1; }
.scene-hoje__list li .val {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-3);
}

.scene-hoje__cursor {
  position: absolute;
  width: 22px;
  height: 22px;
  pointer-events: none;
  filter: drop-shadow(0 4px 8px rgba(10, 10, 18, 0.3));
  animation: hojeCursor 4s var(--ease-in-out) infinite;
}

@keyframes hojeCursor {
  0%, 100% { top: 70%; left: 80%; opacity: 0; }
  10%      { opacity: 1; }
  40%      { top: 38%; left: 28%; opacity: 1; }
  55%      { top: 38%; left: 28%; transform: scale(0.92); }
  60%      { top: 38%; left: 28%; transform: scale(1); opacity: 1; }
  90%      { top: 70%; left: 80%; opacity: 0; }
}

/* ─── Responsivo ─────────────────────── */

@media (max-width: 920px) {
  /* ── Mobile: carrossel horizontal scroll-linked ──
     Section alta (380svh) + sticky container ocupando 1 viewport.
     Layout dentro do container = flex column:
       1. demo__head (auto)
       2. demo__mockup-wrap (altura fixa em px, mockup com cenas absolutas)
       3. demo__dots (auto)
       4. demo__steps (altura fixa em px, steps absolutos com translateX)
     Ordem do HTML é: steps, mockup, dots — corrigimos com `order`. */
  .demo {
    min-height: 380svh;
    overflow: visible; /* sticky precisa do ancestral sem overflow:hidden */
  }
  .demo > .container {
    position: sticky;
    top: 0;
    height: 100svh;
    display: flex;
    flex-direction: column;
    padding-top: max(72px, env(safe-area-inset-top, 0));
    padding-bottom: 16px;
    overflow: hidden; /* steps absolutos não vazam */
  }
  .demo__head {
    order: 0;
    margin-bottom: 16px;
    flex-shrink: 0;
    text-align: center;
  }
  .demo h2 {
    font-size: clamp(24px, 6vw, 32px);
    line-height: 1.15;
    margin-bottom: 8px;
  }
  .demo__sub {
    font-size: 13px;
  }

  /* Override do display:grid base pra usar flex column no mobile.
     Grid não respeita order, flex sim. */
  .demo__grid {
    display: flex !important;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    gap: 0;
    align-items: stretch;
  }

  /* Mockup: visível em cima, altura proporcional ao espaço disponível */
  .demo__mockup-wrap {
    order: 1;
    position: relative;
    top: auto;
    height: auto;
    flex: 1 1 auto;
    min-height: 240px;
    max-height: 60svh;
    /* mockup interno preenche essa altura */
  }
  .demo__mockup {
    position: absolute;
    inset: 0;
  }
  .demo__ecg { display: none; }

  /* Dots logo abaixo do mockup */
  .demo__dots {
    order: 2;
    display: flex;
    justify-content: center;
    gap: 8px;
    padding: 14px 0 10px;
    flex-shrink: 0;
  }
  .demo__dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: rgba(10, 10, 18, 0.18);
    transition: background 220ms var(--ease-out), transform 220ms var(--ease-out);
  }
  .demo__dot.is-active {
    background: var(--purple);
    transform: scale(1.3);
  }

  /* Steps: posicionados absoluto sobrepostos no mesmo frame, transição
     translateX. Container tem altura definida pra absolute funcionar. */
  .demo__steps {
    order: 3;
    flex-shrink: 0;
    position: relative;
    padding: 0;
    gap: 0;
    height: 150px;
    overflow: hidden;
  }
  .demo-step {
    position: absolute;
    inset: 0;
    width: 100%;
    padding: 4px 4px 0;
    transition: transform 520ms var(--ease-out), opacity 420ms var(--ease-out);
    will-change: transform, opacity;
    opacity: 0;
    transform: translateX(60%);
    pointer-events: none;
    text-align: left;
  }
  .demo-step.is-active {
    opacity: 1;
    transform: translateX(0);
    pointer-events: auto;
  }
  .demo-step.is-past {
    opacity: 0;
    transform: translateX(-60%);
  }
  .demo-step__pill {
    display: none;
  }
  .demo-step__num {
    font-size: 11px;
    color: var(--purple);
    letter-spacing: 0.18em;
    text-transform: uppercase;
    display: block;
    margin-bottom: 2px;
  }
  .demo-step h3 {
    font-size: clamp(20px, 5.5vw, 26px);
    line-height: 1.2;
    margin: 0 0 6px;
  }
  .demo-step p {
    font-size: 13.5px;
    line-height: 1.45;
    color: var(--text-2);
    margin: 0;
    /* Limita 4 linhas pra caber no espaço fixo */
    display: -webkit-box;
    -webkit-line-clamp: 4;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }
}

@media (max-width: 640px) {
  .demo > .container {
    padding-top: max(68px, env(safe-area-inset-top, 0));
  }
  .demo__mockup-wrap {
    min-height: 220px;
  }
  .demo__steps {
    height: 160px;
  }
}
