/* Cómo funciona, from the Como Funciona design. Themed with .theme-dark (current) or .theme-light. */

.how {
  background: var(--surface);
  color: var(--on-surface);
  padding-block: 44px;
  scroll-margin-top: calc(var(--header-h) + var(--space-4));
}

.how.theme-dark {
  --how-rule: rgb(255 255 255 / 0.3);
  --how-head-rule: rgb(255 255 255 / 0.22);
  --how-divider: rgb(255 255 255 / 0.18);
  --how-card-bg: rgb(157 196 213 / 0.09);
  --how-card-border: rgb(157 196 213 / 0.28);
  --how-card-label: rgb(255 255 255 / 0.82);
  --how-link-hover: var(--color-lime);
}
.how.theme-light {
  --how-rule: var(--color-border-strong);
  --how-head-rule: var(--color-border-strong);
  --how-divider: var(--color-border);
  --how-card-bg: var(--color-surface);
  --how-card-border: var(--color-border);
  --how-card-label: var(--color-muted);
  --how-link-hover: var(--color-forest-hover);
}

/* INTRO */
.how__intro,
.how__heading {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.how__eyebrow {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.75rem;
  font-weight: var(--fw-semibold);
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--on-surface);
}
.how__eyebrow::before {
  content: '';
  width: 22px;
  height: 2px;
  background: var(--color-lime);
}

.how__title {
  font-size: var(--text-display);
  font-weight: var(--fw-bold);
  line-height: 1.12;
  letter-spacing: -0.015em;
  text-wrap: pretty;
}

.how__lead {
  font-size: var(--text-body);
  line-height: 1.55;
  color: var(--on-surface-muted);
}

/* PART 1: what happens when a patient writes */
.flow {
  display: flex;
  flex-direction: column;
  gap: 18px;
  margin-top: 26px;
}

.flow__head {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}
.flow__title {
  font-size: 1.375rem;
  font-weight: var(--fw-bold);
  line-height: 1.2;
}
.flow__note {
  font-size: var(--text-small);
  line-height: 1.4;
  color: var(--on-surface-muted);
}

/* Was a full solid-lime card — the loudest, most saturated block on the
   page and the only place lime covers this much area (Andrés's feedback,
   2026-09-24: it should be a small accent, never a diluted or solid large
   surface). Now a subtle card matching .build's old treatment, with the
   bubbles reusing the real Aria chat's own bubble colors (.msg--user /
   .msg--aria in chat.css) so this "example" visually ties back to the
   actual product instead of reading as a random lime banner. */
.example {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  padding: 18px;
  border-radius: 20px;
  background: var(--how-card-bg);
  border: 1px solid var(--how-card-border);
  color: var(--on-surface);
}
.example__label {
  font-size: 0.6875rem;
  font-weight: var(--fw-bold);
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--color-lime);
}
.example__bubbles {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  flex: 1;
}
.example__bubble {
  max-width: 92%;
  padding: var(--space-3) 14px;
  font-size: 1rem;
  line-height: 1.45;
}
.example__bubble--patient {
  align-self: flex-start;
  max-width: 90%;
  background: var(--color-sky);
  color: var(--color-forest);
  font-weight: var(--fw-medium);
  border-radius: 16px 16px 16px 6px;
}
.example__bubble--assistant {
  align-self: flex-end;
  background: var(--color-forest-raised);
  color: var(--color-white);
  border-radius: 16px 16px 6px 16px;
}

/* Vertical stepper on phones. */
.flow__steps {
  list-style: none;
  display: flex;
  flex-direction: column;
}
.flow__step {
  display: grid;
  grid-template-columns: 52px 1fr;
  gap: 14px;
}
.flow__num-col {
  display: flex;
  flex-direction: column;
  align-items: center;
}
.flow__num {
  font-size: 2.5rem;
  font-weight: var(--fw-extralight);
  line-height: 1;
}
.flow__num-col::after {
  content: '';
  flex: 1;
  width: 1px;
  margin-top: var(--space-2);
  background: var(--how-rule);
}
.flow__step:last-child .flow__num-col::after {
  flex: none;
  width: 9px;
  height: 9px;
  margin-top: 10px;
  border-radius: 50%;
  background: var(--color-lime);
}
.flow__body {
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding-bottom: 26px;
}
.flow__step:last-child .flow__body { padding-bottom: 0; }
.flow__step-title {
  font-size: 1.125rem;
  font-weight: var(--fw-bold);
}
.flow__step-text {
  font-size: 1rem;
  line-height: 1.5;
  color: var(--on-surface-muted);
}

