/*
 * Universal Mobile Navigation Fix
 * Applies to all pages with header navigation buttons
 * Fixes overlapping mobile navigation issues
 */

/* Mobile-only fixes (max-width: 767px) */
@media screen and (max-width: 767px) {
    
    /* ULTIMATE GAP ELIMINATION: Remove any default spacing that could cause gaps */
    html, body {
        margin: 0 !important;
        padding: 0 !important;
        background: transparent !important;
        background-color: transparent !important;
    }
    
    /* OVERRIDE: Remove the white body background specifically */
    html body {
        background: transparent !important;
        background-color: transparent !important;
    }
    
    /* Ensure all elements touching navigation have zero spacing */
    * {
        box-sizing: border-box !important;
    }
    
    /* TARGETED: Remove white backgrounds only from specific gap-causing elements */
    html body .page-container,
    html body main,
    html body .container:not(.journals-header):not(.books-header),
    html body .nav-container,
    html body .journals-section,
    html body .books-section {
        background-color: transparent !important;
        /* Keep background-image for any elements that might have hero images */
    }
    
    /* RESTORE: Keep hero image backgrounds but remove white container backgrounds */
    html body .journals-header,
    html body .books-header,
    html body section.journals-header,
    html body section.books-header {
        /* DO NOT make background transparent - keep hero images */
        background-color: transparent !important; /* Only remove background-color, keep background-image */
    }
    
    /* Remove white backgrounds from pseudo-elements only */
    html body .journals-header::before,
    html body .books-header::before,
    html body .journals-header::after,
    html body .books-header::after {
        background: transparent !important;
        background-color: transparent !important;
    }
    /* Fix header - only show logo on mobile */
    html body header#header.header,
    html body .header {
        position: sticky !important;
        top: 0 !important;
        z-index: 1000 !important;
        background: rgba(255, 255, 255, 0.98) !important;
        background-image: none !important;
        backdrop-filter: blur(10px) !important;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1) !important;
        padding: 0.75rem 0 !important;
    }
    
    /* Hide header links on mobile to prevent overlap */
    html body header#header.header .header-links,
    html body .header .header-links {
        display: none !important;
    }
    
    /* Adjust header container for mobile */
    html body header#header.header .header-container,
    html body .header .header-container {
        padding: 0 1rem !important;
        justify-content: center !important; /* Center the logo */
    }
    
    /* Style the logo for mobile */
    html body .logo {
        font-size: 1.25rem !important;
    }
    
    /* Navigation menu - clean blue background */
    html body nav.nav-menu,
    html body .nav-menu {
        position: relative !important;
        z-index: 999 !important;
        background: #0c4a60 !important;
        margin-top: 0 !important;
        margin-bottom: 0 !important;
    }
    
    /* Mobile navigation links styling */
    html body .nav-links {
        display: flex !important;
        flex-direction: column !important;
        gap: 0 !important;
        margin: 0 !important;
        padding: 0.25rem 1rem !important;
        list-style: none !important;
    }
    
    html body .nav-links li {
        border-bottom: none !important;
        margin: 0 !important;
    }
    
    html body .nav-links li:last-child {
        border-bottom: none !important;
    }
    
    /* ULTRA HIGH SPECIFICITY: Override wiseleaf-size-optimization.css and wiseleaf-text-links-readable.css */
    html body nav.nav-menu ul.nav-links li a,
    html body .nav-menu ul.nav-links li a,
    html body nav.nav-menu .nav-links li a,
    html body .nav-menu .nav-links li a,
    html body .nav-container .nav-links li a,
    html body nav .nav-links li a,
    html body .nav-links li a {
        display: block !important;
        padding: 0.3rem 0 !important;
        color: white !important;
        text-decoration: none !important;
        font-size: 0.85rem !important;
        line-height: 1.2 !important;
        transition: all 0.2s ease !important;
        background: transparent !important;
        border: none !important;
        border-radius: 0 !important;
        box-shadow: none !important;
        text-shadow: none !important;
        transform: none !important;
        margin: 0 !important;
        outline: none !important;
    }
    
    /* ULTRA HIGH SPECIFICITY: Override hover states - Clean mobile hover */
    html body nav.nav-menu ul.nav-links li a:hover,
    html body .nav-menu ul.nav-links li a:hover,
    html body nav.nav-menu .nav-links li a:hover,
    html body .nav-menu .nav-links li a:hover,
    html body .nav-container .nav-links li a:hover,
    html body nav .nav-links li a:hover,
    html body .nav-links li a:hover {
        color: rgba(255, 255, 255, 0.9) !important;
        background: rgba(255, 255, 255, 0.1) !important;
        padding: 0.3rem 0.5rem !important;
        border-radius: 0 !important;
        box-shadow: none !important;
        text-shadow: none !important;
        transform: none !important;
        margin: 0 !important;
        outline: none !important;
        border: none !important;
    }
    
    /* Show mobile-only navigation items */
    .mobile-only {
        display: block !important;
    }
    
    /* MOBILE HOME BUTTON FIX: Move home button to top of navigation */
    /* Target the 7th li element which contains the home link on sub-pages */
    html body .nav-links li:nth-child(7) {
        order: -1 !important; /* Move to top */
    }
    
    /* Also target any li that contains a home icon as backup */
    html body .nav-links li.mobile-only:nth-child(7),
    html body .nav-links li.mobile-only:first-of-type {
        order: -1 !important;
    }
    
    /* Additional targeting for home links */
    html body .nav-links li:nth-child(7) a[href*="../index.html"],
    html body .nav-links li a[href*="../index.html"]:parent {
        order: -1 !important;
    }
    
    /* MOBILE GAP FIX: ULTRA HIGH SPECIFICITY - Perfect hero container sizing */
    html body .journals-header,
    html body .books-header,
    html body section.journals-header,
    html body section.books-header,
    html[lang="en"] body .journals-header,
    html[lang="en"] body .books-header,
    html[lang="en"] body section.journals-header,
    html[lang="en"] body section.books-header {
        margin: 0 !important;
        margin-top: 0 !important;
        margin-bottom: 0 !important;
        padding: 0 !important;
        padding-top: 0 !important;
        padding-bottom: 0 !important;
        border-top: none !important;
        top: 0 !important;
        /* CRITICAL: Force minimal container height */
        height: 120px !important;
        min-height: 120px !important;
        max-height: 120px !important;
        overflow: hidden !important;
        display: block !important;
    }
    
    /* Ensure no gap between navigation and content sections - NUCLEAR OPTION */
    html body nav.nav-menu + .journals-header,
    html body nav.nav-menu + .books-header,
    html body .nav-menu + .journals-header,
    html body .nav-menu + .books-header,
    html body nav.nav-menu + section.journals-header,
    html body nav.nav-menu + section.books-header,
    html body .nav-menu + section.journals-header,
    html body .nav-menu + section.books-header,
    html[lang="en"] body nav.nav-menu + .journals-header,
    html[lang="en"] body nav.nav-menu + .books-header,
    html[lang="en"] body .nav-menu + .journals-header,
    html[lang="en"] body .nav-menu + .books-header,
    html[lang="en"] body nav.nav-menu + section.journals-header,
    html[lang="en"] body nav.nav-menu + section.books-header,
    html[lang="en"] body .nav-menu + section.journals-header,
    html[lang="en"] body .nav-menu + section.books-header {
        margin: 0 !important;
        margin-top: 0 !important;
        margin-bottom: 0 !important;
        padding-top: 0 !important;
        border-top: none !important;
        top: 0 !important;
        transform: translateY(0) !important;
    }
    
    /* ADDITIONAL FIX: Remove any default spacing from all elements that could cause gaps */
    html body nav.nav-menu,
    html body .nav-menu {
        margin-bottom: 0 !important;
        padding-bottom: 0 !important;
        border-bottom: none !important;
    }
    
    /* Force immediate contact between nav and hero sections */
    html body nav.nav-menu + *,
    html body .nav-menu + * {
        margin-top: 0 !important;
        padding-top: 0 !important;
        border-top: none !important;
    }
    
    /* NUCLEAR OPTION: Force hero sections to connect with negative margins */
    html body .journals-header,
    html body .books-header,
    html body section.journals-header,
    html body section.books-header {
        margin-top: -1px !important;
        position: relative !important;
        z-index: 1 !important;
    }
    
    /* Additional aggressive fix for any remaining gaps */
    html body nav.nav-menu {
        border-bottom: 1px solid #0c4a60 !important;
        box-shadow: none !important;
    }
    
    /* Force overlap to eliminate gap */
    html body nav.nav-menu + .journals-header,
    html body nav.nav-menu + .books-header,
    html body .nav-menu + .journals-header,
    html body .nav-menu + .books-header,
    html body nav.nav-menu + section.journals-header,
    html body nav.nav-menu + section.books-header,
    html body .nav-menu + section.journals-header,
    html body .nav-menu + section.books-header {
        margin-top: -2px !important;
        position: relative !important;
        z-index: 2 !important;
        /* KEEP HERO IMAGES: Only remove background-color, not background-image */
        background-color: transparent !important;
    }
    
    /* SELECTIVE: Target gap-causing elements but preserve hero images */
    html body nav.nav-menu + *:not(.journals-header):not(.books-header),
    html body .nav-menu + *:not(.journals-header):not(.books-header) {
        background-color: transparent !important;
        border: none !important;
        outline: none !important;
        /* Preserve background-image for hero sections */
    }
    
    /* Specifically target the white space issue - but preserve hero images */
    html body .journals-header *:not(.journals-header),
    html body .books-header *:not(.books-header),
    html body section.journals-header *:not(section.journals-header),
    html body section.books-header *:not(section.books-header) {
        background-color: transparent !important;
        /* DO NOT remove background-image to preserve hero images */
    }
}

