/*
 * DEPLA Theme Welle 3: Formulare (Contao-Formulargenerator, Core-Widgets, Altcha)
 * Gilt fuer Kontakt (61) und Bewerbung (62), Klasse style1 am Formular. Felder ohne sichtbare Labels, nur Platzhalter.
 * Messwerte: docs/referenz/kontakt und jobs (1440: Feld 747 x 51 px, Abstand 20 px, Textarea 317 px,
 * Button 44 px hoch, Icon fa-send) und docs/analyse/formulare.md. Nur Tokens aus tokens.css.
 */

.ce_form {
  /* Messwerte live ohne Token: Formular 15px unter dem Einleitungstext, unter der Textarea 9px mehr
   * (live steht die Textarea inline auf der Grundlinie) */
  --form-offset-top: 15px;
  --form-textarea-extra: 9px;
}

.ce_form form {
  padding-top: var(--form-offset-top);
}

.ce_form .widget {
  position: relative;
  margin-bottom: var(--form-gap);
}

.ce_form .widget-textarea {
  margin-bottom: calc(var(--form-gap) + var(--form-textarea-extra));
}

/* Labels: nur Altcha und Checkboxen haben eins, Textfelder arbeiten mit Platzhaltern wie live */
.ce_form .widget > label {
  display: block;
  margin-bottom: 5px;
  font-size: var(--fs-form);
}

.ce_form span.mandatory {
  color: var(--color-error);
}

/* Eingabefelder */
.ce_form .widget :is(input:not([type='checkbox'], [type='radio'], [type='submit'], [type='hidden'], [type='file']), textarea, select) {
  display: block;
  width: 100%;
  margin: 0;
  padding: var(--form-field-pad);
  border: 1px solid var(--color-border-input);
  border-radius: 0;
  background-color: var(--color-white);
  color: var(--color-black);
  font-family: var(--font-body);
  font-size: var(--fs-form);
  font-weight: var(--fw-regular);
  line-height: normal;
  transition: border-color var(--ease-form), background-color var(--ease-form);
  -webkit-appearance: none;
  appearance: none;
}

.ce_form .widget textarea {
  height: var(--form-textarea-h);
  min-height: calc(var(--form-field-pad) * 4);
  resize: vertical;
}

.ce_form .widget :is(input, textarea, select)::placeholder {
  color: var(--color-text);
  opacity: 1;
}

.ce_form .widget :is(input:not([type='checkbox'], [type='radio'], [type='submit']), textarea, select):hover {
  border-color: var(--color-border-input-hover);
}

.ce_form .widget :is(input:not([type='checkbox'], [type='radio'], [type='submit']), textarea, select):focus {
  border-color: var(--color-primary);
  outline: none;
}

.ce_form .widget :is(input, textarea, select):focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}

/* Hinweistext (Einwilligung): Fliesstext wie live */
.ce_form .widget-explanation p:last-child {
  margin-bottom: 0;
}

/* Fehler: Contao setzt p.error vor das Feld und die Klasse error an Feld und Widget */
.ce_form p.error {
  margin: 0 0 5px;
  color: var(--color-error);
  font-size: var(--fs-form);
  line-height: var(--lh-lead);
}

.ce_form .widget :is(input, textarea, select).error {
  border-color: var(--color-error);
}

/* Absenden: Orange mit Papierflieger-Icon (live fa-send) */
.ce_form .widget-submit {
  margin-bottom: 0;
}

.ce_form button.submit,
.ce_form input.submit {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  min-width: 140px;
  margin: 0;
  padding: var(--form-field-pad) 20px;
  border: 0;
  border-radius: var(--radius-form);
  background: var(--color-primary);
  color: var(--color-white);
  font-family: var(--font-body);
  font-size: var(--fs-button-form);
  font-weight: var(--fw-bold);
  line-height: 14px;
  text-align: center;
  cursor: pointer;
  transition: opacity var(--ease-fast);
  -webkit-appearance: none;
  appearance: none;
}

.ce_form button.submit::before {
  content: '';
  display: block;
  flex: 0 0 auto;
  width: 1em;
  height: 1em;
  background-color: currentColor;
  -webkit-mask: url('../img/icons/send.svg') center / contain no-repeat;
  mask: url('../img/icons/send.svg') center / contain no-repeat;
}

.ce_form button.submit:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}

/* AJAX-Versand laeuft (Contao setzt data-ajax-form="loading") */
.ce_form form[data-ajax-form='loading'] button.submit {
  opacity: var(--hover-opacity);
  cursor: progress;
}

/* Bestaetigung nach AJAX-Versand (Kontakt), ersetzt das Formular */
.ce_form .form-confirmation {
  padding: var(--form-field-pad) 20px;
  border-left: 3px solid var(--color-primary);
  background: var(--color-white);
}

.ce_form .form-confirmation p:last-child {
  margin-bottom: 0;
}

/* Altcha (Spamschutz, neu gegenueber live): optisch wie die Eingabefelder, volle Breite.
 * Das Label "Spamschutz" bleibt fuer Screenreader, sichtbar traegt das Widget die Beschriftung. */
.ce_form .widget-altcha > label {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
}

.ce_form altcha-widget {
  display: block;
  --altcha-max-width: 100%;
  --altcha-border-width: 1px;
  --altcha-border-radius: 0;
  --altcha-color-base: var(--color-white);
  --altcha-color-border: var(--color-border-input);
  --altcha-color-border-focus: var(--color-primary);
  --altcha-color-text: var(--color-text);
  --altcha-color-active: var(--color-primary);
  --altcha-color-error-text: var(--color-error);
  font-size: var(--fs-form);
  font-weight: var(--fw-regular);
  line-height: normal;
}

.ce_form .altcha-main {
  padding: 13px var(--form-field-pad);
}

.ce_form .altcha-checkbox input {
  accent-color: var(--color-primary);
}

.ce_form .altcha-footer {
  padding: 0 var(--form-field-pad) 8px;
}

.ce_form .altcha-footer a {
  color: inherit;
}
