/* KASKADE 4.x: Anfrage-Flow. Ab Schritt 2 auf dem Handy als Vollbild (D3). */

/* §9-Layout: Intro oben, darunter Zeile „Anfrage + Zähler | Panel“ (Zeilen-Raster in sections.css, .anfrage) */
.flow__intro { display: flex; flex-direction: column; gap: var(--s-4); padding-bottom: var(--s-7); border-bottom: 1px solid var(--line); }
.flow__intro p { margin: 0; }
.flow__intro .h2 { font-size: clamp(2rem, 1.4rem + 1.8vw, 3rem); }
.flow__panel { position: relative; min-width: 0; }
.flow__seite { display: none; }
.flow__zaehler { margin: 0; font-family: var(--font-mono); font-weight: 500; font-size: clamp(1.75rem, 1.3rem + 1.2vw, 2.5rem); line-height: 1; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.flow.is-fertig .flow__zaehler { visibility: hidden; }
@media (min-width: 768px) and (max-width: 1023px), (min-width: 1280px) {
  .flow__seite { display: flex; flex-direction: column; gap: var(--s-4); align-self: start; position: sticky; top: calc(var(--header-h) + var(--s-5)); }
  /* großer Zähler links ersetzt die Zeile „Schritt x von 6“ optisch; für Screenreader bleibt sie (aria-live) */
  .flow__stand { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
}
.flow.is-angestossen .flow__zeile { animation: flow-puls 900ms var(--ease) 1; }
@keyframes flow-puls {
  0% { background: color-mix(in srgb, var(--akzent-fill) 16%, transparent); box-shadow: 0 0 0 12px color-mix(in srgb, var(--akzent-fill) 16%, transparent); }
  100% { background: transparent; box-shadow: 0 0 0 12px transparent; }
}

.flow__leiste { display: flex; align-items: center; gap: var(--s-4); min-height: 32px; }
.flow__zurueck { display: inline-flex; align-items: center; gap: 6px; font-size: var(--fs-small); text-decoration: none; }
.flow__zurueck svg { width: 18px; height: 18px; }
.flow__stand { margin: 0 0 0 auto; color: var(--muted-dunkel); }
.flow__schliessen { width: 40px; height: 40px; display: grid; place-items: center; border: 1px solid var(--line); border-radius: var(--r-2); background: transparent; }
.flow__schliessen svg { width: 20px; height: 20px; }
.flow__fortschritt { display: grid; grid-template-columns: repeat(6, 1fr); gap: 4px; margin: var(--s-3) 0 var(--s-6); }
@media (min-width: 768px) and (max-width: 1023px), (min-width: 1280px) { .flow__fortschritt { margin-top: 0; } }
.flow__fortschritt span { height: 2px; background: var(--linie-hell); transition: background-color var(--dur) var(--ease); }
.flow__fortschritt span.is-done { background: var(--akzent-strong); }

.flow__schritt { margin: 0; padding: 0; border: 0; min-width: 0; }
.flow__schritt[hidden] { display: none; }
.flow__frage { display: block; float: left; width: 100%; padding: 0; margin-bottom: var(--s-5); outline: none; }
.flow__frage + * { clear: both; }
.flow__subline { margin: calc(-1 * var(--s-3)) 0 var(--s-5); clear: both; }
.flow__mikro { margin: var(--s-4) 0 0; }
.flow.is-wechsel .flow__schritt:not([hidden]) { animation: flow-rein 220ms var(--ease); }
@keyframes flow-rein { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* Kacheln */
.kacheln { display: grid; gap: var(--s-3); }
.kacheln + .kacheln { margin-top: var(--s-3); }
.kachel {
  position: relative; display: flex; align-items: center; gap: var(--s-4); width: 100%; min-height: 64px;
  padding: var(--s-4) 52px var(--s-4) var(--s-4); text-align: left;
  border: 1px solid var(--linie-hell); border-radius: var(--r-2); background: #fff;
  font-size: var(--fs-body); font-weight: 500; line-height: 1.35;
  transition: border-color var(--dur) var(--ease), background-color var(--dur) var(--ease);
}
.kachel > svg { width: 24px; height: 24px; flex: none; color: var(--akzent-strong); }
.kachel:hover { border-color: var(--text-dunkel); }
.kachel::after {
  content: ""; position: absolute; right: 16px; top: 50%; width: 20px; height: 20px; margin-top: -10px;
  border: 1px solid var(--linie-hell); border-radius: var(--r-1); background: #fff;
}
.kachel[aria-checked="true"] { border-color: var(--akzent-strong); box-shadow: inset 0 0 0 1px var(--akzent-strong); background: #fff; }
.kachel[aria-checked="true"]::after {
  border-color: var(--akzent-strong);
  background: var(--akzent-strong) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M5 12.5l4.5 4.5L19 7.5' fill='none' stroke='white' stroke-width='2.5'/%3E%3C/svg%3E") center / 16px no-repeat;
}
@media (min-width: 640px) { .kacheln--2 { grid-template-columns: 1fr 1fr; } }

/* Fahrzeug-Kacheln mit Foto (Schritt 3) */
.kacheln--foto { grid-template-columns: 1fr; }
@media (min-width: 480px) { .kacheln--foto { grid-template-columns: 1fr 1fr; } }
.kachel--foto { flex-direction: column; align-items: stretch; gap: 0; padding: 0; overflow: hidden; }
.kachel--foto::after { top: 12px; margin-top: 0; right: 12px; }
.kachel--foto .foto-folgt, .kachel--foto .media { border-radius: 0; aspect-ratio: 4 / 3; }
.kachel--foto > picture img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; }
.kachel--foto .foto-folgt .label { font-size: 10px; }
.kachel__text { display: flex; flex-direction: column; gap: 4px; padding: var(--s-3) var(--s-4) var(--s-4); }
.kachel__text .label { color: var(--muted-dunkel); }
.kachel__ihre { position: absolute; left: 12px; top: 12px; z-index: 3; }

/* Wünsche + Felder */
.wuensche { margin-bottom: var(--s-5); }
.wuensche .ph-flag { padding: 0 4px; font-size: 9px; }
.felder { display: grid; gap: var(--s-5) var(--s-6); }
@media (min-width: 640px) { .felder { grid-template-columns: 1fr 1fr; } }
.feld { display: flex; flex-direction: column; gap: 6px; }
.feld label { font-size: var(--fs-small); font-weight: 500; }
/* Unterstrich statt Kasten (Referenz). Linie --muted auf Papier ≈ 3:1 (WCAG 1.4.11); Fokus: 2 px Akzent */
.feld input[type="text"], .feld input[type="tel"], .feld input[type="email"], .feld textarea {
  width: 100%; min-height: 48px; padding: 10px 0; border: 0; border-bottom: 1px solid var(--muted); border-radius: 0;
  background: transparent; font-size: 1rem; transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
.feld textarea { min-height: 96px; resize: vertical; }
.feld input:hover, .feld textarea:hover { border-bottom-color: var(--text-dunkel); }
.feld input:focus-visible, .feld textarea:focus-visible { outline: none; border-bottom-color: var(--akzent-strong); box-shadow: 0 1px 0 0 var(--akzent-strong); }
.feld [aria-invalid="true"] { border-bottom-color: var(--error); box-shadow: 0 1px 0 0 var(--error); }
.feld__hinweis, .feld__fehler { margin: 0; font-size: var(--fs-small); }
.feld__fehler { color: var(--error); }
.feld--check { display: grid; grid-template-columns: 20px 1fr; gap: 6px 12px; align-items: start; margin: var(--s-5) 0; }
.feld--check input { width: 20px; height: 20px; margin: 2px 0 0; accent-color: var(--akzent-strong); border-radius: var(--r-1); }
.feld--check label { font-weight: 400; line-height: 1.45; }
.feld--check .feld__fehler { grid-column: 2; }
.feld--hp { position: absolute !important; left: -9999px; width: 1px; height: 1px; overflow: hidden; }
@media (min-width: 768px) { .flow .btn--block { width: auto; } }
.flow__aktionen { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-5); margin-top: var(--s-6); }
.flow__weiter { margin-top: var(--s-5); }
.flow__fehler-senden { color: var(--error); margin-top: var(--s-3); }
.vorschau-hinweis { margin: var(--s-4) 0 0; padding: 8px 12px; border: 1px dashed var(--akzent-strong); border-radius: var(--r-1); color: var(--akzent-strong); font-family: var(--font-mono); font-size: 12px; }
.btn.is-laedt { pointer-events: none; opacity: .7; }

/* Danke */
.flow__danke { display: flex; flex-direction: column; gap: var(--s-5); align-items: flex-start; padding: var(--s-4) 0; }
.flow__danke[hidden] { display: none; }
.flow__danke p { margin: 0; max-width: 60ch; }
.flow__danke h3 { outline: none; }
.flow__danke-icon { width: 48px; height: 48px; display: grid; place-items: center; background: var(--success); color: #fff; border-radius: var(--r-2); }
.flow__danke-icon svg { width: 26px; height: 26px; }
.flow.is-fertig .flow__leiste, .flow.is-fertig .flow__fortschritt { display: none; }

/* Vollbild auf dem Handy ab Schritt 2 */
@media (max-width: 767px) {
  .flow.is-vollbild .flow__panel {
    position: fixed; inset: 0; z-index: 60; overflow-y: auto; overscroll-behavior: contain;
    border: 0; border-radius: 0; padding: var(--s-4) var(--rand) calc(var(--s-7) + env(safe-area-inset-bottom)); background: var(--papier);
  }
  .flow.is-vollbild .flow__leiste { position: sticky; top: calc(-1 * var(--s-4)); z-index: 2; margin: calc(-1 * var(--s-4)) calc(-1 * var(--rand)) 0; padding: var(--s-3) var(--rand); background: var(--papier); border-bottom: 1px solid var(--line); }
  html.flow-offen, html.flow-offen body { overflow: hidden; }
}

/* ---------- §9 dunkle Formularfläche (Referenz 12.10.): .anfrage__inhalt.flaeche-dunkel ----------
   Zweifarbige Headline (erster Teil --muted), Auswahl als Outline-Pills statt weißer Kacheln,
   Unterstrich-Felder hell auf Graphit, Absenden-Button vollbreit mit zentriertem Text.
   Kontraste auf --graphit: --muted 5,3:1 (Linien ≥ 3:1), --akzent 9,3:1, Fehlerrot #FF8A7A 7,3:1. */
.anfrage__inhalt.flaeche-dunkel { --error: #FF8A7A; }
/* Trennlinie zur ebenfalls dunklen Kontaktleiste: mobil oben, Desktop links */
.anfrage__inhalt.flaeche-dunkel { border-top: 1px solid var(--line); }
@media (min-width: 1024px) { .anfrage__inhalt.flaeche-dunkel { border-top: 0; border-left: 1px solid var(--line); } }
.flow__titel-leise { color: var(--muted); }
.flaeche-dunkel .flow__stand { color: var(--muted); }
.flaeche-dunkel .flow__fortschritt span { background: var(--linie-dunkel); }
.flaeche-dunkel .flow__fortschritt span.is-done { background: var(--akzent); }

/* Auswahl-Kacheln → Outline-Pills (Foto-Kacheln in Schritt 3 bleiben Karten) */
.flaeche-dunkel .kacheln:not(.kacheln--foto) { display: flex; flex-wrap: wrap; gap: var(--s-3); }
.flaeche-dunkel .kachel:not(.kachel--foto), .flaeche-dunkel .flow .chip {
  width: auto; max-width: 100%; min-height: 48px; padding: 10px 20px; gap: 0;
  border: 1px solid var(--muted); border-radius: var(--r-3); background: transparent; color: var(--text-hell);
  font-size: var(--fs-small); font-weight: 500; line-height: 1.35; text-align: left;
}
.flaeche-dunkel .kachel:not(.kachel--foto) > svg, .flaeche-dunkel .kachel:not(.kachel--foto)::after { display: none; }
.flaeche-dunkel .kachel:not(.kachel--foto):hover, .flaeche-dunkel .flow .chip:hover { border-color: var(--text-hell); background: rgba(243, 240, 234, .06); }
.flaeche-dunkel .kachel:not(.kachel--foto)[aria-checked="true"], .flaeche-dunkel .flow .chip[aria-pressed="true"] {
  border-color: var(--akzent-fill); background: var(--akzent-fill); color: var(--akzent-on); box-shadow: none;
}

/* Foto-Kacheln auf Graphit */
.flaeche-dunkel .kachel--foto { border-color: var(--linie-dunkel); background: var(--graphit-2); color: var(--text-hell); }
.flaeche-dunkel .kachel--foto:hover { border-color: var(--muted); }
.flaeche-dunkel .kachel--foto::after { border-color: var(--muted); background: var(--graphit); }
.flaeche-dunkel .kachel--foto[aria-checked="true"] { border-color: var(--akzent); box-shadow: inset 0 0 0 1px var(--akzent); background: var(--graphit-2); }
.flaeche-dunkel .kachel--foto[aria-checked="true"]::after {
  border-color: var(--akzent);
  background: var(--akzent) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M5 12.5l4.5 4.5L19 7.5' fill='none' stroke='%2316171A' stroke-width='2.5'/%3E%3C/svg%3E") center / 16px no-repeat;
}
.flaeche-dunkel .kachel__text .label { color: var(--muted); }

/* Felder: Label klein, Linie --muted, Fokus Akzent */
.flaeche-dunkel .feld label { font-weight: 400; color: rgba(243, 240, 234, .86); }
.flaeche-dunkel .feld input[type="text"], .flaeche-dunkel .feld input[type="tel"], .flaeche-dunkel .feld input[type="email"], .flaeche-dunkel .feld textarea {
  border-bottom-color: var(--muted); color: var(--text-hell); caret-color: var(--akzent);
}
.flaeche-dunkel .feld input:hover, .flaeche-dunkel .feld textarea:hover { border-bottom-color: var(--text-hell); }
.flaeche-dunkel .feld input:focus-visible, .flaeche-dunkel .feld textarea:focus-visible { border-bottom-color: var(--akzent); box-shadow: 0 1px 0 0 var(--akzent); }
.flaeche-dunkel .feld [aria-invalid="true"] { border-bottom-color: var(--error); box-shadow: 0 1px 0 0 var(--error); }
.flaeche-dunkel .feld input:-webkit-autofill { -webkit-text-fill-color: var(--text-hell); box-shadow: inset 0 0 0 100px var(--graphit); }
.flaeche-dunkel .feld--check input { accent-color: var(--akzent); }
.flaeche-dunkel .feld--check label { color: var(--text-hell); }
.flaeche-dunkel .vorschau-hinweis { border-color: var(--akzent); color: var(--akzent); }

/* Absenden: vollbreit, Text mittig */
.flaeche-dunkel .flow .btn[data-flow-senden] { width: 100%; justify-content: center; margin-top: var(--s-2); }

@media (max-width: 767px) {
  .flaeche-dunkel .flow.is-vollbild .flow__panel, .flaeche-dunkel .flow.is-vollbild .flow__leiste { background: var(--graphit); }
}
/* Dunkle Fläche läuft bis zum rechten Rand; die 920-px-Begrenzung gilt jetzt für den Inhalt (Desktop-XL regelt ≥ 1920 selbst) */
@media (min-width: 1024px) and (max-width: 1919px) {
  .anfrage__inhalt.flaeche-dunkel { max-width: none; }
  .anfrage__inhalt.flaeche-dunkel > .flow { max-width: calc(920px - 2 * var(--s-8)); }
}
