/* ==========================================================================
   Question flow — pages of a book on yellowed paper.
   Uses tokens from ../style.css. No new colors here.
   ========================================================================== */

.qflow {
  position: relative;
  z-index: 3;
  min-height: 100svh;
  display: flex;
  flex-direction: column;
}

/* -------------------------------------------------------------------------
   Home — quiet way back, top left, out of the progress dots' way
   ------------------------------------------------------------------------- */
.qflow__home {
  position: absolute;
  top: var(--space-2);
  left: var(--space-2);
  z-index: 5;
  display: block;
  text-decoration: none;
  padding: var(--space-1);
  margin: calc(var(--space-1) * -1);
  transition: opacity 0.2s ease;
}

.qflow__home img {
  display: block;
  width: 2.1rem;
  height: 2.1rem;
}

.qflow__home:hover,
.qflow__home:focus-visible {
  opacity: 0.7;
}

/* -------------------------------------------------------------------------
   Progress — six quiet marks, near the top. Seven screens is longer than
   the old five-question flow, so these read a touch more clearly than
   before: a bigger mark, done ones in ink rather than ash, current one
   ringed as well as filled — still no numbers, no percentage.
   ------------------------------------------------------------------------- */
.qflow__progress {
  display: flex;
  justify-content: center;
  gap: var(--space-1);
  padding: var(--space-3) var(--space-2) var(--space-1);
}

.qflow__dot {
  width: 44px;
  height: 44px;
  padding: 0;
  border: none;
  background: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.qflow__dot::before {
  content: '';
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--color-mist);
  box-shadow: 0 0 0 0 transparent;
  transition: background-color 0.3s ease, box-shadow 0.3s ease, transform 0.15s ease;
}

.qflow__dot:hover::before,
.qflow__dot:focus-visible::before {
  transform: scale(1.3);
}

.qflow__dot:focus-visible {
  outline: 2px solid var(--color-crimson);
  outline-offset: 2px;
  border-radius: 50%;
}

.qflow__dot--done::before {
  background: var(--color-ink);
}

.qflow__dot--current::before {
  background: var(--color-crimson);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--color-crimson) 25%, transparent);
}

/* -------------------------------------------------------------------------
   Track — one page per screen, horizontal slide
   ------------------------------------------------------------------------- */
.qflow__viewport {
  flex: 1;
  overflow: hidden;
  position: relative;
}

.qflow__track {
  display: flex;
  height: 100%;
  transition: transform 0.32s ease;
  will-change: transform;
}

@media (prefers-reduced-motion: reduce) {
  .qflow__track {
    transition: none;
  }
}

.qpage {
  flex: 0 0 100%;
  width: 100%;
  box-sizing: border-box;
  padding: var(--space-2) var(--space-3) calc(var(--space-4) + 3.5rem);
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: 0;
}

.qpage__question {
  font-family: var(--font-heading-secondary);
  font-weight: 400;
  font-size: calc(clamp(1.6rem, 7vw, 2.4rem) * var(--heading-scale));
  line-height: 1.25;
  color: var(--color-ink);
  -webkit-text-fill-color: var(--color-ink);
  max-width: var(--measure);
  margin: 0 auto var(--space-1);
  text-align: center;
}

.qpage__subtitle {
  font-family: var(--font-heading-secondary);
  font-size: calc(clamp(1rem, 4.2vw, 1.15rem) * var(--body-scale));
  color: var(--color-ash);
  -webkit-text-fill-color: var(--color-ash);
  max-width: var(--measure);
  margin: 0 auto var(--space-3);
  line-height: 1.5;
  text-align: center;
}

.qpage__privacy-note {
  font-family: var(--font-body);
  font-size: calc(var(--size-quiet) * var(--body-scale));
  font-style: italic;
  color: var(--color-ash);
  -webkit-text-fill-color: var(--color-ash);
  width: 100%;
  margin: 0 0 var(--space-3);
  line-height: 1.5;
}

/* -------------------------------------------------------------------------
   Input — a sheet of notebook paper laid on the page: warmer than the
   surrounding parchment, ruled, writing sits on the lines. Typed text stays
   in the body serif, never brush script — cursive is hard to read while
   typing on a phone, and that's exactly what makes people write less.
   ------------------------------------------------------------------------- */
