.cookie-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1001;
    display: none;
}

.cookie-form {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: var(--background-color-white);
    color: var(--color-text-black);
    padding: var(--spacing-md);
    border-radius: var(--border-radius-15);
    width: clamp(320px, 100%, 620px);
    display: none;
    flex-direction: column;
    gap: var(--spacing-md);
    z-index: 9999;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    max-height: 90vh;
    /* A10: on phones 90vh is taller than the visible area (browser bars), the bottom was cut off. */
    max-height: 90dvh;
    overflow-y: auto;
}

.cookie-section {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-sm);
}

.cookie-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.cookie-close {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: var(--color-text-black);
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background-color var(--transition-fast);
}

.cookie-close:hover {
    background-color: var(--border-color-gray);
}

.cookie-bottom {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: var(--spacing-sm);
}

.cookie-bottom button {
    flex-basis: 50%;
    padding: var(--spacing-sm);
    font-size: var(--font-size-md);
    border: var(--border-radius-15);
}

.cookie-confirm-preferences {
    color: var(--color-text-black);
    border: 1px solid var(--border-color-gray);
}

.cookie-accept {
    color: var(--color-primary);
    border: none;
    background: var(--color-text-dark-blue);
}

.cookie-switch {
    display: flex;
    align-items: center;

    width: 50px;
    height: 25px;
    border-radius: var(--border-radius-15);
    background: transparent;
    border: 1px solid var(--border-color-dark-gray);
    padding: 2px;
    justify-content: flex-end;

    input {
        display: none;
    }

    .slider {
        background: var(--color-text-dark-blue);
        height: 100%;
        aspect-ratio: 1/1;
        border-radius: 50%;
        transition: transform var(--transition-fast);
        transform: translateX(-25px);
    }

    &:has(input:checked) {

        background: var(--color-text-dark-blue);

        .slider {
            background: var(--background-color-white);
            transform: translateX(0);
        }
    }
}
/*
 * Burger breakpoint (<= 768px): the centred modal covered the header, so the burger button could not
 * be reached until the banner was dealt with. Make it a bottom sheet instead: the header stays visible
 * and clickable (it sits above the dimmed overlay), the text scrolls inside the sheet and the buttons
 * stay pinned at its bottom.
 */
@media (max-width: 768px) {
    .cookie-form {
        top: auto;
        bottom: 0;
        left: 0;
        transform: none;
        width: 100%;
        max-height: 70vh;
        max-height: 70dvh;
        border-radius: var(--border-radius-15) var(--border-radius-15) 0 0;
    }

    .cookie-bottom {
        position: sticky;
        bottom: calc(-1 * var(--spacing-md));
        margin-bottom: calc(-1 * var(--spacing-md));
        padding: var(--spacing-sm) 0 var(--spacing-md);
        background: var(--background-color-white);
    }

    /* While the burger menu is open, keep it above the banner (the header is z-index sticky, 1020). */
    body:has(#menu__toggle:checked) .cookie-form {
        z-index: 1010;
    }
}
