/* Mathe-Seite.de – Consent-Banner & blockierte Einbettungen
   ==========================================================

   Nutzt durchgehend die Design-Tokens aus assets/css/app.css. Damit greift
   der Dark Mode der Seite automatisch mit und der Banner bleibt beim
   nächsten Theme-Wechsel konsistent – eigene Hex-Werte wären hier genau die
   Stelle, die man später vergisst.

   Gestaltungsregel für die Buttons: „Nur notwendige“ und „Alle akzeptieren“
   haben identische Geometrie (Padding, Schriftgröße, Gewicht, Radius) und
   unterscheiden sich allein in der Flächenfarbe. Ein optisch schwächerer
   Ablehnen-Button wäre ein Dark Pattern und macht die Einwilligung
   angreifbar – deshalb steht die Gleichbehandlung hier und nicht im
   Ermessen späterer Anpassungen. */

/* ---------- Eigene Tokens ----------
   Zahnrad-Symbol für den Footer-Einstieg, als Maske eingesetzt: es erbt damit
   die Linkfarbe (auch im Dark Mode) und braucht keine zweite Datei. */
:root {
    --icon-cog: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='3'/%3E%3Cpath d='M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 1 1-2.83 2.83l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 1 1-4 0v-.09A1.65 1.65 0 0 0 9 19.4a1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 1 1-2.83-2.83l.06-.06a1.65 1.65 0 0 0 .33-1.82 1.65 1.65 0 0 0-1.51-1H3a2 2 0 1 1 0-4h.09A1.65 1.65 0 0 0 4.6 9a1.65 1.65 0 0 0-.33-1.82l-.06-.06a2 2 0 1 1 2.83-2.83l.06.06A1.65 1.65 0 0 0 9 4.6 1.65 1.65 0 0 0 10 3.09V3a2 2 0 1 1 4 0v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 1 1 2.83 2.83l-.06.06A1.65 1.65 0 0 0 19.4 9a1.65 1.65 0 0 0 1.51 1H21a2 2 0 1 1 0 4h-.09a1.65 1.65 0 0 0-1.51 1z'/%3E%3C/svg%3E");
}

/* ---------- hidden muss gewinnen ----------
   Das HTML-Attribut `hidden` wirkt nur über die UA-Regel `[hidden] {display:none}`
   — und die verliert gegen JEDE eigene display-Angabe auf demselben Element.
   `.consent { display:flex }` allein hat schon höhere Spezifität, also blieb
   der Banner nach dem Klick stehen, obwohl consent.js `hidden` korrekt gesetzt
   hat. Dasselbe traf die Detailebene (`display:grid`) und den
   Speichern-Button (`.btn { display:inline-flex }` aus app.css).

   Attribut-Selektor statt !important: `.consent[hidden]` (0,2,0) schlägt
   `.consent` (0,1,0) regulär. Diese drei Regeln müssen bestehen bleiben, wenn
   jemand die display-Werte unten anpasst — sonst ist der Banner nicht mehr
   schließbar. */
.consent[hidden],
.consent__details[hidden],
.consent .btn[hidden] {
    display: none;
}

/* ---------- Banner ---------- */
.consent {
    position: fixed;
    inset: auto 0 0 0;
    z-index: 1000;
    padding: var(--space-4);
    display: flex;
    justify-content: center;
    /* kein Overlay über der Seite: der Inhalt bleibt lesbar und bedienbar */
    pointer-events: none;
}

.consent__panel {
    pointer-events: auto;
    width: min(56rem, 100%);
    max-height: min(80vh, 44rem);
    overflow-y: auto;
    overscroll-behavior: contain;
    background: var(--bg);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    padding: var(--space-5);
    display: grid;
    gap: var(--space-4);
}

.consent__title {
    font-size: var(--step-1);
    color: var(--text-strong);
    margin: 0;
}
.consent__title:focus-visible { outline: 2px solid var(--brand); outline-offset: 4px; }

.consent__text {
    font-size: var(--step--1);
    color: var(--text-muted);
    margin: var(--space-2) 0 0;
    max-width: 70ch;
}

/* ---------- Aktionen ---------- */
.consent__actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-3);
}

/* Gleiche Größe für Zustimmung und Ablehnung – siehe Kopfkommentar. */
.consent__btn {
    flex: 1 1 12rem;
    padding: var(--space-3) var(--space-5);
    font-size: var(--step--1);
    font-weight: 600;
    cursor: pointer;
    background: var(--bg);
    color: var(--text-strong);
    border: 1px solid var(--border-strong);
}
.consent__btn:hover { background: var(--bg-muted); }

