/* ============================================
   MS INFO CHANNEL - Mobile Responsive Fixes
   Comprehensive mobile optimization layer
   Applied on top of styles.css + page-styles.css
   ============================================ */

/* ---- 1. Prevent horizontal overflow globally ---- */
html,
body {
    overflow-x: hidden;
    max-width: 100%;
}

/* Ensure all images never overflow */
img {
    max-width: 100%;
    height: auto;
}

/* ---- 2. Container: safe padding on mobile ---- */
@media (max-width: 600px) {
    .container {
        padding: 0 1rem;
    }
}

/* ---- 3. Navigation: hamburger breakpoint fix ---- */
/* The previous @media (max-width: 2600px) rule made the drawer
   always active. We override the desktop nav to be inline at >768px */
@media (min-width: 769px) {
    .nav-menu {
        position: static !important;
        right: auto !important;
        width: auto !important;
        max-width: none !important;
        height: auto !important;
        background: transparent !important;
        flex-direction: row !important;
        align-items: center !important;
        padding: 0 !important;
        box-shadow: none !important;
        border-left: none !important;
        transform: none !important;
        z-index: auto !important;
        overflow-y: visible !important;
    }

    .hamburger {
        display: none !important;
    }

    .mobile-nav-overlay {
        display: none !important;
    }
}

/* Mobile nav drawer (<=768px) */
@media (max-width: 768px) {
    .nav-menu {
        position: fixed !important;
        top: 0 !important;
        right: -100% !important;
        left: auto !important;
        width: 85% !important;
        max-width: 320px !important;
        height: 100vh !important;
        background: rgba(10, 26, 20, 0.99) !important;
        flex-direction: column !important;
        align-items: flex-start !important;
        padding: 90px 1.5rem 2rem !important;
        transition: right 0.3s ease !important;
        box-shadow: -4px 0 24px rgba(0, 0, 0, 0.5) !important;
        z-index: 9999 !important;
        overflow-y: auto !important;
        gap: 0 !important;
        transform: none !important;
    }

    .nav-menu.active {
        right: 0 !important;
        transform: none !important;
    }

    .hamburger {
        display: flex !important;
        flex-direction: column !important;
        gap: 5px !important;
        padding: 8px !important;
        z-index: 10001 !important;
    }

    .nav-menu .nav-link {
        font-size: 1rem !important;
        padding: 0.75rem 1rem !important;
        border-bottom: 1px solid rgba(255, 255, 255, 0.1) !important;
        width: 100% !important;
        display: block !important;
        white-space: normal !important;
    }

    /* Search box in mobile nav */
    .search-container {
        width: 100% !important;
        margin-top: 0.5rem !important;
    }

    .search-box {
        width: 100% !important;
    }

    .search-box input {
        width: 100% !important;
        flex: 1 !important;
    }
}

/* ---- 4. Header TOC: hide on small screens ---- */
@media (max-width: 768px) {
    .header-toc {
        display: none !important;
    }
}

/* ---- 5. Affiliate banner: prevent overflow ---- */
@media (max-width: 768px) {
    .affiliate-item {
        min-width: 0 !important;
        max-width: 100% !important;
        flex-shrink: 1 !important;
    }

    .affiliate-item img {
        max-width: 100% !important;
        width: auto !important;
        height: auto !important;
        max-height: 50px !important;
    }
}

/* ---- 6. Hero section: readable on mobile ---- */
@media (max-width: 768px) {
    .hero {
        padding-top: 300px !important;
        padding-bottom: 4rem !important;
        background-attachment: scroll !important; /* Fix iOS parallax bug */
    }

    .hero-title {
        font-size: clamp(1.6rem, 7vw, 2.5rem) !important;
        word-break: break-word !important;
    }

    .hero-subtitle {
        font-size: 1rem !important;
    }

    .hero-stats {
        flex-wrap: wrap !important;
        gap: 1rem !important;
        justify-content: center !important;
    }

    .stat-number {
        font-size: 1.75rem !important;
    }
}

