/* =========================================================
   EWI MOBILE NAV
   Shown below 900px — replaces desktop mega menu
   ========================================================= */

/* Hide mobile nav on desktop */
.ewi-mobile-nav {
    display: none;
}

/* =========================================================
   FIX 1 — NAVIGATION COLLAPSE AT 960px
   Prevents dual-nav state at 901–960px where hamburger
   and desktop nav were both visible simultaneously
   ========================================================= */
@media (max-width: 960px) {
    .main-nav { display: none !important; }
    .nav-toggle { display: flex !important; }
    .ewi-mobile-nav { display: block; }
}

@media (max-width: 900px) {

    /* ── Hide desktop nav ── */
    .main-nav {
        display: none !important;
    }

    /* ── Fix header for mobile ── */
    .site-header {
        height: 56px;
        position: sticky;
        top: 0;
        z-index: 1100;
        overflow: visible !important;
    }

    .container.header-inner,
    .header-inner {
        padding-inline: 16px !important;
        gap: 8px !important;
        margin-inline: 0 !important;
        width: 100% !important;
        max-width: 100% !important;
        box-sizing: border-box !important;
    }

    /* ── Logo ── */
    .site-header .logo img,
    .site-header .ewi-logo {
        width: 140px !important;
        height: auto !important;
    }

    /* ── Hamburger ── */
    .nav-toggle {
        display: flex !important;
        margin-left: auto;
        flex-shrink: 0;
    }

    /* ── Mobile nav overlay ── */
    .ewi-mobile-nav {
        display: block;
        position: fixed;
        top: 56px;
        left: 0;
        right: 0;
        bottom: 0;
        background: #0f1115;
        z-index: 1099;
        overflow-y: auto;
        transform: translateX(100%);
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        border-top: 1px solid rgba(77, 163, 255, 0.15);
    }

    .ewi-mobile-nav.is-open {
        transform: translateX(0);
    }

    .ewi-mobile-nav__inner {
        padding: 8px 0 100px;
    }

    /* ── Menu items ── */
    .ewi-mobile-menu {
        list-style: none;
        margin: 0;
        padding: 0;
    }

    .ewi-mobile-menu__item {
        border-bottom: 1px solid rgba(255,255,255,0.05);
    }

    .ewi-mobile-menu__row {
        display: flex;
        align-items: center;
    }

    .ewi-mobile-menu__link {
        display: block;
        flex: 1;
        padding: 14px 20px;
        color: #e6e6e6;
        text-decoration: none;
        font-size: 0.9375rem;
        font-weight: 500;
        transition: color 0.2s ease;
    }

    .ewi-mobile-menu__link:hover,
    .ewi-mobile-menu__item.is-current > .ewi-mobile-menu__row .ewi-mobile-menu__link {
        color: #4da3ff;
    }

    .ewi-mobile-menu__toggle {
        background: none;
        border: none;
        cursor: pointer;
        padding: 14px 20px;
        color: #6b7280;
        display: flex;
        align-items: center;
        transition: color 0.2s ease, transform 0.2s ease;
        flex-shrink: 0;
    }

    .ewi-mobile-menu__toggle:hover {
        color: #4da3ff;
    }

    .ewi-mobile-menu__item.is-open > .ewi-mobile-menu__row .ewi-mobile-menu__toggle {
        transform: rotate(180deg);
        color: #4da3ff;
    }

    /* ── Submenu ── */
    .ewi-mobile-submenu {
        list-style: none;
        margin: 0;
        padding: 0 0 8px 0;
        background: rgba(0,0,0,0.2);
        display: none;
    }

    .ewi-mobile-menu__item.is-open > .ewi-mobile-submenu {
        display: block;
    }

    .ewi-mobile-submenu__link {
        display: block;
        padding: 10px 20px 10px 32px;
        color: #9ca3af;
        text-decoration: none;
        font-size: 0.875rem;
        transition: color 0.2s ease;
        border-left: 2px solid transparent;
        margin-left: 20px;
    }

    .ewi-mobile-submenu__link:hover {
        color: #4da3ff;
        border-left-color: #4da3ff;
    }

    /* ── Footer CTA ── */
    .ewi-mobile-nav__footer {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        padding: 16px 20px;
        background: #0f1115;
        border-top: 1px solid rgba(77,163,255,0.15);
        display: flex;
        gap: 10px;
        z-index: 1100;
    }

    .ewi-mobile-nav__btn {
        flex: 1;
        display: flex;
        align-items: center;
        justify-content: center;
        padding: 12px 16px;
        border-radius: 8px;
        font-size: 0.875rem;
        font-weight: 600;
        text-decoration: none;
        transition: background 0.2s ease, color 0.2s ease;
        text-align: center;
    }

    .ewi-mobile-nav__btn--primary {
        background: #4da3ff;
        color: #0b0f14;
    }

    .ewi-mobile-nav__btn--primary:hover {
        background: #6db8ff;
    }

    .ewi-mobile-nav__btn--secondary {
        background: rgba(255,255,255,0.06);
        color: #e6e6e6;
        border: 1px solid rgba(255,255,255,0.1);
    }

    .ewi-mobile-nav__btn--secondary:hover {
        background: rgba(255,255,255,0.1);
    }

    .ewi-mobile-nav__btn--ghost {
        background: transparent;
        color: #6b7280;
        border: 1px solid rgba(255,255,255,0.08);
    }

    .ewi-mobile-nav__btn--ghost:hover {
        color: #e6e6e6;
    }

    /* ── Body scroll lock when nav open ── */
    body.mobile-nav-open {
        overflow: hidden;
    }

}

