/* Aggressive reset for all non-active mobile-nav-links in all states */
.mobile-nav-links a:not(.active-page),
.mobile-nav-links a:not(.active-page):focus,
.mobile-nav-links a:not(.active-page):active,
.mobile-nav-links a:not(.active-page):visited,
.mobile-nav-links a:not(.active-page):hover {
    color: white !important;
    background: none !important;
    border: none !important;
    font-weight: 500 !important;
    outline: none !important;
    box-shadow: none !important;
    text-decoration: none !important;
}
/* Ensure only .active-page is bold, all others normal */
.mobile-nav-links a:not(.active-page) {
    font-weight: 500 !important;
}
/* Fix: Remove border from all non-active mobile-nav-links, even on focus/active */
.mobile-nav-links a:not(.active-page):focus,
.mobile-nav-links a:not(.active-page):active {
    border: none !important;
    outline: none !important;
    background: none !important;
}
/**
 * Mobile Menu Component
 * Reusable mobile navigation menu with iPhone optimizations
 * Version: 1.0
 */

/* ==========================================================================
   Mobile Menu Button
   ========================================================================== */

.mobile-menu-btn {
    display: none;
    flex-direction: column;
    cursor: pointer;
    padding: 0.5rem;
    background: none;
    border: none;
    z-index: 1001;
}

.hamburger-line {
    width: 25px;
    height: 3px;
    background: #2d5016;
    margin: 3px 0;
    transition: all 0.3s ease;
    border-radius: 2px;
}

.mobile-menu-btn.active .hamburger-line:nth-child(1) {
    transform: rotate(45deg) translate(5px, 5px);
}

.mobile-menu-btn.active .hamburger-line:nth-child(2) {
    opacity: 0;
}

.mobile-menu-btn.active .hamburger-line:nth-child(3) {
    transform: rotate(-45deg) translate(7px, -6px);
}

/* ==========================================================================
   Mobile Menu Overlay
   ========================================================================== */

.mobile-menu-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100vh;
    height: 100dvh;
    background: rgba(0, 0, 0, 0.5);
    z-index: 999;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    /* iOS Safari optimizations */
    -webkit-tap-highlight-color: transparent;
    touch-action: none;
}

.mobile-menu-overlay.active {
    opacity: 1;
    visibility: visible;
}

/* ==========================================================================
   Mobile Menu Container
   ========================================================================== */