@media (max-width: 480px) {
    .hero {
        padding-top: 260px !important;
    }

    .hero-badge {
        font-size: 0.8rem !important;
        padding: 0.4rem 0.75rem !important;
    }
}

/* ---- 7. Topics / Article grid: single column on mobile ---- */
@media (max-width: 768px) {
    .topics-grid {
        grid-template-columns: 1fr !important;
        gap: 1.25rem !important;
    }

    .topic-card-image {
        height: 180px !important;
    }
}

/* ---- 8. Floating images: un-float on mobile ---- */
@media (max-width: 768px) {
    .image-float-right,
    .image-float-left {
        float: none !important;
        width: 100% !important;
        max-width: 100% !important;
        margin: 0 0 1.5rem 0 !important;
    }
}

/* ---- 9. Comparison cards: single column on mobile ---- */
@media (max-width: 600px) {
    .comparison-cards {
        grid-template-columns: 1fr !important;
    }

    .categories-grid {
        grid-template-columns: 1fr !important;
    }

    .quality-grid {
        grid-template-columns: 1fr !important;
    }
}

/* ---- 10. Tables: horizontal scroll wrapper ---- */
.comparison-table,
.symptom-table {
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch !important;
}

@media (max-width: 600px) {
    .comparison-table table,
    .symptom-table table {
        min-width: 480px;
    }

    .comparison-table th,
    .comparison-table td,
    .symptom-table th,
    .symptom-table td {
        padding: 0.5rem 0.6rem !important;
        font-size: 0.8rem !important;
    }
}

/* ---- 11. Podcast section: stack on mobile ---- */
@media (max-width: 768px) {
    .podcast-wrapper {
        grid-template-columns: 1fr !important;
        gap: 2rem !important;
    }

    .podcast-card {
        flex-direction: column !important;
        text-align: center !important;
        padding: 1rem !important;
    }

    .podcast-cover {
        width: 80px !important;
        height: 80px !important;
        margin: 0 auto !important;
    }

    .podcast-details {
        text-align: left !important;
    }

    .podcast-features {
        flex-wrap: wrap !important;
        gap: 0.5rem !important;
    }
}

/* ---- 12. Newsletter: stack on mobile ---- */
@media (max-width: 600px) {
    .newsletter-wrapper {
        flex-direction: column !important;
        text-align: center !important;
        gap: 1.5rem !important;
    }

    .newsletter-form {
        flex-direction: column !important;
        width: 100% !important;
    }

    .newsletter-form input,
    .newsletter-form button,
    .newsletter-input {
        width: 100% !important;
        min-width: 0 !important;
    }
}

/* ---- 13. Footer: single column on mobile ---- */
@media (max-width: 768px) {
    .footer-grid {
        grid-template-columns: 1fr !important;
        text-align: center !important;
        gap: 2rem !important;
    }

    .footer-brand p {
        max-width: 100% !important;
    }

    .social-links {
        justify-content: center !important;
    }

    .footer-links {
        display: flex !important;
        flex-direction: column !important;
        align-items: center !important;
        gap: 0.5rem !important;
    }

    .footer-bottom {
        text-align: center !important;
        padding: 1rem 0 !important;
        font-size: 0.85rem !important;
    }
}

/* ---- 14. Ad slots: never overflow ---- */
ins.adsbygoogle {
    max-width: 100% !important;
}

.footer-ad-container {
    max-width: 100% !important;
    overflow: hidden !important;
    padding: 0 1rem !important;
}

@media (max-width: 600px) {
    .footer-ad-container {
        padding: 0 0.5rem !important;
    }
}

