/*
 * consent-bundle — neutrale Grundgestaltung. Alles Gestalterische läuft über CSS-Variablen (siehe unten);
 * Projekte setzen sie am <html>/:root oder überschreiben einzelne Regeln mit höherer Spezifität.
 * Kontraste (Standardwerte): Text #1d1d1b auf #fff 17,6:1 · gedämpft #4d4d4d 8,6:1 · Knopf #fff auf #0b3d91 10,6:1.
 */
:root {
  --consent-bg: #fff;
  --consent-fg: #1d1d1b;
  --consent-muted: #4d4d4d;
  --consent-accent: #0b3d91;
  --consent-accent-fg: #fff;
  --consent-accent-hover: #082c69;
  --consent-border: #767676;
  --consent-line: #d0d0d0;
  --consent-soft: #f2f2f2;
  --consent-focus: #0b3d91;
  --consent-overlay: rgba(0, 0, 0, .6);
  --consent-font: inherit;
  --consent-font-size: 1rem;
  --consent-line-height: 1.5;
  --consent-radius: 8px;
  --consent-gap: 16px;
  --consent-pad: 24px;
  --consent-btn-h: 48px;
  --consent-card-w: 480px;
  --consent-edge-x: 16px;
  --consent-edge-y: 16px;
  --consent-z: 2147483000;
}

.consent,
.consent-ph {
  font-family: var(--consent-font);
  font-size: var(--consent-font-size);
  line-height: var(--consent-line-height);
  color: var(--consent-fg);
  box-sizing: border-box;
}
.consent *, .consent *::before, .consent *::after,
.consent-ph *, .consent-ph *::before, .consent-ph *::after { box-sizing: border-box; }
.consent [hidden], .consent-ph[hidden], [data-consent-open][hidden] { display: none !important; }
html.consent-lock { overflow: hidden; }

