/* Wizard-Durchlauf (docs/wizards.md): eine Frage je Seite, große quadratische Kacheln, unten
   immer „Weiter“. Baut auf den Runner-Klassen aus questionnaire_runner.css auf. */

.wizard {
  display: grid;
  gap: var(--space-4);
}

.wizard-header h1 {
  font-size: 1.45rem;
  line-height: 1.3;
}

.wizard-optional {
  color: var(--ink-muted);
  font-size: 0.9rem;
}

.wizard-error {
  margin: 0;
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--danger);
  border-radius: var(--radius-m);
  color: var(--danger);
  font-weight: 700;
  background: var(--surface);
}

.wizard-form {
  display: grid;
  gap: var(--space-4);
}

.wizard-tiles {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-3);
  margin: 0;
  padding: 0;
  border: 0;
}

.wizard-tile {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-3);
  aspect-ratio: 1 / 1;
  padding: var(--space-3);
  border: 2px solid var(--line);
  border-radius: var(--radius-l);
  box-shadow: var(--shadow-1);
  color: var(--ink);
  font-weight: 700;
  text-align: center;
  cursor: pointer;
  background: var(--surface-raised);
  -webkit-tap-highlight-color: transparent;
  transition: border-color 120ms ease, background-color 120ms ease, transform 120ms ease;
}

.wizard-tile:active {
  transform: scale(0.98);
}

/* Nur der Auswahl-Input der Kachel (Radio/Checkbox) wird optisch versteckt – nicht der
   Freitext-`<input>` der „Andere …“-Kachel (docs/wizards.md, „Freitext-Option“), der als
   Nachfahre im selben `.wizard-tile` steckt und sichtbar bleiben muss. */
.wizard-tile input[type="radio"],
.wizard-tile input[type="checkbox"] {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  border: 0;
  white-space: nowrap;
}

.wizard-tile:has(input:checked) {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-soft);
}

.wizard-tile:has(input:focus-visible) {
  outline: 3px solid var(--ink);
  outline-offset: 3px;
}

.wizard-tile__icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 3.5rem;
  height: 3.5rem;
}

.wizard-tile__icon svg {
  width: 100%;
  height: 100%;
}

.wizard-tile__emoji {
  font-size: 3rem;
  line-height: 1;
}

.wizard-tile__label {
  font-size: 1rem;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

/* Free-text option (docs/wizards.md, „Freitext-Option“): a tile of its own after the options.
   While its field is closed it stays square like the others (`.wizard-tile`), its label fills it
   as the tap target, and an empty icon slot keeps the label level with the neighbouring tiles.
   Once the field opens, the tile loses the aspect ratio, spans the full row and carries the answer
   buttons and the field inside, across its whole width; the label shrinks to its content (else it
   would keep the height of the square above the buttons) and an empty icon slot goes. Opening
   scrolls the tile above the fixed „Weiter“ bar (`wizard-step#gewaehlt`, `scroll-margin-bottom`). */
.wizard-tile--other {
  padding: var(--space-3);
  cursor: default;
  scroll-margin-bottom: var(--wizard-nav-space, 0px);
}

.wizard-tile--other:has(.wizard-other-entry:not([hidden])) {
  grid-column: 1 / -1;
  aspect-ratio: auto;
}

.wizard-tile--other:has(.wizard-other-entry:not([hidden])) .wizard-tile__toggle {
  min-height: auto;
}

.wizard-tile--other:has(.wizard-other-entry:not([hidden])) .wizard-tile__icon:not(:has(*)) {
  display: none;
}

.wizard-tile__toggle {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-3);
  min-height: 100%;
  cursor: pointer;
}

.wizard-other-entry {
  display: grid;
  align-self: stretch;
  gap: var(--space-3);
  margin-top: var(--space-3);
  padding-top: var(--space-3);
  border-top: 1px solid var(--line);
  text-align: left;
  cursor: default;
}

.wizard-other-entry[hidden] {
  display: none;
}

