/* =============================================================================
   CONTACT FORM 7 — Formulare im Design des Anfrage-Modals
   PHP: inc/cf7.php · template-parts/sections/s09_formular.php
   Vorbild: template-parts/anfrage-formular.php + css/pages/anfrage.css

   Das Anfrage-Modal ist das führende Design. Seine Felder tragen die Atoms des
   Design Systems (.label .input .select .textarea .checkbox .btn), deshalb
   bekommen auch die CF7-Formulare diese Klassen direkt im Formular-Template
   mit (`class:input`, `class:select` …). Diese Datei ergänzt nur das, was
   CF7 selbst erzeugt und was sich dort nicht beschriften lässt:

     1. die Wrapper-<span>, die CF7 um jedes Feld legt
     2. Radio- und Checkbox-Listen (CF7 baut sie ohne unsere Klassen)
     3. Absende-Zeile, Spinner, Fehlermeldungen, Antwortfeld
     4. den Papier-Block, in dem das Formular steht (wie .anf-page__form)

   Ohne die Klassen im Template greift hier fast nichts — beide Teile gehören
   zusammen, siehe wp-cli-imports/cf7-formulare.php.
   ============================================================================= */

/* ── Grundgerüst ───────────────────────────────────────────────────────────── */

/* CF7 schiebt vor das Formular eine Screenreader-Antwort und hinter jedes Feld
   ein leeres <p>; beides darf keinen Abstand aufreissen. */
.wpcf7 .screen-reader-response { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }

/* Der Formularrumpf setzt die Abstände wie ein Schritt im Modal (.anf-step). */
.ir-cf7 {
  display: flex;
  flex-direction: column;
  gap: clamp(1rem, 2vw, 1.375rem);
}

/* CF7 rendert jedes Feld in <span class="wpcf7-form-control-wrap">. Inline
   bliebe der Wrapper schmaler als das Feld — die Breite von .input (100 %)
   bezöge sich dann auf einen Inline-Kasten und der Fokusrahmen sässe falsch. */
.ir-cf7 .wpcf7-form-control-wrap { display: block; }

/* Feldgruppen: gleiche Zeilenlogik wie im Modal (.form-group aus
   molecules/form-field.css), hier nur die Sonderbreiten der Adresszeile. */
.ir-cf7 .form-field--anrede  { flex: 0 0 8rem; }
.ir-cf7 .form-field--strasse { flex: 2 1 0; }
.ir-cf7 .form-field--plz     { flex: 0 0 8rem; }

@media (max-width: 767px) {
  .ir-cf7 .form-field--anrede,
  .ir-cf7 .form-field--plz { flex: 1 1 auto; }
}

/* Fieldsets tragen nur die Gruppierung, kein Kasten. */
.ir-cf7 fieldset {
  border: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.ir-cf7 legend {
  padding: 0;
  font-size: var(--font-size-text-small);
  font-weight: var(--font-weight-medium);
  color: var(--theme-input-label);
  line-height: var(--line-height-text-small);
}

/* Trennlinie zwischen den Abschnitten — im Modal macht das die Schrittleiste. */
.ir-cf7__trenner {
  margin: 0.25rem 0 0;
  padding-top: 1.25rem;
  border-top: 1px solid var(--hair-soft);
  font-family: var(--display);
  font-size: 1.15rem;
  font-weight: var(--font-weight-regular);
  color: var(--color-brand-primary-700);
}


/* ── Radio-Listen ──────────────────────────────────────────────────────────── */
/* CF7 baut <span class="wpcf7-radio"><span class="wpcf7-list-item"><label>…
   Die Klassen von atoms/radio.css lassen sich dort nicht setzen, also werden
   sie hier auf CF7s eigene Struktur gespiegelt. */

.ir-cf7 .wpcf7-radio,
.ir-cf7 .wpcf7-checkbox {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1.75rem;
}

.ir-cf7 .wpcf7-radio .wpcf7-list-item,
.ir-cf7 .wpcf7-checkbox .wpcf7-list-item { margin: 0; }

.ir-cf7 .wpcf7-radio label,
.ir-cf7 .wpcf7-checkbox label {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  cursor: pointer;
  user-select: none;
  font-size: 0.9375rem;
  font-weight: var(--font-weight-medium);
  color: var(--theme-text-body);
  line-height: 1.4;
}

.ir-cf7 input[type="radio"] {
  flex-shrink: 0;
  appearance: none;
  -webkit-appearance: none;
  width: 1.125rem;
  height: 1.125rem;
  border: 2px solid var(--theme-border-strong);
  border-radius: 50%;
  background-color: var(--theme-bg-page);
  cursor: pointer;
  position: relative;
  transition: border-color 120ms ease, background-color 120ms ease;
}

.ir-cf7 input[type="radio"]::after {
  content: '';
  position: absolute;
  inset: 50% auto auto 50%;
  translate: -50% -50%;
  width: 0.4375rem;
  height: 0.4375rem;
  border-radius: 50%;
  background-color: #fff;
  opacity: 0;
  transition: opacity 120ms ease;
}

.ir-cf7 input[type="radio"]:checked {
  border-color: var(--theme-btn-primary-bg);
  background-color: var(--theme-btn-primary-bg);
}

.ir-cf7 input[type="radio"]:checked::after { opacity: 1; }
.ir-cf7 input[type="radio"]:hover:not(:disabled) { border-color: var(--theme-btn-primary-bg); }

.ir-cf7 input[type="radio"]:focus-visible,
.ir-cf7 input[type="checkbox"]:focus-visible {
  outline: 2px solid var(--theme-border-focus);
  outline-offset: 2px;
}


/* ── Checkboxen + Einwilligung ─────────────────────────────────────────────── */
/* Gleiche Optik wie atoms/checkbox.css (.checkbox__input). */

.ir-cf7 input[type="checkbox"] {
  flex-shrink: 0;
  appearance: none;
  -webkit-appearance: none;
  width: 1.125rem;
  height: 1.125rem;
  margin-top: 0.15em;
  background-color: var(--theme-input-bg);
  border: 1.5px solid var(--theme-input-border);
  border-radius: var(--border-radius-tiny);
  cursor: pointer;
  transition: background-color 0.15s ease, border-color 0.15s ease;
}

.ir-cf7 input[type="checkbox"]:hover { border-color: var(--theme-input-border-hover); }

.ir-cf7 input[type="checkbox"]:checked {
  background-color: var(--theme-btn-primary-bg);
  border-color: var(--theme-btn-primary-border);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath stroke='white' stroke-width='2' stroke-linecap='round' stroke-linejoin='round' fill='none' d='M2 6l3 3 5-5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: center;
  background-size: 0.75rem;
}

/* Die Einwilligung ist Kleingedrucktes, nicht Feldbeschriftung — wie
   .anf-consent .checkbox__label im Modal. */
.ir-cf7 .wpcf7-acceptance label {
  align-items: flex-start;
  font-size: var(--font-fontSize-sm);
  font-weight: var(--font-weight-regular);
  color: var(--ink-soft);
  line-height: 1.5;
}

.ir-cf7 .wpcf7-acceptance a {
  color: var(--color-brand-primary-600);
  text-decoration: underline;
  text-underline-offset: 0.125rem;
}


/* ── Absende-Zeile ─────────────────────────────────────────────────────────── */
/* Entspricht .anf-nav: abgesetzt durch eine Haarlinie, Button rechts. */

.ir-cf7__aktionen {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-top: 0.5rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--hair-soft);
}