.consent__sr, .consent-sr {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ---- Knöpfe (Banner + Platzhalter): alle gleichwertig ---- */
.consent__btn, .consent-btn {
  display: inline-flex; align-items: center; justify-content: center; text-align: center;
  min-height: var(--consent-btn-h); min-width: 44px; margin: 0; padding: 10px 24px;
  font: inherit; font-weight: 700; line-height: 1.25; cursor: pointer; text-decoration: none;
  color: var(--consent-accent-fg); background: var(--consent-accent);
  border: 2px solid var(--consent-accent); border-radius: var(--consent-radius);
  -webkit-appearance: none; appearance: none;
}
.consent__btn:hover, .consent-btn:hover { background: var(--consent-accent-hover); border-color: var(--consent-accent-hover); }
.consent__btn--text {
  color: var(--consent-fg); background: transparent; border-color: transparent;
  text-decoration: underline; text-underline-offset: 3px; font-weight: 600;
}
.consent__btn--text:hover { background: transparent; border-color: transparent; text-decoration-thickness: 2px; }
.consent a:focus-visible, .consent button:focus-visible, .consent input:focus-visible, .consent summary:focus-visible,
.consent-ph a:focus-visible, .consent-ph button:focus-visible, .consent-ph input:focus-visible {
  outline: 3px solid var(--consent-focus); outline-offset: 2px;
}
.consent__l1:focus, .consent__l2:focus { outline: none; }

.consent a { color: inherit; text-decoration: underline; text-underline-offset: 3px; }
.consent a:hover { text-decoration-thickness: 2px; }

/* ---- Erste Ebene: Karte unten links/rechts ----
 * Sitzt dort, wo sonst der Datenschutz-Knopf (consent-button-bundle) steht: Seite aus dem Bundle (config „pos“,
 * Klasse consent--ul|--ur), Randabstände aus den Variablen des Knopfs (--inn-cb-seite/-unten, auch die Leisten-
 * Messung), Fallback --consent-edge-x/-y. Ab --consent-mobile (640 px) fest auf voller Breite unten. Der Schatten liegt als
 * drop-shadow auf dem Rahmen, damit ein Schrägschnitt (clip-path der Karte) ihn nicht abschneidet. */
.consent__l1 {
  position: fixed; bottom: var(--inn-cb-unten, var(--consent-edge-y)); z-index: var(--consent-z);
  width: min(var(--consent-card-w), calc(100vw - 2 * var(--inn-cb-seite, var(--consent-edge-x))));
  filter: drop-shadow(0 6px 22px rgba(0, 0, 0, .28));
}
.consent--ul .consent__l1 { left: var(--inn-cb-seite, var(--consent-edge-x)); }
.consent--ur .consent__l1 { right: var(--inn-cb-seite, var(--consent-edge-x)); }
.consent__card {
  display: flex; flex-direction: column; gap: var(--consent-gap);
  max-height: calc(100vh - var(--inn-cb-unten, var(--consent-edge-y)) - 16px); max-height: calc(100dvh - var(--inn-cb-unten, var(--consent-edge-y)) - 16px);
  overflow-y: auto; overscroll-behavior: contain;
  padding: var(--consent-pad); background: var(--consent-bg); color: var(--consent-fg);
  border-radius: var(--consent-radius);
}
.consent__l1 { outline-offset: 0; }
.consent__text p { margin: 0 0 .5em; }
.consent__text p:last-child { margin-bottom: 0; }
.consent__title { margin: 0 0 .4em; font: inherit; font-size: 1.25em; font-weight: 700; line-height: 1.25; color: inherit; }
.consent__legal { margin: 0; color: var(--consent-muted); }
.consent__sep { margin: 0 .5em; }
.consent__actions { display: flex; flex-direction: column; align-items: stretch; gap: 8px; }
/* Hauptknöpfe: gleich breite Spalten, identische Gestaltung (beide gleichwertig) */
.consent__main { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 12px; }
.consent__actions .consent__btn--text { align-self: center; }

/* ---- Zweite Ebene: Dialog ---- */
.consent__overlay { position: fixed; inset: 0; z-index: var(--consent-z); background: var(--consent-overlay); }
.consent__l2 {
  position: fixed; inset: 0; z-index: calc(var(--consent-z) + 1);
  display: flex; align-items: center; justify-content: center; padding: var(--consent-gap);
  pointer-events: none;
}
.consent__l2[hidden] { display: none; }
.consent__panel {
  pointer-events: auto; display: flex; flex-direction: column; width: 100%; max-width: 760px; max-height: 100%;
  background: var(--consent-bg); color: var(--consent-fg); border-radius: var(--consent-radius);
  box-shadow: 0 8px 40px rgba(0, 0, 0, .35);
}
.consent__panel-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: var(--consent-pad) var(--consent-pad) 0; }
.consent__panel-head .consent__title { margin: 0; font-size: 1.4em; }
.consent__close {
  flex: none; display: inline-flex; align-items: center; justify-content: center; width: 44px; height: 44px; margin: -6px -8px 0 0; padding: 0;
  color: inherit; background: transparent; border: 2px solid transparent; border-radius: var(--consent-radius); cursor: pointer;
}
.consent__close:hover { border-color: var(--consent-border); }
.consent__panel-body { flex: 1 1 auto; overflow-y: auto; overscroll-behavior: contain; padding: var(--consent-gap) var(--consent-pad); }
.consent__panel-body > p { margin: 0 0 .75em; }
.consent__panel-foot { padding: var(--consent-gap) var(--consent-pad) var(--consent-pad); border-top: 1px solid var(--consent-line); }

.consent__cats { margin-top: var(--consent-gap); border-top: 1px solid var(--consent-line); }
.consent__cat { padding: var(--consent-gap) 0; border-bottom: 1px solid var(--consent-line); }
.consent__cat-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.consent__cat-title { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; }
.consent__cat-title label { font-weight: 700; font-size: 1.1em; cursor: pointer; }
.consent__badge { font-size: .875em; color: var(--consent-muted); }
.consent__cat-text { margin: .35em 0 0; color: var(--consent-muted); }
.consent__services { margin-top: .5em; }
.consent__service { border-top: 1px solid var(--consent-line); }
.consent__service:first-child { border-top: 0; }
.consent__service summary { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 44px; padding: 10px 0; font-weight: 600; cursor: pointer; list-style: none; }
.consent__service summary::-webkit-details-marker { display: none; }
.consent__service summary::after {
  content: ""; flex: none; width: 14px; height: 14px;
  background: linear-gradient(currentColor, currentColor) center / 100% 2px no-repeat, linear-gradient(currentColor, currentColor) center / 2px 100% no-repeat;
}
.consent__service[open] summary::after { background: linear-gradient(currentColor, currentColor) center / 100% 2px no-repeat; }
.consent__dl { margin: 0 0 .75em; padding: 0 0 0 1.25em; color: var(--consent-muted); }
dl.consent__dl dt { margin-top: .5em; font-weight: 700; color: var(--consent-fg); }
dl.consent__dl dd { margin: 0; }