/* FOOTER MOBILE FIX: ULTRA HIGH SPECIFICITY - Ensure footer-connect section is visible on mobile */
@media screen and (max-width: 767px) {
    html body footer.wiseleaf-footer div.footer-content div.footer-section.footer-connect,
    html body footer.wiseleaf-footer .footer-content .footer-section.footer-connect,
    html body .wiseleaf-footer .footer-content .footer-section.footer-connect,
    html body .wiseleaf-footer .footer-section.footer-connect,
    html body .wiseleaf-footer .footer-connect {
        display: block !important;
        visibility: visible !important;
        opacity: 1 !important;
        order: 4 !important;
        margin: 0 !important;
        padding: 0 !important;
        height: auto !important;
        overflow: visible !important;
    }
    
    html body footer.wiseleaf-footer div.footer-section.footer-connect div.footer-newsletter,
    html body .wiseleaf-footer .footer-section.footer-connect .footer-newsletter,
    html body .wiseleaf-footer .footer-newsletter {
        display: block !important;
        visibility: visible !important;
        opacity: 1 !important;
        margin-top: 20px !important;
        height: auto !important;
        overflow: visible !important;
    }
    
    html body .wiseleaf-footer .footer-newsletter .newsletter-form,
    html body .wiseleaf-footer .newsletter-form {
        display: flex !important;
        flex-direction: column !important;
        gap: 10px !important;
        visibility: visible !important;
        opacity: 1 !important;
    }
    
    html body .wiseleaf-footer .newsletter-form .newsletter-input,
    html body .wiseleaf-footer .newsletter-input {
        width: 100% !important;
        margin-bottom: 10px !important;
        display: block !important;
        visibility: visible !important;
    }
    
    html body .wiseleaf-footer .newsletter-form .newsletter-btn,
    html body .wiseleaf-footer .newsletter-btn {
        align-self: center !important;
        width: auto !important;
        display: block !important;
        visibility: visible !important;
    }
    
    /* FORCE FOOTER GRID TO SHOW ALL SECTIONS */
    html body footer.wiseleaf-footer .footer-content,
    html body .wiseleaf-footer .footer-content {
        display: grid !important;
        grid-template-columns: 1fr !important;
        gap: 30px !important;
    }
}

