/* cmd one — Datenschutz-Einstellungen: Banner und Dialog (Markup erzeugt /assets/consent.js).
   Nutzt Variablen und Klassen aus site.css (.btn, .btn-primary, .btn-secondary, .sr-only, .link, summary).
   Einbinden mit Versionsnummer (?v=…), bei jeder Änderung hochzählen. */

/* Solange das Banner steht: Platz am Seitenende, Fokus und Sprungziele nicht darunter (WCAG 2.4.11).
   --consent-h setzt consent.js per ResizeObserver. */
html.has-consent-banner { scroll-padding-bottom: calc(var(--consent-h, 0px) + 16px); }
html.has-consent-banner body { padding-bottom: var(--consent-h, 0px); }

/* ---------- Gemeinsam ---------- */
.consent-banner, .consent-dialog { font-size: 16px; line-height: 1.55; color: var(--ink); }
.consent-banner h2, .consent-dialog h2 { font-size: 20px; line-height: 1.3; letter-spacing: -0.01em; }
.consent-dialog h3 { font-size: 17px; line-height: 1.3; letter-spacing: -0.01em; }
.consent-banner p, .consent-dialog p { color: var(--ink-2); text-wrap: pretty; }
.consent-actions { display: flex; flex-wrap: wrap; gap: 12px; }
.consent-links { display: flex; flex-wrap: wrap; gap: 0 20px; font-size: var(--fs-small); }
.consent-links a { display: inline-flex; align-items: center; min-height: 32px; }

/* ---------- Banner (nicht modal, unten fixiert) ---------- */
.consent-banner {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 60;
  max-height: 50svh; overflow-y: auto; overscroll-behavior: contain;
  background: var(--surface); border-top: 1px solid var(--line-heavy);
  box-shadow: 0 -12px 32px -16px rgba(22, 24, 26, 0.24);
}
.consent-banner-inner {
  max-width: var(--container); margin-inline: auto; padding: 20px var(--pad-x);
  display: flex; align-items: center; justify-content: space-between; gap: 16px 40px;
}
.consent-banner-text { max-width: 76ch; }
.consent-banner-text p { margin-top: 6px; font-size: var(--fs-small); }
.consent-banner .consent-links { margin-top: 4px; }
.consent-banner .consent-actions { flex: none; }
.consent-actions .btn-primary { min-width: 9rem; } /* „Ablehnen“ und „Akzeptieren“ gleich breit */

/* ---------- Dialog (modal, natives <dialog>) ---------- */
.consent-dialog {
  width: calc(100% - 32px); max-width: 640px; max-height: calc(100dvh - 32px);
  margin: auto; padding: 0; overflow-y: auto; overscroll-behavior: contain;
  background: var(--surface); border: 1px solid var(--line-2); border-radius: var(--radius);
  box-shadow: 0 24px 64px -24px rgba(22, 24, 26, 0.45);
}
.consent-dialog::backdrop { background: rgba(14, 16, 17, 0.6); }
.consent-dialog-inner { padding: 24px 28px 20px; }
.consent-dialog-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.consent-dialog-head h2 { padding-top: 8px; }
.consent-dialog h2:focus { outline: none; }
.consent-dialog h2:focus-visible { outline: var(--focus); outline-offset: 2px; }
.consent-close {
  flex: none; width: 44px; height: 44px; margin: 0 -10px 0 0; padding: 0;
  display: inline-flex; align-items: center; justify-content: center;
  font: inherit; font-size: 28px; line-height: 1; color: var(--ink);
  background: none; border: 1px solid transparent; border-radius: var(--radius); cursor: pointer;
  transition: background-color .15s ease;
}
.consent-close:hover { background: var(--paper-2); }
.consent-dialog-head + p { margin-top: 12px; font-size: var(--fs-small); }

.consent-category { margin-top: 20px; padding-top: 20px; border-top: 1px solid var(--line); }
.consent-category-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 32px; }
.consent-category p { margin-top: 8px; font-size: var(--fs-small); }
.consent-always {
  flex: none; font-family: var(--mono); font-size: 12px; font-weight: 500; line-height: 1.4;
  letter-spacing: 0.10em; text-transform: uppercase; color: var(--green);
}
.consent-category details { margin-top: 4px; }
.consent-facts { display: grid; gap: 10px; padding: 4px 0 8px 22px; font-size: var(--fs-small); line-height: 1.5; }
.consent-facts dt { font-weight: 600; color: var(--ink); }
.consent-facts dd { color: var(--ink-2); overflow-wrap: anywhere; }
.consent-facts code, .consent-dialog code { font-family: var(--mono); font-size: 0.92em; }
.consent-facts .link { display: inline-flex; align-items: center; min-height: 32px; }

