/**
 * Mobile Menu & Navigation Components
 * Mobile First Approach
 */

/* ============================================================================
   MOBILE MENU CONTAINER
   ============================================================================ */
.mobile-menu {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 999;
    pointer-events: none;
    transition: opacity 0.3s ease;
    opacity: 0;
}

.mobile-menu.is-active {
    pointer-events: auto;
    opacity: 1;
}

/* Dark overlay */
.mobile-menu-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    opacity: 0;
    transition: opacity 0.3s ease;
}

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

/* ============================================================================
   MOBILE MENU CONTENT
   ============================================================================ */
.mobile-menu-content {
    position: absolute;
    top: 0;
    right: 0;
    width: 85%;
    max-width: 400px;
    height: 100%;
    background: white;
    transform: translateX(100%);
    transition: transform 0.3s ease;
    overflow-y: auto;
    padding: calc(var(--header-height) + var(--header-top-height)) 0 30px;
    box-shadow: -5px 0 20px rgba(0, 0, 0, 0.1);
}

/* Slide in from right */
.mobile-menu.is-active .mobile-menu-content {
    transform: translateX(0);
}

/* Alternative: Slide from top */
.mobile-menu-content.slide-from-top {
    top: var(--header-height);
    right: 0;
    left: 0;
    width: 100%;
    max-width: none;
    height: auto;
    max-height: calc(100vh - var(--header-height));
    transform: translateY(-100%);
}

.mobile-menu.is-active .mobile-menu-content.slide-from-top {
    transform: translateY(0);
}

.mobile-cta-buttons {
    padding: 20px;
    border-top: 1px solid #e0e0e0;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.mobile-cta {
    width: 100%;
    text-align: center;
}

/* ============================================================================
   MOBILE NAVIGATION MENU
   ============================================================================ */
.mobile-nav-menu {
    list-style: none;
    margin: 0;
    padding: 20px 0;
}

.mobile-nav-menu li {
    border-bottom: 1px solid #e0e0e0;
}

.mobile-nav-menu a {
    display: block;
    padding: 15px 20px;
    color: var(--text-color);
    text-decoration: none;
    font-size: 16px;
    transition: var(--transition);
    position: relative;
}

.mobile-nav-menu a:active {
    background: #f5f5f5;
}

/* Current page indicator */
.mobile-nav-menu .current-menu-item > a {
    color: var(--accent-color);
    font-weight: 600;
}

.mobile-nav-menu .current-menu-item > a::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 20px;
    background: var(--accent-color);
}

/* ============================================================================
   MOBILE SUBMENU
   ============================================================================ */
   
.mobile-nav-menu .menu-item-has-children {
    position: relative;
}

/* Submenu toggle button */
.submenu-toggle {
    position: absolute;
    right: 0;
    top: 4px;
    width: 50px;
    height: 50px;
    background: none;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2;
}

.submenu-toggle::after {
    content: url(https://85.10.154.84/~themajohn/wp-content/uploads/2025/08/chevron-down-grey.svg);
    font-size: 24px;
    color: var(--text-color);
    transition: transform 0.3s ease;
    top: 7px;
    position: absolute;
}

.submenu-toggle.is-open::after {
    transform: rotatex(180deg);
    top: 14px;
}

/* Submenu container */
.mobile-nav-menu .sub-menu {
    display: none;
    list-style: none;
    margin: 0;
    padding: 0;
    background: #f9f9f9;
}

.mobile-nav-menu .sub-menu.is-open {
    display: block;
    animation: slideDown 0.3s ease;
}

@keyframes slideDown {
    from {
        opacity: 0;
        max-height: 0;
    }
    to {
        opacity: 1;
        max-height: 500px;
    }
}

/* Submenu items */
.mobile-nav-menu .sub-menu li {
    border-bottom: 1px solid #e0e0e0;
}

.mobile-nav-menu .sub-menu a {
    padding-left: 40px;
    font-size: 15px;
}

/* Third level submenu */
.mobile-nav-menu .sub-menu .sub-menu {
    background: #f0f0f0;
}

.mobile-nav-menu .sub-menu .sub-menu a {
    padding-left: 60px;
    font-size: 14px;
}

/* ============================================================================
   MOBILE CTA BUTTON
   ============================================================================ */
.mobile-cta {
    display: block;
    text-align: center;
    padding: 15px 20px;
    background: var(--accent-color);
    color: white;
    text-decoration: none;
    border-radius: 4px;
    font-weight: 600;
}

/* ============================================================================
   BODY STATES
   ============================================================================ */
body.menu-open {
    overflow: hidden;
    position: fixed;
    width: 100%;
}

/* ============================================================================
   ACCESSIBILITY
   ============================================================================ */
.mobile-menu[aria-hidden="true"] {
    visibility: hidden;
}

.mobile-menu[aria-hidden="false"] {
    visibility: visible;
}

/* Focus styles */
.mobile-nav-menu a:focus,
.submenu-toggle:focus {
    outline: 2px solid var(--accent-color);
    outline-offset: 2px;
}

/* ============================================================================
   ANIMATIONS & TRANSITIONS
   ============================================================================ */
.mobile-nav-menu li {
    opacity: 0;
    transform: translateX(20px);
    animation: fadeInRight 0.3s ease forwards;
}

.mobile-menu.is-active .mobile-nav-menu li {
    animation-delay: calc(var(--item-index, 0) * 0.05s);
}

@keyframes fadeInRight {
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* Stagger animation for menu items */
.mobile-nav-menu li:nth-child(1) { --item-index: 1; }
.mobile-nav-menu li:nth-child(2) { --item-index: 2; }
.mobile-nav-menu li:nth-child(3) { --item-index: 3; }
.mobile-nav-menu li:nth-child(4) { --item-index: 4; }
.mobile-nav-menu li:nth-child(5) { --item-index: 5; }
.mobile-nav-menu li:nth-child(6) { --item-index: 6; }
.mobile-nav-menu li:nth-child(7) { --item-index: 7; }
.mobile-nav-menu li:nth-child(8) { --item-index: 8; }

/* ============================================================================
   DESKTOP OVERRIDES (1024px and up)
   ============================================================================ */
@media (min-width: 1024px) {
    /* Hide mobile menu completely */
    .mobile-menu {
        display: none !important;
    }
    
    /* Ensure body is never locked on desktop */
    body.menu-open {
        overflow: auto;
        position: static;
    }
}