/* ==========================================================
   MFTAHY - FAKHAMA THEME CUSTOM CSS
   Organized by component. Original CSS rules are unchanged.
   ========================================================== */

/* ==========================================================
   01. GLOBAL SETTINGS
   Shared glass, layout, footer and Safari variables.
   ========================================================== */

/* Shared CSS variables */

:root {
    --mftahy-glass-rgb: 0, 31, 84;
    --mftahy-glass-opacity: 0.80;
    --mftahy-glass-blur: 18px;
    --mftahy-glass-saturation: 160%;

    
    --mftahy-footer-radius: 1.5rem 1.5rem 0 0;
}

:root {
    --mftahy-glass-rgb: 0, 31, 84;
    --mftahy-glass-opacity: 0.80;
    --mftahy-glass-blur: 18px;
    --mftahy-glass-saturation: 160%;
}

:root {
    --mftahy-content-width: 1280px;
    --mftahy-hero-width: 1280px;
}

:root {
    --mftahy-safari-top: #f8fcff;
    --mftahy-safari-bottom: #f8fcff;
}

/* ==========================================================
   02. TOP HEADER
   Glass effect, sticky behavior, corners and desktop login.
   ========================================================== */

/* Top glass and background */

#mainnav {
    background: transparent !important;
    isolation: isolate;
}

#mainnav:not(.fixed-pinned) {
    position: relative;
}

#mainnav > .inner.bg-inherit {
    background-color: transparent !important;
}

#mainnav::before {
    content: "";

    position: absolute;
    inset: 0;

    border-radius: inherit;

    background: rgba(
        var(--mftahy-glass-rgb),
        var(--mftahy-glass-opacity)
    );

    -webkit-backdrop-filter:
        blur(var(--mftahy-glass-blur))
        saturate(var(--mftahy-glass-saturation));

    backdrop-filter:
        blur(var(--mftahy-glass-blur))
        saturate(var(--mftahy-glass-saturation));

    z-index: -1;
    pointer-events: none;
}

/* Sticky header and corner radius */

.store-header {
    position: sticky !important;
    top: 0 !important;
}

#mainnav.fixed-pinned {
    position: relative !important;
    transform: none !important;
}

#mainnav.fixed-header {
    transform: none !important;
}

body#app[style*="padding-top"] {
    padding-top: 0 !important;
}

.thick-header #mainnav {
    border-radius: 0 0 1.5rem 1.5rem !important;
}

.thin-header #mainnav {
    border-radius: 0 0 1rem 1rem !important;
}

/* Desktop login and header alignment */

@media (min-width: 1024px) {

    

    #mainnav .f_start-btns >
    salla-user-menu.f_user-avatar-button:has(
        .s-user-menu-login-btn--avatar-only
    ) {
        width: max-content !important;
    }


    

    #mainnav .f_start-btns
    .s-user-menu-login-btn--avatar-only {

        display: inline-flex !important;
        align-items: center !important;
        justify-content: center !important;

        width: auto !important;
        min-width: 130px;
        height: 48px !important;

        padding: 0 20px !important;

        background-color: #FFFFFF !important;
        color: #001F54 !important;

        border: none !important;
        border-radius: 999px !important;

        font-size: 15px !important;
        font-weight: 600 !important;
        font-family: inherit !important;
        white-space: nowrap;

        cursor: pointer;

        transition:
            background-color 0.25s ease,
            transform 0.25s ease !important;
    }


    

    #mainnav .f_start-btns
    .s-user-menu-login-btn--avatar-only::after {
        content: "تسجيل الدخول";
        color: #001F54;
    }


    

    #mainnav .f_start-btns
    .s-user-menu-login-btn--avatar-only > svg {
        display: none !important;
    }


    

    #mainnav .f_start-btns
    .s-user-menu-login-btn--avatar-only:hover {
        background-color: #F0F5FF !important;
        transform: translateY(-1px);
    }


    

    #mainnav .f_start-btns
    .s-user-menu-login-btn--avatar-only:focus-visible {
        outline: 2px solid #FFFFFF !important;
        outline-offset: 3px;
    }

}

@media (prefers-reduced-motion: reduce) {
    #mainnav .f_start-btns
    .s-user-menu-login-btn--avatar-only {
        transition: none !important;
        transform: none !important;
    }
}

@media (min-width: 1024px) {

    #mainnav > .inner {

        
        max-width: var(--mftahy-content-width, 1280px);

        
        width: 100%;
        margin-inline: auto;

    }

}

