/*
 * Corporate Design angelehnt an olivertempel.de:
 *   Primärfarbe (Gold/Amber) #f8be5b, Sekundärfarbe (Blau) #61A2D6,
 *   Schrift "Roboto Condensed", Hell/Dunkel-Unterstützung.
 *
 * Für Text/Buttons auf hellem Hintergrund sind die Original-Markenfarben
 * zu kontrastarm (gold auf weiß: 1.7:1, blau auf weiß: 2.8:1- beide
 * unter den von BITV 2.0/WCAG 2.1 AA geforderten 4.5:1 für Text).
 * Deshalb im Hellmodus abgedunkelte, gegengeprüfte Varianten
 * (--primary, --accent-text: beide >5.9:1 auf Weiß). Im Dunkelmodus
 * funktionieren die Originalfarben direkt (>5.8:1 auf #212121, genau
 * wie auf olivertempel.de selbst).
 */

@font-face {
  font-family: 'Roboto Condensed';
  font-style: normal;
  font-weight: 300;
  font-display: swap;
  src: url('fonts/RobotoCondensed-Light.ttf') format('truetype');
}
@font-face {
  font-family: 'Roboto Condensed';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('fonts/RobotoCondensed-Regular.ttf') format('truetype');
}
@font-face {
  font-family: 'Roboto Condensed';
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url('fonts/RobotoCondensed-Bold.ttf') format('truetype');
}

:root {
  --bg: #f5f7fa;
  --card-bg: #ffffff;
  --text: #212121;
  --text-muted: #5b5b5b;
  --border: #d9d9d9;
  --primary: #1a5276;       /* abgedunkeltes Marken-Blau, AA-konform auf Weiß */
  --primary-dark: #123a54;
  --accent-gold: #f8be5b;   /* Original-Markengold, nur dekorativ (Flächen/Icons) */
  --accent-text: #8a5a00;   /* abgedunkeltes Gold, AA-konform als Text/Link */
  --accent-bg: #fff8ec;
  --accent-border: #f3dba8;
  --danger: #b3261e;
  --success-text: #166534;  /* 7.1:1 auf Weiß */
  --focus-ring: #1a5276;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(15, 23, 42, 0.08), 0 1px 2px rgba(15, 23, 42, 0.06);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #212121;
    --card-bg: #2a2a2a;
    --text: #dedede;
    --text-muted: #a8a8a8;
    --border: #494949;
    --primary: #61A2D6;
    --primary-dark: #8fc0e5;
    --accent-gold: #f8be5b;
    --accent-text: #fbd89d;
    --accent-bg: #3a3220;
    --accent-border: #5c4d24;
    --danger: #ff6b60;
    --success-text: #4ade80;  /* 9.2:1 auf #212121 */
    --focus-ring: #fbd89d;
  }
}

* { box-sizing: border-box; }

html {
  scroll-behavior: smooth;
  font-size: 21px;
}

/* Sticky Footer per Flexbox (kein position:fixed/static-Hack): body ist
   mindestens ein Bildschirm hoch und selbst eine Flex-Spalte, .page
   wächst darin (flex: 1) und ist selbst wieder eine Flex-Spalte, in der
   <main> den verbleibenden Platz einnimmt (flex: 1). Kopfbereich
   (.top-bar/header.brand) bleibt dadurch immer oben, Footer
   (.footer-note/.legal-links) immer unten - unabhängig von der
   Inhaltsmenge, und ohne den natürlichen Dokumentfluss/die
   Barrierefreiheit (Lesereihenfolge) zu verändern. */
html, body {
  min-height: 100%;
}
body {
  margin: 0;
  font-family: 'Roboto Condensed', Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a, a:visited {
  color: var(--primary);
}

a:hover { color: var(--primary-dark); }

/* Sichtbarer Fokus-Rahmen für Tastaturbedienung (BITV 2.0 / WCAG 2.4.7) */
a:focus-visible,
button:focus-visible,
input:focus-visible,
summary:focus-visible {
  outline: 3px solid var(--focus-ring);
  outline-offset: 2px;
}

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  background: var(--primary);
  color: #fff;
  padding: 10px 16px;
  border-radius: 0 0 8px 0;
  z-index: 100;
  text-decoration: none;
}

