/* Stage 2, task 16. Only the appearance of existing vertical scrollbars changes.
   The track is a constant 10px; an active thumb grows inside that track. */

@supports selector(::-webkit-scrollbar) and (not (-moz-appearance: none)) {
    /* The standard properties in earlier theme files take priority over the
       WebKit pseudo-elements in recent Chromium. Keep them for Firefox below. */
    :is(html, .fox-scrollbar-ready, .fox-player-list, .fox-online-users.is-ready,
        #chat #chat_messages, .fox-stats-scroll,
        #fox-notification-popover .fox-notification-source,
        .fox-stats-page .fox-stats-player-modal .modal-body) {
        scrollbar-width: auto !important;
        scrollbar-color: auto !important;
    }

    ::-webkit-scrollbar:vertical {
        width: 10px !important;
    }

    ::-webkit-scrollbar-track:vertical {
        border-radius: 999px !important;
        background: rgba(var(--fox-rgb-as2l6, 69, 33, 111), .18) !important;
        box-shadow: inset 0 0 0 1px rgba(var(--fox-rgb-gs4l15, 187, 122, 255), clamp(0, calc(.09 * var(--fox-glow-strength, 1)), 1)) !important;
    }

    ::-webkit-scrollbar-thumb:vertical {
        border: 2px solid transparent !important;
        border-radius: 999px !important;
        background: linear-gradient(180deg, var(--fox-tone-ts3l14, #ab72e8), var(--fox-tone-ts2l11, #8242cf) 52%, var(--fox-tone-ts4l15, #b47efa)) padding-box !important;
        background-clip: padding-box !important;
        box-shadow: inset 0 0 5px rgba(var(--fox-rgb-gs4l19, 255, 237, 255), clamp(0, calc(.32 * var(--fox-glow-strength, 1)), 1)) !important;
        transition: border-width .2s ease, background-color .2s ease, box-shadow .2s ease;
    }

    ::-webkit-scrollbar-thumb:vertical:hover {
        background: linear-gradient(180deg, var(--fox-tone-ts4l16, #c994ff), var(--fox-tone-ts3l13, #a65df0) 52%, var(--fox-tone-ts4l17, #d7acff)) padding-box !important;
        box-shadow: inset 0 0 7px rgba(var(--fox-rgb-gs4l19, 255, 239, 255), clamp(0, calc(.6 * var(--fox-glow-strength, 1)), 1)) !important;
    }

    /* The class is placed only on the element that actually scrolled. The
       visually wider thumb does not alter scrollbar width or page layout. */
    .fox-scrollbar-active::-webkit-scrollbar-thumb:vertical,
    .fox-scrollbar-dragging::-webkit-scrollbar-thumb:vertical {
        border-width: 1px !important;
        background: linear-gradient(180deg, var(--fox-tone-ts4l17, #e3b5ff), var(--fox-tone-ts4l15, #b873ff) 48%, var(--fox-tone-ts4l18, #ebc7ff)) padding-box !important;
        box-shadow: inset 0 0 8px rgba(255, 255, 255, .7), 0 0 8px rgba(var(--fox-rgb-gs4l14, 190, 105, 255), clamp(0, calc(.5 * var(--fox-glow-strength, 1)), 1)) !important;
    }

    .fox-scrollbar-cooling::-webkit-scrollbar-thumb:vertical {
        border-width: 2px !important;
        background: linear-gradient(180deg, var(--fox-tone-ts4l15, #c58cff), var(--fox-tone-ts3l12, #9650e3) 52%, var(--fox-tone-ts4l16, #c690ff)) padding-box !important;
        box-shadow: inset 0 0 6px rgba(var(--fox-rgb-gs4l19, 255, 240, 255), clamp(0, calc(.48 * var(--fox-glow-strength, 1)), 1)) !important;
    }
}

/* Firefox has native scrollbar-width and scrollbar-color but no supported
   thumb pseudo-element width transition. Keep its width thin and fixed. */
@supports (-moz-appearance: none) {
    html {
        scrollbar-width: thin;
        scrollbar-color: var(--fox-tone-as3l13, #a66ce5) var(--fox-tone-as2l2, #150d24);
    }

    .fox-scrollbar-ready {
        scrollbar-width: thin !important;
        scrollbar-color: var(--fox-tone-as3l13, #a66ce5) var(--fox-tone-as2l2, #150d24) !important;
    }

    .fox-scrollbar-active,
    .fox-scrollbar-dragging {
        scrollbar-color: var(--fox-tone-as4l17, #ddaaff) var(--fox-tone-as2l3, #211034) !important;
    }

    .fox-scrollbar-cooling {
        scrollbar-color: var(--fox-tone-as3l15, #c18bf2) var(--fox-tone-as2l2, #1a102c) !important;
    }
}

@media (prefers-reduced-motion: reduce) {
    ::-webkit-scrollbar-thumb:vertical {
        transition: none !important;
    }
}
