/* Reserve the same width before, during and after a modal scroll lock.
   Keep native scrolling, keyboard support and draggable thumbs. */
html,
:is(.mini-cart__body, .account-menu__panel) {
    --ak-scrollbar-thumb: var(--ak-muted-strong);
    scrollbar-gutter: stable;
    scrollbar-width: thin;
    scrollbar-color: var(--ak-scrollbar-thumb) transparent;
}

/* Hide only the decoration, never its width or native hit target. Without JS,
   on touch screens and in high contrast the scrollbar remains visible. */
@media (hover: hover) and (pointer: fine) and (forced-colors: none) {
    html.auto-hide-scrollbars,
    html.auto-hide-scrollbars :is(.mini-cart__body, .account-menu__panel) {
        --ak-scrollbar-thumb: transparent;
    }

    html.auto-hide-scrollbars.is-scrollbar-active,
    html.auto-hide-scrollbars :is(.mini-cart__body, .account-menu__panel).is-scrollbar-active {
        --ak-scrollbar-thumb: var(--ak-muted-strong);
    }
}

/* Chromium/WebKit: a rounded thumb without native arrow buttons or a rail.
   overflow:auto still hides the thumb when the content fits. */
@supports selector(::-webkit-scrollbar) {
    html,
    :is(.mini-cart__body, .account-menu__panel) {
        scrollbar-width: auto;
        scrollbar-color: auto;
    }

    html::-webkit-scrollbar,
    :is(.mini-cart__body, .account-menu__panel)::-webkit-scrollbar {
        width: 10px;
        height: 10px;
    }

    html::-webkit-scrollbar-track,
    :is(.mini-cart__body, .account-menu__panel)::-webkit-scrollbar-track,
    html::-webkit-scrollbar-corner,
    :is(.mini-cart__body, .account-menu__panel)::-webkit-scrollbar-corner {
        background: transparent;
    }

    html::-webkit-scrollbar-thumb,
    :is(.mini-cart__body, .account-menu__panel)::-webkit-scrollbar-thumb {
        min-height: 32px;
        border: 2px solid transparent;
        border-radius: 999px;
        background: var(--ak-scrollbar-thumb);
        background-clip: padding-box;
    }

    html::-webkit-scrollbar-thumb:hover,
    :is(.mini-cart__body, .account-menu__panel)::-webkit-scrollbar-thumb:hover {
        background-color: var(--ak-muted);
    }

    html::-webkit-scrollbar-thumb:active,
    :is(.mini-cart__body, .account-menu__panel)::-webkit-scrollbar-thumb:active {
        background-color: var(--ak-text-soft);
    }

    html::-webkit-scrollbar-button,
    :is(.mini-cart__body, .account-menu__panel)::-webkit-scrollbar-button {
        display: none;
    }
}

/* Leave high-contrast appearance and larger system targets to the browser. */
@media (forced-colors: active) {
    html,
    :is(.mini-cart__body, .account-menu__panel) {
        scrollbar-width: auto;
        scrollbar-color: auto;
    }

    html::-webkit-scrollbar,
    :is(.mini-cart__body, .account-menu__panel)::-webkit-scrollbar {
        width: auto;
        height: auto;
    }

    html::-webkit-scrollbar-thumb,
    :is(.mini-cart__body, .account-menu__panel)::-webkit-scrollbar-thumb {
        background-color: CanvasText;
    }
}
