/* Phone layout (P2.9): bottom tab bar on every page, and on the map a three-height bottom sheet
   (peek / half / full) in place of the right-hand sidebar. Only applies at 768px and below; the
   markup is injected by js/mobileTabs.js. Loaded after style.css / landing.css so it can override. */

.tabbar, .more-sheet, .sheet-handle { display: none; }

@media (max-width: 768px) {
    :root { --tabbar-height: 56px; }

    /* the tab bar (and its More menu) carries every link; the top bar keeps the logo and the map button */
    .nav-links li:not(:has(.nav-cta)) { display: none !important; }
    .site-nav .nav-links { margin-right: 0 !important; }

    /* ---- tab bar ---- */
    .tabbar {
        display: flex;
        position: fixed;
        left: 0; right: 0; bottom: 0;
        z-index: 2000;
        height: calc(var(--tabbar-height) + env(safe-area-inset-bottom, 0px));
        padding-bottom: env(safe-area-inset-bottom, 0px);
        background: rgba(15, 15, 15, 0.98);
        border-top: 1px solid #2a2a2a;
    }
    .tabbar a, .tabbar button {
        flex: 1;
        display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
        min-height: 44px;
        font: inherit; font-size: 11px;
        color: #a0a0a0;
        background: none; border: none; text-decoration: none; cursor: pointer;
    }
    .tabbar svg { width: 22px; height: 22px; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
    .tabbar [aria-current="page"], .tabbar [aria-expanded="true"] { color: #E9AA46; }

    body.has-tabbar { padding-bottom: calc(var(--tabbar-height) + env(safe-area-inset-bottom, 0px)); }
    body.has-tabbar .site-footer { margin-bottom: 0; }

    /* ---- "More" menu ---- */
    .more-sheet {
        display: block;
        position: fixed;
        left: 0; right: 0;
        bottom: calc(var(--tabbar-height) + env(safe-area-inset-bottom, 0px));
        z-index: 1999;
        max-height: 70vh; overflow-y: auto;
        padding: 8px 0;
        background: #141414;
        border-top: 2px solid #E9AA46;
        border-radius: 14px 14px 0 0;
        box-shadow: 0 -8px 30px rgba(0, 0, 0, 0.6);
    }
    .more-sheet[hidden] { display: none; }
    .more-sheet a, .more-sheet button {
        display: block; width: 100%; min-height: 48px; padding: 0 20px;
        font: inherit; font-size: 16px; line-height: 48px; text-align: left;
        color: #f0f0f0; background: none; border: none; text-decoration: none; cursor: pointer;
    }
    .more-sheet a:active, .more-sheet button:active { background: #1f1f1f; }
    .more-sheet hr { border: none; border-top: 1px solid #2a2a2a; margin: 4px 0; }

    /* ---- map: bottom sheet instead of the right sidebar ---- */
    body.map-page #sidebar {
        top: auto !important;
        left: 0; right: 0;
        bottom: calc(var(--tabbar-height) + env(safe-area-inset-bottom, 0px));
        width: 100%;
        max-width: none;
        height: 58vh !important;
        height: 58dvh !important;
        transform: none !important;
        visibility: visible !important;
        border-radius: 14px 14px 0 0;
        box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.6);
        transition: height 0.25s ease !important;
        z-index: 1500;
    }
    body.map-page #sidebar.collapsed { height: 48px !important; overflow: hidden; }
    body.map-page #sidebar.sheet-full {
        height: calc(100vh - var(--map-header-height, 56px) - var(--tabbar-height) - env(safe-area-inset-bottom, 0px)) !important;
        height: calc(100dvh - var(--map-header-height, 56px) - var(--tabbar-height) - env(safe-area-inset-bottom, 0px)) !important;
    }

    .sheet-handle {
        display: block;
        position: sticky; top: 0; z-index: 5;
        width: 100%; height: 48px; padding: 0;
        background: rgba(20, 20, 20, 0.98); border: none; cursor: pointer;
    }
    .sheet-handle::before {
        content: ""; display: block; width: 44px; height: 5px; margin: 0 auto; border-radius: 3px; background: #666;
    }
    .sheet-handle span { display: block; margin-top: 4px; font-size: 12px; color: #a0a0a0; }

    /* the handle replaces the hamburger and the close button */
    #sidebar-open-btn, #sidebar-toggle { display: none !important; }

    /* the floating buttons fold into the More menu */
    body.map-page #discord-link, body.map-page .discord-link,
    body.map-page #donate-btn, body.map-page .donate-btn,
    body.map-page .donate-text, body.map-page #settings-btn { display: none !important; }

    /* zoom: + and - buttons only; the slider is for a mouse */
    body.map-page #custom-zoom { right: 10px !important; top: auto !important; bottom: calc(var(--tabbar-height) + 60px) !important; transform: none !important; }
    body.map-page #custom-zoom .zoom-slider-container { display: none; }
    body.map-page #custom-zoom .zoom-btn { width: 44px; height: 44px; }
    body.map-page #custom-zoom .zoom-icon { width: 100%; height: 100%; object-fit: contain; }

    body.map-page .coords-display { bottom: calc(var(--tabbar-height) + 60px) !important; left: 8px; right: auto !important; }
    body.map-page .legend { display: none !important; } /* the legend lives in the sheet on phones */

    /* the feedback strip and toasts sit above the tab bar */
    body.map-page .general-feedback-box { bottom: calc(var(--tabbar-height) + 56px); }
}
