.site-back-to-top {
    position: fixed;
    right: max(1rem, env(safe-area-inset-right));
    bottom: max(1rem, env(safe-area-inset-bottom));
    z-index: 20;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    inline-size: 3rem;
    block-size: 3rem;
    border: 1px solid var(--bs-border-color);
    border-radius: 50%;
    background: var(--bs-bg-body);
    color: var(--bs-fg-body);
    box-shadow: var(--bs-box-shadow);
    text-decoration: none;
}

.site-back-to-top[hidden] {
    display: none;
}

.site-back-to-top:hover {
    color: var(--bs-fg-body);
}

.site-back-to-top:focus-visible {
    outline: 2px solid currentColor;
    outline-offset: 4px;
}

body:has(#cms-messaging-popup:not([hidden])) .site-back-to-top {
    top: 50%;
    bottom: auto;
    transform: translateY(-50%);
}

body:has(
        #cms-messaging-popup:not([hidden])
            #cms-messaging-popup-panel:not([hidden])
    )
    .site-back-to-top {
    visibility: hidden;
}

html:has(.site-back-to-top) {
    scroll-behavior: smooth;
}

@media (prefers-reduced-motion: reduce) {
    html:has(.site-back-to-top) {
        scroll-behavior: auto;
    }
}