.qpage__input {
  --rule-height: calc(2.5rem * var(--body-scale));
  width: 100%;
  max-width: 1200px;
  margin-left: auto;
  margin-right: auto;
  font-family: var(--font-body);
  font-size: calc(clamp(1.15rem, 4.6vw, 1.375rem) * var(--body-scale));
  line-height: var(--rule-height);
  color: var(--color-ink);
  background-color: var(--color-paper);
  background-image: linear-gradient(to bottom, var(--color-mist-dark) 1px, transparent 1px);
  background-size: 100% var(--rule-height);
  background-position: 0 calc(var(--rule-height) - 1px);
  border: none;
  outline: none;
  resize: none;
  overflow: hidden;
  padding: var(--space-1) var(--space-2) 0;
  /* a few blank ruled lines up front, so the page reads as notebook space
     to write into rather than a box that only grows as you type */
  min-height: calc(var(--rule-height) * 3 + var(--space-1));
}

.qpage__input::placeholder {
  color: var(--color-mist);
}

/* -------------------------------------------------------------------------
   Suggestions — cursive, quiet, below the input. Not placeholder text (that
   vanishes on focus, exactly when someone still needs it) and not clickable
   (they show the grain of a good answer, not options to pick).
   ------------------------------------------------------------------------- */
.qpage__suggestions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  max-width: var(--measure);
  margin: var(--space-2) auto 0;
  font-family: var(--font-cursive);
  font-weight: 600;
  font-size: calc(1.2rem * var(--body-scale));
  line-height: 1.6;
  color: var(--color-ash);
  -webkit-text-fill-color: var(--color-ash);
  text-align: center;
  transition: opacity 0.3s ease;
}

.qpage__suggestions--hidden {
  opacity: 0;
}

.qpage__suggestion:not(:last-child)::after {
  content: '\00B7';
  margin: 0 0.5em;
  color: var(--color-mist-dark);
  -webkit-text-fill-color: var(--color-mist-dark);
}

@media (prefers-reduced-motion: reduce) {
  .qpage__suggestions {
    transition: none;
  }
}

/* -------------------------------------------------------------------------
   Error — quiet, only appears if the final-step verification fails
   ------------------------------------------------------------------------- */
.qflow__error {
  position: fixed;
  left: var(--space-3);
  right: var(--space-3);
  bottom: calc(var(--space-2) + 3.5rem);
  z-index: 4;
  font-family: var(--font-body);
  font-size: calc(var(--size-quiet) * var(--body-scale));
  color: var(--color-ash);
  -webkit-text-fill-color: var(--color-ash);
  text-align: center;
}

.qflow__error[hidden] {
  display: none;
}

/* -------------------------------------------------------------------------
   Nav — persistent back arrow + next/submit, lifted above the keyboard
   ------------------------------------------------------------------------- */
.qflow__nav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 4;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  transition: transform 0.15s ease;
}

.qflow__back,
.qflow__next {
  font-family: var(--font-heading-secondary);
  background: none;
  border: none;
  cursor: pointer;
  color: var(--color-ink);
}

.qflow__back {
  font-size: 1.9rem;
  line-height: 1;
  padding: var(--space-1) var(--space-2) var(--space-1) 0;
  color: var(--color-ash);
  visibility: hidden;
}

.qflow__back--visible {
  visibility: visible;
}

.qflow__next {
  display: inline-flex;
  align-items: center;
  gap: 0.5em;
  font-size: var(--size-cta);
  font-style: italic;
  color: var(--color-parchment);
  -webkit-text-fill-color: var(--color-parchment);
  background: var(--color-crimson);
  padding: 0.6em 1.3em;
  border-bottom: none;
  margin-left: auto;
  transition: opacity 0.2s ease, transform 0.1s ease;
}

.qflow__next-icon {
  font-size: 1.2em;
  font-style: normal;
  line-height: 1;
}

.qflow__next--busy .qflow__next-icon {
  display: none;
}

.qflow__next:hover,
.qflow__next:focus-visible {
  opacity: 0.85;
}

.qflow__next:active {
  transform: scale(0.97);
}

.qflow__back:hover,
.qflow__back:focus-visible {
  opacity: 0.7;
}

@media (min-width: 640px) {
  .qflow__nav {
    max-width: 640px;
    margin: 0 auto;
  }
}
