/**
 * Mobile Menu Styles - Complete Redesign
 *
 * @package Clevertech_Astra_Child
 * @version 2.0.0
 * @updated 2025-01-19 - Comprehensive mobile menu improvements
 */

/* ===== CSS Variables for Mobile Menu ===== */
:root {
    /* Brand Colors */
    --menu-primary: #2C3E50;
    --menu-secondary: #E74C3C;
    --menu-accent: #F39C12;
    --menu-text: #2C3E50;
    --menu-text-light: #5A6C7D;
    --menu-bg: #FFFFFF;
    --menu-overlay: rgba(0, 0, 0, 0.7);

    /* Transitions */
    --menu-transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --menu-slide: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);

    /* Z-index hierarchy */
    --z-overlay: 9998;
    --z-menu: 9999;
    --z-toggle: 10000;
}

/* ===== Mobile Menu Toggle Button ===== */
.mobile-menu-toggle {
    display: none;
    position: relative;
    min-width: 48px;
    min-height: 48px;
    width: 48px;
    height: 48px;
    padding: 12px;
    margin: 0;
    background: transparent;
    border: 2px solid transparent;
    border-radius: 4px;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    z-index: var(--z-toggle);
    transition: var(--menu-transition);
}

body.menu-open .mobile-menu-toggle {
    position: fixed;
    top: 18px;
    right: 20px;
    z-index: var(--z-toggle);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

/* Better touch feedback */
.mobile-menu-toggle:active {
    transform: scale(0.95);
    background: rgba(243, 156, 18, 0.1);
}

/* Hamburger Icon */
.menu-icon {
    position: relative;
    display: inline-block;
    width: 28px;
    height: 24px;
    pointer-events: none;
}

.menu-icon span {
    display: block;
    position: absolute;
    left: 0;
    width: 100%;
    height: 3px;
    background: var(--menu-primary);
    border-radius: 3px;
    transition: var(--menu-transition);
    transform-origin: center;
}

.menu-icon span:nth-child(1) {
    top: 0;
}

.menu-icon span:nth-child(2) {
    top: 50%;
    transform: translateY(-50%);
}

.menu-icon span:nth-child(3) {
    bottom: 0;
}

/* Animated X transformation when active */
.mobile-menu-toggle.active .menu-icon span:nth-child(1) {
    transform: rotate(45deg) translate(8px, 8px);
}

.mobile-menu-toggle.active .menu-icon span:nth-child(2) {
    opacity: 0;
    transform: translateX(-20px);
}

.mobile-menu-toggle.active .menu-icon span:nth-child(3) {
    transform: rotate(-45deg) translate(8px, -8px);
}

/* Hover & Focus states */
.mobile-menu-toggle:hover .menu-icon span,
.mobile-menu-toggle:focus .menu-icon span {
    background: var(--menu-accent);
}

.mobile-menu-toggle:focus-visible {
    outline: 2px solid var(--menu-accent);
    outline-offset: 2px;
    border-radius: 4px;
}

/* ===== Menu Overlay ===== */
.mobile-menu-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--menu-overlay);
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
    z-index: var(--z-overlay);
}

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

/* ===== Mobile Menu Container ===== */
.mobile-menu {
    position: fixed;
    top: 0;
    right: -100%;
    width: 85%;
    max-width: 360px;
    height: 100vh;
    height: 100dvh; /* Dynamic viewport height for mobile */
    background: var(--menu-bg);
    box-shadow: -5px 0 25px rgba(0, 0, 0, 0.15);
    transition: transform 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    z-index: var(--z-menu);
    overflow: hidden;
    display: flex !important;
    flex-direction: column;
    /* GPU acceleration */
    will-change: transform;
    transform: translateZ(0) translateX(0);
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
}

/* Active state - slide in from right */
.mobile-menu.active {
    right: 0 !important;
    transform: translateZ(0) translateX(0) !important;
}

/* Alternative: Slide from left */
.mobile-menu.left-menu {
    right: auto;
    left: -100%;
}

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

/* ===== Menu Header ===== */
.mobile-menu-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.08);
    background: linear-gradient(135deg, #f8f9fa 0%, #ffffff 100%);
}

.mobile-menu-logo {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    color: var(--menu-primary);
    font-weight: 600;
    font-size: 1.1rem;
}

.mobile-menu-logo img {
    width: 32px;
    height: 32px;
    border-radius: 4px;
}