.consent__btn--accept {
    background: var(--brand);
    border-color: var(--brand);
    color: #fff;
}
.consent__btn--accept:hover { background: var(--brand-dark); color: #fff; }

.consent__btn--save {
    background: var(--gray-800);
    border-color: var(--gray-800);
    color: #fff;
}
@media (prefers-color-scheme: dark) {
    .consent__btn--save { background: var(--gray-200); border-color: var(--gray-200); color: var(--gray-900); }
}

.consent__toggle {
    flex: 0 0 auto;
    background: none;
    border: 0;
    padding: var(--space-2);
    font: inherit;
    font-size: var(--step--1);
    color: var(--text-muted);
    text-decoration: underline;
    cursor: pointer;
}
.consent__toggle:hover { color: var(--brand); }

.consent__legal {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin: 0;
}

/* ---------- Detailebene ---------- */
.consent__details {
    display: grid;
    gap: var(--space-4);
    padding-block: var(--space-2);
    border-top: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
}

.consent__group {
    padding: var(--space-3);
    background: var(--bg-subtle);
    border-radius: var(--radius);
}

.consent__switch {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    cursor: pointer;
}
.consent__switch input { width: 1.15rem; height: 1.15rem; accent-color: var(--brand); flex: 0 0 auto; }
.consent__switch input:disabled { cursor: not-allowed; }
.consent__switch-label { font-size: var(--step-0); color: var(--text-strong); }

.consent__required {
    display: inline-block;
    margin-left: var(--space-2);
    padding: 0.1em 0.5em;
    border-radius: var(--radius-full);
    background: var(--bg-muted);
    color: var(--text-muted);
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.consent__group-text {
    font-size: var(--step--1);
    color: var(--text-muted);
    margin: var(--space-2) 0 0;
}

.consent__services { margin-top: var(--space-3); }
.consent__services > summary {
    cursor: pointer;
    font-size: 0.8rem;
    color: var(--text-muted);
    padding: var(--space-1) 0;
}
.consent__services > summary:hover { color: var(--brand); }

.consent__service {
    margin-top: var(--space-3);
    padding-left: var(--space-3);
    border-left: 2px solid var(--border-strong);
    font-size: 0.82rem;
}
.consent__service-name { margin: 0; color: var(--text-strong); }
.consent__service-meta { color: var(--text-muted); font-weight: 400; }
.consent__service-purpose { margin: var(--space-1) 0 0; color: var(--text-muted); }
.consent__service-warn { margin: var(--space-1) 0 0; color: var(--brand); }
.consent__service-link { margin: var(--space-1) 0 0; }

.consent__cookies {
    margin: var(--space-2) 0 0;
    padding-left: 1.2em;
    color: var(--text-muted);
}
.consent__cookies code {
    font-family: var(--font-mono);
    font-size: 0.78rem;
    background: var(--bg-muted);
    padding: 0.05em 0.35em;
    border-radius: var(--radius-sm);
}

/* ---------- Blockierte Einbettung (YouTube etc.) ---------- */
.consent-embed {
    position: relative;
    width: 100%;
    background: var(--bg-muted);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}
.consent-embed iframe {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    border: 0;
}

.consent-embed__notice {
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    padding: var(--space-4);
}

/* Vorschaubild abgedunkelt und unscharf: erkennbar, worum es geht, aber der
   Hinweistext bleibt lesbar. Das Bild kommt vom eigenen Server oder ist als
   Datei hinterlegt – ein YouTube-Thumbnail würde bereits eine Verbindung zum
   Anbieter aufbauen und genau das soll der Platzhalter verhindern. */
.consent-embed__preview {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    filter: blur(6px) brightness(0.5);
}

.consent-embed__box {
    position: relative;
    max-width: 34rem;
    text-align: center;
    background: color-mix(in srgb, var(--bg) 92%, transparent);
    border-radius: var(--radius);
    padding: var(--space-4);
}
.consent-embed__text { font-size: var(--step--1); color: var(--text); margin: 0; }
.consent-embed__actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: var(--space-2);
    margin-top: var(--space-3);
}
.consent-embed__actions .btn { cursor: pointer; font-size: 0.8rem; }
.consent-embed__hint { font-size: 0.75rem; margin: var(--space-2) 0 0; }

/* ---------- Cookie-Tabelle (Datenschutzseite) ---------- */
.consent-table h3 { margin-top: var(--space-6); }
.consent-table code { font-family: var(--font-mono); font-size: 0.8rem; }

/* Aufforderungsbox auf der Datenschutzseite – Ziel des Footer-Links.
   Hervorgehoben, weil wer „Cookie-Einstellungen“ anklickt und ohne JavaScript
   hier landet, den Einstieg sofort sehen muss und nicht in der Tabelle suchen
   soll. */
.consent-cta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-3);
    margin-block: var(--space-5);
    padding: var(--space-4);
    background: var(--bg-subtle);
    border: 1px solid var(--border);
    border-left: 3px solid var(--brand);
    border-radius: var(--radius);
}
.consent-cta p { margin: 0; }

/* Footer-Einstieg sichtbar machen.
   Vorher war es ein Link wie jeder andere in der Rechtliches-Spalte und damit
   praktisch unsichtbar – der häufigste Grund, warum Besucher ihre Auswahl nicht
   wiederfinden. Das kleine Zahnrad-Symbol macht ihn als Schalter erkennbar,
   ohne die Footer-Optik zu brechen. */
.site-footer [data-consent-open]::before {
    content: '';
    display: inline-block;
    width: 0.85em;
    height: 0.85em;
    margin-right: 0.4em;
    vertical-align: -0.08em;
    background: currentColor;
    /* Zahnrad als Maske: erbt die Linkfarbe und braucht keine zweite Datei */
    -webkit-mask: var(--icon-cog) center/contain no-repeat;
    mask: var(--icon-cog) center/contain no-repeat;
}

/* ---------- Bewegungsreduktion ---------- */
@media (prefers-reduced-motion: reduce) {
    .consent__panel, .consent__btn { transition: none; }
}

/* ---------- Schmale Viewports ---------- */
@media (max-width: 560px) {
    .consent { padding: var(--space-2); }
    .consent__panel { padding: var(--space-4); max-height: 88vh; }
    .consent__btn { flex: 1 1 100%; }
    .consent__toggle { width: 100%; text-align: center; }
}
