/* ============================================================
   stepspeak — calm, ultra-legible, accessibility-first.
   ivory ground + deep indigo + one warm coral. AAA-minded.
   ============================================================ */

:root {
  /* light theme (default) */
  --ivory:    #FBFBF7;
  --ivory-2:  #F2F2EA;   /* card wash */
  --indigo:   #1F2450;   /* primary text + ink */
  --indigo-2: #3A3F73;   /* strong secondary */
  --slate:    #565B86;   /* muted, still AA on ivory */
  --coral:    #F2635A;
  --coral-ink:#8C231C;   /* coral text that stays AA on ivory */
  --line:     #D8D8CD;
  --line-2:   #C4C4B6;
  --ring:     #1F2450;   /* focus ring on light */
  --bubble-bg:#FFFFFF;
  --chip-bg:  #1F2450;
  --chip-ink: #FBFBF7;
  --ok:       #1F7A54;

  --shell: #FBFBF7;
  --field: #FFFFFF;

  --sans: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;

  --radius: 16px;
  --radius-sm: 11px;
  --wrap: 960px;
  --wrap-wide: 1080px;
  --ease: cubic-bezier(0.22, 0.61, 0.36, 1);

  /* the one knob the text-size control turns */
  --step-size: 2.5rem;
}

/* dark theme — inverts to an indigo ground with ivory ink */
:root[data-theme="dark"] {
  --ivory:    #14163A;
  --ivory-2:  #1D2050;
  --indigo:   #F3F3EC;
  --indigo-2: #D9DAF0;
  --slate:    #A9ABCf;
  --coral:    #FF7A70;
  --coral-ink:#FFB4AC;
  --line:     #2E3270;
  --line-2:   #3A3F86;
  --ring:     #FF7A70;
  --bubble-bg:#1D2050;
  --chip-bg:  #F2635A;
  --chip-ink: #14163A;
  --ok:       #55D89A;

  --shell: #0F112E;
  --field: #1A1D48;
  color-scheme: dark;
}

/* system-follow dark (only when no explicit choice) */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]):not([data-theme="dark"]) {
    --ivory:    #14163A;
    --ivory-2:  #1D2050;
    --indigo:   #F3F3EC;
    --indigo-2: #D9DAF0;
    --slate:    #A9ABCf;
    --coral:    #FF7A70;
    --coral-ink:#FFB4AC;
    --line:     #2E3270;
    --line-2:   #3A3F86;
    --ring:     #FF7A70;
    --bubble-bg:#1D2050;
    --chip-bg:  #F2635A;
    --chip-ink: #14163A;
    --ok:       #55D89A;
    --shell: #0F112E;
    --field: #1A1D48;
    color-scheme: dark;
  }
}

/* text-size classes on <html> */
:root[data-size="normal"] { --step-size: 1.9rem; }
:root[data-size="large"]  { --step-size: 2.5rem; }
:root[data-size="huge"]   { --step-size: 3.4rem; }

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--shell);
  color: var(--indigo);
  font-family: var(--sans);
  font-size: 17px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1, h2, h3 { margin: 0; font-weight: 800; line-height: 1.1; letter-spacing: -0.02em; }
p { margin: 0; }
em { font-style: normal; font-weight: 700; color: var(--coral-ink); }

/* accessible utilities */
.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0);
  white-space: nowrap; border: 0;
}

.skip-link {
  position: absolute; left: 14px; top: -60px;
  background: var(--coral); color: #2a0906;
  padding: 12px 20px; border-radius: 12px; font-weight: 800;
  z-index: 60; transition: top 0.18s var(--ease); text-decoration: none;
}
.skip-link:focus { top: 14px; }

.kbd {
  font-family: var(--mono);
  font-size: 0.82em;
  font-weight: 700;
  background: var(--ivory-2);
  border: 1px solid var(--line-2);
  border-bottom-width: 2px;
  border-radius: 6px;
  padding: 1px 6px;
  color: var(--indigo-2);
  white-space: nowrap;
}

