/* Header navigation (Pages/Shared/_Nav.cshtml, wwwroot/js/nav.js). Wide
   screens: the brand, the search box, Map, two tool dropdowns and the account menu in
   a row. Below 900px it all goes behind the Menu button as one list. */

.nav {
    position: relative;
    z-index: 1000;
    background: var(--dark);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    height: 4rem;
    display: flex;
    align-items: center;
}

.nav__inner {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    width: 100%;
}

.nav__brand-group {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    flex: none;
    margin-right: auto;
}

.nav__brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    color: #ffffff;
    font-weight: 700;
    font-size: 1.125rem;
    letter-spacing: -0.025em;
    white-space: nowrap;
}

.nav__logo-tile {
    width: 2rem;
    height: 2rem;
    border-radius: 0.25rem;
    background: var(--brand-red);
    display: flex;
    align-items: center;
    justify-content: center;
    flex: none;
}

/* As mastdata.com: the white mark in a red tile. */
.nav__logo-tile img {
    width: 28px;
    height: 28px;
    object-fit: contain;
}

.nav__beta {
    font-size: 0.6875rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em;
    color: #fff; border: 1px solid rgba(255, 255, 255, 0.55); border-radius: 999px;
    padding: 0.125rem 0.5rem; line-height: 1.4;
}
.nav__beta:hover { background: var(--brand-red); border-color: var(--brand-red); }

