/* ============================================
   MOBILE NAV — full-screen modal (Buro brand)
   Full-width, large card-style nav buttons
   ============================================ */

:root {
    --mobile-nav-bg-deep: #072b2e;
    --mobile-nav-bg-mid: #0c3e42;
    --mobile-nav-text: #f3fcf6;
    --mobile-nav-text-muted: rgba(243, 252, 246, 0.7);
    --mobile-nav-master: #5ab774;
    --mobile-nav-accent: #fef3a4;
    --mobile-nav-off: #e8fcec;
    --mobile-nav-line: rgba(255, 255, 255, 0.12);
    --mobile-nav-tap: rgba(90, 183, 116, 0.22);
    --mobile-nav-tap-strong: rgba(90, 183, 116, 0.35);
    --mobile-nav-card-bg: rgba(255, 255, 255, 0.07);
    --mobile-nav-card-border: rgba(255, 255, 255, 0.12);
    --mobile-nav-card-shadow: 0 8px 32px rgba(0, 0, 0, 0.28);
}

/* Toggle (narrow screens) */
.mobile-menu-toggle {
    display: none;
    background: none;
    border: none;
    color: #333;
    cursor: pointer;
    padding: 8px;
    border-radius: 8px;
    transition: background 0.2s ease, color 0.2s ease;
}

.mobile-menu-toggle:hover {
    background: rgba(0, 0, 0, 0.06);
    color: #000;
}

.header-nav-source-hidden {
    display: none !important;
}

.header-dropdown {
    position: relative;
}

button.header-menu-trigger,
button.header-account-trigger,
button.header-menu-action {
    -webkit-appearance: none;
    appearance: none;
    font: inherit;
}

.header-menu-trigger {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    border: none;
    background: none;
    cursor: pointer;
}

.header-menu-caret {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    transition: transform 0.18s ease;
    opacity: 0.82;
}

.header-dropdown:is(:hover, :focus-within, .is-open) .header-menu-caret {
    transform: rotate(180deg);
}