/* ---- one strong, unmistakable focus ring everywhere ---- */
a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
.seg:focus-within,
.switch:focus-within {
  outline: 3px solid var(--ring);
  outline-offset: 3px;
  border-radius: 8px;
}

.eyebrow {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  font-weight: 700;
  color: var(--slate);
}

.section-heading {
  font-size: clamp(1.35rem, 3.2vw, 1.7rem);
  color: var(--indigo);
  margin-bottom: 6px;
}
.section-heading--inline { margin-bottom: 0; }

/* ============================================================
   HERO
   ============================================================ */
.hero {
  border-bottom: 2px solid var(--line);
  background:
    radial-gradient(720px 340px at 88% -30%, rgba(242,99,90,0.12), transparent 62%),
    var(--shell);
}
.hero__inner {
  max-width: var(--wrap);
  margin: 0 auto;
  padding: clamp(26px, 4vw, 40px) clamp(20px, 5vw, 40px) clamp(30px, 4vw, 46px);
}

.brand { display: inline-flex; align-items: center; gap: 13px; }
.brand__mark {
  width: 46px; height: 46px;
  fill: var(--indigo);
}
.brand__num {
  fill: var(--ivory);
  font-family: var(--sans);
  font-size: 18px;
  font-weight: 800;
  text-anchor: middle;
}
.brand__word {
  font-size: 1.5rem; font-weight: 800; letter-spacing: -0.03em;
  color: var(--indigo);
}

.eyebrow { margin-top: clamp(20px, 3vw, 30px); }

.hero__title {
  font-size: clamp(2.2rem, 6vw, 3.7rem);
  margin: 12px 0 0;
  max-width: 16ch;
}
.hero__accent { color: var(--coral-ink); }

.hero__lede {
  margin-top: 18px;
  max-width: 58ch;
  color: var(--slate);
  font-size: clamp(1.02rem, 1.5vw, 1.18rem);
}

.hero__cta {
  margin-top: 26px;
  display: flex; align-items: center; gap: 18px; flex-wrap: wrap;
}
.hero__note { font-size: 0.9rem; color: var(--slate); }

/* ============================================================
   BUTTONS
   ============================================================ */
.btn {
  font-family: var(--sans);
  font-weight: 800;
  font-size: 1.02rem;
  letter-spacing: -0.01em;
  border-radius: 12px;
  cursor: pointer;
  border: 2px solid transparent;
  padding: 14px 26px;
  text-decoration: none;
  display: inline-flex; align-items: center; gap: 10px;
  transition: transform 0.1s var(--ease), background 0.16s var(--ease), border-color 0.16s var(--ease), color 0.16s var(--ease);
}
.btn:active { transform: translateY(1px); }