.skip-link:focus {
  left: 0;
}

.page {
  max-width: 900px;
  margin: 0 auto;
  padding: 32px 20px 80px;
  width: 100%;
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
}

.page > main {
  flex: 1 1 auto;
}

.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.lang-switch {
  font-size: 0.85rem;
  margin: 0;
}

.lang-switch a {
  color: var(--text-muted);
  text-decoration: underline;
  padding: 4px;
}

.lang-switch a:hover,
.lang-switch a[aria-current] { color: var(--primary); font-weight: 700; }

header.brand {
  text-align: center;
  margin-bottom: 32px;
}

.site-logo {
  height: 88px;
  width: auto;
}

header.brand h1 {
  font-size: 1.6rem;
  font-weight: 300;
  margin: 0 0 4px;
  color: var(--text);
}

header.brand p {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.95rem;
}

.card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 28px;
  margin-bottom: 20px;
}

.security-note {
  background: var(--accent-bg);
  border: 1px solid var(--accent-border);
  border-radius: var(--radius);
  padding: 16px 20px;
  margin-bottom: 24px;
  font-size: 0.9rem;
  color: var(--text);
  display: flex;
  gap: 12px;
  align-items: flex-start;
}

.security-note svg { flex: 0 0 auto; margin-top: 2px; color: var(--accent-text); }

/* Bestätigungs-Variante (z. B. "E-Mail-Adresse bestätigt"): weißer
   Kasten statt der gelben Standardfarbe, grüner Text/Rahmen/Icon -
   deutlich lesbarer als grün-auf-grün oder das kontrastarme
   Gold/Braun der Standardvariante. */
.security-note.confirmed {
  background: var(--card-bg);
  border-color: var(--success-text);
  color: var(--success-text);
}
.security-note.confirmed svg { color: var(--success-text); }

label {
  display: block;
  font-weight: 700;
  font-size: 0.875rem;
  margin-bottom: 6px;
  color: var(--text);
}

.required-note {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin: -8px 0 16px;
}

input[type="text"],
input[type="email"],
input[type="date"] {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 1rem;
  font-family: inherit;
  background: var(--card-bg);
  color: var(--text);
}

.field { margin-bottom: 16px; }

input.field-invalid {
  border-color: var(--danger);
}

.field-error {
  display: none;
  color: var(--danger);
  font-size: 0.8rem;
  margin-top: 4px;
}
/* validateField() setzt textContent='' im Erfolgsfall - dadurch wird
   das <p> wieder "leer" und verschwindet automatisch, ohne dass JS
   extra eine Klasse umschalten müsste. */
.field-error:not(:empty) {
  display: block;
}

.row3 {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 12px;
}

@media (max-width: 560px) {
  .row3 { grid-template-columns: 1fr; }
}

.person-block {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px;
  margin-bottom: 14px;
  position: relative;
  background: var(--bg);
}

