/*
 * BattleWarsMu — phone and tablet layout. Loaded last.
 * Tablet: up to 992 px (sidebars go under the content). Phone: up to 640 px.
 */

/* ---------- Close button of the UserCP drawer (only shown when it is a drawer) ---------- */
.bw-ucp-close { display: none; }

@media (max-width: 1100px) {
    /* Main menu: a compact grid instead of a tall list */
    #navbar .navbar-inner .menu {
        display: none;
        grid-template-columns: repeat(3, 1fr);
        gap: 6px; padding: 10px 12px 12px !important;
        max-height: calc(100vh - 56px); overflow-y: auto;
    }
    #navbar.is-open .navbar-inner .menu { display: grid !important; }
    #navbar .navbar-inner .menu li { width: auto !important; min-width: 0; }
    #navbar .navbar-inner .menu a {
        height: 42px !important; padding: 0 10px !important; justify-content: center !important; text-align: center;
        font-size: 11px !important; letter-spacing: .1em !important; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
        border: 1px solid rgba(67, 142, 200,.14) !important; border-radius: 5px;
        background: rgba(255,255,255,.03);
    }
    #navbar .navbar-inner .menu li.active a { color: #14100a !important; background: linear-gradient(180deg, #83bde9, #4087be); border-color: #438ec8 !important; }
    #navbar .navbar-inner .menu a::after { display: none !important; }
    /* dim the page under an open menu; a tap on it closes the menu (bw-app.js) */
    html.bw-nav-open body::before { content: ""; position: fixed; inset: 56px 0 0 0; z-index: 65; background: rgba(2, 6, 12, .62); }
}

@media (max-width: 992px) {
    /* UserCP drawer: leaves a strip of the page visible, has its own close button */
    body .container_web .sidebar .widget.bw-ucp-panel {
        width: min(340px, calc(100vw - 44px)) !important;
        max-height: calc(100vh - 56px) !important; max-height: calc(100dvh - 56px) !important;
        padding: 14px 12px 16px !important; border-radius: 0 0 0 10px;
        overscroll-behavior: contain;
    }
    .bw-ucp-panel .lk-title { position: relative; }
    .bw-ucp-close {
        display: inline-flex; align-items: center; justify-content: center;
        position: absolute; top: -4px; right: -2px; width: 34px; height: 34px;
        color: #438ec8; font-size: 15px; cursor: pointer;
        background: rgba(255,255,255,.04); border: 1px solid rgba(67, 142, 200,.3); border-radius: 50%;
    }
    .bw-ucp-close:hover { color: #d1e4f2; border-color: rgba(67, 142, 200,.6); }
    /* bigger touch targets in the drawer */
    .bw-ucpnav-head { padding: 11px 12px; }
    .bw-ucpnav-link { padding: 10px 9px; font-size: 12.5px; }
    /* no page scrolling behind an open drawer or menu */
    html.bw-ucp-open, html.bw-ucp-open body, html.bw-nav-open, html.bw-nav-open body { overflow: hidden !important; }

    /* Content: less empty space around the page body */
    .content-wrapper > .bw-news-shell { padding: 16px 14px 0 !important; }
}

@media (max-width: 640px) {
    .content-wrapper { padding-left: 14px !important; padding-right: 14px !important; }
    /* thinner side frame so the content keeps its width */
    .content-wrapper::before { border-width: 66px 12px 50px !important; border-image-width: 66px 12px 50px !important; }
    .content-wrapper > .bw-news-shell { padding: 12px 4px 0 !important; }
    #navbar .navbar-inner .menu { grid-template-columns: repeat(2, 1fr); }
    #navbar .navbar-inner { padding: 0 10px !important; }
    /* Panel button: icon + short label, fits next to the bell */
    #navbar .navbar-ucp { padding: 0 10px !important; letter-spacing: .08em !important; }

    /* Sidebar widgets under the content: full width on a phone */
    .container_web > .sidebar > * { flex-basis: min(100%, 360px) !important; width: min(100%, 360px) !important; }
}

/* ---------- Page fixes for phones ---------- */
@media (max-width: 640px) {
    /* Rankings: the class picture and location columns are left out (the class is under the name) */
    .rk-table:has(.col-class) tr > td:nth-child(2),
    .rk-table:has(.col-class) tr > td:last-child { display: none; }
    .rk-table td { padding-left: 6px !important; padding-right: 6px !important; }
    /* any table still wider than the screen scrolls inside its box instead of being cut */
    .content-wrapper :has(> table.rk-table),
    .content-wrapper :has(> table.table) { overflow-x: auto; -webkit-overflow-scrolling: touch; }

    /* Vote: the banner subtitle may wrap */
    .vote-banner-sub { white-space: normal !important; text-align: center; letter-spacing: .1em !important; line-height: 1.5; padding: 0 10px; }
    .auc-empty-note { max-width: 100%; box-sizing: border-box; }
}
