/**
 * Cookiebanner en voorkeurenvenster.
 *
 * Twee dingen zijn hier bewuste keuzes en geen smaak:
 *
 * 1. De drie knoppen in de banner zijn visueel identiek. Weigeren moet even
 *    makkelijk zijn als accepteren, en een opvallende accepteerknop naast een
 *    grijze weigerknop is precies het soort nudging waar de Autoriteit
 *    Persoonsgegevens op handhaaft.
 * 2. De banner legt de site niet plat. Er is geen overlay achter de eerste laag,
 *    want een cookiewall is in Nederland verboden. Het voorkeurenvenster mag wel
 *    blokkeren zolang het open staat.
 *
 * Stapeling, aansluitend op de rest van het platform: mobiele stapkop 900,
 * themabalk 1000, tabbalk 1500, thememodals 2000, pluginmodals 10000. De
 * cookiemelding gaat daar bewust bovenop, want zonder keuze hoort de bezoeker
 * hem altijd te kunnen zien en bedienen.
 */

.ttp-consent__banner {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 10050;
    background: var(--color-dark, #1A1B23);
    color: var(--color-white, #FFFFFF);
    border-top: 3px solid var(--color-primary, #FF6B35);
    box-shadow: 0 -8px 32px rgba(0, 0, 0, 0.28);
    font-family: var(--font-primary, 'Inter', sans-serif);
}

.ttp-consent__banner-inner {
    max-width: var(--container-max-width, 1200px);
    margin: 0 auto;
    padding: 1.5rem var(--container-padding, 2rem);
    display: flex;
    align-items: center;
    gap: 2rem;
}

.ttp-consent__banner-text {
    flex: 1 1 auto;
    min-width: 0;
}

.ttp-consent__title {
    margin: 0 0 0.5rem;
    font-size: 1.0625rem;
    font-weight: 600;
    line-height: 1.3;
    color: inherit;
}

.ttp-consent__banner-text p {
    margin: 0;
    font-size: 0.9375rem;
    line-height: 1.6;
    color: rgba(255, 255, 255, 0.86);
}

.ttp-consent__banner-text a {
    color: var(--color-secondary, #FFA726);
    text-decoration: underline;
}

.ttp-consent__banner-text a:hover,
.ttp-consent__banner-text a:focus {
    color: var(--color-white, #FFFFFF);
}

.ttp-consent__actions {
    flex: 0 0 auto;
    display: flex;
    gap: 0.75rem;
}

/* Alle knoppen delen exact dezelfde vormgeving. Zie de toelichting bovenaan. */
.ttp-consent__btn {
    flex: 0 0 auto;
    min-width: 11rem;
    padding: 0.75rem 1.25rem;
    font-family: inherit;
    font-size: 0.9375rem;
    font-weight: 600;
    line-height: 1.2;
    color: var(--color-white, #FFFFFF);
    background: transparent;
    border: 2px solid var(--color-primary, #FF6B35);
    border-radius: var(--border-radius, 12px);
    cursor: pointer;
    transition: background-color 0.2s ease, color 0.2s ease;
}

.ttp-consent__btn:hover {
    background: var(--color-primary, #FF6B35);
    color: var(--color-white, #FFFFFF);
}

.ttp-consent__btn:focus-visible {
    outline: 3px solid var(--color-secondary, #FFA726);
    outline-offset: 2px;
}

/* ---------------------------------------------------------------------------
 * Het voorkeurenvenster
 * ------------------------------------------------------------------------ */

.ttp-consent__overlay {
    position: fixed;
    inset: 0;
    z-index: 10060;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    background: rgba(26, 27, 35, 0.72);
    overflow-y: auto;
}

.ttp-consent__dialog {
    width: 100%;
    max-width: 46rem;
    max-height: calc(100vh - 3rem);
    display: flex;
    flex-direction: column;
    background: var(--color-white, #FFFFFF);
    color: var(--color-dark, #1A1B23);
    border-radius: var(--border-radius, 12px);
    box-shadow: 0 24px 64px rgba(0, 0, 0, 0.35);
    font-family: var(--font-primary, 'Inter', sans-serif);
}

.ttp-consent__dialog-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 1.5rem 1.75rem;
    border-bottom: 1px solid rgba(100, 116, 139, 0.2);
}

.ttp-consent__dialog .ttp-consent__title {
    font-size: 1.25rem;
    margin: 0;
}

.ttp-consent__close {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.25rem;
    height: 2.25rem;
    padding: 0;
    color: var(--color-gray, #64748B);
    background: transparent;
    border: none;
    border-radius: 50%;
    cursor: pointer;
}

.ttp-consent__close:hover {
    background: var(--color-light-gray, #F8FAFC);
    color: var(--color-dark, #1A1B23);
}

.ttp-consent__close:focus-visible {
    outline: 3px solid var(--color-primary, #FF6B35);
    outline-offset: 2px;
}

.ttp-consent__dialog-body {
    flex: 1 1 auto;
    overflow-y: auto;
    padding: 1.5rem 1.75rem;
}

.ttp-consent__intro {
    margin: 0 0 1.5rem;
    font-size: 0.9375rem;
    line-height: 1.6;
    color: var(--color-gray, #64748B);
}

.ttp-consent__intro a {
    color: var(--color-primary, #FF6B35);
}

.ttp-consent__group {
    padding: 1.25rem 0;
    border-top: 1px solid rgba(100, 116, 139, 0.18);
}

.ttp-consent__group:first-of-type {
    border-top: none;
    padding-top: 0;
}

.ttp-consent__group-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 0.5rem;
}

.ttp-consent__group-text,
.ttp-consent__group-empty {
    margin: 0;
    font-size: 0.9375rem;
    line-height: 1.6;
    color: var(--color-gray, #64748B);
}

.ttp-consent__group-empty {
    margin-top: 0.75rem;
    font-style: italic;
}

.ttp-consent__always {
    flex: 0 0 auto;
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--color-gray, #64748B);
}

/* De schakelaar ------------------------------------------------------------ */

.ttp-consent__switch {
    display: inline-flex;
    align-items: center;
    gap: 0.75rem;
    cursor: pointer;
}

.ttp-consent__switch input {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
    border: 0;
}

.ttp-consent__switch-track {
    position: relative;
    flex: 0 0 auto;
    width: 2.75rem;
    height: 1.5rem;
    background: rgba(100, 116, 139, 0.35);
    border-radius: 1rem;
    transition: background-color 0.2s ease;
}

.ttp-consent__switch-track::after {
    content: '';
    position: absolute;
    top: 0.1875rem;
    left: 0.1875rem;
    width: 1.125rem;
    height: 1.125rem;
    background: var(--color-white, #FFFFFF);
    border-radius: 50%;
    transition: transform 0.2s ease;
}

.ttp-consent__switch input:checked + .ttp-consent__switch-track {
    background: var(--color-primary, #FF6B35);
}

.ttp-consent__switch input:checked + .ttp-consent__switch-track::after {
    transform: translateX(1.25rem);
}

.ttp-consent__switch input:disabled + .ttp-consent__switch-track {
    background: rgba(100, 116, 139, 0.45);
    cursor: not-allowed;
}

.ttp-consent__switch input:focus-visible + .ttp-consent__switch-track {
    outline: 3px solid var(--color-primary, #FF6B35);
    outline-offset: 2px;
}

.ttp-consent__switch-label {
    font-size: 1rem;
    font-weight: 600;
    color: var(--color-dark, #1A1B23);
}

/* De cookietabel ----------------------------------------------------------- */

.ttp-consent__details-toggle {
    margin-top: 0.75rem;
    padding: 0;
    font-family: inherit;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--color-primary, #FF6B35);
    background: none;
    border: none;
    cursor: pointer;
    text-decoration: underline;
}

.ttp-consent__details {
    margin-top: 1rem;
    overflow-x: auto;
}

.ttp-consent__table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.8125rem;
}

.ttp-consent__table th,
.ttp-consent__table td {
    padding: 0.625rem 0.75rem;
    text-align: left;
    vertical-align: top;
    border-bottom: 1px solid rgba(100, 116, 139, 0.18);
}

.ttp-consent__table th {
    font-weight: 600;
    color: var(--color-dark, #1A1B23);
    background: var(--color-light-gray, #F8FAFC);
    white-space: nowrap;
}

.ttp-consent__table td {
    color: var(--color-gray, #64748B);
}

.ttp-consent__table code {
    font-size: 0.75rem;
    color: var(--color-dark, #1A1B23);
    word-break: break-word;
}

.ttp-consent__dialog-foot {
    flex: 0 0 auto;
    display: flex;
    gap: 0.75rem;
    padding: 1.25rem 1.75rem;
    border-top: 1px solid rgba(100, 116, 139, 0.2);
    background: var(--color-light-gray, #F8FAFC);
    border-radius: 0 0 var(--border-radius, 12px) var(--border-radius, 12px);
}

.ttp-consent__dialog-foot .ttp-consent__btn {
    flex: 1 1 0;
    min-width: 0;
    color: var(--color-dark, #1A1B23);
}

.ttp-consent__dialog-foot .ttp-consent__btn:hover {
    color: var(--color-white, #FFFFFF);
}

/* De knop waarmee de keuze later wordt aangepast.
 *
 * Deze knop krijgt altijd de klasse van zijn omgeving mee, zoals
 * footer__legal-link in de footer of legal-consent-button op de
 * cookiebeleidpagina. Die klassen regelen de vormgeving al volledig.
 *
 * Daarom staat deze regel in :where(), waardoor hij specificiteit 0 heeft. Het
 * blijft een bruikbare terugval voor een knop zonder eigen klasse, maar hij kan
 * nooit winnen van de opmaak van de omgeving. Zonder :where() zou hij dat wel
 * doen, omdat cookie-consent.css na main.css wordt geladen en beide selectors
 * even zwaar zijn: de knop kreeg dan de verkeerde kleur en lettergrootte.
 *
 * Dezelfde aanpak als de basisregel voor formuliervelden in community.css.
 */
:where(.ttp-consent-open) {
    font: inherit;
    color: inherit;
    background: none;
    border: none;
    padding: 0;
    cursor: pointer;
    text-decoration: underline;
}

html.ttp-consent-open {
    overflow: hidden;
}

/* Responsief -------------------------------------------------------------- */

@media (max-width: 900px) {
    .ttp-consent__banner-inner {
        flex-direction: column;
        align-items: stretch;
        gap: 1.25rem;
        padding: 1.25rem;
    }

    .ttp-consent__actions {
        flex-wrap: wrap;
    }

    .ttp-consent__btn {
        flex: 1 1 12rem;
        min-width: 0;
    }
}

@media (max-width: 640px) {
    .ttp-consent__banner {
        max-height: 80vh;
        overflow-y: auto;
    }

    .ttp-consent__actions {
        flex-direction: column;
    }

    .ttp-consent__overlay {
        padding: 0;
    }

    .ttp-consent__dialog {
        max-width: none;
        max-height: 100vh;
        height: 100vh;
        border-radius: 0;
    }

    .ttp-consent__dialog-head,
    .ttp-consent__dialog-body,
    .ttp-consent__dialog-foot {
        padding-left: 1.25rem;
        padding-right: 1.25rem;
    }

    .ttp-consent__dialog-foot {
        flex-direction: column;
        border-radius: 0;
    }

    /* De tabel wordt op een smal scherm een lijst, zodat er niets wegvalt. */
    .ttp-consent__table thead {
        position: absolute;
        width: 1px;
        height: 1px;
        margin: -1px;
        overflow: hidden;
        clip: rect(0 0 0 0);
    }

    .ttp-consent__table,
    .ttp-consent__table tbody,
    .ttp-consent__table tr,
    .ttp-consent__table td {
        display: block;
        width: 100%;
    }

    .ttp-consent__table tr {
        padding: 0.75rem 0;
        border-bottom: 1px solid rgba(100, 116, 139, 0.18);
    }

    .ttp-consent__table td {
        padding: 0.25rem 0;
        border: none;
    }

    .ttp-consent__table td::before {
        content: attr(data-label) ': ';
        font-weight: 600;
        color: var(--color-dark, #1A1B23);
    }
}

@media (prefers-reduced-motion: reduce) {
    .ttp-consent__btn,
    .ttp-consent__switch-track,
    .ttp-consent__switch-track::after {
        transition: none;
    }
}