.header-menu-panel {
    position: absolute;
    top: calc(100% + 10px);
    right: 0;
    z-index: 1400;
    min-width: 220px;
    max-width: min(280px, calc(100vw - 24px));
    padding: 10px;
    border-radius: 18px;
    border: 1px solid var(--qb-header-control-border, rgba(15, 23, 42, 0.14));
    background: var(--qb-header-bg, #ffffff);
    box-shadow: 0 18px 50px rgba(15, 23, 42, 0.18);
    display: none;
    flex-direction: column;
    gap: 6px;
}

/* Bridge the gap between trigger and panel so the menu stays open while moving the pointer */
.header-menu-panel::before {
    content: '';
    position: absolute;
    left: 0;
    right: 0;
    bottom: 100%;
    height: 12px;
}

.header-dropdown:is(:hover, :focus-within, .is-open) .header-menu-panel {
    display: flex;
}

.header-more-menu .header-menu-panel {
    left: 0;
    right: auto;
}

.header-menu-link,
.header-menu-action {
    display: flex;
    align-items: center;
    width: 100%;
    min-height: 42px;
    padding: 10px 12px;
    border-radius: 12px;
    border: none;
    background: transparent;
    color: var(--qb-header-text, #111827);
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    text-align: left;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.header-menu-link:hover,
.header-menu-action:hover,
.header-menu-link.active {
    background: var(--qb-header-control-bg, rgba(15, 23, 42, 0.08));
}

.header-menu-link.active {
    font-weight: 600;
}

.header-menu-divider {
    height: 1px;
    margin: 4px 2px;
    background: var(--qb-header-control-border, rgba(15, 23, 42, 0.12));
}

.header-menu-logout {
    color: #FF8A44;
}

.header-menu-logout:hover {
    background: rgba(255, 138, 68, 0.14);
}

.header-menu-logout.is-confirming {
    background: rgba(255, 138, 68, 0.18);
    color: #FF8A44;
}

.header-account-menu {
    display: none;
    align-items: center;
}

.header-account-trigger {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 6px 8px 6px 6px;
    border: 1px solid var(--qb-header-control-border, rgba(15, 23, 42, 0.14));
    border-radius: 999px;
    background: var(--qb-header-control-bg, rgba(15, 23, 42, 0.06));
    color: var(--qb-header-text, #111827);
    cursor: pointer;
    transition: background 0.15s ease, border-color 0.15s ease, transform 0.15s ease;
}

.header-account-trigger:hover,
.header-account-trigger.is-active,
.header-dropdown:is(:hover, :focus-within, .is-open) .header-account-trigger {
    background: var(--qb-header-control-bg-hover, rgba(15, 23, 42, 0.1));
    border-color: var(--qb-header-control-border, rgba(15, 23, 42, 0.22));
}

.header-account-trigger:active {
    transform: scale(0.98);
}

.header-account-avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 999px;
    background: var(--qb-primary, #111827);
    color: #ffffff;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.header-account-label {
    max-width: 120px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 13px;
    font-weight: 600;
}

.header-account-panel {
    right: 0;
    left: auto;
    min-width: 240px;
}

@media (max-width: 1280px) {
    .header-account-label {
        display: none;
    }

    .header-account-trigger {
        padding-right: 6px;
    }
}

/* Backdrop — full viewport, brand gradient */
.mobile-nav-overlay {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    min-height: 100dvh;
    z-index: 12000;
    background: linear-gradient(
        165deg,
        var(--buro-brand-dark-green, var(--mobile-nav-bg-deep)) 0%,
        var(--mobile-nav-bg-mid) 42%,
        var(--buro-brand-dark-green, var(--mobile-nav-bg-deep)) 100%
    );
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.38s cubic-bezier(0.22, 1, 0.36, 1),
        visibility 0.38s cubic-bezier(0.22, 1, 0.36, 1);
    pointer-events: none;
}

.mobile-nav-overlay.active {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

/* Full-screen panel — full-width content; pointer-events trick for overlay close */
.mobile-nav-menu {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    min-height: 100dvh;
    max-width: none;
    z-index: 12001;
    background: transparent;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    box-shadow: none;
    padding-left: max(16px, env(safe-area-inset-left));
    padding-right: max(16px, env(safe-area-inset-right));
    padding-bottom: max(20px, env(safe-area-inset-bottom));
    opacity: 0;
    visibility: hidden;
    transform: translateY(10px);
    transition: opacity 0.38s cubic-bezier(0.22, 1, 0.36, 1),
        visibility 0.38s cubic-bezier(0.22, 1, 0.36, 1),
        transform 0.38s cubic-bezier(0.22, 1, 0.36, 1);
    pointer-events: none;
}

.mobile-nav-menu.active {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
    pointer-events: none;
}

.mobile-nav-menu * {
    pointer-events: auto;
}

/* Top bar — full width */
.mobile-nav-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
    width: 100%;
    max-width: none;
    margin: 0;
    padding-top: max(20px, env(safe-area-inset-top));
    padding-bottom: 22px;
    border-bottom: 1px solid var(--mobile-nav-line);
    margin-bottom: 16px;
}

.mobile-nav-title {
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.22em;
    text-transform: uppercase;
    color: var(--mobile-nav-accent);
    margin: 0;
}

.mobile-nav-close {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 52px;
    height: 52px;
    background: var(--mobile-nav-card-bg);
    border: 1px solid rgba(254, 243, 164, 0.4);
    color: var(--mobile-nav-accent);
    cursor: pointer;
    border-radius: 16px;
    box-shadow: var(--mobile-nav-card-shadow);
    transition: background 0.2s ease, border-color 0.2s ease, transform 0.15s ease;
}

.mobile-nav-close:hover {
    background: var(--mobile-nav-tap-strong);
    border-color: rgba(254, 243, 164, 0.6);
    color: #fffef0;
}

.mobile-nav-close:active {
    transform: scale(0.96);
}

.mobile-nav-close svg {
    width: 26px;
    height: 26px;
}

/* List — full width, spaced card stack */
.mobile-nav-list {
    flex: 1;
    min-height: 0;
    width: 100%;
    max-width: none;
    margin: 0;
    padding: 4px 0 0;
    list-style: none;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.mobile-nav-item {
    margin-bottom: 0;
}

/* Large card buttons — full width */
.mobile-nav-link {
    display: flex;
    align-items: center;
    width: 100%;
    box-sizing: border-box;
    min-height: 68px;
    padding: 20px 22px;
    color: var(--mobile-nav-text);
    text-decoration: none;
    font-size: 1.2rem;
    font-weight: 600;
    letter-spacing: -0.02em;
    line-height: 1.25;
    gap: 18px;
    border-radius: 20px;
    background: var(--mobile-nav-card-bg);
    border: 1px solid var(--mobile-nav-card-border);
    box-shadow: var(--mobile-nav-card-shadow);
    transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease,
        transform 0.15s ease, box-shadow 0.2s ease;
}

.mobile-nav-link:hover {
    background: var(--mobile-nav-tap);
    border-color: rgba(90, 183, 116, 0.45);
    color: #fff;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.35);
}

.mobile-nav-link:active {
    background: var(--mobile-nav-tap-strong);
    transform: scale(0.99);
}

.mobile-nav-link.active {
    background: rgba(232, 252, 236, 0.16);
    color: var(--mobile-nav-off);
    border: 1px solid rgba(90, 183, 116, 0.55);
    border-left: 5px solid var(--mobile-nav-master);
    padding-left: 18px;
    font-weight: 700;
    box-shadow:
        0 0 0 1px rgba(254, 243, 164, 0.18),
        0 12px 40px rgba(0, 0, 0, 0.32);
}

.mobile-nav-link svg {
    flex-shrink: 0;
    width: 28px;
    height: 28px;
    opacity: 0.95;
    color: var(--mobile-nav-master);
}

.mobile-nav-link:hover svg {
    color: var(--mobile-nav-accent);
    opacity: 1;
}

.mobile-nav-link.active svg {
    color: var(--mobile-nav-accent);
}

/* Accent bar — full width feel, slightly wider */
.mobile-nav-menu.active::after {
    content: '';
    flex-shrink: 0;
    display: block;
    width: min(120px, 40%);
    height: 4px;
    margin: 24px auto 0;
    border-radius: 999px;
    background: linear-gradient(
        90deg,
        var(--buro-brand-main-green, var(--mobile-nav-master)),
        var(--buro-brand-accent, var(--mobile-nav-accent))
    );
    opacity: 0.95;
}

@media (prefers-reduced-motion: reduce) {
    .mobile-nav-overlay,
    .mobile-nav-menu {
        transition-duration: 0.01ms;
    }

    .mobile-nav-menu {
        transform: none;
    }

    .mobile-nav-link:active {
        transform: none;
    }
}

@media (max-width: 1024px) {
    /* Hamburger + Sign in: logo left, actions + icon flush right (icon rightmost) */
    .header-container {
        justify-content: flex-start;
        align-items: center;
    }

    .header-container .logo {
        order: 1;
        margin-right: auto;
        flex-shrink: 0;
    }

    .header-container .navigation {
        display: none !important;
    }

    .header-container .header-cta {
        order: 5;
        margin-left: 0;
    }

    .mobile-menu-toggle {
        display: block;
        order: 10;
        margin-left: 0;
        flex-shrink: 0;
    }

    /* Keep Profile / Log out only inside the hamburger modal on small screens */
    .header-cta > .header-profile-link,
    .header-cta > .logout-button {
        display: none !important;
    }

    .header-cta {
        gap: 10px;
    }

    .header-account-label {
        display: none;
    }

    .header-account-trigger {
        padding-right: 6px;
    }
}

/* Log out as a full-width card row (button, not link) */
button.mobile-nav-link {
    -webkit-appearance: none;
    appearance: none;
    font: inherit;
    text-align: left;
    cursor: pointer;
    border-style: solid;
}

.mobile-nav-logout-btn {
    color: rgba(254, 202, 202, 0.95);
    border-color: rgba(248, 113, 113, 0.45) !important;
    background: rgba(220, 38, 38, 0.18);
}

.mobile-nav-logout-btn:hover {
    background: rgba(220, 38, 38, 0.28);
    border-color: rgba(252, 165, 165, 0.55) !important;
    color: #fff;
}

.mobile-nav-logout-btn.is-confirming {
    background: rgba(255, 138, 68, 0.22);
    border-color: rgba(255, 138, 68, 0.5) !important;
    color: #fff3eb;
}

.mobile-nav-logout-btn svg {
    color: rgba(252, 165, 165, 0.95);
}

.mobile-nav-logout-btn.is-confirming svg {
    color: #FFB180;
}

/* Slightly tighter only on very narrow screens — still large targets */
@media (max-width: 380px) {
    .header-account-avatar {
        width: 30px;
        height: 30px;
    }

    .mobile-nav-link {
        min-height: 62px;
        padding: 18px 18px;
        font-size: 1.1rem;
        border-radius: 18px;
        gap: 14px;
    }

    .mobile-nav-link svg {
        width: 26px;
        height: 26px;
    }

    .mobile-nav-list {
        gap: 10px;
    }
}