.nav__menu {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.nav__links {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

/* The search box, on every page (Pages/Search/Index.cshtml). */
.nav__search {
    display: flex;
    align-items: center;
    width: 16rem;
    min-width: 9rem;
    flex: 0 1 16rem;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: var(--radius-sm);
}

.nav__search:focus-within {
    background: #ffffff;
    border-color: #ffffff;
    box-shadow: 0 0 0 3px rgba(205, 35, 27, 0.35);
}

.nav__search input {
    flex: 1;
    min-width: 0;
    padding: 0.4375rem 0.625rem;
    border: 0;
    background: none;
    color: #ffffff;
    font: 0.875rem var(--font-sans);
    outline: none;
}

.nav__search input::placeholder { color: #9ca3af; }
.nav__search:focus-within input { color: var(--dark); }
.nav__search:focus-within input::placeholder { color: #6b7280; }

.nav__search button {
    display: flex;
    padding: 0.4375rem 0.625rem;
    border: 0;
    background: none;
    color: #d1d5db;
    cursor: pointer;
}

.nav__search:focus-within button { color: var(--brand-red); }

.nav__links a,
.nav__group-button,
.nav__link-button {
    color: #d1d5db;
    font-size: 0.875rem;
    font-weight: 500;
    background: none;
    border: none;
    cursor: pointer;
    font-family: inherit;
    white-space: nowrap;
}

.nav__links a:hover,
.nav__group-button:hover,
.nav__link-button:hover,
.nav__links a[aria-current="page"],
.nav__group-button.is-current {
    color: #ffffff;
}

.nav__links > a[aria-current="page"],
.nav__group-button.is-current {
    box-shadow: inset 0 -2px 0 var(--brand-red);
}

.nav__links .btn-primary { color: #ffffff; }

.nav__logout-form {
    display: inline;
}

/* Dropdowns */
.nav__group {
    position: relative;
}

.nav__group-button {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.5rem 0;
}

.nav__group-button::after {
    content: "";
    width: 0.375rem;
    height: 0.375rem;
    border-right: 1.5px solid currentColor;
    border-bottom: 1.5px solid currentColor;
    transform: translateY(-2px) rotate(45deg);
    transition: transform 0.15s;
}

.nav__group.is-open .nav__group-button::after {
    transform: translateY(1px) rotate(-135deg);
}

.nav__dropdown {
    display: none;
    position: absolute;
    top: calc(100% + 0.75rem);
    left: -0.75rem;
    min-width: 13rem;
    padding: 0.375rem;
    background: #ffffff;
    border-radius: var(--radius-md);
    box-shadow: 0 10px 30px rgba(13, 27, 42, 0.25);
}

.nav__dropdown--right {
    left: auto;
    right: -0.75rem;
}

.nav__group.is-open .nav__dropdown {
    display: block;
}

.nav__dropdown a,
.nav__dropdown .nav__link-button {
    display: block;
    width: 100%;
    padding: 0.5rem 0.75rem;
    border-radius: var(--radius-sm);
    color: #374151;
    font-size: 0.875rem;
    text-align: left;
    white-space: nowrap;
}

.nav__dropdown a:hover,
.nav__dropdown .nav__link-button:hover {
    background: #f3f4f6;
    color: #111827;
}

.nav__dropdown a[aria-current="page"] {
    color: var(--brand-red);
    font-weight: 600;
}

.nav__dropdown .nav__logout-form {
    display: block;
    border-top: 1px solid #e5e7eb;
    margin-top: 0.375rem;
    padding-top: 0.375rem;
}

.nav__account-name {
    display: inline-block;
    max-width: 12rem;
    overflow: hidden;
    text-overflow: ellipsis;
    vertical-align: bottom;
}

/* The Menu button, narrow screens only. */
.nav__toggle {
    display: none;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    border: 1px solid rgba(255, 255, 255, 0.25);
    border-radius: var(--radius-sm);
    background: none;
    color: #ffffff;
    font: 500 0.875rem var(--font-sans);
    cursor: pointer;
}

.nav__toggle-bars,
.nav__toggle-bars::before,
.nav__toggle-bars::after {
    display: block;
    width: 1rem;
    height: 2px;
    background: currentColor;
    border-radius: 1px;
}

.nav__toggle-bars {
    position: relative;
}

.nav__toggle-bars::before,
.nav__toggle-bars::after {
    content: "";
    position: absolute;
    left: 0;
}

.nav__toggle-bars::before { top: -5px; }
.nav__toggle-bars::after { top: 5px; }

@media (max-width: 899px) {
    .nav__toggle { display: inline-flex; }

    .nav__menu {
        display: none;
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        max-height: calc(100vh - 4rem);
        max-height: calc(100dvh - 4rem);
        overflow-y: auto;
        flex-direction: column;
        align-items: stretch;
        gap: 0;
        padding: 0.5rem 1rem 1rem;
        background: var(--dark);
        border-top: 1px solid rgba(255, 255, 255, 0.1);
        box-shadow: 0 12px 24px rgba(0, 0, 0, 0.3);
    }

    .nav.is-open .nav__menu { display: flex; }

    .nav__links {
        flex-direction: column;
        align-items: stretch;
        gap: 0;
    }

    .nav__search {
        width: auto;
        flex: none;
        margin: 0.5rem 0;
    }

    .nav__search input { padding: 0.625rem 0.75rem; font-size: 1rem; }

    .nav__links a,
    .nav__dropdown a,
    .nav__dropdown .nav__link-button {
        display: block;
        padding: 0.75rem 0.5rem;
        color: #d1d5db;
        font-size: 1rem;
        border-radius: var(--radius-sm);
    }

    .nav__links > a[aria-current="page"] { box-shadow: none; }

    .nav__links a:hover,
    .nav__dropdown a:hover,
    .nav__dropdown .nav__link-button:hover {
        background: rgba(255, 255, 255, 0.06);
        color: #ffffff;
    }

    .nav__dropdown a[aria-current="page"],
    .nav__links > a[aria-current="page"] {
        color: #ffffff;
        font-weight: 600;
        background: rgba(255, 255, 255, 0.08);
    }

    /* The groups are shown open, under a small heading. */
    .nav__group-button {
        display: block;
        width: 100%;
        margin-top: 0.75rem;
        padding: 0.5rem 0.5rem 0.25rem;
        border-top: 1px solid rgba(255, 255, 255, 0.1);
        font-size: 0.75rem;
        font-weight: 600;
        text-transform: uppercase;
        letter-spacing: 0.08em;
        color: #9ca3af;
        text-align: left;
        cursor: default;
        pointer-events: none;
    }

    .nav__group-button.is-current { box-shadow: none; color: #9ca3af; }
    .nav__group-button::after { display: none; }

    .nav__dropdown,
    .nav__group.is-open .nav__dropdown {
        display: block;
        position: static;
        min-width: 0;
        padding: 0;
        background: none;
        box-shadow: none;
    }

    .nav__account-name { max-width: none; }

    .nav__dropdown .nav__logout-form {
        border-top: 0;
        margin-top: 0;
        padding-top: 0;
    }

    .nav__links--signed-out .btn-primary {
        margin-top: 0.5rem;
        text-align: center;
        color: #ffffff;
    }
}

/* Very narrow phones: drop the word "Portal" before anything overlaps. */
@media (max-width: 379px) {
    .nav__brand > span:last-child { display: none; }
}

@media print {
    .nav__beta, .nav__toggle, .nav__search { display: none; }
}