/* Close button */
.mobile-menu-close {
    width: 40px;
    height: 40px;
    padding: 0;
    background: transparent;
    border: 2px solid transparent;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--menu-transition);
    -webkit-tap-highlight-color: transparent;
    margin: 0 20px 12px auto;
}

.mobile-menu-close:hover,
.mobile-menu-close:focus {
    background: rgba(231, 76, 60, 0.1);
    border-color: var(--menu-secondary);
}

.mobile-menu-close svg {
    width: 20px;
    height: 20px;
    stroke: var(--menu-text);
    transition: var(--menu-transition);
}

.mobile-menu-close:hover svg {
    stroke: var(--menu-secondary);
    transform: rotate(90deg);
}

/* ===== Menu Inner Content ===== */
.mobile-menu-inner {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 20px 0;
    -webkit-overflow-scrolling: touch; /* Smooth iOS scrolling */
}

/* Custom scrollbar */
.mobile-menu-inner::-webkit-scrollbar {
    width: 4px;
}

.mobile-menu-inner::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.05);
}

.mobile-menu-inner::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 2px;
}

/* ===== Menu List ===== */
.mobile-menu-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.mobile-menu-list li {
    margin: 0 0 4px 0; /* Better spacing between items */
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
    animation: menuItemSlide 0.4s ease backwards;
}

.mobile-menu-list li:last-child {
    margin-bottom: 0;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
}

.mobile-menu-list li:nth-child(1) { animation-delay: 0.05s; }
.mobile-menu-list li:nth-child(2) { animation-delay: 0.1s; }
.mobile-menu-list li:nth-child(3) { animation-delay: 0.15s; }
.mobile-menu-list li:nth-child(4) { animation-delay: 0.2s; }
.mobile-menu-list li:nth-child(5) { animation-delay: 0.25s; }