.wizard-text {
  display: grid;
  gap: var(--space-3);
}

.wizard-text__entry textarea {
  width: 100%;
  min-height: 9rem;
  padding: var(--space-3);
  border: 1px solid var(--line);
  border-radius: var(--radius-m);
  color: var(--ink);
  font: inherit;
  font-size: 1.05rem;
  background: var(--surface-raised);
}

/* Einzeiliges Feld (`lines: 1`): eine Zeile, groß genug für den Daumen. */
.wizard-text__line {
  width: 100%;
  min-height: 3.25rem;
  padding: var(--space-3);
  border: 1px solid var(--line);
  border-radius: var(--radius-m);
  color: var(--ink);
  font: inherit;
  font-size: 1.15rem;
  background: var(--surface-raised);
}

/* Two ways to answer a text step or a free-text option (`_dictation_entry`), in the visual
   language of the app's interview card (RunnerCardView, SpeechControls): round buttons side by
   side, each with its caption underneath — dictation large in a filled accent circle, typing small
   in a light one. The caption sits inside the button and is its accessible name. */
.wizard-answers {
  display: grid;
  gap: var(--space-2);
}

.wizard-answers__row {
  display: flex;
  align-items: flex-start;
  justify-content: center;
  gap: var(--space-3) 2.5rem;
}

/* Changing state moves nothing. Captions stay on one line, and the dictation column takes its
   width from the row, never from its caption: 9.5rem holds „Antwort diktieren“ and „Aufnahme
   beenden“; the app's „Upload erneut versuchen“ overflows it evenly on both sides. The timer keeps
   its line while hidden. The typing button's caption never changes, so it keeps its own width. On
   the narrowest phones the gap shrinks, so that the free-text tile still holds both columns. */
.wizard-answers__dictation {
  display: grid;
  flex: 0 1 9.5rem;
  min-width: 0;
  grid-template-columns: minmax(0, 1fr);
  justify-items: center;
  gap: var(--space-1);
}

@media (max-width: 22rem) {
  .wizard-answers__row {
    column-gap: var(--space-3);
  }
}

.wizard-answer {
  display: grid;
  justify-items: center;
  gap: var(--space-2);
  padding: 0;
  border: 0;
  color: var(--ink);
  font: inherit;
  cursor: pointer;
  background: none;
  -webkit-tap-highlight-color: transparent;
}

.wizard-answer[hidden] {
  display: none;
}

.wizard-answer:focus-visible {
  outline: none;
}

.wizard-answer:focus-visible .wizard-answer__circle {
  outline: 3px solid var(--ink);
  outline-offset: 3px;
}

.wizard-answer:disabled {
  cursor: not-allowed;
  opacity: 0.52;
}

.wizard-answer__circle {
  display: grid;
  place-items: center;
  border-radius: 50%;
  transition: background-color 160ms ease, transform 120ms ease;
}

.wizard-answer:active:not(:disabled) .wizard-answer__circle {
  transform: scale(0.96);
}

.wizard-answer__caption {
  font-size: 0.85rem;
  font-weight: 700;
  line-height: 1.25;
  text-align: center;
  white-space: nowrap;
}

.wizard-answer--dictation .wizard-answer__circle {
  width: 5.5rem;
  height: 5.5rem;
  color: var(--accent-ink);
  background: var(--accent);
  box-shadow: var(--shadow-2);
}

.wizard-answer--dictation .wizard-answer__icon {
  width: 2.25rem;
  height: 2.25rem;
}

/* The small one sits lower, so that both circles share their centre line. */
.wizard-answer--type {
  flex: none;
  margin-top: 0.75rem;
}

.wizard-answer--type .wizard-answer__circle {
  width: 4rem;
  height: 4rem;
  border: 1px solid var(--line);
  color: var(--ink);
  background: var(--surface-raised);
  box-shadow: var(--shadow-1);
}

.wizard-answer--type .wizard-answer__icon {
  width: 1.6rem;
  height: 1.6rem;
}

