/* ====================================================== */
/* MYYARNSTORE CUSTOM MOBILE MENU                         */
/* Modern slide-out navigation for mobile devices         */
/* ====================================================== */

/* ============================================ */
/* 1. MOBILE HEADER LAYOUT (CSS GRID)          */
/* ============================================ */
@media screen and (max-width: 768px) {
    
    /* Hide the original Superfish menu completely on mobile */
    #block-martis-mainnavigation {
        display: none !important;
    }

    /* Hide blocks not needed on mobile */
    #block-martis-monthlysales,
    #block-martis-myyarnstoresubmitrequestheaderlink {
        display: none !important;
    }
    
    /* Main header region - CSS Grid for precise control */
    .region-header-top-first {
        display: grid !important;
        grid-template-columns: auto 1fr auto !important;
        grid-template-rows: auto auto !important;
        gap: 8px 10px !important;
        width: 100% !important;
        padding: 10px 15px !important;
        position: relative !important;
        align-items: center !important;
    }
    
    /* ============================================ */
    /* LINE 1: HAMBURGER - LOGO - (empty)          */
    /* ============================================ */
    
    /* RTL Layout */
    [dir="rtl"] .region-header-top-first .custom-mobile-hamburger {
        grid-column: 1 !important;
        grid-row: 1 !important;
        justify-self: start !important;
    }
    
    [dir="rtl"] .region-header-top-first #block-martis-mobilelogo {
        grid-column: 2 / 4 !important;
        grid-row: 1 !important;
        justify-self: end !important;
    }
    
    /* LTR Layout */
    [dir="ltr"] .region-header-top-first #block-martis-mobilelogo {
        grid-column: 1 / 3 !important;
        grid-row: 1 !important;
        justify-self: start !important;
    }
    
    [dir="ltr"] .region-header-top-first .custom-mobile-hamburger {
        grid-column: 3 !important;
        grid-row: 1 !important;
        justify-self: end !important;
    }
    
    /* ============================================ */
    /* LINE 2: CART - ACCOUNT - LANGUAGE           */
    /* ============================================ */
    
    /* RTL: Cart LEFT, Account CENTER, Lang RIGHT */
    [dir="rtl"] .region-header-top-first #block-martis-cartflyout {
        grid-column: 3 !important;
        grid-row: 2 !important;
        justify-self: start !important;
    }
    
    [dir="rtl"] .region-header-top-first #block-user-account-menu {
        grid-column: 2 !important;
        grid-row: 2 !important;
        justify-self: right !important;
    }
    
    /* Force padding on the Account dropdown for RTL mobile layout */
    [dir="rtl"] .dropdown-toggle.header-icon.account-icon {
        padding-left: 15px !important;
    }
    
    [dir="rtl"] .region-header-top-first #block-language-dropdown-switcher {
        grid-column: 1 !important;
        grid-row: 2 !important;
        justify-self: end !important;
    }
    
    /* LTR: Lang LEFT, Account CENTER, Cart RIGHT */
    [dir="ltr"] .region-header-top-first #block-language-dropdown-switcher {
        grid-column: 3 !important;
        grid-row: 2 !important;
        justify-self: start !important;
    }
    
    [dir="ltr"] .region-header-top-first #block-user-account-menu {
        grid-column: 2 !important;
        grid-row: 2 !important;
        justify-self: left !important;
    }
    
    [dir="ltr"] .region-header-top-first #block-martis-cartflyout {
        grid-column: 1 !important;
        grid-row: 2 !important;
        justify-self: end !important;
    }
    
    /* Common block styles */
    #block-martis-mobilelogo,
    #block-martis-cartflyout,
    #block-user-account-menu,
    #block-language-dropdown-switcher {
        margin: 0 !important;
        border: none !important;
        padding: 0 !important;
    }
    
    #block-martis-mobilelogo {
        display: block !important;
    }
    
    #block-martis-mobilelogo img {
        max-height: 50px !important;
    }
    
    #block-martis-mobilelogo .container-wrap,
    #block-martis-mobilelogo .block-content {
        margin: 0 !important;
        padding: 0 !important;
    }
    
    #block-martis-cartflyout,
    #block-user-account-menu,
    #block-language-dropdown-switcher {
        display: flex !important;
        align-items: center !important;
    }

    /* Fix account menu width in grid cell */
    [dir="rtl"] .region-header-top-first #block-user-account-menu .container-wrap {
        width: 100% !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
    }
}

