/*
 * Einwilligung für externe Medien: Banner, Dialog „Cookie-Einstellungen“ und Platzhalter vor Playern.
 * Wird von <x-consent /> in allen Layouts geladen; nutzt die Variablen aus app.css mit Rückfallwerten.
 */

/* ---------- Banner (erster Besuch) ---------- */
.consent-banner {
    position: fixed; left: 16px; right: 16px; bottom: calc(16px + env(safe-area-inset-bottom, 0px)); z-index: 90;
    max-width: 920px; margin-inline: auto;
    display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 1.25rem 2rem; align-items: center;
    padding: 1.35rem 1.6rem 1.35rem 1.9rem;
    background: #fff; color: var(--text, #2a2024);
    border: 1px solid var(--border, #e6dfe1); border-radius: var(--radius, 16px);
    box-shadow: 0 24px 60px -18px rgba(42, 32, 36, 0.45), 0 2px 6px rgba(42, 32, 36, 0.06);
    font-family: var(--font, 'Mulish', sans-serif); font-size: 0.95rem; line-height: 1.5;
    animation: consent-in 0.34s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}
.consent-banner[hidden] { display: none; }
/* Schmaler Farbstreifen als ruhiger Hinweis auf die Marke */
.consent-banner::before {
    content: ''; position: absolute; left: 0; top: 18px; bottom: 18px; width: 4px;
    border-radius: 0 4px 4px 0; background: var(--accent, #9b1131);
}
.consent-banner h2 {
    margin: 0 0 0.3rem; font-family: var(--font-display, 'Mulish', sans-serif);
    font-size: 1.3rem; font-weight: 600; line-height: 1.2; color: var(--text, #2a2024);
}
.consent-banner p { margin: 0; color: var(--muted, #6a5b60); max-width: 62ch; }
.consent-banner__links { margin-top: 0.45rem !important; font-size: 0.85rem; display: flex; flex-wrap: wrap; gap: 0.2rem 1.1rem; }
.consent-banner__links a { color: var(--navy, #5a2433); }
.consent-banner__actions { display: grid; grid-template-columns: 1fr 1fr; gap: 0.6rem; min-width: 320px; }
.consent-banner__actions .btn { width: 100%; white-space: nowrap; }
.consent-banner__more {
    grid-column: 1 / -1; justify-self: center; padding: 0.25rem 0.5rem;
    background: none; border: 0; cursor: pointer; font: inherit; font-size: 0.9rem; font-weight: 600;
    color: var(--navy, #5a2433); text-decoration: underline; text-underline-offset: 3px;
}
.consent-banner__more:hover { text-decoration-thickness: 2px; }
.consent-banner :focus-visible, .consent-dialog :focus-visible, .consent-always:focus-visible, .consent-btn:focus-visible {
    outline: 2px solid var(--navy, #5a2433); outline-offset: 2px;
}

/* Handy: Leisten am unteren Rand (Programme, Community) frei lassen */
body:has(.pbar) .consent-banner, body:has(.tabbar) .consent-banner { bottom: calc(84px + env(safe-area-inset-bottom, 0px)); }

@media (max-width: 760px) {
    .consent-banner { grid-template-columns: 1fr; gap: 1rem; left: 10px; right: 10px; bottom: calc(10px + env(safe-area-inset-bottom, 0px)); padding: 1.15rem 1.15rem 1.05rem 1.45rem; font-size: 0.92rem; }
    .consent-banner h2 { font-size: 1.18rem; }
    .consent-banner__actions { min-width: 0; }
    .consent-banner__actions .btn { padding-inline: 0.5rem; font-size: 0.95rem; }
}
@media (max-width: 340px) {
    .consent-banner__actions { grid-template-columns: 1fr; }
}

@keyframes consent-in {
    from { opacity: 0; transform: translateY(14px); }
    to { opacity: 1; transform: none; }
}

/* ---------- Dialog „Cookie-Einstellungen“ ---------- */
.consent-dialog {
    width: min(580px, calc(100vw - 24px)); max-height: calc(100dvh - 24px); padding: 0;
    border: 0; border-radius: var(--radius, 16px); background: #fff; color: var(--text, #2a2024);
    box-shadow: 0 30px 80px -20px rgba(27, 18, 22, 0.55);
    font-family: var(--font, 'Mulish', sans-serif); font-size: 0.95rem; line-height: 1.5;
}
.consent-dialog[open] { animation: consent-in 0.26s cubic-bezier(0.2, 0.8, 0.2, 1) both; }
.consent-dialog::backdrop { background: rgba(27, 18, 22, 0.5); backdrop-filter: blur(3px); }
.consent-dialog__form { position: relative; padding: 1.75rem 1.75rem 1.4rem; }
.consent-dialog h2 {
    margin: 0 2.2rem 0.4rem 0; font-family: var(--font-display, 'Mulish', sans-serif);
    font-size: 1.5rem; font-weight: 600; line-height: 1.2;
}
.consent-dialog__lead { margin: 0 0 1.1rem; color: var(--muted, #6a5b60); }
.consent-dialog__close {
    position: absolute; top: 0.9rem; right: 0.9rem; width: 2.25rem; height: 2.25rem;
    display: grid; place-items: center; border: 0; border-radius: 50%; background: transparent;
    color: var(--muted, #6a5b60); font-size: 1.5rem; line-height: 1; cursor: pointer;
}
.consent-dialog__close:hover { background: #f5f0f1; color: var(--text, #2a2024); }

.consent-group { margin: 0 0 1rem; padding: 0; border: 1px solid var(--border, #e6dfe1); border-radius: 12px; overflow: hidden; }
.consent-group legend {
    float: left; width: 100%; padding: 0.85rem 1rem 0; margin: 0;
    font-weight: 800; font-size: 0.78rem; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted, #6a5b60);
}
.consent-group__hint { clear: both; margin: 0; padding: 0.3rem 1rem 0.85rem; color: var(--muted, #6a5b60); font-size: 0.85rem; }
.consent-row { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 0.85rem 1rem; }
.consent-group .consent-row + .consent-row, .consent-group__hint + .consent-row { border-top: 1px solid var(--border, #e6dfe1); }
.consent-row__text { min-width: 0; }
.consent-row__text label { cursor: pointer; }
.consent-row__text p { margin: 0.15rem 0 0; color: var(--muted, #6a5b60); font-size: 0.85rem; }
.consent-row__text a { color: var(--navy, #5a2433); }
.consent-fixed { flex: none; font-size: 0.8rem; font-weight: 700; color: var(--muted, #6a5b60); white-space: nowrap; }

/* Schalter */
.consent-switch {
    flex: none; appearance: none; -webkit-appearance: none; position: relative; margin: 0;
    width: 46px; height: 28px; border-radius: 999px; background: #cfc6c9; cursor: pointer;
    transition: background-color 0.16s ease;
}
.consent-switch::after {
    content: ''; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%;
    background: #fff; box-shadow: 0 1px 3px rgba(42, 32, 36, 0.35); transition: transform 0.16s ease;
}
.consent-switch:checked { background: var(--accent, #9b1131); }
.consent-switch:checked::after { transform: translateX(18px); }

.consent-dialog__actions { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0.6rem; margin-top: 1.25rem; }
.consent-dialog__actions .btn { width: 100%; padding-inline: 0.6rem; font-size: 0.92rem; white-space: nowrap; }
.consent-dialog__foot { margin: 1rem 0 0; text-align: center; font-size: 0.82rem; color: var(--muted, #6a5b60); }
.consent-dialog__foot a { color: inherit; }

@media (max-width: 560px) {
    .consent-dialog__form { padding: 1.4rem 1.1rem 1.1rem; }
    .consent-dialog__actions { grid-template-columns: 1fr 1fr; }
    .consent-dialog__actions .btn--ghost { grid-column: 1 / -1; order: 3; }
}

/* ---------- Platzhalter an Stelle eines Players ---------- */
.embed.consent { background: linear-gradient(135deg, #2a2024, color-mix(in srgb, var(--accent, #9b1131) 55%, #2a2024)); color: #fff; }
.consent-btn {
    position: absolute; inset: 0; border: 0; background: transparent; color: #fff; padding: 16px 16px 46px;
    display: grid; place-items: center; align-content: center; gap: 8px; text-align: center; cursor: pointer; font: inherit;
}
.consent-btn .play {
    width: 56px; height: 56px; border-radius: 50%; background: rgba(255, 255, 255, 0.92); color: var(--accent, #9b1131);
    display: grid; place-items: center; transition: transform 0.16s ease;
}
.consent-btn .consent-t { font-weight: 800; }
.consent-btn small { font-size: 11.5px; opacity: 0.85; max-width: 42ch; }
.consent-btn:hover .play { transform: scale(1.06); }
.consent-always {
    position: absolute; left: 50%; bottom: 11px; transform: translateX(-50%); z-index: 1;
    padding: 0.28rem 0.85rem; border-radius: 999px; cursor: pointer; white-space: nowrap;
    border: 1px solid rgba(255, 255, 255, 0.4); background: rgba(255, 255, 255, 0.12); color: #fff;
    font: inherit; font-size: 12px; font-weight: 600;
}
.consent-always:hover { background: rgba(255, 255, 255, 0.24); }
.consent-always[hidden] { display: none; }
.embed.consent noscript a { position: absolute; left: 12px; top: 10px; color: #fff; font-size: 12px; }
/* Podcast-Platzhalter braucht mehr Höhe als der spätere Player */
.embed.embed--audio.consent { height: auto; min-height: max(var(--embed-h, 200px), 210px); }
/* Lektionsvideo: Platzhalter füllt die Videofläche */
.video > .embed.consent { position: absolute; inset: 0; margin: 0; border-radius: 0; aspect-ratio: auto; }

/* ---------- „Cookie-Einstellungen“ in den Fußzeilen ---------- */
.site-footer nav button, .login__footer nav button {
    background: none; border: 0; padding: 0; margin: 0; cursor: pointer; font: inherit; color: inherit;
}
.site-footer nav button { color: rgba(255, 255, 255, 0.85); }
.site-footer nav button:hover { color: #fff; }
.login__footer nav button { color: var(--muted, #6a5b60); }
.login__footer nav button:hover { color: var(--navy, #5a2433); text-decoration: underline; }

@media (prefers-reduced-motion: reduce) {
    .consent-banner, .consent-dialog[open] { animation: none; }
    .consent-switch, .consent-switch::after, .consent-btn .play { transition: none; }
}