/* Hover only on devices that hover: on a touch screen `:hover` sticks to the last tapped button,
   and a hovered dictation circle never covers the recording red. */
@media (hover: hover) {
  /* application.css gives every button a soft hover background and accent text; these buttons
     show hover on their circle only. Same weight as that rule (0,4,0), this sheet comes later. */
  .wizard-answers .wizard-answer:hover:not(:disabled),
  .wizard-answers .wizard-answer:hover:disabled {
    color: var(--ink);
    background: none;
  }

  .wizard-text:not(.runner-dictation--recording) .wizard-answer--dictation:hover:not(:disabled) .wizard-answer__circle {
    background: var(--accent-strong);
  }

  .wizard-answer--type:hover:not(:disabled) .wizard-answer__circle {
    border-color: var(--accent);
  }
}

/* While recording (`runner-dictation--recording` on the block, set by questionnaire-dictation and
   wizard-dictation): red with a stop symbol and the running time, as before and as in the card. */
.wizard-answer__icon--stop,
.runner-dictation--recording .wizard-answer__icon--microphone {
  display: none;
}

.runner-dictation--recording .wizard-answer__icon--stop {
  display: block;
}

.runner-dictation--recording .wizard-answer--dictation .wizard-answer__circle {
  color: var(--dictation-button-recording-ink);
  background: var(--dictation-button-recording-bg);
  animation: runner-dictation-pulse 1.4s ease-in-out infinite;
}

.wizard-answers__timer {
  visibility: hidden;
  min-width: 0;
  text-align: center;
}

.runner-dictation--recording .wizard-answers__timer {
  visibility: visible;
}

/* One line kept free, so that „Aufnahme läuft …“ pushes nothing down. */
.wizard-answers__status {
  min-height: 1lh;
  text-align: center;
}

@media (prefers-reduced-motion: reduce) {
  .runner-dictation--recording .wizard-answer--dictation .wizard-answer__circle {
    animation: none;
  }
}

/* The Ausruf's dictation button (callouts/_dictation_field) keeps the wide red button. */
.wizard-dictation {
  grid-template-columns: minmax(0, 1fr);
}

.wizard-dictation__button {
  flex-direction: column;
  min-height: 9rem;
  border-radius: var(--radius-l);
  font-size: 1.15rem;
}

.wizard-dictation__icon {
  width: 3rem;
  height: 3rem;
}

.wizard-dictation .runner-dictation__timer {
  text-align: center;
}

.wizard-nav {
  grid-template-columns: minmax(0, 1fr);
}

.wizard-exit {
  justify-self: center;
  font-size: 0.9rem;
}

.wizard-summary {
  display: grid;
  gap: var(--space-3);
  padding: var(--space-4);
  border: 1px solid var(--line);
  border-radius: var(--radius-l);
  background: var(--surface-raised);
}

.wizard-summary h2 {
  margin: 0;
  font-size: 1.05rem;
}

.wizard-summary__list {
  display: grid;
  gap: var(--space-3);
  margin: 0;
}

.wizard-summary__row dt {
  color: var(--ink-muted);
  font-size: 0.85rem;
}

.wizard-summary__row dd {
  margin: var(--space-1) 0 0;
  font-weight: 700;
}

.wizard-summary__skipped {
  color: var(--ink-muted);
  font-weight: 400;
}

.wizard-completion__actions {
  display: grid;
  gap: var(--space-3);
}

.wizard-completion__home,
.wizard-handoff__button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 3.25rem;
  text-decoration: none;
}

/* „Zum Gespräch“ (docs/wizards.md, „Weiter zum Gespräch“): Knopf in voller Breite, darunter
   der Grund, falls er noch wartet. */
.wizard-handoff {
  display: grid;
  gap: var(--space-2);
}

.wizard-handoff__form {
  display: grid;
}

.wizard-handoff__button {
  width: 100%;
}

.wizard-handoff__hint {
  margin: 0;
  text-align: center;
  color: var(--ink-muted);
}