/* ============================================ */
/* 2. HAMBURGER BUTTON                          */
/* ============================================ */
.custom-mobile-hamburger {
    display: none;
}

@media screen and (max-width: 768px) {
    .custom-mobile-hamburger {
        display: block !important;
        z-index: 1000 !important;
    }
    
    .custom-hamburger-btn {
        display: flex !important;
        flex-direction: column !important;
        justify-content: center !important;
        align-items: center !important;
        gap: 5px !important;
        width: 44px !important;
        height: 44px !important;
        background: #f8f8f8 !important;
        border: 1px solid #e0e0e0 !important;
        border-radius: 8px !important;
        cursor: pointer !important;
        padding: 0 !important;
        margin: 0 !important;
        transition: all 0.3s ease !important;
    }
    
    .custom-hamburger-btn:hover,
    .custom-hamburger-btn:focus {
        background: #f0f0f0 !important;
        border-color: #ccc !important;
    }
    
    .custom-hamburger-btn .bar {
        display: block !important;
        width: 22px !important;
        height: 2px !important;
        background-color: #333 !important;
        border-radius: 2px !important;
        transition: all 0.3s ease !important;
    }
    
    /* Hamburger to X animation */
    .custom-hamburger-btn.is-active .bar:nth-child(1) {
        transform: rotate(45deg) translate(5px, 5px) !important;
    }
    
    .custom-hamburger-btn.is-active .bar:nth-child(2) {
        opacity: 0 !important;
    }
    
    .custom-hamburger-btn.is-active .bar:nth-child(3) {
        transform: rotate(-45deg) translate(5px, -5px) !important;
    }
}

/* ============================================ */
/* 3. MOBILE MENU OVERLAY                       */
/* ============================================ */
.custom-mobile-menu-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 999998;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.custom-mobile-menu-overlay.is-visible {
    display: block;
    opacity: 1;
}

/* ============================================ */
/* 4. MOBILE MENU PANEL                         */
/* ============================================ */
.custom-mobile-menu {
    position: fixed;
    top: 0;
    width: 85%;
    max-width: 320px;
    height: 100vh;
    height: 100dvh;
    background: #ffffff;
    z-index: 999999;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), visibility 0.3s ease;
    box-shadow: none;
    visibility: hidden;
}

/* RTL: Slide from right */
[dir="rtl"] .custom-mobile-menu {
    right: 0;
    left: auto;
    transform: translateX(100%);
}

[dir="rtl"] .custom-mobile-menu.is-open {
    transform: translateX(0);
    visibility: visible;
    box-shadow: -5px 0 20px rgba(0, 0, 0, 0.15);
}

/* LTR: Slide from left */
[dir="ltr"] .custom-mobile-menu {
    left: 0;
    right: auto;
    transform: translateX(-100%);
}

[dir="ltr"] .custom-mobile-menu.is-open {
    transform: translateX(0);
    visibility: visible;
    box-shadow: 5px 0 20px rgba(0, 0, 0, 0.15);
}

/* Prevent body scroll when menu is open */
body.mobile-menu-open {
    overflow: hidden !important;
}

/* ============================================ */
/* 5. MENU HEADER                               */
/* ============================================ */
.custom-mobile-menu-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 15px 20px;
    background: #f9f9f9;
    border-bottom: 1px solid #eee;
    flex-shrink: 0;
}

.custom-mobile-menu-title {
    font-size: 18px;
    font-weight: 600;
    color: #333;
    margin: 0;
}

.custom-mobile-menu-close {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 50%;
    font-size: 20px;
    color: #666;
    cursor: pointer;
    transition: all 0.2s ease;
    padding: 0;
    line-height: 1;
}

.custom-mobile-menu-close:hover {
    background: #e91e63;
    border-color: #e91e63;
    color: #fff;
}

/* ============================================ */
/* 6. MENU CONTENT (Scrollable)                 */
/* ============================================ */
.custom-mobile-menu-content {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
}

/* ============================================ */
/* 7. MENU ITEMS                                */
/* ============================================ */
.custom-mobile-menu-nav {
    list-style: none;
    margin: 0;
    padding: 0;
}

.custom-mobile-menu-nav li {
    border-bottom: 1px solid #f0f0f0;
    margin: 0;
    padding: 0;
}

.custom-mobile-menu-nav li:last-child {
    border-bottom: none;
}

