/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */

browser-window-controls {
    display: flex;
    align-items: center;
    -moz-window-dragging: no-drag;
    padding-inline: var(--csd-margin-start, 4px) var(--csd-margin-end, 4px);
}

browser-window-controls button:focus-visible {
    outline: none !important;
}

browser-window-controls[hidden] {
    display: none !important;
}

:root[chromepopup] browser-window-controls .control-min {
    display: none;
}

:root[chromemargin=""] :host(browser-application)::part(csd),
:root:not([chromemargin]) :host(browser-application)::part(csd) {
    display: none;
}

:root[chromemargin=""] :host(browser-application)::part(csd),
:root:not([chromemargin]) :host(browser-application)::part(csd) {
    visibility: hidden;
    max-width: 0;
}

@media (-moz-gtk-csd-available) {

    /* Add a gap when using GTK csd, Gecko no longer does this for us */
    browser-window-controls {
        gap: 5px;
    }

    @media (-moz-gtk-csd-minimize-button) {
        browser-window-controls .control-min {
            appearance: auto;
            -moz-default-appearance: -moz-window-button-minimize;
        }
    }

    @media (-moz-gtk-csd-minimize-button: 0) {
        browser-window-controls .control-min {
            display: none;
        }
    }

    @media (-moz-gtk-csd-maximize-button) {
        browser-window-controls .control-max {
            appearance: auto;
            -moz-default-appearance: -moz-window-button-maximize;
        }

        browser-window-controls .control-restore {
            appearance: auto;
            -moz-default-appearance: -moz-window-button-restore;
        }
    }

    @media (-moz-gtk-csd-maximize-button: 0) {

        browser-window-controls .control-max,
        browser-window-controls .control-restore {
            display: none;
        }
    }

    @media (-moz-gtk-csd-close-button) {
        browser-window-controls .control-close {
            appearance: auto;
            -moz-default-appearance: -moz-window-button-close;
        }
    }

    @media (-moz-gtk-csd-close-button: 0) {
        browser-window-controls .control-close {
            display: none;
        }
    }

    @media (-moz-gtk-csd-reversed-placement) {
        browser-window-controls {
            --csd-margin-end: calc(var(--csd-margin-start) * 4);
        }
    }

    @media not (-moz-gtk-csd-reversed-placement) {
        browser-window-controls {
            margin-left: auto;
        }
    }
}