@media (min-width: 1024px) {

    #mainnav > .inner {

        
        max-width: var(--mftahy-content-width, 1280px);

        
        width: 100%;
        margin-inline: auto;

    }

}

/* ==========================================================
   03. BOTTOM NAVIGATION
   Mobile navigation glass, corners and Safari edge colors.
   ========================================================== */

/* Mobile bottom glass */

.f_bottom-menu {
    background: transparent !important;
    isolation: isolate;
}

.f_bottom-menu > ul.with-titles {
    background: transparent !important;
}

.f_bottom-menu::before {
    content: "";

    position: absolute;
    inset: 0;

    background: rgba(
        var(--mftahy-glass-rgb),
        var(--mftahy-glass-opacity)
    );

    -webkit-backdrop-filter:
        blur(var(--mftahy-glass-blur))
        saturate(var(--mftahy-glass-saturation));

    backdrop-filter:
        blur(var(--mftahy-glass-blur))
        saturate(var(--mftahy-glass-saturation));

    z-index: -1;
    pointer-events: none;
}

.thick-header .f_bottom-menu::before {
    border-radius: 2rem 2rem 0 0;
}

.thin-header .f_bottom-menu::before {
    border-radius: 1.5rem 1.5rem 0 0;
}

@supports not (
    (backdrop-filter: blur(1px)) or
    (-webkit-backdrop-filter: blur(1px))
) {
    #mainnav::before,
    .f_bottom-menu::before {
        background: rgba(0, 31, 84, 0.90);
    }
}

/* Bottom corner adjustments */

.thick-header .f_bottom-menu {
    border-radius: 1.5rem 1.5rem 0 0 !important;
}

.thin-header .f_bottom-menu {
    border-radius: 1rem 1rem 0 0 !important;
}

.f_bottom-menu::before {
    border-radius: inherit !important;
}

/* Safari top and bottom colors */

@media (max-width: 767px) {

    
    .store-header {
        background-color: var(--mftahy-safari-top) !important;
        background-image: none !important;
        -webkit-background-clip: text !important;
        background-clip: text !important;
    }

    #mainnav {
        background: transparent !important;
    }

    
    .f_bottom-menu,
    .f_bottom-menu > ul.with-titles {
        background-color: var(--mftahy-safari-bottom) !important;
        background-image: none !important;
        -webkit-background-clip: text !important;
        background-clip: text !important;
    }
}

/* ==========================================================
   04. MOBILE MENU
   Text, icon and image styling.
   ========================================================== */

#mobile-menu,
#mobile-menu a,
#mobile-menu span,
#mobile-menu p,
#mobile-menu button,
#mobile-menu h1,
#mobile-menu h2,
#mobile-menu h3,
#mobile-menu h4 {
    color: #001F54 !important;
}

#mobile-menu svg,
#mobile-menu i {
    color: #001F54 !important;
}

#mobile-menu img {
    border-radius: 23% !important;
    aspect-ratio: 1 / 1;
    object-fit: cover;
}

/* ==========================================================
   05. LAYOUT & TYPOGRAPHY
   Section titles and desktop content widths.
   ========================================================== */

.s-slider-block__title h2,
.s-block__title h2,
.f_block__title h2 {
    font-size: 30px !important;
    font-weight: 700 !important;
    line-height: 1.4 !important;
    color: #001F54 !important;
    letter-spacing: 0 !important;
}

@media (min-width: 1024px) {

    

    body.index #main-content > section.page-content-section,

    section.s-block--testimonials,

    salla-slider#RVP-slider,

    section#viewed-section,

    footer.store-footer .store-footer__inner {

        width: 100%;
        max-width: var(--mftahy-content-width);

        margin-inline: auto;
        box-sizing: border-box;
    }


    

    body.index #E_slider_sec_0 {
        max-width: var(--mftahy-hero-width);
    }

}

/* ==========================================================
   06. CATEGORY CARDS
   Stable text, CTA buttons and floating images.
   ========================================================== */

/* Card text and floating CTA */

.f_ad-banner-content h2,
.f_ad-banner-content h2:hover,
.f_ad-banner-content > div > a,
.f_ad-banner-content > div > a:hover {
    color: #001F54 !important;
    transform: none !important;
    transition: none !important;
    animation: none !important;
}

.f_ad-banner-content > div {
    transform: none !important;
    transition: none !important;
    animation: none !important;
}

