/* sticky-scrollbar.css — goes with sticky-scrollbar.js
 *
 * The scrollbar follows the same styling as in the module interface. .stickyScrollbar__track really
 * scrolls, so what you see is the browser's own bar. The JS gives that element the height this browser uses for one.
 */

.stickyScrollbar {
    --scrollbar-track-color: oklch(1 0 0 / 0.85);
    --scrollbar-thumb-color: oklch(0.84 0 0);

    position: fixed;
    z-index: 60;
    display: flex;
    align-items: center;
    box-sizing: border-box;
    padding: 0;
    /* Nothing should be here but the bar, so the strip must not catch the mouse
       either; only the scrolling element inside it does. */
    background: none;
    pointer-events: none;

    &[hidden] {
        display: none;
    }
}

/* Read by the JS: keeps the bar above the fixed ButtonPanel (51px high). */
body:has(.ButtonPanel:not(.ButtonPanel--hidden)) {
    --sticky-scrollbar-inset-bottom: 51px;
}

.stickyScrollbar__area {
    position: relative;
    flex: 1;
    min-width: 0;
    /* The bar plus a grab zone above it. --scrollbar-height is set by the JS. */
    height: calc(var(--scrollbar-height, 15px) + 12px);
}

.stickyScrollbar__track {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    height: var(--scrollbar-height, 15px);
    overflow-x: scroll;
    overflow-y: hidden;
    scrollbar-color: var(--scrollbar-thumb-color) var(--scrollbar-track-color);
    /* The strip itself is pointer-events: none, so the bar needs its own. */
    pointer-events: auto;
}

/* Sits above the bar, never on it, so hovering the bar still darkens the thumb. */
.stickyScrollbar__grip {
    position: absolute;
    left: 0;
    right: 0;
    top: 0;
    height: 12px;
    pointer-events: auto;
    touch-action: none;
}

.stickyScrollbar__spacer {
    height: 1px;
}

/* Safari only reveals its overlay bar on user scrolls, so there we draw one in the
   same shape and fade it ourselves. */
.stickyScrollbar.--emulate {
    .stickyScrollbar__track {
        opacity: 0;
        transition: opacity .3s ease .2s;
    }

    &.--visible .stickyScrollbar__track {
        opacity: 1;
        transition: opacity .1s ease 0s;
    }

    .stickyScrollbar__track::-webkit-scrollbar {
        height: 11px;
    }

    .stickyScrollbar__track::-webkit-scrollbar-track {
        background: transparent;
    }

    .stickyScrollbar__track::-webkit-scrollbar-thumb {
        background: rgba(0, 0, 0, .42);
        border: 3px solid transparent;
        background-clip: content-box;
        border-radius: 99px;
    }

    .stickyScrollbar__track::-webkit-scrollbar-thumb:hover {
        background: rgba(0, 0, 0, .62);
        background-clip: content-box;
    }
}
