/*=============== MOBILE NAVIGATION ENHANCEMENTS ===============*/
/* Complementary styles for responsive-master.css */
/* Focus: Animations, iOS/Android fixes, Performance */

/*=============== MOBILE MENU SMOOTH SLIDE ANIMATION ===============*/
@media screen and (max-width: 991px) {

    /* Enhanced nav__center slide animation */
    .nav__center {
        transform: translateY(-100%);
        transition:
            transform 0.4s cubic-bezier(0.4, 0, 0.2, 1),
            opacity 0.3s ease,
            visibility 0.3s ease;
    }

    .nav__center.show-menu {
        transform: translateY(0);
    }

    /* Staggered link animations */
    .nav__center.show-menu .nav__item {
        animation: slideInFromTop 0.4s ease forwards;
    }

    .nav__center.show-menu .nav__item:nth-child(1) {
        animation-delay: 0.05s;
    }

    .nav__center.show-menu .nav__item:nth-child(2) {
        animation-delay: 0.1s;
    }

    .nav__center.show-menu .nav__item:nth-child(3) {
        animation-delay: 0.15s;
    }

    .nav__center.show-menu .nav__item:nth-child(4) {
        animation-delay: 0.2s;
    }

    .nav__center.show-menu .nav__item:nth-child(5) {
        animation-delay: 0.25s;
    }

    .nav__center.show-menu .nav__item:nth-child(6) {
        animation-delay: 0.3s;
    }

    .nav__center.show-menu .nav__item:nth-child(7) {
        animation-delay: 0.35s;
    }

    @keyframes slideInFromTop {
        from {
            opacity: 0;
            transform: translateY(-20px);
        }

        to {
            opacity: 1;
            transform: translateY(0);
        }
    }

    /* Enhanced link hover effects */
    .nav__link {
        position: relative;
        overflow: hidden;
    }

    .nav__link::before {
        content: '';
        position: absolute;
        top: 0;
        left: -100%;
        width: 100%;
        height: 100%;
        background: linear-gradient(90deg, transparent, rgba(239, 193, 169, 0.1), transparent);
        transition: left 0.5s ease;
    }

    .nav__link:hover::before {
        left: 100%;
    }
}

/*=============== DROPDOWN SMOOTH ANIMATIONS ===============*/
@media screen and (max-width: 991px) {

    /* Dropdown content animation */
    .nav__item.dropdown .dropdown-menu {
        transform-origin: top center;
        transition:
            max-height 0.35s cubic-bezier(0.4, 0, 0.2, 1),
            padding 0.35s cubic-bezier(0.4, 0, 0.2, 1),
            opacity 0.25s ease;
    }

    .nav__item.dropdown.active .dropdown-menu,
    .nav__item.dropdown.active-dropdown .dropdown-menu {
        animation: expandDropdown 0.35s ease forwards;
    }

    @keyframes expandDropdown {
        from {
            opacity: 0;
            max-height: 0;
        }

        to {
            opacity: 1;
            max-height: 300px;
        }
    }

    /* Dropdown item stagger animation */
    .nav__item.dropdown.active .dropdown-menu li,
    .nav__item.dropdown.active-dropdown .dropdown-menu li {
        animation: fadeInUp 0.3s ease forwards;
    }

    .nav__item.dropdown.active .dropdown-menu li:nth-child(1),
    .nav__item.dropdown.active-dropdown .dropdown-menu li:nth-child(1) {
        animation-delay: 0.05s;
    }

    .nav__item.dropdown.active .dropdown-menu li:nth-child(2),
    .nav__item.dropdown.active-dropdown .dropdown-menu li:nth-child(2) {
        animation-delay: 0.1s;
    }

    .nav__item.dropdown.active .dropdown-menu li:nth-child(3),
    .nav__item.dropdown.active-dropdown .dropdown-menu li:nth-child(3) {
        animation-delay: 0.15s;
    }

    @keyframes fadeInUp {
        from {
            opacity: 0;
            transform: translateY(10px);
        }

        to {
            opacity: 1;
            transform: translateY(0);
        }
    }
}