.consent__switch {
  -webkit-appearance: none; appearance: none; flex: none; position: relative; width: 52px; height: 30px; margin: 0;
  background: var(--consent-bg); border: 2px solid var(--consent-border); border-radius: 15px; cursor: pointer;
}
.consent__switch::before {
  content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: var(--consent-border);
}
.consent__switch:checked { background: var(--consent-accent); border-color: var(--consent-accent); }
.consent__switch:checked::before { transform: translateX(22px); background: var(--consent-accent-fg); }
.consent__switch:disabled { cursor: default; opacity: .7; }

@media (prefers-reduced-motion: no-preference) {
  .consent__switch::before { transition: transform .15s ease, background-color .15s ease; }
  .consent__l1 { animation: consent-up .25s ease-out; }
  .consent__l2, .consent__overlay { animation: consent-fade .2s ease-out; }
}
@keyframes consent-up { from { transform: translateY(24px); opacity: 0; } }
@keyframes consent-fade { from { opacity: 0; } }

/* ---- Mobil: Karte volle Breite unten ---- */
@media (max-width: 640px) {
  .consent__l1 { left: 0 !important; right: 0 !important; bottom: 0; width: auto; padding-bottom: env(safe-area-inset-bottom, 0); }
  .consent__card { padding: 16px; max-height: 90vh; max-height: 90dvh; }
  .consent__main { grid-auto-flow: row; }
  .consent__actions .consent__btn { width: 100%; }
  .consent__l2 { padding: 8px; }
  .consent__panel-head { padding: 16px 16px 0; }
  .consent__panel-body { padding: 12px 16px; }
  .consent__panel-foot { padding: 12px 16px 16px; }
  .consent__panel-foot .consent__btn { width: 100%; }
}

/* ---- Platzhalter für gesperrte iframes ---- */
.consent-ph {
  display: flex; align-items: center; justify-content: center; width: 100%; min-height: 220px; max-width: 100%;
  padding: 16px; background: var(--consent-soft); border: 1px solid var(--consent-line); border-radius: var(--consent-radius); text-align: center;
}
.consent-ph__box { max-width: 560px; }
.consent-ph__title { margin: 0 0 .4em; font-size: 1.15em; font-weight: 700; }
.consent-ph__text { margin: 0 0 1em; color: var(--consent-muted); }
.consent-ph__text a { color: inherit; text-decoration: underline; text-underline-offset: 3px; }
.consent-ph__actions { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 12px 20px; }
.consent-ph__always { display: inline-flex; align-items: center; gap: 8px; min-height: 44px; cursor: pointer; }
.consent-ph__always input { width: 22px; height: 22px; margin: 0; accent-color: var(--consent-accent); }
.ratio > .consent-ph, [class*="ratio"] > .consent-ph { position: absolute; inset: 0; height: 100%; }

/* ---- Diensttabelle (Insert-Tag {{inn_consent::tabelle}}) ----
 * Breit: Tabelle. Unter 700 px: je Dienst eine Karte, die Spaltenköpfe stehen als Beschriftung (data-label) vor den Werten. */
.consent-table-wrap { margin: 1em 0; }
.consent-table { width: 100%; border-collapse: collapse; font-size: .9em; }
.consent-table caption { padding: 0 0 .5em; text-align: left; font-weight: 700; }
.consent-table th, .consent-table td { padding: .5em .75em; text-align: left; vertical-align: top; border: 1px solid #c4c4c4; }
.consent-table thead th { background: #f2f2f2; }
.consent-table__anbieter { font-weight: 400; }
@media (max-width: 699px) {
  .consent-table, .consent-table tbody, .consent-table tr, .consent-table th, .consent-table td, .consent-table caption { display: block; width: 100%; box-sizing: border-box; }
  .consent-table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .consent-table tr { margin: 0 0 var(--consent-gap); padding: 0; border: 1px solid #c4c4c4; }
  .consent-table th, .consent-table td { border: 0; padding: .5em .75em; }
  .consent-table tbody th { background: #f2f2f2; }
  .consent-table td[data-label]::before { content: attr(data-label); display: block; font-weight: 700; }
  .consent-table td + td { border-top: 1px solid #e3e3e3; }
}

@media print { .consent { display: none !important; } }