.mobile-menu {
    position: fixed;
    top: 0;
    right: -320px;
    width: 320px;
    height: 100vh;
    height: 100dvh;
    min-height: 100vh;
    min-height: 100dvh;
    background: linear-gradient(135deg, #2d5016, #3d6b1f);
    z-index: 1000;
    transition: right 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    padding: 6rem 1.5rem 0;
    padding-bottom: calc(1rem + env(safe-area-inset-bottom, 20px));
    box-shadow: -5px 0 25px rgba(0, 0, 0, 0.15);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    display: flex;
    flex-direction: column;
}

.mobile-menu.active {
    right: 0;
}

/* ==========================================================================
   Mobile Menu Navigation
   ========================================================================== */

.mobile-nav-links {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    list-style: none;
    flex: 1;
    margin: 0;
    padding: 0;
}

.mobile-nav-links a {
    color: white;
    text-decoration: none;
    font-size: 1.1rem;
    font-weight: 500;
    padding: 0.8rem 1rem;
    border: none;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    transition: all 0.3s ease;
    display: block;
    outline: none;
    margin: 0;
    box-sizing: border-box;
}

.mobile-nav-links a:hover,
.mobile-nav-links a:focus {
    color: #c8e6c9;
    padding-left: 1rem;
    border: none;
    outline: none;
}

.mobile-nav-links a.active-page {
    color: #c8e6c9;
    background: rgba(255, 255, 255, 0.1);
    border: 2px solid #c8e6c9;
    border-radius: 8px;
    font-weight: 600;
    margin: 0.2rem 0;
    padding: 0.6rem 1rem;
    outline: none;
    box-sizing: border-box;
}

.mobile-nav-links a.active-page:hover,
.mobile-nav-links a.active-page:focus {
    padding-left: 1rem;
    border: 2px solid #c8e6c9;
    outline: none;
}

/* ==========================================================================
   Mobile Menu Footer
   ========================================================================== */

.mobile-menu-footer {
    flex-shrink: 0;
    margin-top: auto;
    padding: 1rem 1.5rem;
    padding-bottom: calc(1rem + env(safe-area-inset-bottom, 20px));
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.mobile-contact-info {
    color: rgba(255, 255, 255, 0.8);
    font-size: 0.85rem;
    line-height: 1.5;
}

.mobile-contact-info p {
    margin-bottom: 0.3rem;
}

.mobile-contact-info a {
    color: white;
    text-decoration: none;
    font-weight: 500;
    transition: color 0.3s ease;
}

.mobile-contact-info a:hover,
.mobile-contact-info a:focus {
    color: #c8e6c9;
}

/* ==========================================================================
   Responsive Design
   ========================================================================== */

/* Show mobile menu button on mobile devices */
@media (max-width: 768px) {
    .nav-links {
        display: none;
    }
    
    .mobile-menu-btn {
        display: flex;
    }
    
    .nav-container {
        padding: 0 1rem;
    }
    
    .mobile-menu {
        width: 280px;
        right: -280px;
    }
    
    .mobile-menu.active {
        right: 0;
    }
}

/* ==========================================================================
   iOS Safari Optimizations
   ========================================================================== */

/* iPhone specific optimizations using feature detection */
@supports (-webkit-touch-callout: none) {
    .mobile-menu {
        width: 300px !important;
        right: -300px !important;
        height: 100vh !important;
        height: 100dvh !important;
        min-height: 100vh !important;
        min-height: 100dvh !important;
        padding: 5rem 1.5rem 0 !important;
        padding-bottom: calc(2rem + env(safe-area-inset-bottom, 30px)) !important;
        /* Enhanced iOS performance */
        -webkit-backface-visibility: hidden;
        backface-visibility: hidden;
        will-change: right;
        -webkit-overflow-scrolling: touch !important;
        overflow-y: auto !important;
    }
    
    .mobile-menu.active {
        right: 0 !important;
    }
    
    .mobile-nav-links {
        overflow-y: visible !important;
        flex-shrink: 0 !important;
    }
    
    .mobile-menu-footer {
        padding: 1rem 1.5rem !important;
        padding-bottom: calc(2rem + env(safe-area-inset-bottom, 30px)) !important;
        flex-shrink: 0 !important;
        margin-bottom: 0 !important;
    }
}

/* iPhone device targeting with pixel ratio detection */
@media only screen and (max-device-width: 430px) and (-webkit-device-pixel-ratio: 2),
       only screen and (max-device-width: 430px) and (-webkit-device-pixel-ratio: 3) {
    .mobile-menu {
        padding: 4rem 1.2rem 0 !important;
        height: 100vh !important;
        height: 100dvh !important;
        max-height: none !important;
        min-height: 100vh !important;
        min-height: 100dvh !important;
        overflow-y: auto !important;
        -webkit-overflow-scrolling: touch !important;
    }
    
    .mobile-nav-links {
        flex: 1 !important;
        min-height: 0 !important;
        gap: 1.2rem !important;
    }
    
    .mobile-nav-links a {
        padding: 0.7rem 0 !important;
        font-size: 1rem !important;
    }
    
    .mobile-menu-footer {
        flex-shrink: 0 !important;
        padding: 0.8rem 1.2rem !important;
        padding-bottom: calc(1rem + env(safe-area-inset-bottom, 20px)) !important;
        margin-bottom: 0 !important;
    }
    
    .mobile-contact-info {
        font-size: 0.8rem !important;
    }
}

/* ==========================================================================
   Accessibility Improvements
   ========================================================================== */

/* Focus management */
.mobile-menu-btn:focus {
    outline: 2px solid #2d5016;
    outline-offset: 2px;
}

.mobile-nav-links a:focus,
.mobile-contact-info a:focus {
    outline: 2px solid #c8e6c9;
    outline-offset: 2px;
}

/* Reduced motion preferences */
@media (prefers-reduced-motion: reduce) {
    .mobile-menu,
    .mobile-menu-overlay,
    .hamburger-line,
    .mobile-nav-links a,
    .mobile-contact-info a {
        transition: none;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .mobile-menu {
        background: #1a1a1a;
        border-left: 2px solid #ffffff;
    }
    
    .mobile-nav-links a {
        border-bottom-color: #ffffff;
    }
    
    .mobile-menu-footer {
        border-top-color: #ffffff;
    }
}