/*=============== HAMBURGER SMOOTH ANIMATION ===============*/
@media screen and (max-width: 991px) {

    .nav__toggle {
        transition:
            transform 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55),
            background-color 0.3s ease,
            border-color 0.3s ease,
            box-shadow 0.3s ease;
    }

    .nav__toggle span {
        transition:
            transform 0.35s cubic-bezier(0.68, -0.55, 0.265, 1.55),
            opacity 0.25s ease,
            background-color 0.25s ease;
    }

    /* Hamburger press feedback */
    .nav__toggle:active {
        transform: scale(0.92);
    }

    /* Hamburger X animation refinement */
    .nav__toggle.active {
        animation: togglePulse 0.4s ease;
    }

    @keyframes togglePulse {
        0% {
            transform: scale(1);
        }

        50% {
            transform: scale(1.15);
        }

        100% {
            transform: scale(1.1);
        }
    }
}

/*=============== OVERLAY ANIMATIONS ===============*/
@media screen and (max-width: 991px) {

    .nav__overlay {
        transition:
            opacity 0.35s ease,
            visibility 0.35s ease,
            backdrop-filter 0.35s ease;
    }

    .nav__overlay.show {
        animation: fadeIn 0.35s ease forwards;
    }

    @keyframes fadeIn {
        from {
            opacity: 0;
            backdrop-filter: blur(0px);
        }

        to {
            opacity: 1;
            backdrop-filter: blur(4px);
        }
    }
}

/*=============== iOS SPECIFIC FIXES ===============*/
@supports (-webkit-touch-callout: none) {
    @media screen and (max-width: 991px) {

        /* iOS viewport height fix */
        .nav__center {
            height: 100vh;
            height: -webkit-fill-available;
        }

        /* iOS smooth scrolling */
        .nav__center {
            -webkit-overflow-scrolling: touch;
            overscroll-behavior: contain;
        }

        /* Prevent iOS rubber-banding */
        body.nav-open {
            position: fixed;
            top: 0;
            left: 0;
            right: 0;
            bottom: 0;
            -webkit-overflow-scrolling: none;
        }

        /* iOS safe area padding */
        .nav__center {
            padding-bottom: env(safe-area-inset-bottom, 20px);
        }
    }
}

/*=============== ANDROID SPECIFIC FIXES ===============*/
@media screen and (max-width: 991px) {

    /* Android 3D acceleration */
    .nav__center,
    .nav__overlay,
    .nav__toggle {
        -webkit-transform: translateZ(0);
        transform: translateZ(0);
        -webkit-perspective: 1000px;
        perspective: 1000px;
    }

    /* Android Chrome address bar fix */
    .nav__center {
        height: 100vh;
        height: 100dvh;
        min-height: -webkit-fill-available;
    }
}

/*=============== PERFORMANCE OPTIMIZATIONS ===============*/
@media screen and (max-width: 991px) {

    /* GPU acceleration hints */
    .nav__center,
    .nav__toggle,
    .nav__overlay,
    .nav__link,
    .dropdown-menu {
        will-change: transform, opacity;
        backface-visibility: hidden;
        -webkit-backface-visibility: hidden;
    }

    /* Disable animations on reduced motion preference */
    @media (prefers-reduced-motion: reduce) {

        .nav__center,
        .nav__toggle,
        .nav__overlay,
        .nav__link,
        .dropdown-menu,
        .nav__toggle span {
            transition-duration: 0.01ms !important;
            animation-duration: 0.01ms !important;
        }
    }

    /* Lower-end device optimizations */
    @media (max-resolution: 150dpi) {
        .nav__center {
            transition-duration: 0.25s;
            backdrop-filter: none;
        }

        .nav__overlay {
            backdrop-filter: none;
        }
    }
}

/*=============== TOUCH INTERACTION IMPROVEMENTS ===============*/
@media screen and (max-width: 991px) {

    /* Remove tap highlight */
    .nav__toggle,
    .nav__link,
    .nav__overlay,
    .dropdown-menu a {
        -webkit-tap-highlight-color: transparent;
        -webkit-touch-callout: none;
        user-select: none;
        -webkit-user-select: none;
    }

    /* Touch-friendly spacing */
    .nav__link {
        min-height: 48px;
        touch-action: manipulation;
    }

    .dropdown-menu a {
        min-height: 44px;
        touch-action: manipulation;
    }

    /* Prevent accidental double-tap zoom */
    .nav__toggle {
        touch-action: manipulation;
    }
}

