/* Overlay safety + mobile drawer polish (loads after social.min.css) */

/* old raid pulse removed - use tra-v3 */

/* Mobile drawer — slide-in panel above header/bottom nav */
@media (max-width: 1100px) {
    .mobile-sidebar-panel {
        position: fixed !important;
        inset: 0 !important;
        z-index: 2147483200 !important;
        display: none;
        margin: 0 !important;
        padding: 0 !important;
        background: transparent !important;
        overflow: hidden;
        isolation: isolate;
        pointer-events: none;
        opacity: 0;
        visibility: hidden;
        transition: opacity 0.2s ease, visibility 0.2s ease;
    }

    .mobile-sidebar-panel.open {
        display: block !important;
        pointer-events: auto;
        opacity: 1;
        visibility: visible;
    }

    .mobile-sidebar-backdrop {
        position: absolute;
        inset: 0;
        border: 0;
        margin: 0;
        padding: 0;
        width: 100%;
        height: 100%;
        background: rgba(0, 0, 0, 0.62);
        backdrop-filter: blur(2px);
        -webkit-backdrop-filter: blur(2px);
        cursor: pointer;
        z-index: 0;
    }

    .mobile-sidebar-drawer {
        position: absolute;
        top: 0;
        left: 0;
        bottom: 0;
        z-index: 1;
        width: min(88vw, 320px);
        max-width: 320px;
        display: flex;
        flex-direction: column;
        background: linear-gradient(180deg, #0a0a0c 0%, #111116 100%);
        border-right: 1px solid rgba(71, 217, 255, 0.14);
        box-shadow: 12px 0 40px rgba(0, 0, 0, 0.45);
        transform: translateX(-104%);
        transition: transform 0.24s cubic-bezier(0.22, 1, 0.36, 1);
        padding-top: env(safe-area-inset-top, 0);
        padding-bottom: env(safe-area-inset-bottom, 0);
    }

    .mobile-sidebar-panel.open .mobile-sidebar-drawer {
        transform: translateX(0);
    }

    .mobile-sidebar-content {
        position: relative;
        z-index: 1;
        display: flex;
        flex-direction: column;
        width: 100%;
        height: 100%;
        min-height: 0;
        overflow-y: auto;
        overflow-x: hidden;
        -webkit-overflow-scrolling: touch;
        touch-action: pan-y;
        overscroll-behavior: contain;
        padding: 0 14px max(20px, env(safe-area-inset-bottom, 0px));
        box-sizing: border-box;
    }

    .mobile-sidebar-head {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 12px;
        position: sticky;
        top: 0;
        z-index: 3;
        margin: 0 -14px 8px;
        padding: 14px 14px 12px;
        background: linear-gradient(180deg, rgba(10, 10, 12, 0.98) 70%, rgba(10, 10, 12, 0));
        border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    }

    .mobile-sidebar-title {
        font-size: 17px;
        font-weight: 800;
        letter-spacing: -0.02em;
        color: #e7e9ea;
    }

    .mobile-sidebar-close {
        position: static;
        flex: 0 0 auto;
        width: 40px;
        height: 40px;
        border: 1px solid rgba(255, 255, 255, 0.1);
        border-radius: 999px;
        background: rgba(255, 255, 255, 0.06);
        color: #e7e9ea;
        font-size: 1.4rem;
        line-height: 1;
        cursor: pointer;
    }

    .mobile-sidebar-panel .sidebar {
        display: flex !important;
        flex-direction: column;
        position: static !important;
        left: auto !important;
        top: auto !important;
        width: 100% !important;
        height: auto !important;
        min-height: 0 !important;
        padding: 0 !important;
        gap: 4px !important;
        background: transparent !important;
    }

    .mobile-sidebar-panel .sidebar-brand,
    .mobile-sidebar-panel .sidebar-brand-cluster {
        display: none !important;
    }

    .mobile-sidebar-panel .sidebar-nav {
        display: flex;
        flex-direction: column;
        gap: 2px;
    }

    .mobile-sidebar-panel .sidebar-item,
    .mobile-sidebar-panel .btn-post {
        font-size: 17px !important;
        font-weight: 600;
        padding: 12px 14px !important;
        gap: 14px !important;
        border-radius: 12px;
        min-height: 48px;
        box-sizing: border-box;
    }

    .mobile-sidebar-panel .sidebar-item:hover,
    .mobile-sidebar-panel .sidebar-item.active {
        background: rgba(29, 155, 240, 0.12);
    }

    .mobile-sidebar-panel .sidebar-item .icon svg,
    .mobile-sidebar-panel .btn-post .icon svg {
        width: 22px !important;
        height: 22px !important;
    }

    .mobile-sidebar-panel .sidebar-item-label {
        font-size: 17px !important;
        line-height: 1.2;
    }

    .mobile-sidebar-panel .sidebar-below-nav {
        margin-top: 8px;
        padding-top: 8px;
        border-top: 1px solid rgba(255, 255, 255, 0.08);
    }

    .mobile-sidebar-panel .portal-sidebar-divider {
        margin: 8px 0;
    }

    .mobile-sidebar-panel .btn-post {
        width: 100%;
        max-width: 100%;
        margin: 0;
        justify-content: flex-start;
    }

    .mobile-sidebar-panel .sidebar-bottom {
        margin-top: auto;
        padding-top: 16px;
        border-top: 1px solid rgba(255, 255, 255, 0.08);
    }

    .mobile-sidebar-panel .sidebar-account {
        width: 100%;
        border-radius: 12px;
        padding: 10px 12px;
        background: rgba(255, 255, 255, 0.04);
    }

    .mobile-sidebar-panel .sidebar-account-name,
    .mobile-sidebar-panel .sidebar-account-handle {
        font-size: 14px !important;
    }

    .mobile-sidebar-panel .sidebar-auth-actions {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 8px;
        margin-top: 10px;
    }

    html.mobile-menu-open,
    body.mobile-menu-open {
        overflow: hidden !important;
        overscroll-behavior: none;
        height: 100%;
        width: 100%;
    }

    body.mobile-menu-open .page,
    body.mobile-menu-open .layout-grid,
    body.mobile-menu-open .main-content,
    body.mobile-menu-open .portal-main-content,
    body.mobile-menu-open .mobile-header,
    body.mobile-menu-open .mobile-nav,
    body.mobile-menu-open #ted-overlay-root,
    body.mobile-menu-open .pwa-push-banner,
    body.mobile-menu-open .pwa-install-banner,
    body.mobile-menu-open .toast-share,
    body.mobile-menu-open .ted-raid-alert-overlay {
        visibility: hidden !important;
        pointer-events: none !important;
    }
}

/* Unified admin hub badge (sidebar, mobile header, admin.php) */
.sidebar-brand-cluster {
    display: flex;
    align-items: center;
    gap: 2px;
    margin: 2px 0 4px 2px;
    min-width: 0;
}

.sidebar-brand-cluster .sidebar-brand {
    margin: 0;
    flex-shrink: 0;
}

.mobile-header-logo-cluster {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    max-width: calc(100% - 120px);
    pointer-events: none;
}

.mobile-header-logo-cluster .mobile-header-logo,
.mobile-header-logo-cluster .admin-hub {
    pointer-events: auto;
}

.mobile-header-logo-cluster .mobile-header-logo {
    position: static;
    left: auto;
    transform: none;
}

.admin-hub {
    position: relative;
    flex-shrink: 0;
}

.admin-hub-badge {
    display: grid;
    place-items: center;
    width: 32px;
    height: 32px;
    padding: 4px;
    border: 0;
    border-radius: 999px;
    background: transparent;
    cursor: pointer;
    transition: background 0.15s;
}

.admin-hub-badge:hover,
.admin-hub.is-open .admin-hub-badge {
    background: var(--social-hover, rgba(231, 233, 234, 0.08));
}

.admin-hub-badge img {
    width: 22px;
    height: 22px;
    object-fit: contain;
    display: block;
}

.admin-hub-menu {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    z-index: 1200;
    pointer-events: auto;
    min-width: 220px;
    max-width: min(280px, calc(100vw - 24px));
    padding: 6px;
    border: 1px solid var(--social-border, #2f3336);
    border-radius: 14px;
    background: var(--bg-glass-strong, rgba(0, 0, 0, 0.92));
    backdrop-filter: blur(16px);
    box-shadow: var(--shadow-elevated, 0 8px 32px rgba(0, 0, 0, 0.65));
}

.admin-hub--mobile .admin-hub-menu {
    left: 50%;
    transform: translateX(-50%);
}

.admin-hub--admin .admin-hub-menu {
    left: auto;
    right: 0;
}

.admin-hub-item {
    display: grid;
    gap: 2px;
    padding: 10px 12px;
    border-radius: 10px;
    text-decoration: none;
    color: var(--text, #e7e9ea);
    transition: background 0.15s;
    pointer-events: auto;
    cursor: pointer;
}

.admin-hub-item:hover,
.admin-hub-item:focus-visible {
    background: var(--social-hover, rgba(231, 233, 234, 0.08));
    outline: none;
}

.admin-hub-item.is-active {
    background: rgba(29, 155, 240, 0.12);
}

.admin-hub-item-label {
    font-size: 14px;
    font-weight: 700;
    line-height: 1.2;
}

.admin-hub-item-desc {
    font-size: 12px;
    line-height: 1.3;
    color: var(--text-muted, #71767b);
}

.admin-hub--admin {
    margin-left: auto;
}

.admin-hub--admin .admin-hub-badge {
    width: 36px;
    height: 36px;
}

/* Admins: mod badge replaces TedLOGO (not shown alongside it) */
.sidebar-brand-cluster--hub-only {
    gap: 0;
}

.admin-hub--brand.admin-hub--sidebar .admin-hub-badge {
    width: 52px;
    height: 52px;
    padding: 12px;
    margin: 2px 0 4px 2px;
}

.admin-hub--brand.admin-hub--sidebar .admin-hub-badge img {
    width: 28px;
    height: 28px;
}

.admin-hub--brand.admin-hub--mobile {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
}

.admin-hub--brand.admin-hub--mobile .admin-hub-badge {
    width: 40px;
    height: 40px;
    padding: 6px;
}

.admin-hub--brand.admin-hub--mobile .admin-hub-badge img {
    width: 28px;
    height: 28px;
}

.admin-hub--brand.admin-hub--admin {
    margin-left: 0;
    width: 100%;
}

.admin-hub--brand.admin-hub--admin .admin-hub-badge {
    width: 52px;
    height: 52px;
    margin: 0 auto;
    padding: 8px;
}

.admin-hub--brand.admin-hub--admin .admin-hub-badge img {
    width: 32px;
    height: 32px;
}

.sidebar-brandbar--hub-only {
    justify-content: center;
}

@media (min-width: 1101px) {
    .sidebar-brand-cluster {
        margin: 0 0 clamp(1px, 0.2vh, 4px) 2px;
    }

    .admin-hub--brand.admin-hub--sidebar .admin-hub-badge {
        width: clamp(40px, 5vh, 52px);
        height: clamp(40px, 5vh, 52px);
        padding: clamp(8px, 1.05vh, 12px);
        margin: 0 0 clamp(1px, 0.2vh, 4px) 2px;
    }

    .admin-hub--brand.admin-hub--sidebar .admin-hub-badge img {
        width: clamp(20px, 2.8vh, 28px);
        height: clamp(20px, 2.8vh, 28px);
    }
}

/* Ported admin hub menus (mobile / admin pages) sit above drawers */
.admin-hub-menu.is-ported {
    position: fixed !important;
    z-index: 2147483000 !important;
    pointer-events: auto !important;
    transform: none !important;
    max-width: min(300px, calc(100vw - 20px));
    max-height: min(70dvh, 420px);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    box-shadow: 0 18px 48px rgba(0, 0, 0, 0.55), 0 0 0 1px rgba(47, 51, 54, 0.8);
}