/* ---- 15. Page hero on inner pages: adequate padding ---- */
@media (max-width: 768px) {
    .page-hero {
        padding-top: 300px !important;
        min-height: auto !important;
        height: auto !important;
    }

    .page-hero-content {
        padding: 1rem !important;
    }

    .page-hero h1 {
        font-size: clamp(1.5rem, 6vw, 2rem) !important;
        word-break: break-word !important;
    }

    .page-intro {
        font-size: 1rem !important;
    }

    .page-meta {
        flex-wrap: wrap !important;
        gap: 0.5rem !important;
        justify-content: center !important;
    }
}

@media (max-width: 480px) {
    .page-hero {
        padding-top: 240px !important;
    }
}

/* ---- 16. Sidebar TOC: hidden on mobile ---- */
@media (max-width: 1200px) {
    .toc-sidebar {
        display: none !important;
    }
}

/* ---- 17. Content sections: readable font, padding ---- */
@media (max-width: 600px) {
    .content-section h2 {
        font-size: 1.35rem !important;
        word-break: break-word !important;
    }

    .content-section h3 {
        font-size: 1.1rem !important;
    }

    .content-section p {
        font-size: 0.9375rem !important;
        line-height: 1.7 !important;
    }

    .article-content {
        padding: 0 0.25rem !important;
    }

    .highlight-box {
        padding: 1rem !important;
    }

    .info-box {
        flex-direction: column !important;
        gap: 0.75rem !important;
        padding: 1rem !important;
    }
}

/* ---- 18. Sorten/strain cards grid ---- */
@media (max-width: 768px) {
    .strain-cards,
    .related-grid,
    .strain-grid,
    .pilze-grid,
    .heilpflanzen-grid,
    .terpene-grid,
    .vitalpilze-grid,
    .studies-grid,
    .podcast-episodes-grid {
        grid-template-columns: 1fr !important;
    }
}

@media (max-width: 900px) and (min-width: 601px) {
    .strain-cards,
    .related-grid,
    .strain-grid,
    .pilze-grid,
    .heilpflanzen-grid,
    .terpene-grid,
    .vitalpilze-grid,
    .studies-grid,
    .podcast-episodes-grid {
        grid-template-columns: 1fr 1fr !important;
    }
}

/* ---- 19. Cookie banner: readable on mobile ---- */
@media (max-width: 600px) {
    #cookie-banner > div {
        flex-direction: column !important;
        gap: 12px !important;
        text-align: center !important;
    }

    #cookie-banner > div > div {
        width: 100% !important;
        justify-content: center !important;
    }

    #cookie-banner button {
        flex: 1 !important;
    }
}

/* ---- 20. App Beta banner: already has mobile styles, ensure buttons wrap ---- */
@media (max-width: 480px) {
    .app-beta-content {
        gap: 8px !important;
    }

    .app-beta-text {
        font-size: 0.85rem !important;
    }

    .app-beta-btn {
        font-size: 0.8rem !important;
        padding: 6px 12px !important;
        min-height: 40px !important;
    }
}

/* ---- 21. Back-to-top & theme toggle: don't overlap on mobile ---- */
@media (max-width: 480px) {
    .back-to-top {
        width: 42px !important;
        height: 42px !important;
        right: 12px !important;
        bottom: 12px !important;
        font-size: 1.2rem !important;
    }

    .theme-toggle {
        width: 42px !important;
        height: 42px !important;
        right: 12px !important;
        bottom: 64px !important;
        font-size: 1.2rem !important;
    }
}

/* ---- 22. Body text minimum readable size ---- */
body {
    font-size: max(14px, 1rem);
    line-height: 1.65;
}

/* ---- 23. Touch target minimum size ---- */
@media (max-width: 768px) {
    .nav-link,
    .topic-link,
    .app-beta-btn,
    .podcast-play-btn,
    .back-btn {
        min-height: 44px;
    }
}

/* ---- 24. Mega-menu: no min-width on desktop causing overflow ---- */
@media (max-width: 1100px) {
    .mega-menu {
        min-width: 300px !important;
    }
}