.consent-dialog .consent-actions { margin-top: 24px; padding-top: 20px; border-top: 1px solid var(--line); }
.consent-dialog .consent-links { margin-top: 12px; }

/* Schalter: eigene Optik, 44×24 px, Kontur ≥ 3:1 (--ink-3 auf Weiß), an = Grün mit weißem Knopf */
.consent-switch {
  -webkit-appearance: none; appearance: none;
  position: relative; flex: none; width: 44px; height: 24px; margin: 0;
  background: var(--surface); border: 1px solid var(--ink-3); border-radius: 999px;
  cursor: pointer; transition: background-color .15s ease, border-color .15s ease;
}
.consent-switch::before {
  content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px;
  border-radius: 50%; background: var(--ink-3); transition: transform .15s ease;
}
.consent-switch:checked { background: var(--green); border-color: var(--green); }
.consent-switch:checked::before { background: #fff; transform: translateX(20px); }
.consent-switch:hover { border-color: var(--ink); }
.consent-switch:checked:hover { background: var(--green-hover); border-color: var(--green-hover); }
.consent-switch:focus-visible { outline: 2px solid var(--green); outline-offset: 2px; }

/* ---------- Unter 900 px: Text oben, Knöpfe darunter ---------- */
@media (max-width: 900px) {
  .consent-banner-inner { flex-direction: column; align-items: stretch; gap: 12px; }
}
/* Genug Höhe (nicht bei starker Vergrößerung): Knöpfe bleiben am Bannerrand sichtbar, der Text scrollt. */
@media (max-width: 900px) and (min-height: 500px) {
  .consent-banner { scroll-padding-bottom: 72px; } /* fokussierte Links nicht unter den Knöpfen */
  .consent-banner-inner { padding-bottom: 0; }
  .consent-banner .consent-actions { position: sticky; bottom: 0; padding: 4px 0 16px; background: var(--surface); }
}

/* ---------- Unter 640 px ---------- */
@media (max-width: 640px) {
  .consent-banner { scroll-padding-bottom: 124px; }
  .consent-banner-inner { padding-block: 12px 0; }
  .consent-banner h2 { font-size: 18px; }
  .consent-banner-text p { margin-top: 4px; font-size: 14px; line-height: 1.45; }
  .consent-banner .consent-links { margin-top: 2px; }
  .consent-banner .consent-links a { min-height: 28px; }
  .consent-banner .consent-actions { display: grid; padding-bottom: 12px; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 8px; }
  .consent-banner .consent-actions .btn-primary { min-width: 0; } /* gleiche Spalten statt Mindestbreite */
  .consent-banner [data-consent-action="settings"] { grid-column: 1 / -1; } /* oben, wie in der Tab-Reihenfolge */
  .consent-banner .btn, .consent-dialog .btn { padding-inline: 12px; }
  .consent-dialog-inner { padding: 16px 20px; }
  .consent-dialog .consent-actions { flex-direction: column; align-items: stretch; gap: 8px; }
  .consent-facts { padding-left: 0; }
}

/* ---------- Kontrastmodus ---------- */
@media (forced-colors: active) {
  .consent-banner { border-top-color: CanvasText; }
  .consent-dialog { border-color: CanvasText; }
  .consent-switch { forced-color-adjust: none; background: Canvas; border-color: CanvasText; }
  .consent-switch::before { background: CanvasText; }
  .consent-switch:checked { background: Highlight; border-color: Highlight; }
  .consent-switch:checked::before { background: HighlightText; }
  .consent-switch:focus-visible { outline-color: CanvasText; }
}

/* ---------- Reduzierte Bewegung ---------- */
@media (prefers-reduced-motion: reduce) {
  .consent-switch, .consent-switch::before, .consent-close { transition: none; }
}

/* ---------- Druck ---------- */
@media print {
  .consent-banner, .consent-dialog { display: none !important; }
  html.has-consent-banner body { padding-bottom: 0; }
}