/*=============== RTL MOBILE ANIMATIONS ===============*/
@media screen and (max-width: 991px) {

    body.rtl .nav__center {
        transform: translateY(-100%);
    }

    body.rtl .nav__center.show-menu {
        transform: translateY(0);
    }

    body.rtl .nav__link:hover {
        transform: translateX(-8px);
    }

    body.rtl .dropdown-menu a:hover {
        transform: translateX(-5px);
    }
}

/*=============== DARK THEME MOBILE ENHANCEMENTS ===============*/
@media screen and (max-width: 991px) {

    body.dark-theme .nav__center {
        background: linear-gradient(180deg,
                var(--body-color, #1a1a2e) 0%,
                rgba(26, 26, 46, 0.98) 100%);
    }

    body.dark-theme .nav__link {
        border: 1px solid rgba(239, 193, 169, 0.15);
    }

    body.dark-theme .nav__link:hover {
        background: rgba(239, 193, 169, 0.12);
        border-color: rgba(239, 193, 169, 0.3);
    }

    body.dark-theme .nav__toggle {
        box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    }

    body.dark-theme .nav__overlay {
        background: rgba(0, 0, 0, 0.7);
    }
}

/*=============== LANDSCAPE MODE FIXES ===============*/
@media screen and (max-width: 991px) and (orientation: landscape) and (max-height: 500px) {

    .nav__center {
        padding-top: 60px;
        overflow-y: auto;
    }

    .nav__list {
        padding: 0.5rem 1rem;
        gap: 0.3rem;
    }

    .nav__link {
        padding: 0.5rem 0.75rem;
        min-height: 40px;
        font-size: 0.9rem;
    }

    .nav__toggle {
        top: 0.5rem;
        right: 0.5rem;
        width: 42px;
        height: 42px;
    }
}

/*=============== ACCESSIBILITY IMPROVEMENTS ===============*/
@media screen and (max-width: 991px) {

    /* Focus visible states */
    .nav__toggle:focus-visible,
    .nav__link:focus-visible,
    .dropdown-menu a:focus-visible {
        outline: 3px solid var(--first-color, #efc1a9);
        outline-offset: 2px;
    }

    /* Screen reader only class */
    .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;
    }

    /* High contrast mode support */
    @media (prefers-contrast: high) {
        .nav__toggle {
            border-width: 3px;
        }

        .nav__link {
            border: 2px solid currentColor;
        }
    }
}

/*=============== EXTRA SMALL SCREEN OPTIMIZATIONS ===============*/
@media screen and (max-width: 360px) {

    .nav__center {
        padding-top: 70px;
    }

    .nav__menu {
        padding: 0 0.5rem;
    }

    .nav__list {
        gap: 0.3rem;
    }

    .nav__link {
        padding: 0.7rem 0.75rem;
        font-size: 0.85rem;
    }

    .nav__link i {
        width: 28px;
        height: 28px;
        font-size: 0.95rem;
    }

    .dropdown-menu a {
        padding: 0.6rem 0.75rem;
        font-size: 0.8rem;
    }
}

/*=============== MINIMUM SCREEN SUPPORT (320px) ===============*/
@media screen and (max-width: 320px) {

    .nav__center {
        padding-top: 60px;
    }

    .nav__link {
        padding: 0.6rem;
        font-size: 0.8rem;
        gap: 0.5rem;
    }

    .nav__link i {
        width: 26px;
        height: 26px;
        font-size: 0.9rem;
    }

    .nav__link span {
        flex: 1;
        text-align: left;
    }

    body.rtl .nav__link span {
        text-align: right;
    }
}

/*=============== PRINT STYLES ===============*/
@media print {

    .nav__toggle,
    .nav__overlay,
    .nav__center {
        display: none !important;
    }
}