/* =========================================================
   MOBILE HOMEPAGE — show analysis feed only
   ========================================================= */

@media (max-width: 900px) {

    /* FIX 2 — Hide secondary sections; keep pricing + CTA visible for conversion */
    .fp-stats,
    .fp-features,
    .fp-faq {
        display: none !important;
    }

    /* Stack pricing cards single column on mobile */
    .fp-pricing-grid,
    .fp-pricing__grid,
    .fp-pricing__plans,
    .fp-pricing .pricing-grid {
        grid-template-columns: 1fr !important;
        gap: 16px !important;
    }

    .fp-cta-strip {
        padding-block: 24px !important;
    }

    .fp-tools {
        padding-block: 20px !important;
    }

    /* Simplify the teaser section */
    .fp-teaser {
        padding-top: 16px !important;
        padding-bottom: 16px !important;
    }

    .fp-teaser .fp-section-header {
        display: none !important;
    }

    .fp-teaser .container {
        padding-inline: 12px !important;
    }

    .fp-teaser .latest-analysis-grid {
        margin-top: 0 !important;
    }

    /* Add mobile feed header */
    .fp-teaser::before {
        content: 'Latest Analysis';
        display: block;
        font-size: 1.125rem;
        font-weight: 700;
        color: #e6e6e6;
        padding: 0 12px 12px;
    }

}

/* =========================================================
   MOBILE FILTER BAR — compact
   ========================================================= */

@media (max-width: 900px) {

    .ap-filterbar {
        padding: 8px 12px !important;
        gap: 6px !important;
        flex-wrap: wrap !important;
    }

    .ap-filterbar__search {
        width: 100% !important;
        max-width: 100% !important;
        order: -1;
    }

    .ap-filterbar__input {
        height: 36px !important;
        font-size: 0.875rem !important;
        padding: 0 10px !important;
    }

    /* FIX 3 — Raise filter buttons to 44px minimum tap target */
    .ap-filter-btn,
    .ap-dd-trigger {
        min-height: 44px !important;
        height: auto !important;
        padding: 8px 12px !important;
        font-size: 0.8125rem !important;
    }

    .ap-filterbar__dropdowns {
        gap: 6px !important;
        flex-wrap: wrap !important;
    }
}

/* =========================================================
   MOBILE COOKIE BANNER — compact
   ========================================================= */

@media (max-width: 900px) {

    .ewi-cookie-banner {
        padding: 12px 16px !important;
    }

    .ewi-cookie-banner__inner {
        grid-template-columns: 1fr !important;
        gap: 10px !important;
    }

    .ewi-cookie-banner__title {
        font-size: 0.9375rem !important;
        margin-bottom: 4px !important;
    }

    /* FIX 7 — Restore cookie banner text (required for GDPR compliance) */
    .ewi-cookie-banner__text {
        font-size: 0.8125rem !important;
        display: block !important;
        margin-top: 4px !important;
        line-height: 1.4 !important;
    }

    .ewi-cookie-banner__actions {
        flex-direction: row !important;
        gap: 8px !important;
    }

    .ewi-cookie-btn {
        flex: 1 !important;
        min-height: 38px !important;
        padding: 8px 12px !important;
        font-size: 0.8125rem !important;
    }

    .ewi-cookie-banner__prefs {
        display: none !important;
    }
}

