/* ==========================================================================
   The store's frame on every page: the top bar (#portalTopbar, header.php) and
   the bar under it (.portal-subbar). Loaded by header.php on every page.

   Below 992px the top bar holds the store name, the cart and the menu button on
   one line. The name used to be one unbreakable line, so a long one ("Karabetian
   Import & Distribution, Inc.") pushed the menu button onto a second line and the
   bar grew to twice its height, while the bar under it stayed pinned at a fixed
   57px and slid underneath. --portal-topbar-h is the bar's real height, measured
   by portal-shell.js; 57px is only the stand-in until that runs.
   ========================================================================== */

:root {
    --portal-topbar-h: 57px;
}

.portal-subbar {
    z-index: 1020;
}

/* Tablet and up: the bar under the top bar stays pinned below it, as before. */
@media (min-width: 768px) {
    .portal-subbar {
        position: sticky;
        top: var(--portal-topbar-h, 57px);
    }
}

@media (max-width: 991.98px) {
    #portalTopbar > .container {
        flex-wrap: nowrap;
    }

    /* Two lines at most, then "...", instead of shoving the buttons off the line. */
    #portalTopbar .portal-brand {
        flex: 1 1 auto;
        min-width: 0;
        max-width: none;
        margin-right: .5rem;
        font-size: 1.1rem;
        line-height: 1.2;
        white-space: normal;
        overflow: hidden;
        display: -webkit-box;
        -webkit-box-orient: vertical;
        -webkit-line-clamp: 2;
        line-clamp: 2;
    }

    #portalTopbar .portal-topbar-cart {
        flex: 0 0 auto;
        margin-right: .5rem;
        padding: .3rem .6rem;
        white-space: nowrap;
    }

    #portalTopbar .portal-topbar-cart .badge {
        margin-left: .25rem;
    }

    #portalTopbar .navbar-toggler {
        flex: 0 0 auto;
    }

    /* The open menu drops over the page instead of growing the pinned bar, which
       pushed everything below it down and kept half the screen covered while
       scrolling. portal-shell.js also closes it on a scroll or a tap outside. */
    /* Positioned against the bar itself (it is sticky, so it is a containing
       block), so the menu spans the full width right under its bottom edge. */
    #portalTopbar > .container {
        background-color: inherit;
    }

    #portalTopbar .navbar-collapse {
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        max-height: calc(100vh - var(--portal-topbar-h, 57px));
        overflow-y: auto;
        padding: 0 1.5rem .75rem;
        background-color: inherit;
        border-bottom: 1px solid rgba(0, 0, 0, .1);
        box-shadow: 0 8px 16px rgba(0, 0, 0, .12);
    }

    #portalTopbar .navbar-collapse .nav-link {
        padding-top: .65rem;
        padding-bottom: .65rem;
    }

    #portalTopbar .navbar-collapse > .d-flex {
        align-items: center;
        justify-content: space-between;
        gap: .5rem;
        padding-top: .75rem;
        border-top: 1px solid rgba(0, 0, 0, .08);
    }

    #portalTopbar .navbar-collapse > .d-flex > div:first-child {
        text-align: left !important;
        margin-top: 0 !important;
        min-width: 0;
    }

    #portalTopbar .navbar-collapse .btn {
        white-space: nowrap;
        flex: 0 0 auto;
    }
}

@media (max-width: 575.98px) {
    #portalTopbar > .container,
    .portal-subbar > .container {
        padding-left: .75rem !important;
        padding-right: .75rem !important;
    }

    #portalTopbar .navbar-collapse {
        padding-left: .75rem;
        padding-right: .75rem;
    }
}

/* Phones: the price notice takes one or two small lines rather than two big ones,
   and the Balance / Payment buttons stay beside it. */
@media (max-width: 767.98px) {
    .portal-subbar {
        padding-top: .35rem;
        padding-bottom: .35rem;
    }

    .portal-subbar > .container {
        flex-wrap: nowrap;
        gap: .5rem;
    }

    .portal-subbar .portal-notice {
        font-size: .8rem;
        line-height: 1.3;
        min-width: 0;
    }

    /* The buttons keep their size; the notice is what wraps. */
    .portal-subbar > .container > .d-flex {
        flex: 0 0 auto;
    }

    .portal-subbar .btn {
        white-space: nowrap;
    }
}
