.contao-cookiebar {
    --ccb-backdrop: rgb(0 0 0 / 75%);
    --ccb-anim-duration: 0.5s;
    --ccb-checked-clr: #399d32;
    --ccb-checked-bg: #dcf3db;
    --ccb-unchecked-clr: #9c9b99;
    --ccb-unchecked-bg: #fff;
    --ccb-disabled-clr: #c8c7c5;
    --ccb-disabled-bg: #f4f4f4;
    --ccb-focus-clr: #00a4f4;

    position: fixed;
    inset: 0;
    z-index: 9999;
    display: flex;
    align-items: var(--ccb-align, center);
    justify-content: var(--ccb-justify, center);
    letter-spacing: 0;
    padding: 15px;
    max-height: 100dvh;
    box-sizing: border-box;
    pointer-events: none;
    overflow: hidden;
    color: var(--ccb-clr, #444);

    * {
        box-sizing: border-box;
    }

    p {
        color: var(--ccb-text, #868686);
        line-height: 1.4;
    }

    label {
        position: relative;
        display: block;
        padding: 8px 13px 8px 0;
        line-height: 1.2rem;

        &.group {
            font-weight: 600;
        }
    }

    input {
        position: absolute;
        width: 1px;
        height: 1px;
        outline: 0 none;
        opacity: 0;

        + label {
            padding: 8px 13px 8px 45px;
            cursor: pointer;

            &::before,
            &::after {
                content: "";
                position: absolute;
                border-radius: 10px;
            }

            &::before {
                top: 7px;
                left: 0;
                width: 35px;
                height: 18px;
                margin: 0;
                box-sizing: content-box;
                background: var(--ccb-unchecked-bg);
                border: 1px solid var(--ccb-unchecked-clr);
                transition: border-color 0.2s;
            }

            &::after {
                display: block;
                top: 11px;
                left: 4px;
                width: 12px;
                height: 12px;
                background: var(--ccb-unchecked-clr);
                transition: background 0.2s, margin-left 0.2s, padding 0.2s;
            }

            &:active::after {
                padding-left: 5px;
            }
        }

        &.cc-group-half + label::after {
            background: linear-gradient(
                to right,
                var(--ccb-unchecked-clr) 0%,
                var(--ccb-unchecked-clr) 50%,
                var(--ccb-checked-clr) 50%,
                var(--ccb-checked-clr) 100%
            );
        }

        &:checked + label {
            &::after {
                background: var(--ccb-checked-clr);
                margin-left: 17px;
            }

            &:active::after {
                margin-left: 12px;
            }

            &::before {
                background: var(--ccb-checked-bg);
                border-color: var(--ccb-checked-clr);
            }
        }

        &:disabled + label {
            pointer-events: none;

            &::after {
                background: var(--ccb-disabled-clr);
            }

            &::before {
                background: var(--ccb-disabled-bg);
                border-color: var(--ccb-disabled-clr);
            }
        }

        &:focus-visible:not(.cc-hide-focus) {
            + label {
                &::before {
                    outline: 3px dashed var(--ccb-focus-clr);
                    outline-offset: 2px;
                }
            }
        }
    }

    .cc-btn {
        display: inline-block;
        cursor: pointer;
        width: 100%;
        padding: 8px 14px;
        margin-bottom: 8px;
        font-size: 15px;
        outline: 0 none;
        border: 1px solid var(--ccb-btn-bdr, #cfcfcf);
        border-radius: 4px;
        color: var(--ccb-btn-clr, #444);
        background: var(--ccb-btn-bg, #f5f5f5);

        &:hover,
        &:focus {
            background: var(--ccb-btn-bg-hvr, #ececec);
        }

        &:last-child {
            margin-bottom: 0;
        }
    }

    .grayscale {
        --ccb-btn-bg: #f1efef;
        --ccb-btn-bg-hvr: #ececec;

        .success {
            --ccb-btn-bg: #fbfbfb;
            --ccb-btn-bg-hvr: #f7f7f7;
        }
    }

    .highlight {
        .success {
            --ccb-btn-bg: #4e9e3e;
            --ccb-btn-bg-hvr: #4c933f;
            --ccb-btn-bdr: #3e7830;
            --ccb-btn-clr: #fff;
        }
    }
}

.cc-head > * {
    &:first-child {
        margin-top: 0;
    }

    &:last-child {
        margin-bottom: 15px;
    }
}

.cc-focus:not(.cc-hide-focus) {
    &:focus-visible {
        outline: 3px dashed var(--ccb-focus-clr);
        outline-offset: -3px;
    }
}

.cc-invisible {
    border: 0;
    clip: rect(0 0 0 0); /* stylelint-disable-line property-no-deprecated */
    height: 1px;
    margin: -1px;
    overflow: hidden;
    padding: 0;
    position: absolute;
    width: 1px;
    float: left;
}

.cc-inner {
    position: relative;
    display: inline-block;
    overflow-y: auto;
    max-height: 100%;
    max-width: 100%;
    padding: 23px;
    border-radius: 3px;
    opacity: 0;
    pointer-events: none;
    visibility: hidden;
    font-size: 1rem;
    text-align: left;
    background: var(--ccb-bg, #fff);
    box-shadow: var(--ccb-box-shadow, rgb(99 99 99 / 20%)) 0 2px 8px 0;
    animation: var(--ccb-anim, cookiebar-middle-in) var(--ccb-anim-duration) ease-in-out forwards;
}

.cc-close {
    position: absolute;
    inset: 6px 6px auto auto;
    cursor: pointer;
    border: none;
    background: none !important;
    color: inherit !important;
    font-weight: 700;
    height: 24px;
    width: 24px;
}

.cc-group {
    position: relative;
    border: 1px solid var(--ccb-bdr, #d0d0d0);
    border-radius: 5px;
    margin-bottom: 10px;
}

.cc-cookie-info {
    font-size: 0.875rem;
    background: var(--ccb-info-bg, #fff);
    border: 1px solid var(--ccb-info-bdr, #efefef);
    padding: 10px;
    border-radius: 5px;

    &:empty {
        display: none;
    }

    > div {
        > span {
            font-weight: 600;
        }

        + div {
            margin-top: 5px;
            overflow-wrap: break-word;
        }
    }

    + button.cc-detail-btn-details {
        margin-top: 15px;
    }
}

.cc-cookies {
    background: var(--ccb-cookies-bg, #fbfbfb);
    border-radius: 0 0 5px 5px;

    > p {
        font-size: 0.875rem;
    }

    > p,
    > .cc-cookie {
        margin: 0;
        padding: 15px;
        border-top: 1px solid var(--ccb-cookies-bdr, #fbfbfb);
    }
}

.cc-cookie {
    label.cookie + * {
        margin-top: 10px;
    }

    p {
        margin: 0 0 15px;
        font-size: 0.875rem;
    }
}

.cc-cookie-desc {
    p {
        margin-bottom: 0;
    }
}

.cc-footer,
.cc-info {
    text-align: center;
}

.cc-info {
    margin-top: 15px;

    > p {
        font-size: 0.875rem;
    }

    > a {
        display: inline-block;
        font-size: 0.813rem;
        color: var(--ccb-detail-clr, #a2a2a2);
        text-decoration: none;

        &:hover {
            color: var(--ccb-detail-clr-hvr, #717171);
        }

        + a::before {
            display: inline-block;
            content: "·";
            margin-right: 5px;
        }
    }
}

.cc-active {
    .cc-inner {
        opacity: 1;
        pointer-events: auto;
        visibility: visible;
    }

    &.cc-blocked {
        pointer-events: auto;
        animation: cookiebar-overlay-in var(--ccb-anim-duration) ease-in-out forwards;
    }
}

.cc-saved {
    &.cc-inner {
        opacity: 0;
        pointer-events: none;
        visibility: hidden;
    }

    &.cc-blocked {
        pointer-events: none;
        animation: cookiebar-overlay-out var(--ccb-anim-duration) ease-in-out forwards;
    }
}

.cc-left {
    --ccb-justify: flex-start;
}

.cc-right {
    --ccb-justify: flex-end;
}

.cc-top {
    --ccb-align: flex-start;

    &.cc-active {
        --ccb-anim: cookiebar-top-in;
    }

    &.cc-saved {
        --ccb-anim: cookiebar-top-out;
    }
}

.cc-middle {
    &.cc-active {
        --ccb-anim: cookiebar-middle-in;
    }

    &.cc-saved {
        --ccb-anim: cookiebar-middle-out;
    }
}

.cc-bottom {
    --ccb-align: flex-end;

    &.cc-active {
        --ccb-anim: cookiebar-bottom-in;
    }

    &.cc-saved {
        --ccb-anim: cookiebar-bottom-out;
    }
}

@media (width >= 768px) {
    .contao-cookiebar {
        .cc-btn {
            width: auto;
            margin-bottom: 0;
        }
    }

    .cc-inner {
        max-width: var(--ccb-max-width, 750px);
    }
}

@media (forced-colors) {
    .contao-cookiebar {
        input {
            + label {
                &::after {
                    border: 1px solid currentcolor;
                }
            }
        }
    }

    .cc-inner {
        border: 1px solid currentcolor;
    }

    input.cc-group-half + label::after {
        margin-left: 9px;
    }
}

@media (prefers-reduced-motion) {
    .contao-cookiebar {
        --ccb-anim-duration: 2s;
    }
}

@media print {
    .contao-cookiebar {
        opacity: 0;
    }
}

@keyframes cookiebar-overlay-in {
    0% {
        background: rgb(0 0 0 / 0%);
    }

    100% {
        background: var(--ccb-backdrop);
    }
}

@keyframes cookiebar-overlay-out {
    0% {
        background: var(--ccb-backdrop);
    }

    100% {
        background: rgb(0 0 0 / 0%);
        visibility: hidden;
    }
}

@keyframes cookiebar-top-in {
    0% {
        opacity: 0;
        transform: translateY(-100%);
    }

    100% {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes cookiebar-top-out {
    0% {
        opacity: 1;
        visibility: visible;
        transform: translateY(0);
    }

    100% {
        opacity: 0;
        visibility: hidden;
        transform: translateY(-100%);
    }
}

@keyframes cookiebar-middle-in {
    0% {
        opacity: 0;
        transform: scale(0);
    }

    100% {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes cookiebar-middle-out {
    0% {
        opacity: 1;
        visibility: visible;
        transform: scale(1);
    }

    100% {
        opacity: 0;
        visibility: hidden;
        transform: scale(0);
    }
}

@keyframes cookiebar-bottom-in {
    0% {
        opacity: 0;
        transform: translateY(100%);
    }

    100% {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes cookiebar-bottom-out {
    0% {
        opacity: 1;
        visibility: visible;
        transform: translateY(0);
    }

    100% {
        opacity: 0;
        visibility: hidden;
        transform: translateY(100%);
    }
}
