/*
 * Mobile navigation (below 992px) after the designer's layout: no burger menu; logo and search in the grey bar,
 * below it the pill navigation (Work, Life, Guides, Jobs) on white. A click on a main item opens its submenu
 * (Partials/Page/Navigation/MobileNavigation.html, MobileNavigation.js); icons per page like the subnavigation.
 */
.mobilenav {
    display: none;
}

@media (max-width: 991.98px) {
    :root {
        --mobilenav-bar: 64px;
    }

    /* grey bar with logo and search, white area with the pill navigation and the submenu */
    #page-header.navbar-mainnavigation.navbar-default {
        padding: 0 16px 20px;
        background-image: linear-gradient(to bottom, #F2F2F2 0 var(--mobilenav-bar), #C4C4C4 var(--mobilenav-bar) calc(var(--mobilenav-bar) + 1px), rgba(0, 0, 0, .1) calc(var(--mobilenav-bar) + 1px), #fff calc(var(--mobilenav-bar) + 9px));
        box-shadow: 0 2px 10px 0 rgba(0, 0, 0, .15);
    }

    #page-header .container-mainnavigation {
        flex-wrap: wrap;
        align-items: center;
        padding: 0;
    }

    #page-header .navbar-brand {
        order: 1;
        display: flex;
        align-items: center;
        height: var(--mobilenav-bar);
        margin: 0;
        padding: 0;
    }

    #page-header .navbar-brand-image img {
        width: 147px;
        height: auto;
        margin-top: 0;
        top: auto;
        transform: none;
    }

    /* next to the logo: the other language, then the search at the far right; both buttons 40px */
    #page-header #subnavigation {
        order: 2;
        display: flex;
        flex: 0 0 auto;
        flex-direction: row;
        align-items: center;
        gap: .5rem;
        height: var(--mobilenav-bar);
        margin: 0 0 0 auto;
        padding: 0;
    }

    #page-header #subnavigation > .navbar-nav {
        flex-direction: row;
        gap: .5rem;
        margin: 0;
        padding: 0;
    }

    #page-header #language_menu {
        order: 1;
    }

    #page-header .navbar-search {
        order: 2;
    }

    #page-header #language_menu .nav-item.active {
        display: none;
    }

    #page-header #language_menu .nav-item {
        width: 40px;
        height: 40px;
    }

    #page-header #language_menu .nav-link {
        display: flex;
        align-items: center;
        justify-content: center;
        height: 100%;
        padding: 0;
    }

    #page-header .navbar-search .search-link {
        width: 40px;
        height: 40px;
        padding: 0;
    }

    /* search field opens below the button (it would leave the screen to the right) */
    #page-header .navbar-search .nav-item {
        position: relative;
    }

    #page-header #subnavigation .headersuche {
        top: 100%;
        right: 0;
        padding-top: .5rem;
    }

    #page-header #subnavigation .navbar-search input.suchfeld {
        height: 48px;
        line-height: 48px;
        margin: 0;
        padding-left: 1rem;
    }

    #page-header #subnavigation .navbar-search:hover input.suchfeld,
    #page-header #subnavigation .navbar-search .is-search-open input.suchfeld {
        width: min(260px, calc(100vw - 32px)) !important;
    }

    #page-header #subnavigation .navbar-search .is-search-open .headersuche {
        visibility: visible;
        opacity: 1;
    }

    #page-header .navbar-linkedin,
    #page-header .navbar-toggler {
        display: none;
    }

    /* pill navigation */
    #page-header #mainnavigation {
        order: 3;
        display: block;
        flex: 0 0 100%;
        height: auto;
        margin-top: 28px;
        padding: .375rem;
        border-radius: 32px;
        box-shadow: 0 2px 6px 0 rgba(0, 0, 0, .15);
    }

    #mainnavigation > .navbar-nav {
        flex-direction: row;
        align-items: center;
    }

    #mainnavigation > .navbar-nav > .nav-item {
        position: relative;
        flex: 1 1 0;
        border-radius: 26px;
    }

    #mainnavigation > .navbar-nav > .nav-item + .nav-item::before {
        content: "";
        position: absolute;
        top: 50%;
        left: 0;
        height: 2rem;
        border-left: 1px solid var(--nav-divider);
        transform: translateY(-50%);
    }

    #mainnavigation > .navbar-nav > .nav-item > .nav-link {
        justify-content: center;
        padding: .625rem .25rem;
        color: #000;
        font-size: 1rem;
        text-transform: uppercase;
    }

    /* red: the opened item, otherwise the current section */
    #page-header:not(.mobilenav-open) #mainnavigation > .navbar-nav > .nav-item:has(> .nav-link.active),
    #mainnavigation > .navbar-nav > .nav-item.is-open {
        background: var(--nav-highlight);
    }

    #page-header:not(.mobilenav-open) #mainnavigation > .navbar-nav > .nav-item:has(> .nav-link.active) > .nav-link,
    #mainnavigation > .navbar-nav > .nav-item.is-open > .nav-link {
        color: var(--nav-highlight-text);
    }

    /* no divider next to the red item */
    #page-header:not(.mobilenav-open) #mainnavigation > .navbar-nav > .nav-item:has(> .nav-link.active)::before,
    #page-header:not(.mobilenav-open) #mainnavigation > .navbar-nav > .nav-item:has(> .nav-link.active) + .nav-item::before,
    #mainnavigation > .navbar-nav > .nav-item.is-open::before,
    #mainnavigation > .navbar-nav > .nav-item.is-open + .nav-item::before {
        display: none;
    }

    /* submenu */
    .mobilenav {
        order: 4;
        display: block;
        flex: 0 0 100%;
    }

    .mobilenav-panel {
        padding: 1.5rem .25rem 0;
        text-align: left;
        text-transform: none;
        font-weight: 400;
    }

    .mobilenav-list {
        margin: 0;
        padding: 0;
        list-style: none;
    }

    .mobilenav-panel > .mobilenav-list {
        display: grid;
        grid-template-columns: minmax(0, 1fr);
        gap: .25rem .75rem;
    }

    .mobilenav-panel--columns > .mobilenav-list {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .mobilenav-item-header {
        display: flex;
        align-items: center;
    }

    .mobilenav-link {
        display: flex;
        flex: 0 1 auto;
        align-items: center;
        gap: .625rem;
        min-width: 0;
        padding: .5rem 0;
        color: #000;
        font-size: 1rem;
        line-height: 1.4;
        text-decoration: none;
    }

    .mobilenav-link:hover,
    .mobilenav-link:focus-visible {
        color: var(--nav-highlight);
    }

    .mobilenav-item.active > .mobilenav-item-header > .mobilenav-link {
        color: var(--nav-highlight);
        font-weight: 700;
    }

    /* icon per page (second level) */
    .mobilenav-list[data-level="2"] > .mobilenav-item > .mobilenav-item-header > .mobilenav-link::before {
        content: "";
        flex: 0 0 16px;
        height: 16px;
        background-repeat: no-repeat;
        background-position: center;
        background-size: contain;
    }

    .mobilenav-link[data-page="13"]::before { background-image: url(../Icons/building.svg); }
    .mobilenav-link[data-page="14"]::before { background-image: url(../Icons/bag.svg); }
    .mobilenav-link[data-page="15"]::before { background-image: url(../Icons/graph.svg); }
    .mobilenav-link[data-page="16"]::before { background-image: url(../Icons/search.svg); }
    .mobilenav-link[data-page="17"]::before { background-image: url(../Icons/file.svg); }
    .mobilenav-link[data-page="18"]::before { background-image: url(../Icons/college.svg); }
    .mobilenav-link[data-page="19"]::before { background-image: url(../Icons/crown.svg); }
    .mobilenav-link[data-page="20"]::before { background-image: url(../Icons/album.svg); }
    .mobilenav-link[data-page="39"]::before { background-image: url(../Icons/house.svg); }
    .mobilenav-link[data-page="40"]::before { background-image: url(../Icons/circle.svg); }
    .mobilenav-link[data-page="41"]::before { background-image: url(../Icons/family.svg); }
    .mobilenav-link[data-page="42"]::before { background-image: url(../Icons/color.svg); }
    .mobilenav-link[data-page="43"]::before { background-image: url(../Icons/car.svg); }
    .mobilenav-link[data-page="44"]::before { background-image: url(../Icons/file.svg); }
    .mobilenav-link[data-page="45"]::before { background-image: url(../Icons/umbrella.svg); }
    .mobilenav-link[data-page="46"]::before { background-image: url(../Icons/info.svg); }

    /* + / – for the third level */
    .mobilenav-toggle {
        position: relative;
        flex: 0 0 auto;
        width: 1.25rem;
        height: 1.5rem;
        padding: 0;
        border: 0;
        background: transparent;
        color: var(--nav-highlight);
    }

    .mobilenav-toggle::before,
    .mobilenav-toggle::after {
        content: "";
        position: absolute;
        top: 50%;
        left: 50%;
        width: .5rem;
        height: .125rem;
        background: currentColor;
        transform: translate(-50%, -50%);
    }

    .mobilenav-toggle::after {
        transform: translate(-50%, -50%) rotate(90deg);
        transition: opacity .15s ease;
    }

    .mobilenav-toggle[aria-expanded="true"]::after {
        opacity: 0;
    }

    /* third level: bullet below the icon, wrapped lines aligned with the text */
    .mobilenav-sub {
        padding: 0 0 .25rem .25rem;
    }

    .mobilenav-sub .mobilenav-link {
        align-items: flex-start;
        padding: .25rem 0;
    }

    .mobilenav-sub .mobilenav-link::before {
        content: "•";
        flex: 0 0 auto;
    }

    .mobilenav-sub .mobilenav-link {
        gap: .5rem;
    }
}