/* =========================================================
   MOBILE FEED CARDS — wider
   ========================================================= */

@media (max-width: 900px) {

    .ap-feed-grid {
        grid-template-columns: 1fr !important;
        gap: 12px !important;
        padding: 0 !important;
    }

    .ap-analysis-card {
        width: 100% !important;
        margin: 0 !important;
    }

    /* ── Cookie banner button overflow fix ── */
    .ewi-cookie-banner {
        overflow: hidden !important;
    }

    .ewi-cookie-banner__actions {
        flex-wrap: wrap !important;
        width: 100% !important;
    }

    .ewi-cookie-btn {
        max-width: 100% !important;
        box-sizing: border-box !important;
        word-break: break-word !important;
    }
}

/* =========================================================
   MOBILE FEED PROMO BUTTONS — fix overflow
   ========================================================= */

@media (max-width: 900px) {
    .ewi-feed-promo__actions {
        flex-direction: column !important;
        gap: 8px !important;
        width: 100% !important;
    }

    .ewi-feed-promo__btn {
        white-space: normal !important;
        width: 100% !important;
        justify-content: center !important;
        text-align: center !important;
        padding: 10px 16px !important;
    }
}

/* =========================================================
   MOBILE FEED — full width fix
   ========================================================= */

@media (max-width: 900px) {

    /* Feed container */
    .ap-feed-wrapper,
    .ap-feed-container,
    .ap-feed-inner,
    .analysis-feed-wrap {
        padding: 0 !important;
        margin: 0 !important;
        width: 100% !important;
        max-width: 100% !important;
        box-sizing: border-box !important;
    }

    /* Grid */
    .ap-feed-grid {
        grid-template-columns: 1fr !important;
        width: 100% !important;
        padding: 0 12px !important;
        box-sizing: border-box !important;
    }

    /* Cards */
    .ap-analysis-card {
        width: 100% !important;
        max-width: 100% !important;
        margin: 0 !important;
        box-sizing: border-box !important;
    }

    /* Promo buttons */
    .ewi-feed-promo__actions {
        flex-direction: column !important;
        width: 100% !important;
    }

    .ewi-feed-promo__btn {
        white-space: normal !important;
        width: 100% !important;
        justify-content: center !important;
        box-sizing: border-box !important;
    }
}

/* =========================================================
   EDUCATIONAL HUB — mobile fixes
   ========================================================= */

@media (max-width: 900px) {
    .edu-hub__module-nav-inner {
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch !important;
        flex-wrap: nowrap !important;
        gap: 8px !important;
        padding-bottom: 8px !important;
        scrollbar-width: none !important;
    }
    .edu-hub__module-nav-inner::-webkit-scrollbar { display: none !important; }
    .edu-hub__module-nav-item {
        flex-shrink: 0 !important;
        min-width: 80px !important;
        padding: 8px 12px !important;
        font-size: 0.8125rem !important;
    }
    .edu-hub__guides,
    .edu-hub__guides--two,
    .edu-hub__guides--three { grid-template-columns: 1fr !important; }
    .edu-hub__hero-inner { padding: 24px 16px !important; }
    .edu-hub__module-header { flex-direction: column !important; gap: 12px !important; }
    .edu-hub__cta-inner { flex-direction: column !important; gap: 16px !important; text-align: center !important; }
    .edu-hub__cta-actions { flex-direction: column !important; width: 100% !important; }
    .edu-hub__cta-actions .btn { width: 100% !important; text-align: center !important; }
}

/* =========================================================
   GUIDE PAGES — TOC/sidebar fix
   ========================================================= */

@media (max-width: 900px) {
    .ew-guide-layout { grid-template-columns: 1fr !important; }
    .ew-guide-sidebar { order: -1 !important; }
    .ew-guide-sidebar__inner { position: static !important; grid-template-columns: 1fr !important; }
    .ew-guide-toc { grid-column: 1 / -1 !important; overflow-x: hidden !important; }
    .ew-guide-toc a, .guide-toc a, .toc-link {
        white-space: normal !important;
        word-break: break-word !important;
        display: block !important;
        padding: 8px 12px !important;
    }
}

/* =========================================================
   TOOLS PAGE — contain content
   ========================================================= */