@keyframes mftahyFloat {
    0%, 100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-2px);
    }
}

.f_ad-banner-content > a {
    font-size: 20px !important;
    font-weight: 700 !important;
    animation: mftahyFloat 4s ease-in-out infinite !important;
}

.f_ad-banner-content > a i {
    font-size: 22px !important;
    animation: none !important;
}

/* Floating category images */

.f_ad-banners .f_ad-banner-img {
    animation: mftahyImageFloat 5s ease-in-out infinite !important;
}

@keyframes mftahyImageFloat {
    0%, 100% {
        translate: 0 0;
    }

    50% {
        translate: 0 -5px;
    }
}

/* ==========================================================
   07. CART & NOTIFICATIONS
   Cart button corners and success notices.
   ========================================================== */

salla-button:has(+ salla-button[href*="/cart"]) .s-button-element,
salla-button:has(+ salla-button[href*="/cart"]) + salla-button[href*="/cart"] .s-button-element {
    border-radius: 18px !important;
    overflow: hidden !important;
}

.swal2-popup:has(.swal2-icon.swal2-success) {
    border-radius: 18px !important;
    overflow: hidden !important;
}

.swal2-popup:has(.swal2-icon.swal2-success),
.swal2-popup:has(.swal2-icon.swal2-success) *,
.swal2-popup:has(.swal2-icon.swal2-success) *::before,
.swal2-popup:has(.swal2-icon.swal2-success) *::after {
    animation: none !important;
    transition: none !important;
}

/* ==========================================================
   08. REVIEWS & LOAD MORE
   Review link appearance and load-more button.
   ========================================================== */

a.f_block__display-all {
    display: flex !important;
    width: fit-content !important;
    margin: 20px auto 0 !important;
    align-self: center !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 6px !important;
    float: none !important;
    position: relative !important;

    color: #B80000 !important;
    font-size: 17px !important;
    font-weight: 700 !important;
    text-decoration: none !important;

    animation: mftahyFloat 4s ease-in-out infinite !important;
}

a.f_block__display-all i {
    color: #B80000 !important;
    font-size: 15px !important;
}

a.s-infinite-scroll-btn {
    border-radius: 16px !important;
}

/* ==========================================================
   09. FAQ ACCORDION
   Original and updated accordion animations, kept in order.
   ========================================================== */

/* Original FAQ rules */

.faqs__item {
    transition:
        box-shadow 0.35s ease,
        background-color 0.35s ease !important;
}

.faqs__item .faq-answer {
    display: block !important;
    max-height: 0;
    opacity: 0;
    visibility: hidden;
    overflow: hidden;
    transform: translateY(-8px);

    transition:
        max-height 0.5s ease,
        opacity 0.3s ease,
        transform 0.4s ease,
        visibility 0s linear 0.5s !important;
}

.faqs input[type="checkbox"]:checked + .faqs__item .faq-answer {
    max-height: 900px;
    opacity: 1;
    visibility: visible;
    transform: translateY(0);

    transition:
        max-height 0.6s ease,
        opacity 0.35s ease 0.08s,
        transform 0.4s ease,
        visibility 0s !important;
}

.faqs input[type="checkbox"]:checked + .faqs__item {
    box-shadow: 0 6px 24px rgba(0, 31, 84, 0.05);
}

.faqs__item label .sicon-add {
    transition:
        transform 0.35s ease,
        color 0.35s ease !important;
}

.faqs input[type="checkbox"]:checked + .faqs__item label .sicon-add {
    transform: scale(1.12);
    color: #B80000;
}

/* Later FAQ overrides - keep after the original rules */

.faqs__item {
    transition:
        box-shadow 0.4s ease,
        background-color 0.4s ease !important;
}

.faqs__item .faq-answer {
    display: grid !important;
    grid-template-rows: 0fr;
    max-height: none !important;
    opacity: 0;
    visibility: hidden;
    overflow: hidden;
    transform: translateY(-4px);

    transition:
        grid-template-rows 0.55s cubic-bezier(0.4, 0, 0.2, 1),
        opacity 0.4s ease,
        transform 0.55s ease,
        visibility 0s linear 0.55s !important;
}

.faqs__item .faq-answer > * {
    min-height: 0;
    overflow: hidden;
    margin-block: 0;
}