.person-block .person-title {
  font-weight: 700;
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 12px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.remove-person {
  position: absolute;
  top: 12px;
  right: 12px;
  background: none;
  border: 1px solid transparent;
  color: var(--danger);
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 700;
  padding: 4px 6px;
  border-radius: 6px;
}

.add-person-btn {
  width: 100%;
  padding: 12px;
  border: 1px dashed var(--primary);
  background: var(--card-bg);
  color: var(--primary);
  border-radius: 8px;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  font-size: 0.9rem;
  margin-bottom: 20px;
}

.add-person-btn:hover { background: var(--accent-bg); }

.plupload-drop-area {
  border: 2px dashed var(--border);
  border-radius: 10px;
  padding: 24px;
  text-align: center;
  background: var(--bg);
  margin-bottom: 4px;
}

.plupload-drop-area p {
  margin: 0 0 10px;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.id-file-list {
  list-style: none;
  margin: 8px 0 0;
  padding: 0;
}

.id-file-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  margin-bottom: 8px;
  font-size: 0.9rem;
}

.id-file-list li.error { border-color: var(--danger); color: var(--danger); }

.id-file-list .file-remove-btn {
  flex: 0 0 auto;
  background: none;
  border: 1px solid var(--danger);
  color: var(--danger);
  border-radius: 6px;
  padding: 4px 10px;
  font-size: 0.85rem;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
}

.id-file-list .file-remove-btn:hover { background: var(--accent-bg); }

.cost-box {
  background: var(--accent-bg);
  border: 1px solid var(--accent-border);
  border-radius: var(--radius);
  padding: 18px 20px;
  margin: 24px 0;
}

.cost-box h3 {
  margin: 0 0 8px;
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
}

.cost-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.cost-table th { text-align: left; font-weight: 400; padding: 4px 0; }
.cost-table td { padding: 4px 0; }
.cost-table td:last-child { text-align: right; font-variant-numeric: tabular-nums; }
.cost-table tr.total th,
.cost-table tr.total td { font-weight: 700; border-top: 1px solid var(--accent-border); padding-top: 8px; }

.consent {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  margin-bottom: 14px;
  font-size: 0.9rem;
  color: var(--text);
}

.consent input[type="checkbox"] {
  margin-top: 3px;
  width: 20px;
  height: 20px;
  flex: 0 0 auto;
}

details.privacy {
  margin-bottom: 20px;
  font-size: 0.85rem;
  color: var(--text-muted);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 14px;
}

details.privacy summary {
  cursor: pointer;
  font-weight: 700;
  color: var(--text);
}

details.privacy p { margin: 10px 0; }

button.submit-btn {
  width: 100%;
  padding: 14px;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 1.05rem;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
}

button.submit-btn:hover { background: var(--primary-dark); }
button.submit-btn:disabled { opacity: 0.6; cursor: not-allowed; }

.form-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.form-actions .submit-btn { flex: 2 1 240px; }

button.reset-btn {
  flex: 1 1 180px;
  padding: 14px;
  background: transparent;
  color: var(--danger);
  border: 1px solid var(--danger);
  border-radius: 8px;
  font-size: 0.95rem;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
}

button.reset-btn:hover { background: var(--accent-bg); }

.encrypt-progress {
  list-style: none;
  margin: 16px 0 0;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.encrypt-progress li {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.88rem;
  color: var(--text-muted);
}

.encrypt-progress .ep-icon {
  flex: 0 0 auto;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid var(--border);
  position: relative;
}

.encrypt-progress li.ep-active .ep-icon {
  border-color: var(--primary);
  animation: ep-pulse 1s ease-in-out infinite;
}

.encrypt-progress li.ep-done {
  color: var(--text);
}

.encrypt-progress li.ep-done .ep-icon {
  border-color: var(--primary);
  background: var(--primary);
}

.encrypt-progress li.ep-done .ep-icon::after {
  content: '';
  position: absolute;
  left: 4px;
  top: 1px;
  width: 5px;
  height: 9px;
  border-right: 2px solid #fff;
  border-bottom: 2px solid #fff;
  transform: rotate(40deg);
}

@keyframes ep-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(26, 82, 118, 0.35); }
  50% { box-shadow: 0 0 0 5px rgba(26, 82, 118, 0); }
}

.status-msg {
  margin-top: 14px;
  font-size: 0.9rem;
  text-align: center;
}

.status-msg.error { color: var(--danger); font-weight: 700; }
.status-msg.ok { color: var(--success-text); font-weight: 700; }

.status-msg.error a,
.status-msg.error a:visited {
  color: inherit;
  text-decoration: underline;
}

.footer-note {
  text-align: center;
  color: var(--text-muted);
  font-size: 0.8rem;
  margin-top: 28px;
}