@media (max-width: 900px) {
    .ewi-tools-wrap, .ewi-calc-wrap, .ewi-calendar-wrap {
        padding-inline: 16px !important;
        max-width: 100% !important;
        overflow-x: hidden !important;
        box-sizing: border-box !important;
    }
    .ewi-calc-grid, .ewi-calc-form { grid-template-columns: 1fr !important; }
    .ewi-calendar-embed { overflow-x: auto !important; -webkit-overflow-scrolling: touch !important; }
    .ep-hero, .tlc-hero, .rd-hero { grid-template-columns: 1fr !important; padding: 20px 16px !important; }
    .ep-twoCol, .tlc-twoCol, .rd-twoCol { grid-template-columns: 1fr !important; }
    .ep-grid3, .tlc-grid3, .rd-grid3 { grid-template-columns: 1fr 1fr !important; }
    .ep-pricing, .tlc-pricing { grid-template-columns: 1fr !important; }
}


/* =========================================================
   FEATURE 1 — BOTTOM TAB BAR
   Hidden on desktop. Fixed to bottom on ≤960px.
   Body gains padding-bottom to prevent content hiding
   behind the bar. Safe-area-inset handles iPhone notch.
   ========================================================= */

/* Hidden by default on all screen sizes */
.ewi-bottom-nav {
    display: none;
}

@media (max-width: 960px) {

    /* Push page content above the tab bar */
    body {
        padding-bottom: calc(60px + env(safe-area-inset-bottom)) !important;
    }

    /* The nav bar itself */
    .ewi-bottom-nav {
        display: flex;
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        height: calc(60px + env(safe-area-inset-bottom));
        padding-bottom: env(safe-area-inset-bottom);
        background: #0f1115;
        border-top: 1px solid rgba(77, 163, 255, 0.15);
        z-index: 1200;
        -webkit-tap-highlight-color: transparent;
    }

    /* Individual tab */
    .ewi-bottom-nav__tab {
        flex: 1;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 3px;
        color: #6b7280;
        text-decoration: none;
        font-size: 0.625rem;
        font-weight: 600;
        letter-spacing: 0.03em;
        text-transform: uppercase;
        transition: color 0.15s ease;
        position: relative;
        min-height: 44px;
        padding-top: 6px;
    }

    .ewi-bottom-nav__tab:hover,
    .ewi-bottom-nav__tab:focus {
        color: #9ca3af;
        text-decoration: none;
        outline: none;
    }

    .ewi-bottom-nav__tab.is-active {
        color: #4da3ff;
    }

    /* Active indicator — small bar at the top of the active tab */
    .ewi-bottom-nav__tab.is-active::before {
        content: '';
        position: absolute;
        top: 0;
        left: 25%;
        right: 25%;
        height: 2px;
        background: #4da3ff;
        border-radius: 0 0 2px 2px;
    }

    .ewi-bottom-nav__tab svg {
        flex-shrink: 0;
        transition: transform 0.15s ease;
    }

    .ewi-bottom-nav__tab.is-active svg {
        transform: translateY(-1px);
    }

    .ewi-bottom-nav__tab span:not(.ewi-bottom-nav__badge):not(.ewi-bottom-nav__avatar) {
        line-height: 1;
    }

    /* New posts badge */
    .ewi-bottom-nav__badge {
        position: absolute;
        top: 4px;
        left: calc(50% + 6px);
        background: #ef4444;
        color: #fff;
        font-size: 9px;
        font-weight: 700;
        line-height: 1;
        min-width: 16px;
        height: 16px;
        border-radius: 8px;
        display: flex;
        align-items: center;
        justify-content: center;
        padding: 0 3px;
        pointer-events: none;
    }

    /* Avatar initial bubble (logged-in account tab) */
    .ewi-bottom-nav__avatar {
        width: 24px;
        height: 24px;
        border-radius: 50%;
        background: rgba(77, 163, 255, 0.15);
        border: 1.5px solid rgba(77, 163, 255, 0.4);
        color: #4da3ff;
        font-size: 0.6875rem;
        font-weight: 700;
        display: flex;
        align-items: center;
        justify-content: center;
        line-height: 1;
        flex-shrink: 0;
    }

    .ewi-bottom-nav__tab.is-active .ewi-bottom-nav__avatar {
        background: rgba(77, 163, 255, 0.25);
        border-color: #4da3ff;
    }

    /* Prevent the mobile nav footer CTA from doubling up with the tab bar */
    .ewi-mobile-nav__footer {
        display: none !important;
    }
}