.faqs input[type="checkbox"]:checked + .faqs__item .faq-answer {
    grid-template-rows: 1fr;
    max-height: none !important;
    opacity: 1;
    visibility: visible;
    transform: translateY(0);

    transition:
        grid-template-rows 0.55s cubic-bezier(0.4, 0, 0.2, 1),
        opacity 0.4s ease 0.08s,
        transform 0.55s ease,
        visibility 0s !important;
}

.faqs input[type="checkbox"]:checked + .faqs__item {
    box-shadow: 0 6px 24px rgba(0, 31, 84, 0.05);
}

.faqs__item label .sicon-add {
    transition:
        transform 0.4s ease,
        color 0.4s ease !important;
}

.faqs input[type="checkbox"]:checked + .faqs__item label .sicon-add {
    transform: scale(1.12);
    color: #B80000;
}

@media (prefers-reduced-motion: reduce) {
    .faqs__item,
    .faqs__item .faq-answer,
    .faqs__item label .sicon-add {
        transition: none !important;
        transform: none !important;
    }
}

/* ==========================================================
   10. FOOTER
   Full-width glass copyright bar.
   ========================================================== */

.store-footer__bottom {
    position: relative !important;
    isolation: isolate;

    background: transparent !important;

    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    text-align: center !important;
}

.store-footer__bottom::before {
    content: "";

    position: absolute;

    top: 0;
    bottom: 0;
    left: 50%;

    width: 100vw;
    transform: translateX(-50%);

    
    border-radius: var(--mftahy-footer-radius);

    
    background: rgba(
        var(--mftahy-glass-rgb),
        var(--mftahy-glass-opacity)
    );

    
    -webkit-backdrop-filter:
        blur(var(--mftahy-glass-blur))
        saturate(var(--mftahy-glass-saturation));

    backdrop-filter:
        blur(var(--mftahy-glass-blur))
        saturate(var(--mftahy-glass-saturation));

    
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.10);

    z-index: -1;
    pointer-events: none;
}

.store-footer__bottom .copyright-text {
    position: relative;
    z-index: 1;

    color: #FFFFFF !important;
    opacity: 1 !important;
}

.store-footer__bottom .copyright-text p,
.store-footer__bottom .copyright-text a {
    color: #FFFFFF !important;
    opacity: 1 !important;
}

.store-footer__bottom .copyright-text p {
    margin: 0 !important;
}

@supports not (
    (backdrop-filter: blur(1px)) or
    (-webkit-backdrop-filter: blur(1px))
) {
    .store-footer__bottom::before {
        background: rgba(0, 31, 84, 0.90);
    }
}

/* ==========================================================
   11. RESPONSIVE & ACCESSIBILITY
   Mobile font sizing and reduced-motion rules.
   ========================================================== */

@media (max-width: 767px) {

    
    .s-slider-block__title h2,
    .s-block__title h2,
    .f_block__title h2 {
        font-size: 24px !important;
    }

    
    a.f_block__display-all {
        font-size: 15px !important;
    }

}

@media (prefers-reduced-motion: reduce) {

    
    .f_ad-banner-content > a,
    a.f_block__display-all,
    .f_ad-banners .f_ad-banner-img {
        animation: none !important;
    }

    
    .f_ad-banners .f_ad-banner-img {
        translate: none;
    }

    
    .faqs__item,
    .faqs__item .faq-answer,
    .faqs__item label .sicon-add {
        transition: none !important;
        transform: none !important;
    }

}


/* ==========================================================
   MFTAHY - FLOATING MOBILE LIQUID GLASS HEADER
   ==========================================================
   Purpose:
   Create a floating mobile header with soft corners,
   balanced spacing, and a subtle shadow.

   Preserves:
   - Existing Liquid Glass effect
   - Sticky header behavior
   - Safari color customization
   - Logo and navigation layout
   ========================================================== */

@media (max-width: 767px) {

    /* 01. Floating Header Settings */
    .store-header {
        --mftahy-floating-gap: 12px;
        --mftahy-floating-top: 12px;
        --mftahy-floating-radius: 26px;

        padding-top: var(--mftahy-floating-top) !important;
    }

    /* 02. Floating Header Container */
    .store-header > #mainnav {
        position: relative !important;
        inset: auto !important;
        transform: none !important;

        width: calc(
            100% - var(--mftahy-floating-gap) - var(--mftahy-floating-gap)
        ) !important;

        margin-inline: var(--mftahy-floating-gap) !important;

        border-radius: var(--mftahy-floating-radius) !important;
        overflow: visible !important;

        /* Soft Floating Shadow */
        box-shadow:
            0 8px 24px rgba(0, 31, 84, 0.14),
            0 2px 6px rgba(0, 31, 84, 0.06) !important;
    }

    /* 03. Match Liquid Glass Corners */
    .store-header > #mainnav::before {
        border-radius: inherit !important;
    }
}


