/**
 * SerraFi Mobile Menu Styles
 * 
 * Full-screen mobile menu with smooth animations, accordion sections,
 * and responsive typography following the design requirements.
 */

/* ========================================
   Mobile Menu Overlay & Panel
   ======================================== */

.mobile-menu-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 9999;
    display: none !important;
    
    /* Initially hidden, animate when opened */
    opacity: 0;
    visibility: hidden;
    transition: opacity 200ms ease-out, visibility 200ms ease-out;
}

/* Explicitly ensure closed state */
.mobile-menu-overlay:not(.mobile-menu-open) {
    display: none !important;
    opacity: 0 !important;
    visibility: hidden !important;
}

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

.mobile-menu-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
}

.mobile-menu-panel {
    position: relative;
    width: 100%;
    height: 100%;
    background: #ffffff;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    
    /* Slide in animation */
    transform: translateY(100%);
    transition: transform 200ms ease-out;
}

.mobile-menu-overlay.mobile-menu-open .mobile-menu-panel {
    transform: translateY(0);
}

/* ========================================
   Menu Header & Close Button
   ======================================== */

.mobile-menu-header {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    padding: 17px 20px 16px;
    border-bottom: 1px solid #f1f3f4;
}

.mobile-menu-close {
    background: none;
    border: none;
    padding: 12px;
    margin: -12px -12px -12px 0;
    cursor: pointer;
    border-radius: 8px;
    transition: background-color 150ms ease;
    
    /* Ensure 48px tap target */
    min-width: 48px;
    min-height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.mobile-menu-close:hover {
    background: #f8f9fa;
}

.mobile-menu-close:focus {
    outline: 2px solid #007bff;
    outline-offset: 2px;
}

.mobile-menu-close svg {
    width: 24px;
    height: 24px;
    color: #374151;
}

/* ========================================
   Menu Content & Sections
   ======================================== */

.mobile-menu-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 0 20px 20px;
}

.mobile-menu-sections {
    flex: 1;
}

/* ========================================
   Accordion Sections
   ======================================== */

.mobile-menu-accordion {
    border-bottom: 1px solid #f1f3f4;
}

.mobile-menu-accordion:last-child {
    border-bottom: none;
}

.mobile-menu-accordion-trigger {
    width: 100%;
    background: none;
    border: none;
    padding: 20px 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
    
    /* Ensure 48px tap target */
    min-height: 48px;
    
    /* Typography */
    font-family: inherit;
    text-align: left;
}

.mobile-menu-accordion-trigger:focus {
    outline: 2px solid #007bff;
    outline-offset: -2px;
    border-radius: 4px;
}

.mobile-menu-accordion-title {
    font-size: 18px;
    font-weight: 600;
    color: #111827;
    line-height: 1.4;
}

.mobile-menu-chevron {
    width: 16px;
    height: 16px;
    color: #6b7280;
    transition: transform 200ms ease-out;
    flex-shrink: 0;
    margin-left: 12px;
}

/* ========================================
   Accordion Content
   ======================================== */

.mobile-menu-accordion-content {
    height: 0;
    overflow: hidden;
    transition: height 200ms ease-out;
}



.mobile-menu-accordion-inner {
    padding-bottom: 16px;
    /* Indent sub-items slightly to the right for better hierarchy */
    padding-left: 12px;
}

/* ========================================
   Menu Links
   ======================================== */

.mobile-menu-link {
    display: block;
    /* Add horizontal padding so the highlight “bubble” doesn’t hug text */
    padding: 14px 12px;
    text-decoration: none;
    color: inherit;
    border-radius: 12px;
    transition: background-color 150ms ease;
    
    /* Ensure 48px tap target */
    min-height: 48px;
    display: flex;
    align-items: center;
}

.mobile-menu-link:hover {
    background: #f8f9fa;
}

.mobile-menu-link:focus {
    outline: 2px solid #007bff;
    outline-offset: -2px;
}

/* Active/tap state for more realistic touch feedback */
.mobile-menu-link:active {
    background: #eef2f7;
}

.mobile-menu-link-content {
    flex: 1;
}

.mobile-menu-link-title {
    font-size: 16px;
    font-weight: 500;
    color: #111827;
    margin: 0 0 4px 0;
    line-height: 1.4;
}