@keyframes menuItemSlide {
    from {
        opacity: 0;
        transform: translateX(30px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.mobile-menu-list a {
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 48px; /* Minimum touch target */
    padding: 16px 25px;
    color: var(--menu-text);
    text-decoration: none;
    font-size: clamp(1rem, 2.5vw, 1.1rem); /* Responsive font size */
    font-weight: 500;
    transition: var(--menu-transition);
    position: relative;
    overflow: hidden;
}

/* Menu item hover effect */
.mobile-menu-list a::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    height: 100%;
    width: 4px;
    background: var(--menu-accent);
    transform: translateX(-4px);
    transition: transform 0.3s ease;
}

.mobile-menu-list a:hover::before,
.mobile-menu-list a:focus::before,
.mobile-menu-list .current-menu-item a::before {
    transform: translateX(0);
}

.mobile-menu-list a:hover,
.mobile-menu-list a:focus {
    background: linear-gradient(90deg, rgba(243, 156, 18, 0.08) 0%, transparent 100%);
    color: var(--menu-accent);
    padding-left: 30px;
}

/* Current page indicator */
.mobile-menu-list .current-menu-item a {
    color: var(--menu-accent);
    background: rgba(243, 156, 18, 0.05);
}

/* Keep Contact link neutral in mobile menu */
.mobile-menu-list a[href*="/contact"] {
    background: transparent !important;
    color: var(--menu-text) !important;
}

.mobile-menu-list a[href*="/contact"]:hover,
.mobile-menu-list a[href*="/contact"]:focus {
    background: linear-gradient(90deg, rgba(243, 156, 18, 0.08) 0%, transparent 100%) !important;
    color: var(--menu-accent) !important;
    padding-left: 30px;
}

/* Menu item arrow */
.mobile-menu-list a::after {
    content: '→';
    font-size: 1.2rem;
    opacity: 0;
    transform: translateX(-10px);
    transition: var(--menu-transition);
}

.mobile-menu-list a:hover::after,
.mobile-menu-list a:focus::after {
    opacity: 0.5;
    transform: translateX(0);
}

/* ===== Submenu Support ===== */
.mobile-menu-list .menu-item-has-children > a::after {
    content: '+';
    font-size: 1.5rem;
    font-weight: 300;
    transition: transform 0.3s ease;
}

.mobile-menu-list .menu-item-has-children.active > a::after {
    transform: rotate(45deg);
}

.mobile-menu-list .sub-menu {
    list-style: none;
    margin: 0;
    padding: 0;
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
    background: rgba(0, 0, 0, 0.02);
}

.mobile-menu-list .menu-item-has-children.active .sub-menu {
    max-height: 500px;
}

.mobile-menu-list .sub-menu a {
    padding-left: 45px;
    font-size: 0.95rem;
}

/* ===== CTA Section ===== */
.mobile-menu-cta {
	padding: 16px 20px 20px;
	border-top: 1px solid rgba(0, 0, 0, 0.05);
	margin-top: 4px;
	background: linear-gradient(135deg, #f8f9fa 0%, #ffffff 100%);
}


.mobile-menu-cta .btn {
	display: block;
	width: 100%;
	padding: 15px 25px;
	background: linear-gradient(90deg, var(--menu-secondary) 0%, var(--menu-accent) 100%);
	color: white;
	text-align: center;
	text-decoration: none;
	font-weight: 600;
	font-size: 1.05rem;
	border-radius: 30px;
	transition: var(--menu-transition);
	box-shadow: 0 4px 15px rgba(231, 76, 60, 0.3);
}

.mobile-menu-cta .btn:hover,
.mobile-menu-cta .btn:focus {
	transform: translateY(-2px);
	box-shadow: 0 6px 20px rgba(231, 76, 60, 0.4);
}

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


/* ===== Social Links in Menu ===== */
.mobile-menu-social {
    display: flex;
    justify-content: center;
    gap: 15px;
    padding: 20px;
    margin-top: auto;
}

.mobile-menu-social a {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    background: var(--menu-primary);
    color: white;
    border-radius: 50%;
    text-decoration: none;
    transition: var(--menu-transition);
}

.mobile-menu-social a:hover,
.mobile-menu-social a:focus {
    background: var(--menu-accent);
    transform: translateY(-3px);
}

/* ===== Body State When Menu is Open ===== */
body.menu-open {
    overflow: hidden;
    position: fixed;
    width: 100%;
    height: 100%;
}

/* iOS scroll prevention */
body.menu-open::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: var(--z-overlay);
    pointer-events: none;
}

/* ===== Responsive Breakpoints ===== */
@media (max-width: 1024px) {
    .mobile-menu-toggle {
        display: flex;
        align-items: center;
        justify-content: center;
    }

    /* Hide desktop navigation */
    .main-navigation {
        display: none !important;
    }
}

@media (max-width: 480px) {
    .mobile-menu {
        width: 90%;
        max-width: 100%;
    }

    .mobile-menu-list a {
        padding: 16px 20px;
        font-size: 1rem;
    }

    .mobile-menu-cta {
        padding: 15px;
    }

    .mobile-menu-cta .btn {
        padding: 14px 20px;
        font-size: 1rem;
    }
}

/* Extra small screens */
@media (max-width: 360px) {
    .mobile-menu {
        width: 100%;
    }

    .mobile-menu-header {
        padding: 15px;
    }

    .mobile-menu-list a {
        padding: 15px;
        font-size: 0.95rem;
    }
}

/* ===== Accessibility Improvements ===== */
/* Focus visible for keyboard navigation */
.mobile-menu *:focus-visible {
    outline: 2px solid var(--menu-accent);
    outline-offset: 2px;
}

/* Skip navigation link */
.mobile-menu-skip {
    position: absolute;
    top: -40px;
    left: 0;
    background: var(--menu-primary);
    color: white;
    padding: 8px;
    text-decoration: none;
    z-index: 10000;
}

.mobile-menu-skip:focus {
    top: 0;
}

/* Screen reader text */
.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;
}

/* ===== Animation Performance ===== */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.001ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.001ms !important;
    }

    .mobile-menu {
        transition: none;
    }

    .mobile-menu-overlay {
        transition: none;
    }
}

/* ===== Dark Mode Support - DISABLED ===== */
/* Dark mode adaptation disabled to maintain brand consistency */
/* The mobile menu uses the light theme colors defined globally */
/*
@media (prefers-color-scheme: dark) {
    :root {
        --menu-bg: #1a1a1a;
        --menu-text: #e0e0e0;
        --menu-text-light: #b0b0b0;
        --menu-overlay: rgba(0, 0, 0, 0.9);
    }

    .mobile-menu {
        background: var(--menu-bg);
        box-shadow: -5px 0 25px rgba(0, 0, 0, 0.5);
    }

    .mobile-menu-header,
    .mobile-menu-cta {
        background: linear-gradient(135deg, #2a2a2a 0%, #1a1a1a 100%);
    }

    .mobile-menu-list li {
        border-bottom-color: rgba(255, 255, 255, 0.1);
    }

    .mobile-menu-close:hover {
        background: rgba(231, 76, 60, 0.2);
    }
}
*/

/* ===== Print Styles ===== */
@media print {
    .mobile-menu-toggle,
    .mobile-menu,
    .mobile-menu-overlay {
        display: none !important;
    }
}