.btn--primary {
  background: var(--coral);
  color: #33100c;
  border-color: var(--coral);
}
.btn--primary:hover { background: #ef4d43; border-color: #ef4d43; }

.btn--ghost {
  background: transparent;
  color: var(--indigo);
  border-color: var(--line-2);
}
.btn--ghost:hover { border-color: var(--indigo); background: var(--ivory-2); }

.btn--small { padding: 9px 16px; font-size: 0.92rem; }
.btn--go { padding: 16px 34px; font-size: 1.1rem; }

/* ============================================================
   COMPOSER (input)
   ============================================================ */
.make { border-bottom: 2px solid var(--line); }
.make__inner {
  max-width: var(--wrap);
  margin: 0 auto;
  padding: clamp(30px, 5vw, 52px) clamp(20px, 5vw, 40px);
}

.composer__field { display: flex; flex-direction: column; }
.composer__label {
  font-size: 1.05rem; font-weight: 800; color: var(--indigo);
}
.composer__hint {
  margin-top: 5px; font-size: 0.92rem; color: var(--slate);
  line-height: 1.5;
}
.composer__area {
  margin-top: 14px;
  font-family: var(--sans);
  font-size: 1.12rem;
  line-height: 1.6;
  color: var(--indigo);
  background: var(--field);
  border: 2px solid var(--line-2);
  border-radius: var(--radius);
  padding: 18px 20px;
  width: 100%;
  resize: vertical;
  min-height: 190px;
}
.composer__area::placeholder { color: var(--slate); opacity: 0.8; }
.composer__area:hover { border-color: var(--indigo-2); }
.composer__count {
  margin-top: 10px; font-size: 0.9rem; font-weight: 700; color: var(--slate);
}
.composer__count.has-steps { color: var(--ok); }

/* examples */
.examples { margin-top: 22px; display: flex; align-items: center; gap: 12px 16px; flex-wrap: wrap; }
.examples__label { font-size: 0.95rem; font-weight: 700; color: var(--slate); }
.examples__row { display: flex; gap: 10px; flex-wrap: wrap; }
.pill {
  font-family: var(--sans);
  font-size: 0.95rem; font-weight: 700;
  color: var(--indigo);
  background: var(--ivory-2);
  border: 2px solid var(--line-2);
  border-radius: 999px;
  padding: 9px 18px;
  cursor: pointer;
  transition: border-color 0.16s var(--ease), background 0.16s var(--ease);
}
.pill:hover { border-color: var(--coral); background: var(--field); }

.composer__actions {
  margin-top: 26px;
  display: flex; gap: 14px; flex-wrap: wrap; align-items: center;
}

/* ============================================================
   STEPPER + the SPEECH BUBBLE signature
   ============================================================ */
.stepper { border-bottom: 2px solid var(--line); }
.stepper[hidden] { display: none; }
.stepper__inner {
  max-width: var(--wrap);
  margin: 0 auto;
  padding: clamp(30px, 5vw, 52px) clamp(20px, 5vw, 40px);
}
.stepper__bar {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  flex-wrap: wrap;
}

/* progress */
.progress { margin-top: 20px; }
.progress__track {
  height: 12px;
  background: var(--ivory-2);
  border: 2px solid var(--line-2);
  border-radius: 999px;
  overflow: hidden;
}
.progress__fill {
  height: 100%; width: 0%;
  background: var(--coral);
  border-radius: 999px;
  transition: width 0.4s var(--ease);
}
.progress__read {
  margin-top: 8px;
  font-size: 0.9rem; font-weight: 700; color: var(--slate);
  font-variant-numeric: tabular-nums;
}

/* the bubble */
.bubble {
  position: relative;
  margin-top: 26px;
  background: var(--bubble-bg);
  border: 2px solid var(--line-2);
  border-radius: 26px;
  padding: clamp(32px, 5vw, 56px) clamp(26px, 4vw, 48px) clamp(40px, 5vw, 60px);
  box-shadow: 0 24px 60px -40px rgba(31,36,80,0.55);
  min-height: 220px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}
/* bubble tail — the speech motif */
.bubble::after {
  content: "";
  position: absolute;
  left: 52px; bottom: -20px;
  width: 40px; height: 22px;
  background: var(--bubble-bg);
  border-right: 2px solid var(--line-2);
  border-bottom: 2px solid var(--line-2);
  border-bottom-right-radius: 6px;
  transform: skewX(-24deg);
}
.bubble__count {
  font-size: 0.9rem; font-weight: 800;
  text-transform: uppercase; letter-spacing: 0.14em;
  color: var(--slate);
  font-variant-numeric: tabular-nums;
}
.bubble__chip {
  position: absolute;
  top: -26px; left: 34px;
  min-width: 54px; height: 54px;
  padding: 0 14px;
  border-radius: 16px;
  background: var(--chip-bg);
  color: var(--chip-ink);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 1.7rem; font-weight: 800;
  font-variant-numeric: tabular-nums;
  box-shadow: 0 12px 26px -14px rgba(31,36,80,0.7);
}
.bubble__text {
  margin-top: 16px;
  font-size: var(--step-size);
  line-height: 1.25;
  font-weight: 700;
  letter-spacing: -0.015em;
  color: var(--indigo);
  overflow-wrap: break-word;
}
.bubble.is-speaking { border-color: var(--coral); }
.bubble.is-speaking .bubble__chip {
  background: var(--coral); color: #33100c;
}

/* nav */
.nav {
  margin-top: 30px;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 14px;
  align-items: stretch;
}
.btn--nav {
  background: var(--ivory-2);
  color: var(--indigo);
  border-color: var(--line-2);
  justify-content: center;
  padding: 18px 22px;
  font-size: 1.1rem;
}
.btn--nav:hover:not(:disabled) { border-color: var(--indigo); background: var(--field); }
.btn--nav-next { justify-self: end; }
.btn--nav:first-child { justify-self: start; }
.btn--nav:disabled { opacity: 0.4; cursor: not-allowed; }
.nav__arrow { font-size: 1.5rem; line-height: 1; }

.btn--repeat {
  background: var(--indigo);
  color: var(--ivory);
  border-color: var(--indigo);
  padding: 18px 26px;
  font-size: 1.05rem;
  justify-content: center;
}
.btn--repeat:hover { background: var(--indigo-2); border-color: var(--indigo-2); }
:root[data-theme="dark"] .btn--repeat,
:root:not([data-theme="light"]) .btn--repeat { color: var(--shell); }
.nav__icon {
  width: 20px; height: 20px;
  fill: none; stroke: currentColor; stroke-width: 2.2;
  stroke-linecap: round; stroke-linejoin: round;
}

.nav__keys {
  margin-top: 16px;
  font-size: 0.88rem; color: var(--slate);
  text-align: center;
}

/* ============================================================
   SETTINGS
   ============================================================ */
.settings { border-bottom: 2px solid var(--line); }
.settings__inner {
  max-width: var(--wrap-wide);
  margin: 0 auto;
  padding: clamp(30px, 5vw, 52px) clamp(20px, 5vw, 40px);
}
.settings__grid {
  margin-top: 16px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
  align-items: start;
}
.card {
  border: 2px solid var(--line-2);
  border-radius: var(--radius);
  background: var(--ivory-2);
  padding: 22px 22px 24px;
  margin: 0;
  min-width: 0;
}
.card__legend {
  font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.14em;
  font-weight: 800; color: var(--slate);
  padding: 0 8px; margin-left: -8px;
}

.control { margin-top: 20px; }
.control:first-of-type { margin-top: 0; }
.control__label {
  display: flex; align-items: baseline; justify-content: space-between; gap: 10px;
  font-size: 0.95rem; font-weight: 700; color: var(--indigo);
  margin-bottom: 9px;
}
.control__val {
  font-family: var(--mono); font-weight: 700; color: var(--coral-ink);
  font-variant-numeric: tabular-nums;
}
.control__note { margin-top: 9px; font-size: 0.85rem; color: var(--slate); line-height: 1.5; }

.control__select {
  font-family: var(--sans);
  font-size: 1rem; font-weight: 600;
  color: var(--indigo);
  background: var(--field);
  border: 2px solid var(--line-2);
  border-radius: var(--radius-sm);
  padding: 11px 14px;
  width: 100%;
  cursor: pointer;
}
.control__select:hover { border-color: var(--indigo-2); }

.control__range {
  -webkit-appearance: none; appearance: none;
  width: 100%; height: 10px;
  background: var(--field);
  border: 2px solid var(--line-2);
  border-radius: 999px;
  cursor: pointer;
}
.control__range::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 26px; height: 26px; border-radius: 50%;
  background: var(--coral);
  border: 3px solid var(--field);
  box-shadow: 0 2px 8px -1px rgba(31,36,80,0.5);
  cursor: pointer;
}
.control__range::-moz-range-thumb {
  width: 22px; height: 22px; border-radius: 50%;
  background: var(--coral);
  border: 3px solid var(--field);
  cursor: pointer;
}

