/* =============================================
   NEW ERA MAGAZINE — RESPONSIVE / MOBILE
   Drawer · Accordion · Content · A11y
   Hang-safe: transform/opacity only
   ============================================= */

/* Shared drawer animations (if not already in site.css) */
@keyframes drawerHeaderIn {
    from {
        opacity: 0;
        transform: translateY(-8px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes drawerItemIn {
    from {
        opacity: 0;
        transform: translateX(-14px);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes accordionItemIn {
    from {
        opacity: 0;
        transform: translateX(-8px);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* =============================================
   WIDE TABLET
   ============================================= */
@media (max-width: 1300px) {
    .top-bar-inner {
        padding: 6px 20px;
    }

    .trending-items {
        max-width: 420px;
    }

    .main-header-inner {
        padding: 0 20px;
    }

    .nav-list > li {
        margin: 0 2px;
    }

    .nav-actions {
        gap: 6px;
    }
}

/* =============================================
   MOBILE DRAWER  (≤ 1100px)
   Matches: mobile-menu.js → .is-open / .open
   ============================================= */
@media (max-width: 1100px) {

    .main-header-inner {
        min-height: 64px;
        padding: 0 16px;
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 10px;
    }

    /* Interviews / Columns / Afsana → 3-dot menu only */
    .nav-collapsible-item,
    li.nav-collapsible-item,
    .nav-collapsible-item.collapsed-hidden {
        display: none !important;
    }

    /* Hamburger */
    .mobile-toggle {
        display: inline-flex !important;
        align-items: center;
        justify-content: center;
        width: 44px;
        height: 44px;
        min-width: 44px;
        min-height: 44px;
        border: none;
        background: transparent;
        color: #1a1a1a;
        cursor: pointer;
        border-radius: 10px;
        flex-shrink: 0;
        order: 1;
        z-index: 1001;
        padding: 0;
        transition: background 0.2s ease, transform 0.15s ease;
    }

        .mobile-toggle:hover {
            background: rgba(232, 25, 44, 0.07);
        }

        .mobile-toggle:active {
            transform: scale(0.92);
        }

        .mobile-toggle.active .hamburger-bar {
            background: #e8192c;
        }

    /* Logo center */
    .site-logo {
        order: 2;
        flex: 1;
        display: flex;
        flex-direction: column;
        align-items: center;
        text-align: center;
        max-width: calc(100vw - 170px);
        overflow: hidden;
    }

        .site-logo::before {
            /* shine can look odd when logo is centered/small */
            animation-duration: 10s;
        }

    .logo-row {
        justify-content: center;
        gap: 5px;
    }

    /* Readable but not huge — 32px was oversized on tablet */
    .logo-new,
    .logo-mag {
        font-size: 22px;
        letter-spacing: 0.6px;
    }

    .logo-sub {
        font-size: 9px;
        letter-spacing: 0.4px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        max-width: 100%;
    }

    /* Actions right */
    .nav-actions {
        order: 3;
        display: flex;
        align-items: center;
        gap: 6px;
        flex-shrink: 0;
    }

        /* Search: hide in bar on mobile (drawer/search page still available) */
        .nav-actions .search-box {
            display: none !important;
        }

    /* Show more (Interviews/Columns/Afsana) */
    .more-menu-btn {
        display: inline-flex !important;
    }

    /* ---------- Off-canvas drawer ---------- */
    .nav-list-wrap {
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        width: 290px;
        max-width: 88vw;
        height: 100vh;
        height: 100dvh;
        background: #ffffff;
        box-shadow: 4px 0 30px rgba(0, 0, 0, 0.15);
        z-index: 9999;
        overflow-y: auto;
        overflow-x: hidden;
        transform: translateX(-105%) !important;
        transition: transform 0.35s cubic-bezier(0.22, 1, 0.36, 1) !important;
        will-change: transform;
        padding: 0;
        margin: 0 !important;
        display: flex !important;
        flex-direction: column !important;
        justify-content: flex-start;
        -webkit-overflow-scrolling: touch;
        overscroll-behavior: contain;
        backface-visibility: hidden;
    }

        .nav-list-wrap.is-open,
        .nav-list-wrap.open {
            transform: translateX(0) !important;
        }

    /* Drawer header */
    .nav-drawer-header {
        display: flex !important;
        align-items: center;
        justify-content: space-between;
        gap: 10px;
        padding: 0 12px 0 18px;
        border-bottom: 1px solid #f0f0f0;
        position: sticky;
        top: 0;
        background: #fff;
        z-index: 10;
        width: 100%;
        box-sizing: border-box;
        flex-shrink: 0;
        min-height: 64px;
    }

    .nav-drawer-logo {
        display: inline-flex;
        align-items: baseline;
        gap: 5px;
        text-decoration: none;
        white-space: nowrap;
    }

    .nav-drawer-logo-new,
    .nav-drawer-logo-mag {
        font-family: 'Antonio', sans-serif;
        font-weight: 800;
        font-size: 16px;
        letter-spacing: 0.5px;
    }

    .nav-drawer-logo-new {
        color: #e8192c;
    }

    .nav-drawer-logo-mag {
        color: #222;
    }

    /* Close (X) */
    .nav-drawer-close {
        display: inline-flex !important;
        align-items: center;
        justify-content: center;
        width: 38px;
        height: 38px;
        min-width: 38px;
        min-height: 38px;
        border: 1.5px solid #eee;
        background: #fff;
        color: #444;
        border-radius: 8px;
        cursor: pointer;
        flex-shrink: 0;
        margin-left: auto;
        transition: background 0.2s ease, color 0.2s ease, border-color 0.2s ease;
        padding: 0;
    }

        .nav-drawer-close:hover {
            background: rgba(232, 25, 44, 0.1);
            color: #e8192c;
            border-color: #e8192c;
        }

        .nav-drawer-close .hamburger-bar:nth-child(1) {
            top: 7px;
            transform: rotate(45deg);
        }

        .nav-drawer-close .hamburger-bar:nth-child(2) {
            opacity: 0;
        }

        .nav-drawer-close .hamburger-bar:nth-child(3) {
            top: 7px;
            transform: rotate(-45deg);
        }

    /* Nav list column */
    .nav-list {
        flex-direction: column !important;
        align-items: stretch !important;
        flex-wrap: nowrap !important;
        padding: 8px 0 32px;
        margin: 0;
        width: 100%;
        list-style: none;
        gap: 0 !important;
        flex: 1;
    }

        .nav-list > li {
            width: 100%;
            margin: 0;
            border-bottom: 1px solid #f2f2f2;
            position: relative;
            flex-shrink: 0;
        }

            .nav-list > li > a,
            .nav-list > li > .nav-link-main {
                display: flex !important;
                align-items: center;
                width: 100%;
                padding: 15px 54px 15px 20px !important; /* room for accordion btn */
                font-size: 14px !important;
                font-weight: 700;
                color: #222;
                text-decoration: none;
                box-sizing: border-box;
                border-radius: 0;
                white-space: nowrap;
                transform: none !important;
                background: transparent;
                transition: color 0.2s ease, background 0.2s ease, padding-left 0.2s ease;
            }

                .nav-list > li > a:hover,
                .nav-list > li > .nav-link-main:hover {
                    color: #e8192c;
                    background: rgba(232, 25, 44, 0.04);
                    padding-left: 24px !important;
                    transform: none !important;
                }

            .nav-list > li.active > a,
            .nav-list > li.active > .nav-link-main {
                color: #e8192c;
                background: rgba(232, 25, 44, 0.06);
                border-left: 3px solid #e8192c;
                padding-left: 17px !important;
            }

            .nav-list > li > a::after {
                display: none !important;
            }

    .nav-link-main .nav-arrow {
        display: none !important;
    }

    /* Accordion toggle */
    .dropdown-toggle-mobile {
        display: inline-flex !important;
        align-items: center;
        justify-content: center;
        position: absolute;
        right: 0;
        top: 0;
        width: 52px;
        height: 100%;
        min-height: 50px;
        background: transparent;
        border: none;
        border-left: 1px solid #f0f0f0;
        color: #999;
        font-size: 13px;
        cursor: pointer;
        padding: 0;
        min-width: unset;
        transition: color 0.2s ease, background 0.2s ease;
        z-index: 2;
    }

        .dropdown-toggle-mobile i {
            transition: transform 0.28s ease;
        }

        .dropdown-toggle-mobile:hover {
            color: #e8192c;
            background: rgba(232, 25, 44, 0.04);
        }

        .nav-dropdown.open .dropdown-toggle-mobile,
        .nav-dropdown.is-open .dropdown-toggle-mobile,
        .nav-dropdown.accordion-open .dropdown-toggle-mobile,
        .dropdown-toggle-mobile[aria-expanded="true"] {
            color: #e8192c;
            background: rgba(232, 25, 44, 0.06);
        }

        .nav-dropdown.open .dropdown-toggle-mobile i,
        .nav-dropdown.open .dropdown-toggle-mobile svg,
        .nav-dropdown.is-open .dropdown-toggle-mobile i,
        .nav-dropdown.is-open .dropdown-toggle-mobile svg,
        .nav-dropdown.accordion-open .dropdown-toggle-mobile i,
        .nav-dropdown.accordion-open .dropdown-toggle-mobile svg,
        .dropdown-toggle-mobile[aria-expanded="true"] i,
        .dropdown-toggle-mobile[aria-expanded="true"] svg {
            transform: rotateX(180deg) !important;
        }

    /* Kill desktop hover bridge on mobile */
    .nav-dropdown::after {
        display: none !important;
    }

    /* Accordion submenu
       IMPORTANT: use max-height (not display:none) so open anim works
       JS may toggle .open OR .is-open
    */
    .nav-dropdown-menu {
        position: static !important;
        left: auto !important;
        top: auto !important;
        background: #fafafa;
        box-shadow: inset 0 2px 6px rgba(0, 0, 0, 0.04);
        border-radius: 0;
        padding: 0;
        margin: 0;
        opacity: 1 !important;
        visibility: visible !important;
        pointer-events: auto !important;
        transform: none !important;
        max-height: 0;
        overflow: hidden;
        transition: max-height 320ms cubic-bezier(0.22, 0.61, 0.36, 1), padding 280ms ease;
        border-top: 0 solid #f0f0f0;
        width: 100%;
        min-width: 0 !important;
    }

    .nav-dropdown.open .nav-dropdown-menu,
    .nav-dropdown.is-open .nav-dropdown-menu,
    .nav-dropdown.accordion-open .nav-dropdown-menu {
        max-height: 640px;
        padding: 4px 0;
        border-top: 1px solid #f0f0f0;
    }

    .nav-dropdown-menu li {
        opacity: 1 !important;
        transform: none !important;
        width: 100%;
        transition: none !important;
    }

        .nav-dropdown-menu li a {
            display: flex !important;
            align-items: center;
            justify-content: flex-start;
            gap: 10px;
            padding: 12px 20px 12px 36px !important;
            font-size: 13px !important;
            font-weight: 600;
            color: #555;
            width: 100%;
            box-sizing: border-box;
            border-radius: 0;
            text-decoration: none;
            transform: none !important;
            transition: color 0.2s ease, background 0.2s ease, padding-left 0.2s ease;
            min-height: unset;
            min-width: unset;
        }

            .nav-dropdown-menu li a:hover {
                color: #e8192c;
                background: rgba(232, 25, 44, 0.04);
                padding-left: 42px !important;
                transform: none !important;
            }

            .nav-dropdown-menu li a::before,
            .nav-dropdown-menu li a::after {
                display: none !important;
            }

            .nav-dropdown-menu li a .arrow-icon,
            .nav-dropdown-menu li a .fa-angle-right {
                margin-left: auto;
                opacity: 0.35;
                font-size: 10px;
            }

    /* Overlay — keep opacity transition from site.css; ensure visible works */
    .nav-overlay {
        /* base styles live in site.css; reinforce mobile z-index */
        z-index: 9998;
    }

        .nav-overlay.is-visible {
            opacity: 1 !important;
            visibility: visible !important;
            pointer-events: auto !important;
        }

    /* Stagger only when open (cheap) */
    .nav-list-wrap.is-open .nav-drawer-header,
    .nav-list-wrap.open .nav-drawer-header {
        animation: drawerHeaderIn 0.3s ease both;
    }

    .nav-list-wrap.is-open .nav-list > li,
    .nav-list-wrap.open .nav-list > li {
        animation: drawerItemIn 0.32s cubic-bezier(0.22, 0.61, 0.36, 1) both;
    }

        .nav-list-wrap.is-open .nav-list > li:nth-child(1),
        .nav-list-wrap.open .nav-list > li:nth-child(1) {
            animation-delay: 0.04s;
        }

        .nav-list-wrap.is-open .nav-list > li:nth-child(2),
        .nav-list-wrap.open .nav-list > li:nth-child(2) {
            animation-delay: 0.08s;
        }

        .nav-list-wrap.is-open .nav-list > li:nth-child(3),
        .nav-list-wrap.open .nav-list > li:nth-child(3) {
            animation-delay: 0.12s;
        }

        .nav-list-wrap.is-open .nav-list > li:nth-child(4),
        .nav-list-wrap.open .nav-list > li:nth-child(4) {
            animation-delay: 0.16s;
        }

        .nav-list-wrap.is-open .nav-list > li:nth-child(5),
        .nav-list-wrap.open .nav-list > li:nth-child(5) {
            animation-delay: 0.20s;
        }

        .nav-list-wrap.is-open .nav-list > li:nth-child(6),
        .nav-list-wrap.open .nav-list > li:nth-child(6) {
            animation-delay: 0.24s;
        }

        .nav-list-wrap.is-open .nav-list > li:nth-child(7),
        .nav-list-wrap.open .nav-list > li:nth-child(7) {
            animation-delay: 0.28s;
        }

        .nav-list-wrap.is-open .nav-list > li:nth-child(8),
        .nav-list-wrap.open .nav-list > li:nth-child(8) {
            animation-delay: 0.32s;
        }

    .nav-dropdown.open .nav-dropdown-menu li,
    .nav-dropdown.is-open .nav-dropdown-menu li {
        animation: accordionItemIn 0.2s ease both;
    }

        .nav-dropdown.open .nav-dropdown-menu li:nth-child(1),
        .nav-dropdown.is-open .nav-dropdown-menu li:nth-child(1) {
            animation-delay: 0.03s;
        }

        .nav-dropdown.open .nav-dropdown-menu li:nth-child(2),
        .nav-dropdown.is-open .nav-dropdown-menu li:nth-child(2) {
            animation-delay: 0.06s;
        }

        .nav-dropdown.open .nav-dropdown-menu li:nth-child(3),
        .nav-dropdown.is-open .nav-dropdown-menu li:nth-child(3) {
            animation-delay: 0.09s;
        }

        .nav-dropdown.open .nav-dropdown-menu li:nth-child(4),
        .nav-dropdown.is-open .nav-dropdown-menu li:nth-child(4) {
            animation-delay: 0.12s;
        }

        .nav-dropdown.open .nav-dropdown-menu li:nth-child(5),
        .nav-dropdown.is-open .nav-dropdown-menu li:nth-child(5) {
            animation-delay: 0.15s;
        }
}

/* =============================================
   SMALL PHONES
   ============================================= */
@media (max-width: 480px) {
    .mobile-toggle {
        width: 38px;
        height: 38px;
        min-width: 38px;
        min-height: 38px;
    }

    .nav-list-wrap {
        width: 270px;
    }

    .logo-new,
    .logo-mag {
        font-size: 18px;
    }

    .logo-sub {
        font-size: 8px;
    }
}

@media (max-width: 350px) {
    .nav-list-wrap {
        width: 250px;
        max-width: 92vw;
    }

    .nav-list > li > a,
    .nav-list > li > .nav-link-main {
        padding: 13px 48px 13px 16px !important;
        font-size: 13px !important;
    }

    .logo-new,
    .logo-mag {
        font-size: 16px;
    }
}

/* =============================================
   CONTENT ≤ 768px
   ============================================= */
@media (max-width: 768px) {

    body {
        overflow-x: hidden;
    }

    .page-content {
        overflow-x: hidden;
        min-width: 0;
    }

    /* Top bar off on small screens (space) */
    .top-bar {
        display: none;
    }

    /* When top-bar hidden, sticky header sits at top cleanly */
    .main-header {
        top: 0;
    }

    /* Categories */
    .cat-section {
        padding: 14px 16px;
    }

    .cat-grid {
        flex-wrap: wrap;
        border: none;
        box-shadow: none;
        background: transparent;
        border-radius: 0;
        gap: 10px;
        display: flex;
    }

    .cat-item {
        flex: 1 1 calc(33.333% - 10px);
        min-width: 0;
        background: #fff;
        border: 1px solid #eee;
        border-radius: 8px;
        box-shadow: 0 1px 6px rgba(0, 0, 0, 0.05);
        padding: 16px 8px;
    }

        .cat-item::after {
            display: none;
        }

    .cat-icon,
    .cat-icon img {
        width: 36px;
        height: 36px;
    }

    .cat-name {
        font-size: 12px;
    }

    .cat-sub {
        font-size: 10.5px;
    }

    /* Hero (supports both class naming styles) */
    .hero-section {
        height: auto;
        min-height: 340px;
    }

    .hero-content,
    .hero-text-panel {
        padding-left: 20px;
        padding-right: 20px;
    }

    .hero-title {
        font-size: 26px;
        line-height: 1.3;
    }

    .hero-excerpt,
    .hero-desc {
        font-size: 14px;
    }

    /* Generic grids */
    .article-grid,
    .poetry-grid,
    .book-grid,
    .articles-grid,
    .featured-grid-4,
    .trending-stories-row,
    .epk-grid {
        grid-template-columns: 1fr !important;
        gap: 16px;
    }

    .featured-main-container,
    .latest-main-container,
    .trending-main-container {
        flex-direction: column !important;
    }

    .featured-right-col,
    .categories-sidebar,
    .trending-right-col,
    .featured-left-col,
    .trending-left-col {
        width: 100% !important;
        max-width: 100% !important;
        flex: none !important;
    }

    /* Footer */
    .footer-inner {
        flex-direction: column;
        gap: 28px;
    }

    .footer-brand {
        text-align: center;
        flex: none;
        width: 100%;
    }

    .footer-social {
        justify-content: center;
    }

    .footer-cols {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 20px;
        width: 100%;
        padding: 0;
    }

    .footer-col {
        flex: none;
    }

    .footer-newsletterr,
    .footer-newsletter {
        width: 100%;
        flex: none;
    }

    .footer-bottom .footer-inner {
        flex-direction: column;
        align-items: center;
        gap: 12px;
        text-align: center;
    }

    /* Overflow guards */
    .container,
    .container-fluid {
        max-width: 100%;
        overflow-x: hidden;
    }

    .trending-wrap {
        max-width: 100%;
        overflow: hidden;
    }

    .trending-items {
        white-space: nowrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
    }

        .trending-items::-webkit-scrollbar {
            display: none;
        }

    img {
        max-width: 100%;
        height: auto;
    }

    table {
        display: block;
        width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    pre,
    code {
        overflow-x: auto;
        word-wrap: break-word;
        white-space: pre-wrap;
    }

    /* Preloader sizing */
    .nem-preloader-logo-title {
        font-size: 36px;
        letter-spacing: 2px;
    }

    .nem-preloader-logo-subtitle {
        font-size: 12px;
        letter-spacing: 4px;
    }

    .nem-progress-line {
        width: min(240px, 70vw);
    }

    .nem-dual-ring-spinner {
        width: 60px;
        height: 60px;
    }

    /* Don't keep will-change hot forever */
    .hero-section,
    .article-card,
    .poetry-card,
    .fg-card,
    .trending-card {
        will-change: auto;
    }
}

/* =============================================
   ≤ 576px
   ============================================= */
@media (max-width: 576px) {
    .logo-new,
    .logo-mag {
        font-size: 20px;
    }

    .logo-sub {
        font-size: 8px;
    }

    .cat-grid {
        gap: 8px;
    }

    .cat-item {
        flex: 1 1 calc(50% - 8px);
        padding: 14px 8px;
    }

    .cat-icon,
    .cat-icon img {
        width: 32px;
        height: 32px;
    }

    .cat-name {
        font-size: 11.5px;
    }

    .cat-sub {
        font-size: 10px;
    }

    .hero-section {
        min-height: 320px;
    }

    .hero-title {
        font-size: 22px;
    }

    .hero-excerpt,
    .hero-desc {
        font-size: 13px;
    }

    .footer-cols {
        grid-template-columns: 1fr;
    }

    .newsletter-section {
        margin-left: 12px;
        margin-right: 12px;
        max-width: calc(100% - 24px);
        padding: 24px 16px;
    }
}

/* =============================================
   ≤ 400px
   ============================================= */
@media (max-width: 400px) {
    .main-header-inner {
        padding: 0 10px;
        gap: 8px;
    }

    .logo-new,
    .logo-mag {
        font-size: 16px;
        letter-spacing: 0.4px;
    }

    .cat-section {
        padding: 12px;
    }

    .cat-grid {
        gap: 6px;
    }

    .cat-item {
        flex: 1 1 calc(50% - 6px);
        padding: 12px 6px;
        gap: 5px;
    }

    .cat-icon,
    .cat-icon img {
        width: 28px;
        height: 28px;
    }

    .cat-name {
        font-size: 11px;
    }

    .cat-sub {
        font-size: 9.5px;
    }

    .hero-section {
        min-height: 300px;
    }

    .hero-content,
    .hero-text-panel {
        padding: 20px 14px;
    }

    .hero-title {
        font-size: 19px;
    }

    .btn-register {
        display: none;
    }
}

/* Keep collapsibles hidden on this range too (safety) */
@media (max-width: 1000px) {
    .nav-collapsible-item {
        display: none !important;
    }
}

/* =============================================
   ACCESSIBILITY
   ============================================= */
@media (max-width: 768px) {
    /* Prevent iOS zoom on focus — only text fields */
    input[type="text"],
    input[type="email"],
    input[type="password"],
    input[type="search"],
    input[type="tel"],
    input[type="url"],
    textarea,
    select {
        font-size: 16px;
    }

    *:focus-visible {
        outline: 2px solid #e8192c;
        outline-offset: 2px;
    }
}

/* =============================================
   REDUCED MOTION
   ============================================= */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}
