/* ============================================================
   Glommer visual system – mobile navigation
   Hamburger menu and mobile overrides.
   ============================================================ */

.NavToggle {
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0;
}

/* The checkbox is a pixel of nothing, so focusing it showed a ring around a
   pixel of nothing - somebody tabbing had no idea they were on the menu. The
   ring goes on the bars they can actually see instead. */
.NavToggle:focus-visible + .NavAlertDot + .NavHamburger,
.NavToggle:focus-visible + .NavHamburger {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.NavHamburger {
    display: none;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 0.5rem;
    width: 2.25rem;
    cursor: pointer;
}

.NavHamburgerBar {
    width: 1.35rem;
    height: 2px;
    border-radius: var(--radius-pill);
    background-color: var(--ink);
    transition:
        transform 0.2s ease,
        opacity 0.2s ease;
}

.NavToggle:checked ~ .NavHamburger .NavHamburgerBar:nth-child(1) {
    transform: translateY(calc(0.5rem + 2px)) rotate(45deg);
}

.NavToggle:checked ~ .NavHamburger .NavHamburgerBar:nth-child(2) {
    opacity: 0;
}

.NavToggle:checked ~ .NavHamburger .NavHamburgerBar:nth-child(3) {
    transform: translateY(calc(-0.5rem - 2px)) rotate(-45deg);
}

@media (max-width: 48rem), (max-height: 32rem) {
    .NavHamburger {
        display: flex;
        position: fixed;
        top: 0;
        inset-inline-end: 1rem;
        height: var(--nav-height);
        z-index: 30;
    }

    .MainNavigation {
        display: block !important;
        height: var(--nav-height);
        overflow: hidden;
        padding-block: 0;
        /* The rows carry this themselves once the nav is a list of them, so
           that a row reaches both edges and its own padding is the only thing
           holding the words off them. */
        padding-inline: 0;
    }

    .MainNavigation:has(.NavToggle:checked) {
        pointer-events: none;
    }

    .MainNavigation:has(.NavToggle:checked) a,
    .MainNavigation:has(.NavToggle:checked) .LogoutButton,
    .MainNavigation:has(.NavToggle:checked) .NavHamburger {
        pointer-events: auto;
    }

    .MainNavigation:has(.NavToggle:checked) {
        height: 100dvh;
        overflow-y: auto;
        padding-bottom: 0.5rem;
    }

    .MainNavigation .NavDropdown,
    .MainNavigation .NavDropdownMenu,
    .MainNavigation .NavAccount,
    .MainNavigation .NotificationsNavLink,
    .MainNavigation .LogoutForm,
    .MainNavigation > .MainNavigationSiteLinks,
    .MainNavigation > .MainNavigationAccountLinks {
        display: contents !important;
    }

    .MainNavigation a,
    .MainNavigation .LogoutButton {
        display: block;
        width: 100%;
        box-sizing: border-box;
        margin: 0;
        padding: 0.5rem var(--content-padding-inline) !important;
        border: none !important;
        /* Square, because a row that reaches both edges has no corners to
           round without cutting the screen's own. */
        border-radius: 0 !important;
        background: none !important;
        opacity: 1 !important;
        color: var(--ink) !important;
        font-weight: 500;
        font-size: 1rem;
        text-align: start;
    }

    .MainNavigation a:hover,
    .MainNavigation .LogoutButton:hover {
        background-color: var(--surface-2) !important;
    }

    .MainNavigation .NavBrand {
        display: flex;
        align-items: center;
        min-height: var(--nav-height);
    }

    .NotificationDropdown {
        display: none !important;
    }

    /* The site's name loses its mark here: the menu is closed, so one mark
       beside the hamburger stands for everything inside it instead. */
    .MainNavigation .NavBrand .MessageDot {
        display: none !important;
    }

    /* Size and colour come from the shared rule in layout.css - only where it
       sits is a mobile concern. */
    .NavAlertDot.Active {
        display: block;
        position: fixed;
        top: calc(var(--nav-height) / 2 - 0.25rem);
        inset-inline-end: 3.25rem;
        z-index: 30;
    }

    /* Once the menu is open, the marks inside it are the answer to which of
       them it was - so the one beside the hamburger stands down. */
    .MainNavigation:has(.NavToggle:checked) .NavAlertDot {
        display: none;
    }

    /* Both marks ride beside their label in the open menu. The flattening
       above (display: contents) leaves them as siblings of the link they
       belong to, so positioning them against it is no longer possible. */
    .MainNavigation .NotificationDot,
    .MainNavigation .MessageDot {
        position: static;
        margin: 0 0 0 0.4rem;
        vertical-align: 0.08rem;
        align-self: center;
        flex: 0 0 auto;
    }

    .MainNavigation .NotificationDot.Active,
    .MainNavigation .MessageDot.Active {
        display: inline-block;
    }
}