/* ==========================================================
   MFTAHY - FLOATING MOBILE BOTTOM NAVIGATION
   ==========================================================
   Floating bottom bar with matching rounded corners.
   Preserves existing Liquid Glass and navigation layout.
   ========================================================== */

@media (max-width: 767px) {

    /* 01. Floating Bottom Navigation */
    .f_bottom-menu {
        left: 12px !important;
        right: 12px !important;
        bottom: 12px !important;

        width: calc(100% - 24px) !important;

        border-radius: 22px !important;

        /* Soft Floating Shadow */
        box-shadow:
            0 8px 24px rgba(0, 31, 84, 0.14),
            0 2px 6px rgba(0, 31, 84, 0.06) !important;
    }

    /* 02. Match All Header Variants */
    .thick-header .f_bottom-menu,
    .thin-header .f_bottom-menu {
        border-radius: 26px !important;
    }

    /* 03. Match Liquid Glass Corners */
    .f_bottom-menu::before {
        border-radius: inherit !important;
    }
}

/* ==========================================
   MOBILE - ZOOM CONTROL
   Disable double-tap and input focus zoom
   Keep two-finger pinch zoom enabled
   ========================================== */

@media (max-width: 767px) {

    /* Prevent Double-Tap Zoom */
    html,
    body {
        touch-action: manipulation !important;
    }

    /* Prevent Safari Input Focus Zoom */
    input:not([type="checkbox"]):not([type="radio"]):not([type="range"]),
    textarea,
    select,
    [contenteditable="true"],
    #coupon-input {
        font-size: 16px !important;
        touch-action: manipulation !important;
    }
}

/* ==========================================
   SPLASH SCREEN - LIQUID GLASS & FADE OUT
   ========================================== */

#splash-screen {
    background: rgba(248, 252, 255, 0.80) !important;

    -webkit-backdrop-filter: blur(18px) saturate(160%);
    backdrop-filter: blur(18px) saturate(160%);

    opacity: 1;
    transition: opacity 0.35s ease-in-out !important;
}

/* Smooth Exit */
#splash-screen.mftahy-splash-exit {
    opacity: 0 !important;
    pointer-events: none !important;
}


/* ==========================================
   MFTAHY - CUSTOMER ACCOUNT MENU
   ========================================== */