/* CLOSING LINE */
.how__close {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  margin-top: 28px;
}
.how__close-text {
  font-size: 1.1875rem;
  font-weight: var(--fw-light);
  line-height: 1.35;
}
.how__link {
  display: inline-flex;
  align-self: flex-start;
  align-items: center;
  gap: var(--space-2);
  height: 44px;
  border-bottom: 2px solid var(--color-lime);
  color: var(--on-surface);
  font-size: var(--text-body);
  font-weight: var(--fw-semibold);
  text-decoration: none;
  transition: color 0.15s ease;
}
.how__link:hover { color: var(--how-link-hover); }

/* Soft reveal on scroll. Only active when JS runs (see js/reveal.js) and
   motion is allowed. Single shared rule for the whole site: 12px offset,
   60ms per step, capped at 5 chained items (index 0-4 — min() below stops
   a 6th+ item from just keeping getting later). Every component that wants
   its .reveal siblings to stagger sets --reveal-i (0, 1, 2…) per item via
   its own nth-child selectors below; the timing math itself lives only
   here, so changing the step or the cap only ever means editing this rule. */
.js-reveal .reveal {
  --reveal-i: 0;
  opacity: 0;
  transform: translateY(12px);
  transition: opacity 0.5s cubic-bezier(0.2, 0.8, 0.3, 1), transform 0.5s cubic-bezier(0.2, 0.8, 0.3, 1);
  transition-delay: calc(min(var(--reveal-i), 4) * 0.06s);
}
.js-reveal .reveal.is-visible {
  opacity: 1;
  transform: none;
}
.flow__step:nth-child(2) { --reveal-i: 1; }
.flow__step:nth-child(3) { --reveal-i: 2; }
.flow__step:nth-child(4) { --reveal-i: 3; }
.flow__step:nth-child(5) { --reveal-i: 4; }
@media (prefers-reduced-motion: reduce) {
  .js-reveal .reveal { opacity: 1; transform: none; transition: none; }
}

/* DESKTOP */
@media (min-width: 900px) {
  .how { padding-block: 80px 72px; }

  .how__intro {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-16);
    align-items: end;
  }
  .how__heading { gap: 18px; }
  .how__eyebrow { font-size: var(--text-eyebrow); }
  .how__eyebrow::before { width: 28px; }
  .how__title { line-height: 1.08; letter-spacing: -0.02em; text-wrap: balance; }
  .how__lead {
    max-width: 52ch;
    margin-bottom: 6px;
    font-size: 1.1875rem;
    line-height: 1.6;
  }

  .flow { gap: 26px; margin-top: var(--space-16); }
  .flow__head {
    flex-direction: row;
    flex-wrap: wrap;
    align-items: baseline;
    justify-content: space-between;
    gap: var(--space-6);
    padding-bottom: var(--space-4);
    border-bottom: 1px solid var(--how-head-rule);
  }
  .flow__title { font-size: 1.75rem; line-height: 1.15; }
  .flow__note { font-size: 0.9375rem; }

  /* Five steps in a row, joined by a thin line that the numbers sit on. */
  .flow__steps {
    position: relative;
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: var(--space-6);
  }
  .flow__steps::before {
    content: '';
    position: absolute;
    inset: 26px 0 auto 0;
    height: 1px;
    background: var(--how-rule);
  }
  .flow__step {
    display: flex;
    flex-direction: column;
    gap: 10px;
  }
  .flow__num-col {
    position: relative;
    z-index: 1;
    flex-direction: row;
    align-items: center;
    align-self: flex-start;
    gap: 10px;
    padding-right: 10px;
    background: var(--surface);
  }
  .flow__num { font-size: 3.25rem; }
  .flow__num-col::after { display: none; }
  .flow__step:last-child .flow__num-col::after {
    display: block;
    width: 10px;
    height: 10px;
    margin: 0;
  }
  .flow__body { gap: 10px; padding-bottom: 0; }
  .flow__step-title { font-size: 1.1875rem; }

  /* The example goes below the row. Plain column layout (label above the
     bubbles, same as mobile) now that it's a subtle card instead of a
     lime banner — the old vertical spine label was decorative flair for
     that banner and doesn't belong on a quiet card. */
  .example {
    order: 3;
    max-width: 640px;
    padding: 26px 30px;
    border-radius: var(--radius-lg);
  }
  .example__bubble { padding: 14px 18px; font-size: 1.0625rem; }
  .example__bubble--patient { max-width: 58%; border-radius: 18px 18px 18px 6px; }
  .example__bubble--assistant { max-width: 62%; border-radius: 18px 18px 6px 18px; }

  .how__close {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-8);
    margin-top: var(--space-12);
  }
  .how__close-text { max-width: 34ch; font-size: 1.625rem; line-height: 1.3; }
  .how__link { height: 48px; gap: 10px; font-size: 1.125rem; }
}