/* Übergang ins Gespräch ohne Zwischenstopp (docs/wizards.md, „Weiter zum Gespräch“): nur ein
   Wartehinweis mit Kreisel, darunter der Grund, falls es noch nicht losgeht. */
.wizard-uebergang {
  gap: var(--space-4);
}

.wizard-uebergang h1 {
  font-size: 1.45rem;
  line-height: 1.3;
}

.wizard-uebergang__spinner {
  display: block;
  width: 3.25rem;
  height: 3.25rem;
  margin-inline: auto;
  border: 4px solid var(--line);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: wizard-uebergang-spin 850ms linear infinite;
}

@keyframes wizard-uebergang-spin {
  to { transform: rotate(360deg); }
}

@media (prefers-reduced-motion: reduce) {
  .wizard-uebergang__spinner {
    animation: none;
  }
}

.wizard-handoff__button[hidden] {
  display: none;
}

/* Schrittwechsel ohne Animation: Der neue Schritt steht sofort. */
.wizard-step {
  display: grid;
  gap: var(--space-4);
}

/* Onboarding (docs/wizards.md): Info-Seite vor dem ersten Schritt. Die Markdown-Typografie kommt
   aus `.wiki-body` (wiki.css); das Häkchen ist groß genug für den Daumen. */
.wizard-onboarding__text {
  font-size: 1.05rem;
}

/* Die Kopfzeile hat hier nur den Wizard-Namen; `.runner-header p:last-child` würde ihn sonst
   ausgrauen wie einen Hinweis unter der Frage. */
.wizard-onboarding .runner-header .runner-header__eyebrow:last-child {
  color: var(--accent);
}

.wizard-onboarding__dismiss {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  min-height: 2.75rem;
  color: var(--ink-muted);
  cursor: pointer;
}

.wizard-onboarding__dismiss input {
  flex: 0 0 auto;
  width: 1.5rem;
  height: 1.5rem;
  margin: 0;
  accent-color: var(--accent);
}

/* `display: grid`/`flex` schlägt das UA-Stylesheet für [hidden]; versteckte Schritte und
   Kacheln (ausgeblendete Optionen, docs/wizards.md „Bedingungen“) bleiben weg. */
.wizard-step[hidden],
.wizard-completion[hidden],
.wizard-tile[hidden] {
  display: none;
}

.wizard-header__row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-3);
}

.wizard-read-aloud {
  flex: 0 0 auto;
  width: 2.75rem;
  height: 2.75rem;
  border: 1px solid var(--line);
  border-radius: 50%;
  font-size: 1.2rem;
  cursor: pointer;
  background: var(--surface-raised);
}

.wizard-read-aloud--active {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.wizard-text__status {
  margin: 0;
  color: var(--ink-muted);
  font-size: 0.85rem;
  text-align: center;
}

.wizard-completion__sync {
  margin: 0;
  color: var(--ink-muted);
  text-align: center;
}

.wizard-summary__note {
  color: var(--ink-muted);
  font-size: 0.8rem;
  font-weight: 400;
}

/* Wizard: Kopfzeile wie auf der Startseite, die leere Topbar des Runners fällt weg. „Weiter“
   und „Beenden“ stehen in einer festen Leiste ganz unten; der Inhalt bekommt unten Platz dafür. */
.wizard-runner-page .questionnaire-runner-topbar {
  display: none;
}

/* The room the fixed bar takes at the bottom: kept free below the content and below the opened
   free-text tile when it is scrolled into view. */
.wizard-runner-page {
  --wizard-nav-space: calc(9rem + env(safe-area-inset-bottom));
}

.wizard-runner-page .questionnaire-runner-shell {
  padding-top: var(--space-4);
  padding-bottom: var(--wizard-nav-space);
}

.wizard-runner-page .wizard-nav {
  position: fixed;
  right: 0;
  bottom: 0;
  left: 0;
  margin: 0;
  padding: var(--space-3) max(var(--space-4), calc((100% - 48rem) / 2)) calc(var(--space-3) + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  background: var(--surface);
}
