/* 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-status {
    display: flex;
    align-items: center;
    height: 100%;
    pointer-events: none;
    min-height: 0;
    max-width: calc(100% - 4rem);
    overflow: hidden;
    flex: 250 250;
    padding: 0px 4px;

    &:-moz-locale-dir(ltr) {
        mask-image: linear-gradient(to right, black 90%, #fff0);
    }

    &:-moz-locale-dir(rtl) {
        mask-image: linear-gradient(to left, black 90%, #fff0);
    }
}

browser-status .browser-status-label {
    white-space: nowrap;
    overflow: hidden;
    /* We make the font size of the status slightly smaller than baseline, to accomodate longer URIs */
    font-size: 0.95rem;
}

browser-status[inactive] {
    & .browser-status-label {
        visibility: hidden;
        opacity: 0;
    }

    &:not([inactive-instant]) .browser-status-label {
        transition: 0.1s opacity ease-out, 0.1s visibility;
    }

    &:not([inactive-instant]):is([statustype="overLink"], [statustype="tooltip"]) .browser-status-label {
        transition: 0.1s opacity ease-out 0.4s, 0.1s visibility 0.4s;
    }

    &:not([inactive-instant])[statustype="busy"] .browser-status-label {
        transition: 0.25s opacity ease-out 0.4s, 0.25s visibility 0.4s;
    }
}

browser-status:not([inactive]) {
    & .browser-status-label {
        opacity: 1;
        visibility: visible;
    }

    &:not([inactive-instant]):not([statustype="busy"]) .browser-status-label {
        transition: 0.2s opacity ease-out, 0.2s visibility;
    }
}

:host(browser-web-contents) browser-status {
    position: absolute;
    bottom: 0;
    height: max-content;
    flex: auto;
    padding: 0;
    mask-image: none !important;
    /* todo: find a better way of doing this, without needing important flags */

    & .browser-status-label {
        display: block;
        padding: 0.3rem 0.4rem;

        background-color: var(--toolbar-bgcolor);

        border-top: 1px solid var(--border-override, var(--chrome-content-separator-color));

        text-overflow: ellipsis;

        pointer-events: none;

        user-select: none;
    }

    &[statustype="busy"] .browser-status-label {
        min-width: 400px;
    }

    &[side="left"] {
        left: 0;
        padding-right: 4rem;
    }

    &[side="left"] .browser-status-label {
        border-right: 1px solid var(--border-override, var(--chrome-content-separator-color));
        border-top-right-radius: 0.4rem;
    }

    &[side="right"] {
        right: 0;
        padding-left: 4rem;
        max-width: 50%;
    }

    &[side="right"] .browser-status-label {
        border-left: 1px solid var(--border-override, var(--chrome-content-separator-color));
        border-top-left-radius: 0.4rem;
    }
}

@media (prefers-contrast) {
    browser-status .browser-status-label {
        --border-override: color-mix(in srgb, currentColor 75%, transparent 100%);
    }
}