/*
 * FUZ Engine Forms – Grund-CSS
 *
 * Bewusst minimal und mit :where() ohne Spezifität geschrieben: Jedes Theme
 * überschreibt alles mit einfachen Selektoren, ohne !important.
 * Enthalten ist, was jedes Formular braucht – Layout, Barrierefreiheit,
 * Fokus, Fehlerzustände, Hochkontrast – und ein neutraler Fallback-Button.
 *
 * Anpassen über Custom Properties, z. B. im Theme:
 *   .fuz-form { --fuz-form-accent: #d23f3a; --fuz-form-radius: 3px; }
 */

:where(.fuz-form-wrap, .fuz-request-form-wrap) {
    --fuz-form-gap: 1.25rem;
    --fuz-form-accent: currentColor;          /* Fokus, Pflichtfeld-Stern */
    --fuz-form-error: #b3261e;                 /* 6:1 auf Weiß */
    --fuz-form-border: currentColor;
    --fuz-form-radius: 0.375rem;
    --fuz-form-control-padding: 0.75rem 0.875rem;
    width: 100%;
}

/* ---------- Layout ---------- */
:where(.fuz-form) { display: flex; flex-direction: column; gap: var(--fuz-form-gap); }
:where(.fuz-form__fields) { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: var(--fuz-form-gap) 1rem; }
:where(.fuz-form__field) { grid-column: 1 / -1; min-width: 0; margin: 0; padding: 0; border: 0; }
@media (min-width: 768px) {
    :where(.fuz-form__field--half) { grid-column: span 3; }
    :where(.fuz-form__field--third) { grid-column: span 2; }
}

/* ---------- Beschriftung, Hinweise, Fehler ---------- */
:where(.fuz-form__label) { display: block; margin: 0 0 0.375rem; padding: 0; font-weight: 600; }
:where(.fuz-form__required) { margin-left: 0.125rem; color: var(--fuz-form-accent); }
:where(.fuz-form__hint) { margin: 0 0 0.375rem; font-size: 0.875em; }
:where(.fuz-form__error) { display: flex; gap: 0.375rem; margin: 0.375rem 0 0; font-size: 0.875em; font-weight: 600; color: var(--fuz-form-error); }
/* Fehler nicht nur über Farbe erkennbar (WCAG 1.4.1): Warnzeichen vor dem Text */
:where(.fuz-form__error:not([hidden]))::before { content: "!"; display: inline-grid; place-items: center; flex: none; width: 1.2em; height: 1.2em; border-radius: 50%; background: var(--fuz-form-error); color: #fff; font-size: 0.8em; line-height: 1; }
:where(.fuz-form__legend) { margin: 0; font-size: 0.875em; }

/* ---------- Felder ---------- */
:where(.fuz-form__control) {
    display: block; width: 100%; max-width: 100%; margin: 0; box-sizing: border-box;
    padding: var(--fuz-form-control-padding); font: inherit; line-height: 1.4; color: inherit;
    background: transparent; border: 1px solid var(--fuz-form-border); border-radius: var(--fuz-form-radius);
}
:where(textarea.fuz-form__control) { min-height: 8rem; resize: vertical; }
:where(.fuz-form__field.is-invalid .fuz-form__control) { border-color: var(--fuz-form-error); border-width: 2px; }

:where(.fuz-form__options) { display: grid; gap: 0.5rem; }
:where(.fuz-form__option, .fuz-form__check) { display: flex; align-items: flex-start; gap: 0.75rem; }
/* Zielgröße mindestens 24 × 24 px (WCAG 2.5.8) */
:where(.fuz-form__option input, .fuz-form__check input) { flex: none; width: 1.5rem; height: 1.5rem; margin: 0; accent-color: var(--fuz-form-accent); }
:where(.fuz-form__option label, .fuz-form__check label) { padding-top: 0.125rem; cursor: pointer; }

/* ---------- Fokus (WCAG 2.4.7 / 2.4.11) ---------- */
:where(.fuz-form) :where(input, select, textarea, button, a):focus-visible,
:where(.fuz-form__summary, .fuz-form__status):focus-visible {
    outline: 2px solid var(--fuz-form-accent);
    outline-offset: 2px;
}
:where(.fuz-form) :where(input, select, textarea):focus:not(:focus-visible) { outline: none; }

/* ---------- Fehlerliste und Statusmeldung ---------- */
:where(.fuz-form__summary) { padding: 1rem 1.25rem; border: 2px solid var(--fuz-form-error); border-radius: var(--fuz-form-radius); }
:where(.fuz-form__summary-title) { margin: 0; font-weight: 700; }
:where(.fuz-form__summary ul) { margin: 0.5rem 0 0; padding-left: 1.25rem; }
:where(.fuz-form__summary a) { color: inherit; text-decoration: underline; }
:where(.fuz-form__status:not([hidden])) { padding: 1rem 1.25rem; margin-bottom: 1rem; border: 1px solid currentColor; border-radius: var(--fuz-form-radius); }

/* ---------- Button (neutraler Fallback – das Theme stylt .fuz-button) ---------- */
:where(.fuz-button) {
    display: inline-flex; align-items: center; justify-content: center; gap: 0.75rem;
    min-height: 44px; padding: 0.75rem 1.5rem; font: inherit; font-weight: 700; line-height: 1;
    color: inherit; background: transparent; border: 1px solid currentColor; border-radius: var(--fuz-form-radius, 0.375rem);
    cursor: pointer; text-decoration: none;
}
:where(.fuz-button__icon svg) { display: block; width: 1.25em; height: auto; }
:where(.fuz-button:focus-visible) { outline: 2px solid var(--fuz-form-accent, currentColor); outline-offset: 3px; }
:where(.fuz-button:disabled, .fuz-button[aria-disabled="true"]) { opacity: 0.6; cursor: not-allowed; }
:where(.fuz-form[aria-busy="true"] .fuz-form__submit) { cursor: progress; }
:where(.fuz-form__submit) { align-self: flex-start; }

/* ---------- Hilfsklassen ---------- */
:where(.fuz-request-form__honeypot, .fuz-request-form__hidden) {
    position: absolute !important; left: -9999px !important; width: 1px !important; height: 1px !important; overflow: hidden !important;
}
:where(.fuz-form) .screen-reader-text {
    position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden;
    clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; border: 0;
}

/* ---------- Bewegung reduzieren ---------- */
@media (prefers-reduced-motion: reduce) {
    :where(.fuz-form *, .fuz-form-wrap *) { transition-duration: 0.01ms !important; animation-duration: 0.01ms !important; }
}

/* ---------- Hochkontrast (Windows) ---------- */
@media (forced-colors: active) {
    :where(.fuz-form__control, .fuz-button, .fuz-form__summary, .fuz-form__status) { border: 1px solid CanvasText; }
    :where(.fuz-form__error) { color: CanvasText; }
    :where(.fuz-form) :where(input, select, textarea, button, a):focus-visible { outline: 2px solid Highlight; }
}

/* ---------- 1.0.x-Kompatibilität (Standardformular „request“) ---------- */
:where(.fuz-request-form__grid--three .fuz-form__field--third) { grid-column: span 6; }
@media (min-width: 1100px) { :where(.fuz-request-form__grid--three .fuz-form__field--third) { grid-column: span 2; } }
:where(.fuz-request-form__consent label) { display: inline-block; }