(() => {
    if (window.mftahyAccountMenuV2) return;
    window.mftahyAccountMenuV2 = true;

    const styleId = "mftahy-account-menu-style";

    const css = `
        /* Account Menu Appearance */
        .s-user-menu-dropdown {
            background: #F8FCFF !important;
            border-radius: 24px !important;
            box-shadow:
                0 14px 36px rgba(0, 31, 84, 0.13),
                0 3px 10px rgba(0, 31, 84, 0.05) !important;
        }

        /* Welcome Text */
        .s-user-menu-dropdown-header-content > span {
            font-size: 0 !important;
        }

        .s-user-menu-dropdown-header-content > span::after {
            content: "نورت مفتاحي";
            display: block;
            font-size: 19px;
            font-weight: 800;
            line-height: 1.4;
        }

        /* Customer Name */
        .s-user-menu-dropdown-header-content > p {
            font-size: 16px !important;
            font-weight: 700 !important;
        }

        /* Menu Text - Exclude Logout */
        .s-user-menu-dropdown-item:not(
            .s-user-menu-dropdown-item-logout
        ) .s-user-menu-dropdown-item-title {
            color: #011E54 !important;
        }

        /* Desktop */
        @media (min-width: 768px) {
            .s-user-menu-dropdown {
                width: 340px !important;
                max-width: calc(100vw - 32px) !important;
            }

            .s-user-menu-dropdown-header {
                padding: 20px 22px !important;
            }

            .s-user-menu-dropdown-list {
                padding: 12px 16px !important;
            }

            .s-user-menu-dropdown-item-link {
                padding: 12px 14px !important;
                border-radius: 12px !important;
            }

            .s-user-menu-dropdown-item:not(
                .s-user-menu-dropdown-item-logout
            ) > .s-user-menu-dropdown-item-link:hover {
                background: #EAF2FA !important;
            }
        }

        /* Mobile - Fixed Upper Center */
        @media (max-width: 767px) {
            .s-user-menu-toggler .s-user-menu-dropdown,
            .s-user-menu-toggler.opened .s-user-menu-dropdown {
                position: fixed !important;
                top: 43dvh !important;
                left: 50vw !important;
                right: auto !important;
                bottom: auto !important;

                transform: translate(-50%, -50%) !important;
                transform-origin: center center !important;

                width: calc(100vw - 32px) !important;
                max-width: 390px !important;
                max-height: calc(100dvh - 40px) !important;

                margin: 0 !important;
                overflow-y: auto !important;
                overscroll-behavior: contain !important;

                animation: none !important;
                transition: none !important;
                z-index: 2147483000 !important;
            }

            .s-user-menu-dropdown-header {
                padding: 18px 20px !important;
            }

            .s-user-menu-dropdown-list {
                padding: 10px 14px 14px !important;
            }

            .s-user-menu-dropdown-item-link {
                padding: 12px 14px !important;
                border-radius: 12px !important;
            }

            .s-user-menu-dropdown-item-title {
                font-size: 16px !important;
                font-weight: 700 !important;
            }
        }
    `;

    /* Inject Styles */
    function injectStyle(root) {
        if (root.querySelector("#" + styleId)) return;

        const style = document.createElement("style");
        style.id = styleId;
        style.textContent = css;

        if (root === document) {
            document.head.appendChild(style);
        } else {
            root.appendChild(style);
        }
    }

    injectStyle(document);

    /* Prevent Background Scrolling */
    const lockStyle = document.createElement("style");
    lockStyle.textContent = `
        @media (max-width: 767px) {
            html.mftahy-account-open,
            html.mftahy-account-open body {
                overflow: hidden !important;
                overscroll-behavior: none !important;
            }
        }
    `;
    document.head.appendChild(lockStyle);

    const observedRoots = new WeakSet();
    const roots = new Set();

    /* Update Greeting & Open State */
    function syncMenu() {
        let isOpen = false;

        roots.forEach(root => {
            const greeting = root.querySelector(
                ".s-user-menu-dropdown-header-content > span"
            );

            if (
                greeting &&
                greeting.textContent.trim() !== "نورت مفتاحي"
            ) {
                greeting.textContent = "نورت مفتاحي";
            }

            if (
                root.querySelector(
                    ".s-user-menu-toggler.opened .s-user-menu-dropdown"
                )
            ) {
                isOpen = true;
            }
        });

        document.documentElement.classList.toggle(
            "mftahy-account-open",
            isOpen && window.innerWidth <= 767
        );
    }

    /* Watch Salla Account Component */
    function attach(host) {
        const root = host.shadowRoot || host;

        if (observedRoots.has(root)) return;

        observedRoots.add(root);
        roots.add(root);

        if (host.shadowRoot) injectStyle(root);

        new MutationObserver(syncMenu).observe(root, {
            childList: true,
            subtree: true,
            attributes: true,
            attributeFilter: ["class"]
        });

        syncMenu();
    }

    function findMenus() {
        document.querySelectorAll("salla-user-menu").forEach(host => {
            attach(host);

            if (typeof host.componentOnReady === "function") {
                host.componentOnReady().then(() => attach(host));
            }
        });
    }

    /* Handle Delayed Rendering */
    if (document.readyState === "loading") {
        document.addEventListener("DOMContentLoaded", findMenus, {
            once: true
        });
    } else {
        findMenus();
    }

    const finder = new MutationObserver(() => {
        findMenus();

        if (document.querySelector("salla-user-menu")) {
            finder.disconnect();
        }
    });

    finder.observe(document.documentElement, {
        childList: true,
        subtree: true
    });

    customElements.whenDefined("salla-user-menu").then(findMenus);

    /* Block Touch Scrolling Outside Open Menu */
    document.addEventListener("touchmove", event => {
        if (
            !document.documentElement.classList.contains(
                "mftahy-account-open"
            )
        ) return;

        const insideMenu = event.composedPath().some(
            node => node?.classList?.contains(
                "s-user-menu-dropdown"
            )
        );

        if (!insideMenu && event.cancelable) {
            event.preventDefault();
        }
    }, { passive: false });

    window.addEventListener("resize", syncMenu);
})();