/* Hide mobile-only navigation items on desktop */
@media screen and (min-width: 768px) {
    .mobile-only {
        display: none !important;
    }
}

/* Hero responsive fixes for all pages */
@media screen and (max-width: 767px) {
    /* Hero sections on all pages */
    html body .hero,
    html body section.hero,
    html body .about-hero,
    html body .page-hero {
        padding: 2rem 1rem !important;
        min-height: 40vh !important;
        background-size: cover !important;
        background-position: center center !important;
        background-attachment: scroll !important;
        background-repeat: no-repeat !important;
    }
    
    /* Help hero uses its own height settings */
    html body .help-hero {
        background-size: cover !important;
        background-position: center center !important;
        background-attachment: scroll !important;
        background-repeat: no-repeat !important;
    }
    
    /* Override any CSS that removes background images - PRESERVE CSS BACKGROUNDS */
    html body .hero[style*="background-image"],
    html body section.hero[style*="background-image"],
    html body .help-hero[style*="background-image"],
    html body .about-hero[style*="background-image"],
    html body .page-hero,
    html body .registration-hero {
        background-size: cover !important;
        background-position: center center !important;
        background-repeat: no-repeat !important;
        background-attachment: scroll !important;
    }
}

/* Desktop hero adjustments */
@media screen and (min-width: 768px) {
    html body .hero,
    html body section.hero,
    html body .about-hero,
    html body .page-hero {
        min-height: 60vh !important;
        padding: 4rem 1rem !important;
    }
    
    /* Help hero uses its own height and padding settings */
}

/* Ensure hero backgrounds work on all devices */
html body .hero,
html body section.hero,
html body .help-hero,
html body .about-hero,
html body .page-hero {
    background-size: cover !important;
    background-position: center center !important;
    background-repeat: no-repeat !important;
    background-attachment: scroll !important;
}

/* SPECIAL: Help hero needs background fallback but not override */
html body .help-hero {
    background-color: #0c4a60 !important;
}

/* CRITICAL FIX: Override minified CSS that hides hero text - EXCEPT webinars page-hero */
html body .hero.about-hero .hero-title,
html body .hero.about-hero .hero-subtitle,
html body .hero.about-hero .hero-description,
html body section.hero.about-hero .hero-title,
html body section.hero.about-hero .hero-subtitle,
html body section.hero.about-hero .hero-description,
html body .hero.registration-hero .hero-title,
html body .hero.registration-hero .hero-subtitle,
html body .hero.registration-hero .hero-description {
    display: block !important;
    opacity: 1 !important;
    visibility: visible !important;
    color: white !important;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.7) !important;
    z-index: 10 !important;
    position: relative !important;
}

/* Allow webinars-images.css to control page-hero text visibility */

/* Mobile responsive JavaScript override for all pages */
@media screen and (max-width: 767px) {
    html body .hero[style*="background-image"],
    html body section.hero[style*="background-image"],
    html body .help-hero[style*="background-image"],
    html body .about-hero[style*="background-image"],
    html body .page-hero[style*="background-image"] {
        background-size: cover !important;
        background-position: center center !important;
        background-attachment: scroll !important;
        background-repeat: no-repeat !important;
    }
}