.legal-links {
  text-align: center;
  margin-top: 8px;
  font-size: 0.8rem;
}

.legal-links a {
  color: var(--text-muted);
  text-decoration: underline;
  margin: 0 6px;
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
}

/* Info-Dialoge (native <dialog>): "Hinweise zur Verwendung" auf dem
   Formular, "Ihre übermittelten Daten" auf der Danke-Seite. */
.info-link-btn {
  background: none;
  border: none;
  padding: 0;
  color: var(--primary);
  text-decoration: underline;
  font: inherit;
  font-size: 0.88rem;
  cursor: pointer;
}
.info-link-btn:hover { color: var(--primary-dark); }

dialog.info-dialog {
  border: none;
  border-radius: var(--radius);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.3);
  padding: 0;
  width: min(680px, calc(100vw - 32px));
  max-height: min(85vh, 800px);
  color: var(--text);
  background: var(--card-bg);
  /* WICHTIG: dialog ist standardmäßig (ohne [open]) unsichtbar - das
     darf hier nicht überschrieben werden, sonst steht das Overlay
     dauerhaft im Seitenfluss statt nur bei showModal(). Erst mit
     [open] auf flex umschalten (für den Header/Body/Footer-Aufbau). */
  display: none;
  flex-direction: column;
}
dialog.info-dialog[open] { display: flex; }
/* Größere Varianten (angelehnt an Bootstraps .modal-lg/.modal-xl). */
dialog.info-dialog.info-dialog-lg {
  width: min(800px, calc(100vw - 32px));
}
/* xl: 75% der Fensterbreite, mit Mindest-/Höchstwert für sehr schmale
   bzw. sehr breite Bildschirme. */
dialog.info-dialog.info-dialog-xl {
  width: min(max(75vw, 320px), calc(100vw - 32px), 1400px);
}
dialog.info-dialog::backdrop {
  background: rgba(15, 23, 42, 0.55);
}
.info-dialog-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
}
.info-dialog-header h2 {
  margin: 0;
  font-weight: 300;
  font-size: 1.3rem;
}
.info-dialog-close {
  flex: 0 0 auto;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
}
.info-dialog-close:hover { background: var(--accent-bg); color: var(--primary-dark); }
.info-dialog-header,
.info-dialog-footer {
  flex: 0 0 auto;
}
.info-dialog-body {
  padding: 20px 24px;
  overflow-y: auto;
  flex: 1 1 auto;
  min-height: 0;
  font-size: 0.92rem;
  line-height: 1.55;
}
.info-dialog-footer {
  padding: 14px 24px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
}
.info-dialog-body h3 {
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--text-muted);
  margin: 22px 0 8px;
}
.info-dialog-body h3:first-child { margin-top: 0; }
.info-dialog-body ol,
.info-dialog-body ul {
  margin: 0 0 0 20px;
  padding: 0;
}
.info-dialog-body li { margin-bottom: 6px; }
.info-dialog-body .local-only-banner {
  background: var(--accent-bg);
  border: 1px solid var(--accent-border);
  border-radius: 8px;
  padding: 12px 14px;
  font-size: 0.85rem;
  margin: 0 0 18px;
}
.info-dialog-body .b64-block {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  font-family: monospace;
  font-size: 0.72rem;
  word-break: break-all;
  max-height: 90px;
  overflow-y: auto;
  margin: 0 0 14px;
}
.info-dialog-body .attachment-block {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 14px;
  margin: 0 0 14px;
}
.info-dialog-body .attachment-block .att-name {
  font-weight: 700;
  font-size: 0.85rem;
  margin: 0 0 8px;
}
.info-dialog-body .log-entry {
  border-left: 2px solid var(--border);
  padding: 0 0 10px 12px;
  margin-bottom: 4px;
  font-size: 0.82rem;
}
.info-dialog-body .log-entry .log-ts {
  color: var(--text-muted);
  font-size: 0.72rem;
}
