/* Mobile Homepage Layout Fixes */

/* Mobile Menu Styles */
@media screen and (max-width: 640px) {
    /* Hide desktop menu on mobile */
    .main-nav__nav-bar {
        display: none !important;
    }
    
    /* Show mobile menu button */
    .main-nav__menu-toggle {
        display: block !important;
        background: #000;
        color: #fff;
        border: none;
        padding: 10px 15px;
        position: relative;
        z-index: 1001;
    }
    
    /* Mobile menu overlay styles */
    #mobileNav {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100vh;
        background: rgba(51, 34, 17, 0.85);
        z-index: 1000;
        padding: 20px;
        box-sizing: border-box;
        overflow-y: auto;
    }
    
    #mobileNav ul {
        list-style: none;
        padding: 0;
        margin: 40px 0 0 0;
    }
    
    #mobileNav li {
        margin-bottom: 20px;
    }
    
    #mobileNav a {
        color: #fff;
        font-size: 18px;
        text-decoration: none;
        display: block;
        padding: 10px 0;
        border-bottom: 1px solid rgba(255,255,255,0.2);
    }
    
    #mobileNav .close-button {
        position: absolute;
        top: 20px;
        right: 20px;
        background: none;
        border: none;
        color: #fff;
        font-size: 30px;
        cursor: pointer;
        z-index: 1001;
    }
    
    /* Fix homepage layout stacking on mobile */
    .row {
        margin-left: -0.625rem;
        margin-right: -0.625rem;
    }
    
    /* Ensure proper stacking of Articles and Events sections */
    .small-12.medium-8.columns,
    .small-12.medium-4.columns {
        clear: both;
        float: none;
        width: 100%;
        margin-bottom: 20px;
    }
    
    /* Prevent overlapping content */
    .vspace-small-12 {
        margin-bottom: 20px !important;
        clear: both;
    }
    
    /* Fix slideshow on mobile */
    .slideshow {
        margin-bottom: 20px;
        clear: both;
    }
    
    /* Article tiles responsive spacing */
    .article-tile {
        margin-bottom: 20px;
        clear: both;
    }
    
    /* Fix any floating issues */
    .row::after {
        content: "";
        display: table;
        clear: both;
    }
    
    /* Upcoming Events section - ensure it doesn't overlap */
    .small-12.medium-4.columns {
        position: relative;
        z-index: 1;
        background: #fff;
        padding-top: 20px;
    }
    
    /* Recent Articles section */
    .small-12.medium-8.columns {
        position: relative;
        z-index: 2;
        background: #fff;
        padding-bottom: 20px;
    }
}

/* Fix subnav overlap issue */
.subnav.subnav--main {
    height: auto !important;
    min-height: 53px;
    line-height: 1.3;
}


/* NUCLEAR OPTION: Override ALL subnav spacing AND container height */
.subnav.subnav--main {
    height: auto !important;
    min-height: auto !important;
    white-space: normal !important;
    overflow: visible !important;
}

/* Override the specific SCSS breakpoint that forces 53px height */
@media screen and (min-width: 1025px) and (max-width: 1156px) {
    .subnav.subnav--main {
        height: auto !important;
        min-height: auto !important;
        white-space: normal !important;
        overflow: visible !important;
        line-height: 1 !important;
    }
    
    /* CRITICAL: Remove line spacing for non-articles sections */
    .subnav.subnav--main:not(.articles) .subnav__item {
        line-height: 1 !important;
        margin-bottom: 0 !important;
        padding-bottom: 0.7rem !important;
        vertical-align: top !important;
    }
    
    /* Only articles section gets the line spacing */
    .subnav.subnav--main.articles .subnav__item {
        line-height: 1.3 !important;
        padding-bottom: 0.9rem !important;
        margin-bottom: 0 !important;
    }
}

.subnav .subnav__item {
    margin-bottom: 0 !important;
    padding-bottom: 0 !important;
}

/* Add 0.7rem padding for non-articles sections */
.subnav:not(.articles) .subnav__item {
    padding-bottom: 0.7rem !important;
}

/* BRUTAL OVERRIDE: Articles selected items get 16px, audio-programs gets 12px */
@media screen and (min-width: 1025px) {
    /* Reset all selected item anchor padding to 16px first */
    .subnav .subnav__item--is-selected > a {
        padding-bottom: 16px !important;
    }
    
    /* Then brutally override ONLY audio-programs to 12px */
    .subnav.audio-programs .subnav__item--is-selected > a {
        padding-bottom: 12px !important;
    }
}

.subnav.articles .subnav__item {
    padding-bottom: 0.9rem !important;
}

@media screen and (min-width: 1025px) {
    /* Allow container to grow naturally */
    .subnav.subnav--main {
        height: auto !important;
        min-height: auto !important;
        white-space: normal !important;
        overflow: visible !important;
    }
    
    /* Reset padding AND margin for all subnav items */
    .subnav.subnav--main .subnav__item {
        padding-bottom: 0 !important;
        margin-bottom: 0 !important;
    }
    
    /* Apply 0.7rem padding to non-articles sections */
    .subnav.subnav--main:not(.articles) .subnav__item {
        padding-bottom: 0.7rem !important;
        margin-bottom: 0 !important;
    }
    
    /* Apply 0.9rem padding to articles section */
    .subnav.subnav--main.articles .subnav__item {
        padding-bottom: 0.9rem !important;
        margin-bottom: 0 !important;
    }
    
    /* Apply padding to selected items in articles section only */
    .subnav.subnav--main.articles .subnav__item.subnav__item--is-selected {
        padding-bottom: 0.9rem !important;
        margin-bottom: 0 !important;
    }
}

@media screen and (min-width: 1025px) and (max-width: 1156px) {
    .subnav.subnav--main {
        height: auto !important;
        min-height: auto !important;
        white-space: normal !important;
        overflow: visible !important;
        padding-bottom: 10px;
    }
    
    .subnav.subnav--main .subnav__item {
        margin-bottom: 0 !important;
        padding-bottom: 0 !important;
        display: inline-block;
        vertical-align: top;
    }
    
    /* Non-articles sections get 0.7rem padding */
    .subnav.subnav--main:not(.articles) .subnav__item {
        margin-bottom: 0 !important;
        padding-bottom: 0.7rem !important;
    }
    
    /* Articles section gets 0.9rem padding */
    .subnav.subnav--main.articles .subnav__item {
        margin-bottom: 0 !important;
        padding-bottom: 0.9rem !important;
    }
}

/* Tablet and small desktop adjustments */
@media screen and (min-width: 641px) and (max-width: 1024px) {
    /* Ensure proper spacing on tablets */
    .vspace-small-12 {
        margin-bottom: 30px;
    }
    
    /* Hide mobile menu toggle on larger screens */
    .main-nav__menu-toggle {
        display: none !important;
    }
    
    #mobileNav {
        display: none !important;
    }
}