/* Copyright 2024 user0, Peter Mack
 * SPDX-License-Identifier: MPL-2.0 */

/* Source from reddit users /u/BatDogOnBatMobile, /u/moko1960, and /u/It_Was_The_Other_Guy
 * https://old.reddit.com/r/FirefoxCSS/comments/s4wsww/
 * https://old.reddit.com/r/FirefoxCSS/comments/yb8tr9/ */

@media (max-width: 901px) {
    @media not (-moz-bool-pref: "mcf.tabcounter.disable"),
        not (-moz-pref("mcf.tabcounter.disable")) {
        /* Show Tab Manager Menu button */
        #alltabs-button {
            display: -moz-box !important;
        }

        /* Tab Manager Menu button tab counter */
        #TabsToolbar-customization-target {
            counter-reset: tabCount;
        }

        .tabbrowser-tab {
            counter-increment: tabCount;
        }

        #alltabs-button > .toolbarbutton-badge-stack > .toolbarbutton-icon {
            visibility: collapse !important;
        }

        #alltabs-button > .toolbarbutton-badge-stack {
             position: relative !important;
        }

        #alltabs-button > .toolbarbutton-badge-stack::before {
            content: counter(tabCount);
            color: var(--toolbarbutton-icon-fill);
            opacity: var(--toolbarbutton-icon-fill-opacity);
            position: absolute;
            bottom: var(--toolbarbutton-inner-padding);
            left: 50%;
            transform: translateX(-50%);
            /* Tab Manager Menu button styling inspired by Firefox for Android */
            border: 1px solid var(--toolbarbutton-icon-fill);
            border-radius: var(--tab-border-radius);
            padding: 0 5px 0 5px;
            font-size: 10px !important;
            font-weight: 600 !important;
        }

        #alltabs-button > .toolbarbutton-badge-stack {
            border-radius: var(--toolbarbutton-border-radius);
        }

        /* Tab Manager Menu tab counter */
        @media (-moz-bool-pref: "mcf.tabcounter.countinmenu"),
            -moz-pref("mcf.tabcounter.countinmenu") {
            #allTabsMenu-allTabsView-tabs {
                counter-reset: nn_tabs 0 !important;
            }
            .all-tabs-button::before {
                display: -moz-inline-box !important;
                -moz-padding-end: 8px !important;
                content: counter(nn_tabs) !important;
                font-size: 12px !important;
                margin-top: -2px !important;
                margin-right: -2px !important;
            }
            .all-tabs-item {
                counter-increment: nn_tabs !important;
            }
        }
    }
}