.mobile-menu-link-subtitle {
    font-size: 14px;
    font-weight: 400;
    color: #6b7280;
    margin: 0;
    line-height: 1.4;
}

/* ========================================
   Call-to-Action Button
   ======================================== */

.mobile-menu-cta {
    margin-top: 32px;
    padding-top: 24px;
    border-top: 1px solid #f1f3f4;
}

.mobile-menu-cta-button {
    display: block;
    width: 100%;
    padding: 16px 24px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #ffffff;
    text-decoration: none;
    border-radius: 12px;
    font-size: 16px;
    font-weight: 600;
    text-align: center;
    transition: transform 150ms ease, box-shadow 150ms ease;
    
    /* Ensure good tap target */
    min-height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.mobile-menu-cta-button:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.mobile-menu-cta-button:focus {
    outline: 2px solid #ffffff;
    outline-offset: 2px;
}

.mobile-menu-cta-button:active {
    transform: translateY(0);
}

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

/* Tablets and larger phones */
@media (min-width: 480px) {
    .mobile-menu-header {
        padding: 24px 32px 20px;
    }
    
    .mobile-menu-content {
        padding: 0 32px 32px;
    }
    
    .mobile-menu-accordion-trigger {
        padding: 24px 0;
    }
    
    .mobile-menu-accordion-title {
        font-size: 19px;
    }
    
    .mobile-menu-link {
        padding: 18px 0;
        border-radius: 12px;
    }
    
    .mobile-menu-link-title {
        font-size: 17px;
    }
    
    .mobile-menu-link-subtitle {
        font-size: 14px;
    }
}

/* ========================================
   Critical Fixes for Solutions Pages
   ======================================== */

/* Override solutions page overflow issues that clip mobile menu content */
body:has(.mobile-menu-overlay.mobile-menu-open) .solutions-section-hero,
body:has(.mobile-menu-overlay.mobile-menu-open) .section-main.solutions-section-hero {
    overflow-y: visible !important;
    overflow-x: hidden !important; /* Maintain horizontal scroll prevention */
}

/* Fallback for browsers without :has() support */
body.mobile-menu-scroll-locked .solutions-section-hero,
body.mobile-menu-scroll-locked .section-main.solutions-section-hero {
    overflow-y: visible !important;
    overflow-x: hidden !important; /* Maintain horizontal scroll prevention */
}

/* Ensure mobile menu is above all solutions page elements including ribbons */
.mobile-menu-overlay {
    z-index: 99999 !important; /* Higher than any solutions page element */
}

/* Prevent body scroll when mobile menu is open - SIMPLE approach */
body.mobile-menu-scroll-locked {
    overflow: hidden !important;
}

/* Ensure body never has borders or hairlines */
body {
    border: none !important;
    outline: none !important;
    box-shadow: none !important;
}

/* Hide desktop "Get in touch" button on mobile devices */
@media (max-width: 991px) {
    .button-wrapper,
    .black-button,
    .navbar-content-wrapper.hidden-on-mobile .button-wrapper,
    .navbar-content-wrapper.hidden-on-mobile .black-button {
        display: none !important;
        visibility: hidden !important;
        opacity: 0 !important;
    }
}

/* Prevent any hairline/border above header on mobile */
@media (max-width: 991px) {
    .navbar,
    .navbar-container,
    .navbar-content-wrapper {
        border-top: none !important;
        border-bottom: none !important;
        box-shadow: none !important;
        outline: none !important;
        transition: none !important;
        animation: none !important;
    }
    
    /* Ensure no pseudo-elements create hairlines */
    .navbar::before,
    .navbar::after,
    .navbar-container::before,
    .navbar-container::after {
        display: none !important;
        content: none !important;
    }
    
    /* Prevent any Webflow animations from affecting navbar */
    .navbar.w-animate,
    .navbar.w-animate-fade-in,
    .navbar.w-animate-slide-in-top {
        border-top: none !important;
        border-bottom: none !important;
        box-shadow: none !important;
        outline: none !important;
    }
    
    /* Prevent w--open class from affecting hamburger button layout during transitions */
    .menu-button.w--open,
    .menu-button.black-menu-button.w--open,
    .w-nav-button.w--open {
        border: none !important;
        box-shadow: none !important;
        outline: none !important;
        /* Prevent background color changes from affecting layout */
        background-color: transparent !important;
    }
}

/* Ensure mobile menu content is properly visible */
.mobile-menu-overlay.mobile-menu-open {
    display: flex !important;
}

.mobile-menu-overlay.mobile-menu-open .mobile-menu-panel {
    display: flex !important;
    flex-direction: column !important;
}

.mobile-menu-overlay.mobile-menu-open .mobile-menu-content {
    display: flex !important;
    flex-direction: column !important;
    flex: 1 !important;
}

.mobile-menu-overlay.mobile-menu-open .mobile-menu-sections {
    display: block !important;
    flex: 1 !important;
}

/* Force mobile menu accordion content to be visible when expanded */
.mobile-menu-accordion-expanded .mobile-menu-accordion-content {
    display: block !important;
    overflow: visible !important;
}

.mobile-menu-accordion-expanded .mobile-menu-accordion-inner {
    display: block !important;
}

/* ========================================
   Desktop vs Mobile Navigation Control
   ======================================== */

/* Hide mobile menu and hamburger on desktop */
@media (min-width: 992px) {
    .mobile-menu-overlay {
        display: none !important;
    }
    
    .menu-button {
        display: none !important;
    }
    
    /* Ensure desktop navigation is visible */
    .nav-menu-main {
        display: flex !important;
    }
    
    .navbar-content-wrapper:not(.hidden-on-mobile) {
        display: flex !important;
    }
}

/* Show hamburger button and hide desktop nav on mobile */
@media (max-width: 991px) {
    .menu-button {
        display: block !important;
    }
    
    /* Hide desktop mega menus on mobile */
    .mega-menu-panel {
        display: none !important;
    }
    
    /* Hide desktop navigation items */
    .nav-menu-main .mega-menu-container {
        display: none !important;
    }
    
    /* Keep mobile CTA visible */
    .mobile-menu-toggle.display-on-mobile {
        display: block !important;
    }
}

/* ========================================
   Performance Optimizations
   ======================================== */

/* Use hardware acceleration for smoother animations */
.mobile-menu-panel,
.mobile-menu-chevron {
    will-change: transform;
}

.mobile-menu-overlay {
    will-change: opacity, visibility;
}

/* Reduce motion for users who prefer it */
@media (prefers-reduced-motion: reduce) {
    .mobile-menu-overlay,
    .mobile-menu-panel,
    .mobile-menu-chevron,
    .mobile-menu-accordion-content {
        transition: none !important;
    }
    
    .mobile-menu-cta-button:hover {
        transform: none;
    }
}

/* ========================================
   Dark Mode Support (Optional)
   ======================================== */

@media (prefers-color-scheme: dark) {
    .mobile-menu-panel {
        background: #1f2937;
    }
    
    .mobile-menu-header {
        border-bottom-color: #374151;
    }
    
    .mobile-menu-close:hover,
    .mobile-menu-link:hover {
        background: #2b3441;
    }
    
    .mobile-menu-close svg {
        color: #d1d5db;
    }
    
    .mobile-menu-accordion {
        border-bottom-color: #374151;
    }
    
    .mobile-menu-accordion-title {
        color: #f9fafb;
    }
    
    .mobile-menu-chevron {
        color: #9ca3af;
    }
    
    .mobile-menu-link-title {
        color: #f9fafb;
    }
    
    .mobile-menu-link-subtitle {
        color: #9ca3af;
    }
    
    /* Dark mode active/tap state */
    .mobile-menu-link:active {
        background: #313b49;
    }
    
    .mobile-menu-cta {
        border-top-color: #374151;
    }
}

/* ========================================
   Focus Management & Accessibility
   ======================================== */

/* Ensure focus indicators are visible */
.mobile-menu-overlay [tabindex="-1"]:focus {
    outline: none;
}

/* Skip link for screen readers */
.mobile-menu-skip-link {
    position: absolute;
    top: -40px;
    left: 6px;
    background: #000;
    color: #fff;
    padding: 8px;
    text-decoration: none;
    border-radius: 4px;
    z-index: 10000;
}

.mobile-menu-skip-link:focus {
    top: 6px;
}

/* Screen reader only content */
.mobile-menu-sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}
