/* Mobile slide-in menu (three-bar button) ------------------------------------
   Desktop: the drawer is not rendered. Mobile (<= 860px): the top nav is
   replaced by a left drawer with dropdown groups (Verification, Education...). */

.mdrawer, .mdrawer-backdrop { display: none; }

@media (max-width: 860px) {
    /* header: three-bar button on the LEFT of the brand */
    .site-header .nav-wrap { justify-content: flex-start; gap: 12px; }
    .site-header .menu-toggle { order: -1; flex: none; }
    .site-header .menu-toggle span { width: 20px; }
    .site-header .main-nav, .site-header .main-nav.is-open { display: none !important; }
    .site-header .menu-toggle[aria-expanded="true"] span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
    .site-header .menu-toggle[aria-expanded="true"] span:nth-child(2) { opacity: 0; }
    .site-header .menu-toggle[aria-expanded="true"] span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }
    .site-header .menu-toggle span { transition: transform .22s ease, opacity .15s ease; }

    /* the drawer already carries the admin section links */
    .app-sidebar { display: none !important; }

    body.drawer-open { overflow: hidden; }

    .mdrawer-backdrop {
        display: block; position: fixed; inset: 0; z-index: 90;
        background: rgba(12, 20, 34, .5); opacity: 0; visibility: hidden;
        transition: opacity .25s ease, visibility .25s;
    }
    .mdrawer-backdrop.is-open { opacity: 1; visibility: visible; }

    .mdrawer {
        display: flex; flex-direction: column; position: fixed; top: 0; bottom: 0; left: 0; z-index: 100;
        width: min(86vw, 340px); background: var(--c-surface); color: var(--c-text);
        box-shadow: 8px 0 32px rgba(12, 20, 34, .22);
        transform: translateX(-102%); visibility: hidden;
        transition: transform .28s cubic-bezier(.2, .8, .2, 1), visibility 0s linear .28s;
        overscroll-behavior: contain;
    }
    .mdrawer.is-open { transform: none; visibility: visible; transition-delay: 0s; }

    .mdrawer__head {
        display: flex; align-items: center; justify-content: space-between; gap: 12px; flex: none;
        padding: 14px 16px; border-bottom: 1px solid var(--c-line);
    }
    .mdrawer__brand { display: inline-flex; align-items: center; gap: 9px; min-width: 0; font: 700 17px/1.1 var(--f-display); color: var(--c-text); text-decoration: none; }
    .mdrawer__brand img { width: 30px; height: 30px; object-fit: contain; flex: none; }
    .mdrawer__brand span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
    .mdrawer__close {
        flex: none; width: 40px; height: 40px; border: 1px solid var(--c-line-strong); border-radius: var(--r-md);
        background: var(--c-surface); color: var(--c-text); font-size: 26px; line-height: 1; cursor: pointer;
    }

    .mdrawer__scroll { flex: 1 1 auto; overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 12px 12px 16px; }

    .mdrawer__user {
        display: flex; align-items: center; gap: 12px; margin-bottom: 12px; padding: 12px;
        border-radius: var(--r-lg); background: var(--c-brand-softer); border: 1px solid var(--c-brand-soft);
    }
    .mdrawer__avatar { flex: none; display: grid; place-items: center; width: 40px; height: 40px; border-radius: 50%; background: var(--c-brand); color: #fff; font-weight: 700; }
    .mdrawer__user-text { display: grid; min-width: 0; flex: 1; }
    .mdrawer__user-text b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14.5px; }
    .mdrawer__user-text small { color: var(--c-muted); font-size: 12.5px; }
    .mdrawer__fund { flex: none; padding: 8px 12px; border-radius: 999px; background: var(--c-brand); color: #fff; font-size: 12.5px; font-weight: 600; text-decoration: none; }

    .mdrawer__nav { display: flex; flex-direction: column; gap: 2px; }
    .mdrawer__nav a, .mdrawer__group-toggle {
        display: flex; align-items: center; gap: 12px; width: 100%; min-height: 46px; padding: 10px 12px;
        border: 0; border-radius: var(--r-md); background: transparent; color: var(--c-text);
        font: 500 15px/1.25 var(--f-body); text-align: left; text-decoration: none; cursor: pointer;
    }
    .mdrawer__nav a:active, .mdrawer__group-toggle:active { background: var(--c-sunken); }
    .mdrawer__nav .icon { flex: none; width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; color: var(--c-muted); }
    .mdrawer__nav a.is-active { background: var(--c-brand-soft); color: var(--c-brand-deep); font-weight: 600; }
    .mdrawer__nav a.is-active .icon { color: var(--c-brand); }

    .mdrawer__group-toggle span { flex: 1; font-weight: 600; }
    .mdrawer__group.has-active > .mdrawer__group-toggle { color: var(--c-brand-deep); }
    .mdrawer__count { flex: none; min-width: 22px; padding: 2px 7px; border-radius: 999px; background: var(--c-sunken); color: var(--c-muted); font: 600 11.5px/1.4 var(--f-body); text-align: center; font-style: normal; }
    .mdrawer__chevron {
        flex: none; width: 9px; height: 9px; margin-right: 4px; border-right: 2px solid var(--c-faint); border-bottom: 2px solid var(--c-faint);
        transform: rotate(45deg); transition: transform .22s ease;
    }
    .mdrawer__group.is-open > .mdrawer__group-toggle .mdrawer__chevron { transform: rotate(-135deg) translate(-2px, -2px); }

    /* dropdown panel: animated height without JS measuring */
    .mdrawer__sub { display: grid; grid-template-rows: 0fr; transition: grid-template-rows .24s ease; }
    .mdrawer__group.is-open > .mdrawer__sub { grid-template-rows: 1fr; }
    .mdrawer__sub-inner { overflow: hidden; min-height: 0; display: flex; flex-direction: column; gap: 1px; margin-left: 21px; padding-left: 10px; border-left: 2px solid var(--c-line); }
    .mdrawer__group:not(.is-open) .mdrawer__sub-inner a { visibility: hidden; }
    .mdrawer__sub-inner a { min-height: 42px; padding: 9px 12px; font-size: 14.5px; color: var(--c-muted); }
    .mdrawer__sub-inner a .icon { width: 18px; height: 18px; }
    .mdrawer__sub-inner a.is-active { color: var(--c-brand-deep); }

    .mdrawer__rule { width: 100%; height: 1px; margin: 8px 0; border: 0; background: var(--c-line); }

    .mdrawer__foot { flex: none; padding: 12px 16px calc(12px + env(safe-area-inset-bottom)); border-top: 1px solid var(--c-line); }
    .mdrawer__foot form { margin: 0; }
    .mdrawer__logout {
        display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; min-height: 46px;
        border: 1px solid var(--c-line-strong); border-radius: var(--r-md); background: var(--c-surface); color: var(--c-danger);
        font: 600 14.5px/1 var(--f-body); cursor: pointer;
    }
    .mdrawer__logout .icon { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
    .mdrawer__signup { width: 100%; justify-content: center; }
}

@media (prefers-reduced-motion: reduce) {
    .mdrawer, .mdrawer-backdrop, .mdrawer__sub, .mdrawer__chevron, .site-header .menu-toggle span { transition: none !important; }
}


/* ---------- Fixed bottom tab bar (signed-in customer pages, mobile) ---------- */
.mbnav { display: none; }

@media (max-width: 860px) {
    body.has-mbnav { padding-bottom: calc(72px + env(safe-area-inset-bottom)); }

    .mbnav {
        display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 80;
        align-items: stretch; justify-content: space-around;
        padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
        background: var(--c-surface, #fff); border-top: 1px solid var(--c-line, #d6dce5);
        box-shadow: 0 -6px 18px rgba(12, 20, 34, .08);
    }
    .mbnav a {
        flex: 1 1 0; min-width: 0; min-height: 52px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
        border-radius: 12px; color: var(--c-muted, #555d69); text-decoration: none;
        font: 600 11.5px/1 var(--f-body, 'Public Sans', system-ui, sans-serif);
        -webkit-tap-highlight-color: transparent;
    }
    .mbnav a .icon { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
    .mbnav a.is-active { color: var(--c-brand, #0b4fb5); }
    .mbnav a.is-active .icon { stroke-width: 2.1; }
    .mbnav a:active { background: var(--c-brand-softer, #eef3fa); }
    body.drawer-open .mbnav { visibility: hidden; }

    /* keep the live-support launcher clear of the tab bar */
    body.has-mbnav .support-widget { bottom: calc(80px + env(safe-area-inset-bottom)); }

    /* responsive safeguards for customer pages */
    body.has-mbnav .table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
    body.has-mbnav img, body.has-mbnav video { max-width: 100%; height: auto; }
}

/* Pages without the large site footer no longer need the space reserved for it */
body.no-site-footer .support-widget { bottom: 20px; }
@media (max-width: 860px) {
    body.no-site-footer .support-widget { bottom: 14px; }
}

@media print {
    .mbnav { display: none !important; }
    body.has-mbnav { padding-bottom: 0; }
}
