/* Mobile-only nav chrome (top fixed header + slide-out drawer + bottom tab bar).
   Loaded by jobs.html and talent.html; reusable across other module pages. */

@media only screen and (max-width: 767px) {

    /* ===================================
       Top header — fixed, collapsed
       =================================== */
    .header {
        position: fixed !important;
        top: 0;
        left: 0;
        right: 0;
        z-index: 1000;
        background: var(--white);
        box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    }

    .top-nav {
        border-bottom: 2px solid var(--primary-color);
        min-height: 56px;
    }

    .top-nav-wrapper {
        display: grid;
        grid-template-columns: auto 1fr auto auto;
        align-items: center;
        gap: 0.5rem;
        padding: 0.5rem 0;
        position: relative;
    }

    .mobile-menu-toggle {
        display: flex;
        align-items: center;
        justify-content: center;
        /* Sit above the .brand subtree so a decoration overhanging the button
           can never intercept the tap (the logo's pseudos steal clicks). */
        position: relative;
        z-index: 2;
        width: 40px;
        height: 40px;
        font-size: 1.25rem;
        color: var(--gray-700);
        background: transparent;
        border: 0;
        border-radius: 8px;
        transition: all 0.2s ease;
        cursor: pointer;
    }

    .mobile-menu-toggle:hover,
    .mobile-menu-toggle:active {
        background: var(--gray-100);
        color: var(--primary-color);
    }

    .brand {
        flex-shrink: 0;
    }

    .brand .logo-container {
        display: flex;
        align-items: center;
        gap: 0.5rem;
        padding: 0;
    }

    .brand .logo {
        width: 36px;
        height: 36px;
        animation: none;
    }

    .brand .logo img {
        width: 100%;
        height: 100%;
        object-fit: contain;
    }

    .brand .brand-text h1 {
        font-size: 1.1rem;
        line-height: 1;
        letter-spacing: 0.02em;
    }

    .brand .brand-text h1::after {
        display: none;
    }

    .brand .slogan {
        display: none;
    }

    /* Hide desktop-only header chrome */
    .search-container,
    .deliver-to,
    .user-account,
    .saved-jobs-container {
        display: none !important;
    }


    /* Messages icon survives on mobile */
    .messages-container {
        position: relative;
        display: flex;
        align-items: center;
        justify-content: center;
        width: 40px;
        height: 40px;
        font-size: 1.25rem;
        color: var(--gray-700);
        cursor: pointer;
        padding: 0;
        border-radius: 8px;
        transition: all 0.2s ease;
    }

    .messages-container:hover {
        background: var(--gray-100);
        color: var(--primary-color);
    }

    .message-count {
        position: absolute;
        top: 2px;
        right: 2px;
        font-size: 0.65rem;
        padding: 1px 4px;
        min-width: 16px;
        height: 16px;
        display: flex;
        align-items: center;
        justify-content: center;
        background: var(--primary-color);
        color: var(--white);
        border-radius: 10px;
        font-weight: 600;
    }

    .user-actions {
        display: flex;
        align-items: center;
        gap: 0.25rem;
    }

    /* ===================================
       Slide-out drawer + overlay
       =================================== */
    .mobile-menu-overlay {
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, 0.5);
        opacity: 0;
        visibility: hidden;
        transition: opacity 0.3s ease;
        z-index: 1998;
    }

    .mobile-menu-overlay.active {
        opacity: 1;
        visibility: visible;
    }

    .mobile-menu {
        position: fixed;
        top: 0;
        left: 0;
        width: 280px;
        max-width: 85vw;
        height: 100vh;
        background: var(--white);
        z-index: 1999;
        transform: translateX(-100%);
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        display: flex;
        flex-direction: column;
        box-shadow: 2px 0 20px rgba(0, 0, 0, 0.1);
    }

    .mobile-menu.active {
        transform: translateX(0);
    }

    /* ---------- Header: branded logo lockup (mirrors the homepage) ---------- */
    .mobile-menu-header {
        display: flex;
        justify-content: space-between;
        align-items: center;
        gap: 0.75rem;
        padding: 1rem 1rem 1.1rem;
        border-bottom: 1px solid var(--gray-200);
        background: linear-gradient(135deg, #f0fdf4 0%, var(--white) 65%);
    }

    .mobile-menu-logo {
        display: flex;
        align-items: center;
        gap: 0.6rem;
        text-decoration: none;
        min-width: 0;
    }

    .mobile-menu-logo-img {
        flex: 0 0 auto;
        width: 40px;
        height: 40px;
        display: grid;
        place-items: center;
    }

    .mobile-menu-logo-img img {
        width: 100%;
        height: 100%;
        object-fit: contain;
        filter: drop-shadow(0 2px 4px rgba(26, 137, 23, 0.18));
    }

    .mobile-menu-brand-text {
        display: flex;
        flex-direction: column;
        gap: 0.12rem;
        min-width: 0;
    }

    /* Reuse the homepage brand spans (.brand-v/.brand-m carry the green); we
       size it for the drawer and tame their heavy 3D shadow. */
    .mobile-menu-brand-name {
        font-family: var(--font-logo);
        font-size: 1.2rem;
        font-weight: 700;
        line-height: 1.05;
        white-space: nowrap;
    }

    .mobile-menu-brand-name .brand-v,
    .mobile-menu-brand-name .brand-m {
        text-shadow: 0 1px 1px rgba(20, 104, 18, 0.22);
    }

    .mobile-menu-header .slogan {
        margin: 0;
        font-size: 0.62rem;
        letter-spacing: 0.16em;
        opacity: 0.85;
    }

    /* Close — circular ghost button */
    .mobile-menu-close {
        flex: 0 0 auto;
        width: 38px;
        height: 38px;
        display: grid;
        place-items: center;
        font-size: 1.1rem;
        color: var(--gray-600);
        background: var(--white);
        border: 1px solid var(--gray-200);
        border-radius: 50%;
        cursor: pointer;
        transition: all 0.2s ease;
    }

    .mobile-menu-close:hover {
        background: var(--gray-100);
        color: var(--gray-900);
        border-color: var(--gray-300);
    }

    /* ---------- Signed-in user block (auth.js fills it: avatar + "Hello, [name]") ---------- */
    .mobile-menu-user {
        display: flex;
        align-items: center;
        gap: 0.75rem;
        padding: 0.85rem 1rem;
        border-bottom: 1px solid var(--gray-200);
        background: var(--gray-50);
    }

    .mobile-menu-user i {
        font-size: 2rem;
        color: var(--gray-400);
    }

    .mobile-menu-user-info h4 {
        font-size: 0.95rem;
        font-weight: 600;
        color: var(--gray-900);
        margin: 0;
    }

    .mobile-menu-user-info p {
        font-size: 0.8rem;
        color: var(--gray-600);
        margin: 0;
    }

    /* ---------- Nav ---------- */
    .mobile-menu-nav {
        flex: 1;
        overflow-y: auto;
        padding: 0.75rem 0.6rem 0.5rem;
        display: flex;
        flex-direction: column;
        gap: 0.15rem;
    }

    .mobile-menu-section {
        margin: 0.85rem 0 0.3rem;
        padding: 0 0.6rem;
        font-size: 0.68rem;
        font-weight: 700;
        text-transform: uppercase;
        letter-spacing: 0.08em;
        color: var(--gray-400);
    }

    .mobile-menu-section:first-child {
        margin-top: 0.1rem;
    }

    .mobile-menu-link {
        display: flex;
        align-items: center;
        gap: 0.75rem;
        padding: 0.6rem;
        border-radius: 12px;
        color: var(--gray-700);
        font-size: 0.95rem;
        font-weight: 500;
        text-decoration: none;
        transition: background 0.18s ease, color 0.18s ease;
    }

    .mobile-menu-link i {
        flex: 0 0 auto;
        width: 36px;
        height: 36px;
        display: grid;
        place-items: center;
        font-size: 1rem;
        color: var(--gray-500);
        background: var(--gray-100);
        border-radius: 10px;
        transition: background 0.18s ease, color 0.18s ease;
    }

    .mobile-menu-link:hover,
    .mobile-menu-link:focus-visible,
    .mobile-menu-link.is-active {
        background: var(--primary-tint);
        color: var(--primary-dark);
    }

    .mobile-menu-link:hover i,
    .mobile-menu-link:focus-visible i,
    .mobile-menu-link.is-active i {
        background: var(--primary-color);
        color: var(--white);
    }

    /* ---------- Footer ---------- */
    .mobile-menu-footer {
        /* Clear the fixed 60px bottom tab-bar + notch safe area so the Sign in /
           Sign out CTA isn't jammed against the very bottom of the screen. */
        padding: 1rem 1rem calc(1rem + 60px + env(safe-area-inset-bottom, 0px));
        border-top: 1px solid var(--gray-200);
        background: var(--gray-50);
        display: flex;
        flex-direction: column;
        gap: 0.5rem;
    }

    .mobile-menu-cta {
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 0.5rem;
        width: 100%;
        padding: 0.8rem;
        border-radius: 10px;
        font-weight: 600;
        font-size: 0.9rem;
        font-family: inherit;
        text-decoration: none;
        cursor: pointer;
        background: var(--primary-color);
        color: var(--white);
        border: 1.5px solid var(--primary-color);
        transition: all 0.2s ease;
    }

    .mobile-menu-cta:hover {
        background: var(--primary-dark);
        border-color: var(--primary-dark);
    }

    /* Honor the `hidden` attribute on auth-gated drawer items — the
       .mobile-menu-link / .mobile-menu-cta display rules above otherwise
       win over the UA [hidden] { display: none }, leaving auth-hidden
       items visible. applyAuthVisibility() toggles el.hidden as the single
       source of truth; this makes the CSS respect it. */
    [data-auth][hidden] {
        display: none !important;
    }

    .mobile-menu-logout {
        background: transparent;
        color: var(--gray-700);
        border-color: var(--gray-300);
    }

    .mobile-menu-logout:hover {
        background: var(--gray-100);
        color: var(--gray-900);
        border-color: var(--gray-400);
    }

    /* ===================================
       Bottom tab bar
       =================================== */
    .mobile-nav {
        display: flex;
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        background: var(--white);
        border-top: 1px solid var(--gray-200);
        height: 60px;
        padding: 0 0 env(safe-area-inset-bottom);
        z-index: 1000;
        box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.08);
    }

    .mobile-nav-item {
        flex: 1;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 2px;
        color: var(--gray-600);
        font-size: 0.7rem;
        padding: 8px 0;
        position: relative;
        transition: all 0.2s ease;
        text-decoration: none;
    }

    .mobile-nav-item i {
        font-size: 1.15rem;
        transition: transform 0.2s ease;
    }

    .mobile-nav-item.active {
        color: var(--primary-color);
    }

    .mobile-nav-item.active::before {
        content: '';
        position: absolute;
        top: 0;
        left: 50%;
        transform: translateX(-50%);
        width: 40px;
        height: 3px;
        background: var(--primary-color);
        border-radius: 0 0 3px 3px;
    }

    .mobile-nav-item:active i {
        transform: scale(0.9);
    }

    .mobile-message-badge {
        position: absolute;
        top: 4px;
        right: calc(50% - 22px);
        font-size: 0.6rem;
        font-weight: 700;
        background: var(--primary-color);
        color: var(--white);
        border-radius: 10px;
        padding: 1px 5px;
        min-width: 16px;
        height: 16px;
        line-height: 14px;
        text-align: center;
    }

    /* ===================================
       Page offsets so content clears fixed chrome
       =================================== */
    body {
        padding-top: 56px;
        padding-bottom: calc(60px + env(safe-area-inset-bottom));
    }

    /* Hero already has its own top padding (Iter5: 4rem). Keep that intact;
       the 56px body padding-top handles the fixed-header clearance. */
}

/* Tablet / desktop: ensure all mobile-only chrome is hidden. */
@media (min-width: 768px) {
    .mobile-menu-toggle,
    .mobile-menu,
    .mobile-menu-overlay,
    .mobile-nav {
        display: none !important;
    }
}