/* switch (auto-speak) */
.switch {
  display: flex; align-items: center; gap: 13px;
  cursor: pointer;
  font-size: 0.98rem; font-weight: 700; color: var(--indigo);
}
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch__box {
  flex: none;
  width: 50px; height: 28px; border-radius: 999px;
  background: var(--field);
  border: 2px solid var(--line-2);
  position: relative;
  transition: background 0.18s var(--ease), border-color 0.18s var(--ease);
}
.switch__box::after {
  content: "";
  position: absolute; left: 3px; top: 3px;
  width: 18px; height: 18px; border-radius: 50%;
  background: var(--slate);
  transition: transform 0.18s var(--ease), background 0.18s var(--ease);
}
.switch input:checked + .switch__box { background: var(--coral); border-color: var(--coral); }
.switch input:checked + .switch__box::after { transform: translateX(22px); background: #fff; }

/* segmented */
.segmented {
  display: flex; gap: 5px;
  background: var(--field);
  border: 2px solid var(--line-2);
  border-radius: 12px;
  padding: 5px;
}
.seg { position: relative; flex: 1; }
.seg input { position: absolute; opacity: 0; inset: 0; cursor: pointer; margin: 0; }
.seg span {
  display: block; text-align: center;
  padding: 10px 8px;
  border-radius: 8px;
  font-weight: 700; font-size: 0.95rem;
  color: var(--slate);
  cursor: pointer;
  transition: background 0.16s var(--ease), color 0.16s var(--ease);
}
.seg input:hover + span { color: var(--indigo); }
.seg input:checked + span { background: var(--indigo); color: var(--ivory); }
:root[data-theme="dark"] .seg input:checked + span,
:root:not([data-theme="light"]) .seg input:checked + span { color: var(--shell); }

.settings__save { margin-top: 20px; font-size: 0.88rem; color: var(--slate); }

/* ============================================================
   HOW IT WORKS
   ============================================================ */
.how__inner {
  max-width: var(--wrap);
  margin: 0 auto;
  padding: clamp(30px, 5vw, 52px) clamp(20px, 5vw, 40px);
}
.how__list {
  list-style: none; margin: 18px 0 0; padding: 0;
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px;
}
.how__item { display: flex; gap: 16px; align-items: flex-start; }
.how__num {
  flex: none;
  width: 44px; height: 44px; border-radius: 13px;
  background: var(--ivory-2);
  border: 2px solid var(--line-2);
  color: var(--coral-ink);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 1.3rem; font-weight: 800;
}
.how__title { font-size: 1.1rem; color: var(--indigo); }
.how__body { margin-top: 6px; font-size: 0.95rem; color: var(--slate); line-height: 1.55; }

/* ============================================================
   FOOTER
   ============================================================ */
.foot { background: var(--shell); }
.foot__inner {
  max-width: var(--wrap);
  margin: 0 auto;
  padding: 30px clamp(20px, 5vw, 40px) 44px;
}
.foot__disclaimer {
  font-size: 0.92rem; color: var(--slate); max-width: 76ch; line-height: 1.6;
}
.foot__disclaimer strong { color: var(--indigo); }
.foot__meta {
  margin-top: 18px;
  display: flex; flex-wrap: wrap; gap: 8px 10px;
  font-size: 0.82rem; color: var(--slate);
}
.foot__dot { color: var(--line-2); }

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 820px) {
  .settings__grid { grid-template-columns: 1fr; }
  .how__list { grid-template-columns: 1fr; gap: 22px; }
}
@media (max-width: 560px) {
  .nav { grid-template-columns: 1fr 1fr; }
  .btn--repeat { grid-column: 1 / -1; order: 3; }
  .btn--nav-next { justify-self: stretch; }
  .btn--nav:first-child { justify-self: stretch; }
  .composer__actions .btn { flex: 1; }
  .hero__cta { align-items: flex-start; }
}

/* ============================================================
   REDUCED MOTION
   ============================================================ */
@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}
