/* ==========================================================================
   Komponenten: wiederverwendbare Bausteine
   (Raute-Streifen, Buttons, Formular-Meldungen, Dialog)
   ========================================================================== */

/* ---------- Raute-Streifen (bayerisches Rautenmuster) ---------- */
.raute-strip {
  height: 8px;
  background-color: var(--navy-dark);
  background-image:
    linear-gradient(45deg, var(--blue-accent) 25%, transparent 25%, transparent 75%, var(--blue-accent) 75%),
    linear-gradient(45deg, var(--blue-accent) 25%, transparent 25%, transparent 75%, var(--blue-accent) 75%);
  background-size: 16px 16px;
  background-position: 0 0, 8px 8px;
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--blue-accent);
  color: var(--white);
  font-weight: 600;
  border: none;
  border-radius: 4px;
  transition: background-color .15s ease;
}
.btn:hover { background: var(--blue-hover); }
.btn:disabled { opacity: .6; cursor: wait; }

.btn--block { width: 100%; }

/* Dezenter Text-Button, z. B. „Zurück“ */
.btn-link {
  display: block;
  width: 100%;
  padding: 10px;
  margin-top: 4px;
  background: none;
  border: none;
  color: var(--muted);
  font-size: .82rem;
  font-weight: 500;
  text-decoration: underline;
}
.btn-link:hover { color: var(--navy-dark); }

/* ---------- Formular-Meldungen ---------- */
.form-error {
  color: var(--error);
  font-size: .82rem;
  padding: 8px 8px 0;
}
.form-error:empty { padding: 0; }

.form-success {
  padding: 28px 18px;
  text-align: center;
}
.form-success:focus { outline: none; }
.form-success-icon {
  width: 44px;
  height: 44px;
  margin: 0 auto 12px;
  border-radius: 50%;
  background: var(--blue-accent);
  color: var(--white);
  font-size: 1.4rem;
  line-height: 44px;
}
.form-success-title {
  color: var(--navy-dark);
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 4px;
}
.form-success p { color: var(--muted); font-size: .9rem; }

/* ---------- Dialog (nutzt das native <dialog>-Element) ---------- */
.modal {
  width: calc(100% - 40px);
  max-width: 380px;
  margin: auto;
  padding: 0;
  border: none;
  background: transparent;
  overflow: visible;
}
.modal[open] { animation: modalIn .2s ease; }
.modal::backdrop { background: rgba(10, 28, 64, .7); }

@keyframes modalIn {
  from { opacity: 0; transform: translateY(12px); }
}

/* Seite im Hintergrund nicht scrollen, solange der Dialog offen ist */
body:has(.modal[open]) { overflow: hidden; }

.modal-box {
  position: relative;
  padding: 32px;
  background: var(--white);
  border-radius: var(--radius);
}

.modal-close {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 36px;
  height: 36px;
  background: none;
  border: none;
  border-radius: 50%;
  font-size: 1.2rem;
  color: #9aa4b5;
}
.modal-close:hover { color: var(--navy-dark); background: var(--grey-bg); }

.modal-title {
  color: var(--navy-dark);
  font-size: 1.2rem;
  margin-bottom: 8px;
  padding-right: 28px;
}

.modal-text {
  color: var(--muted);
  font-size: .88rem;
  margin-bottom: 18px;
}

.modal-input {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: .9rem;
}
.modal-input:focus { border-color: var(--blue-accent); outline: none; box-shadow: 0 0 0 3px rgba(46, 116, 230, .2); }
.modal-input[aria-invalid="true"] { border-color: var(--error); }
textarea.modal-input { min-height: 96px; resize: vertical; }

.modal-submit {
  padding: 12px;
  margin-top: 12px;
  font-size: .9rem;
}

/* Breitere Variante für längere Formulare; lange Inhalte scrollen innerhalb des Dialogs */
.modal--breit { max-width: 440px; }
.modal-box { max-height: calc(100dvh - 32px); overflow-y: auto; }

/* ---------- Formularfelder ---------- */
.form-feld {
  margin-bottom: 12px;
  border: none;
  min-width: 0;
}

.form-label {
  display: block;
  margin-bottom: 4px;
  font-size: .8rem;
  font-weight: 600;
  color: var(--navy-dark);
}
.form-label .optional { font-weight: 400; color: var(--muted); }

/* Checkbox mit längerem Text, z. B. Einwilligung */
.form-check {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin: 4px 0 8px;
  font-size: .8rem;
  color: var(--muted);
  cursor: pointer;
}
.form-check input {
  flex-shrink: 0;
  width: 18px;
  height: 18px;
  margin-top: 1px;
  accent-color: var(--blue-accent);
}
.form-check:has([aria-invalid="true"]) { color: var(--error); }

/* Kleiner Hinweis unter Formularen (z. B. Datenschutz) */
.form-hinweis {
  margin-top: 8px;
  font-size: .75rem;
  color: var(--muted);
}
.form-hinweis a { color: var(--blue-accent); text-decoration: underline; }

/* Spam-Schutz (Honeypot): für Menschen unsichtbar, bleibt aber im Formular */
.hp-feld {
  position: absolute;
  left: -10000px;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

/* ---------- Sterne-Auswahl (Radio-Buttons) ---------- */
.sterne-wahl {
  position: relative;
  display: flex;
  gap: 4px;
}

.sterne-wahl input {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: 0;
  opacity: 0;
}

.sterne-wahl label {
  font-size: 2rem;
  line-height: 1;
  color: #c9d1de;
  cursor: pointer;
  border-radius: 4px;
  transition: color .1s ease;
}

/* Ausgewählt: alle Sterne bis einschließlich des gewählten. Beim Überfahren
   mit der Maus zeigt die Vorschau stattdessen die Sterne bis zum Mauszeiger. */
.sterne-wahl:not(:hover) input:checked + label,
.sterne-wahl:not(:hover) label:has(~ input:checked),
.sterne-wahl label:hover,
.sterne-wahl label:has(~ label:hover) { color: var(--star); }

.sterne-wahl input:focus-visible + label { outline: 3px solid var(--blue-bright); outline-offset: 2px; }
.sterne-feld:has([aria-invalid="true"]) .form-label { color: var(--error); }