/* CF7 hängt den Spinner direkt hinter den Button. Er läuft nur beim Senden;
   davor darf er keine Lücke in die Zeile reissen. */
.ir-cf7 .wpcf7-spinner { margin: 0 0 0 0.25rem; }
.ir-cf7 .wpcf7-spinner:not(.is-active) { display: none; }


/* ── Fehler + Antwort ──────────────────────────────────────────────────────── */

/* Feldfehler: Ton und Grösse von .form-field__error. */
.ir-cf7 .wpcf7-not-valid-tip {
  display: block;
  margin-top: var(--spacer-xxsmall);
  font-size: var(--font-size-text-tiny);
  line-height: var(--line-height-text-tiny);
  color: var(--theme-status-error-text);
}

.ir-cf7 .wpcf7-not-valid { border-color: var(--theme-input-border-error); }

/* Antwortfeld: CF7 blendet es über aria-hidden aus, nicht über display.
   Die Farbe kommt aus dem Zustand am <form> (init/sent/invalid/failed). */
.wpcf7 form .wpcf7-response-output {
  margin: 1.25rem 0 0;
  padding: 0.875rem 1.125rem;
  border: 1px solid currentColor;
  border-radius: var(--border-radius-small);
  font-size: var(--font-fontSize-sm);
  line-height: 1.5;
}

.wpcf7 form.init .wpcf7-response-output,
.wpcf7 form.resetting .wpcf7-response-output,
.wpcf7 form.submitting .wpcf7-response-output { display: none; }

.wpcf7 form.sent .wpcf7-response-output {
  color: var(--color-brand-primary-600);
  background: color-mix(in srgb, var(--color-brand-primary-500) 8%, transparent);
}

.wpcf7 form.invalid .wpcf7-response-output,
.wpcf7 form.unaccepted .wpcf7-response-output,
.wpcf7 form.payment-required .wpcf7-response-output,
.wpcf7 form.failed .wpcf7-response-output,
.wpcf7 form.aborted .wpcf7-response-output {
  color: var(--theme-status-error-text);
  background: color-mix(in srgb, var(--color-error-500) 7%, transparent);
}


/* ── Papier-Block ──────────────────────────────────────────────────────────── */
/* Wie .anf-page__form: das Formular steht auf hellem Papier, damit es sich vom
   Sektionshintergrund (oft Cream) abhebt — im Modal leistet das der Dialog. */

.rg-form__embed {
  padding: clamp(1.5rem, 3.5vw, 2.5rem);
  border: 1px solid var(--hair-soft);
  border-radius: var(--border-radius-large);
  background: var(--paper, #fff);
}

@media (max-width: 720px) {
  .rg-form__embed {
    padding: 1.25rem;
    border-radius: var(--border-radius-medium);
  }
}