.custom-mobile-menu-nav > li > a {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    color: #333;
    text-decoration: none;
    font-size: 16px;
    font-weight: 500;
    transition: all 0.2s ease;
}

.custom-mobile-menu-nav > li > a:hover,
.custom-mobile-menu-nav > li > a:focus {
    background: #f8f8f8;
    color: #e91e63;
}

/* Parent item indicator */
.custom-mobile-menu-nav li.has-submenu > a::after {
    content: "";
    width: 8px;
    height: 8px;
    border-right: 2px solid #999;
    border-bottom: 2px solid #999;
    transition: transform 0.3s ease;
}

/* RTL arrow direction */
[dir="rtl"] .custom-mobile-menu-nav li.has-submenu > a::after {
    transform: rotate(135deg);
}

[dir="ltr"] .custom-mobile-menu-nav li.has-submenu > a::after {
    transform: rotate(-45deg);
}

/* Rotate arrow when submenu is open */
.custom-mobile-menu-nav li.has-submenu.is-open > a::after {
    transform: rotate(45deg) !important;
}

/* ============================================ */
/* 8. SUBMENUS                                  */
/* ============================================ */
.custom-mobile-menu-nav .submenu {
    display: none;
    list-style: none;
    margin: 0;
    padding: 0;
    background: #f9f9f9;
}

.custom-mobile-menu-nav li.has-submenu.is-open > .submenu {
    display: block;
}

.custom-mobile-menu-nav .submenu li {
    border-bottom: 1px solid #eee;
}

.custom-mobile-menu-nav .submenu li:last-child {
    border-bottom: none;
}

.custom-mobile-menu-nav .submenu li a {
    display: block;
    padding: 14px 20px;
    color: #555;
    text-decoration: none;
    font-size: 15px;
    transition: all 0.2s ease;
}

/* RTL submenu indent */
[dir="rtl"] .custom-mobile-menu-nav .submenu li a {
    padding-right: 40px;
}

/* LTR submenu indent */
[dir="ltr"] .custom-mobile-menu-nav .submenu li a {
    padding-left: 40px;
}

.custom-mobile-menu-nav .submenu li a:hover,
.custom-mobile-menu-nav .submenu li a:focus {
    background: #f0f0f0;
    color: #e91e63;
}

/* ============================================ */
/* 9. MENU FOOTER (Optional)                    */
/* ============================================ */
.custom-mobile-menu-footer {
    padding: 15px 20px;
    background: #f9f9f9;
    border-top: 1px solid #eee;
    flex-shrink: 0;
}

.custom-mobile-menu-footer-links {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: center;
}

.custom-mobile-menu-footer-links a {
    font-size: 13px;
    color: #666;
    text-decoration: none;
}

.custom-mobile-menu-footer-links a:hover {
    color: #e91e63;
}

/* ============================================ */
/* 10. ANIMATIONS & TRANSITIONS                 */
/* ============================================ */
@keyframes slideInRight {
    from {
        transform: translateX(100%);
    }
    to {
        transform: translateX(0);
    }
}

@keyframes slideInLeft {
    from {
        transform: translateX(-100%);
    }
    to {
        transform: translateX(0);
    }
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

/* Submenu slide animation */
.custom-mobile-menu-nav .submenu {
    animation: fadeIn 0.2s ease;
}

/* ============================================ */
/* 11. ACCESSIBILITY                            */
/* ============================================ */
.custom-mobile-menu:focus {
    outline: none;
}

.custom-mobile-menu-nav a:focus {
    outline: 2px solid #e91e63;
    outline-offset: -2px;
}

/* Screen reader only */
.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;
}

/* ============================================ */
/* 12. HIDE ORIGINAL SUPERFISH ON MOBILE        */
/* ============================================ */
@media screen and (max-width: 768px) {
    #superfish-main-accordion,
    #superfish-main,
    .sf-accordion-toggle,
    #block-martis-mainnavigation .sf-accordion-toggle {
        display: none !important;
    }

/* ============================================ */
/* 13. CONTACT US MENU ITEM                     */
/* ============================================ */
.mobile-menu-contact-us {
    border-top: 2px solid #f0f0f0 !important;
    margin-top: 8px !important;
}

.mobile-menu-contact-us a {
    display: flex !important;
    flex-direction: row !important;
    justify-content: flex-start !important;
    direction: rtl !important;
    align-items: center !important;
    gap: 8px !important;
    font-weight: 600 !important;
}

.mobile-menu-contact-us a svg {
    flex-shrink: 0;
}
}