/* MIDZ Arabic mobile hotfix
 * Loaded only for Arabic and after all shared CSS.
 * Purpose: 100% mobile parity with English — sticky card stacking, perfect header
 * navigation at top of page and on scroll, and zero element collision.
 */

/* 1. STICKY STACKING & OVERFLOW PRESERVATION FOR ARABIC
 * CSS position:sticky requires overflow-y:visible on all ancestor elements.
 * Use overflow-x:clip to prevent horizontal wobble on mobile screens without
 * creating a scroll container that breaks position:sticky.
 */
html[dir="rtl"],
html[lang="ar"],
html[dir="rtl"] body,
html[lang="ar"] body,
html[dir="rtl"] .aixor-main {
  overflow-x: clip !important;
  overflow-y: visible !important;
  max-width: 100% !important;
  width: 100% !important;
  box-sizing: border-box !important;
}

html[dir="rtl"] .feature-sec,
html[dir="rtl"] .feature-sec > .feature-project-lists,
html[dir="rtl"] .feature-sec .feature-project-lists {
  overflow: visible !important;
  overflow-x: visible !important;
  overflow-y: visible !important;
  max-width: 100% !important;
  width: 100% !important;
  box-sizing: border-box !important;
}

html[dir="rtl"] .feature-sec .feature-project {
  position: sticky !important;
  top: 8px !important;
  height: 98vh !important;
  min-height: 520px !important;
  box-sizing: border-box !important;
}

html[dir="rtl"] .feature-sec .feature-project:nth-child(1) { z-index: 1 !important; }
html[dir="rtl"] .feature-sec .feature-project:nth-child(2) { z-index: 2 !important; }
html[dir="rtl"] .feature-sec .feature-project:nth-child(3) { z-index: 3 !important; }
html[dir="rtl"] .feature-sec .feature-project:nth-child(4) { z-index: 4 !important; }
html[dir="rtl"] .feature-sec .feature-project:nth-child(5) { z-index: 5 !important; }
html[dir="rtl"] .feature-sec .feature-project:nth-child(6) { z-index: 6 !important; }
html[dir="rtl"] .feature-sec .feature-project:nth-child(7) { z-index: 7 !important; }
html[dir="rtl"] .feature-sec .feature-project:nth-child(8) { z-index: 8 !important; }

/* 2. FEATURED PROJECTS MOBILE LAYOUT & STICKY STACKING PARITY */
@media (max-width: 991px) {
  html[dir="rtl"] .feature-sec {
    padding-top: 24px !important;
    padding-bottom: 24px !important;
  }

  html[dir="rtl"] .feature-sec .section-header,
  html[dir="rtl"] .feature-sec .section-header.section-header2 {
    margin-bottom: 24px !important;
  }

  html[dir="rtl"] .feature-sec .feature-project-lists {
    gap: 16px !important;
    margin-top: 0 !important;
    padding-top: 0 !important;
  }

  /* Consistent 86vh card height matching English for clean sticky stacking */
  html[dir="rtl"] .feature-sec .feature-project {
    position: sticky !important;
    top: 6px !important;
    height: 86vh !important;
    min-height: 440px !important;
    max-height: none !important;
    padding: 12px 12px 20px !important;
    gap: 12px !important;
    border-radius: 18px !important;
    box-sizing: border-box !important;
  }

  html[dir="rtl"] .feature-sec .feature-project .img-box {
    flex: 1 1 auto !important;
    height: 100% !important;
    min-height: 220px !important;
    overflow: hidden !important;
    border-radius: 14px !important;
    position: relative !important;
  }

  html[dir="rtl"] .feature-sec .feature-project .img-box img {
    width: 100% !important;
    height: 100% !important;
    object-fit: cover !important;
    display: block !important;
  }

  html[dir="rtl"] .feature-sec .feature-project .feature-project-infos {
    display: grid !important;
    grid-template-columns: 1fr 1fr !important;
    gap: 6px 12px !important;
    padding: 6px 10px !important;
    flex-shrink: 0 !important;
    width: 100% !important;
    box-sizing: border-box !important;
  }

  html[dir="rtl"] .feature-sec .feature-project-info-box {
    width: 100% !important;
    max-width: 100% !important;
  }

  html[dir="rtl"] .feature-sec .feature-project-info-box .title {
    font-size: 11px !important;
    line-height: 14px !important;
    opacity: 0.72 !important;
  }

  html[dir="rtl"] .feature-sec .feature-project-info-box .subtitle {
    font-size: 13px !important;
    line-height: 18px !important;
    color: #ffffff !important;
  }

  /* Safe container width without overflow:hidden */
  html[dir="rtl"] .aixor-main,
  html[dir="rtl"] .custom-container,
  html[dir="rtl"] .hero-sec,
  html[dir="rtl"] .feature-sec,
  html[dir="rtl"] .about-sec,
  html[dir="rtl"] .service-sec,
  html[dir="rtl"] .contact-sec,
  html[dir="rtl"] .footer-area {
    max-width: 100% !important;
    width: 100% !important;
    box-sizing: border-box !important;
  }

  /* 3. ARABIC RTL MOBILE HEADER NAVIGATION & FLOATING MENU (☰) */
  /* Hide fixed scroll container base transform */
  html[dir="rtl"] .scroll-to-show-menu,
  html[lang="ar"] .scroll-to-show-menu,
  body.locale-ar .scroll-to-show-menu {
    display: block !important;
    visibility: visible !important;
    pointer-events: none !important;
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    width: 100% !important;
    max-width: 100% !important;
    height: 0 !important;
    transform: none !important;
    z-index: 1065 !important;
  }

  /* Round floating circular hamburger menu (52px) */
  html[dir="rtl"] .scroll-to-show-menu .hamburg-menu,
  html[lang="ar"] .scroll-to-show-menu .hamburg-menu,
  body.locale-ar .scroll-to-show-menu .hamburg-menu,
  body.is-rtl .scroll-to-show-menu .hamburg-menu {
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 5px !important;
    width: 52px !important;
    height: 52px !important;
    min-width: 52px !important;
    min-height: 52px !important;
    border: 2px solid #ffffff !important;
    border-radius: 50% !important;
    background-color: #1a1a1a !important;
    position: fixed !important;
    top: calc(max(8px, env(safe-area-inset-top, 0px)) + 8px) !important;
    left: max(14px, env(safe-area-inset-left, 0px)) !important;
    right: auto !important;
    z-index: 1066 !important;
    pointer-events: auto !important;
    cursor: pointer !important;
    transform-origin: center !important;
    transition: transform 0.3s ease, opacity 0.3s ease, background-color 0.3s ease !important;
  }

  html[dir="rtl"] .scroll-to-show-menu .hamburg-menu span,
  html[lang="ar"] .scroll-to-show-menu .hamburg-menu span,
  body.locale-ar .scroll-to-show-menu .hamburg-menu span {
    display: block !important;
    width: 18px !important;
    height: 1.5px !important;
    background-color: #ffffff !important;
    margin: 0 !important;
    transform: none !important;
    opacity: 1 !important;
  }

  html[dir="rtl"] .scroll-to-show-menu .hamburg-menu:hover,
  html[dir="rtl"] .scroll-to-show-menu .hamburg-menu:focus-visible {
    background-color: #ffffff !important;
  }

  html[dir="rtl"] .scroll-to-show-menu .hamburg-menu:hover span,
  html[dir="rtl"] .scroll-to-show-menu .hamburg-menu:focus-visible span {
    background-color: #000000 !important;
  }

  /* Hidden when at top of page (not scrolled) to prevent collision with header items */
  html[dir="rtl"] body:not(.midz-scrolled-menu):not(.menu-open) .scroll-to-show-menu:not(.is-visible) .hamburg-menu,
  body.locale-ar:not(.midz-scrolled-menu):not(.menu-open) .scroll-to-show-menu:not(.is-visible) .hamburg-menu {
    transform: scale(0) !important;
    opacity: 0 !important;
    visibility: hidden !important;
    pointer-events: none !important;
  }

  /* Reveal floating 52px circular menu on scroll down (y > 80px) or menu open */
  html[dir="rtl"] body.midz-scrolled-menu .scroll-to-show-menu .hamburg-menu,
  html[dir="rtl"] body.menu-open .scroll-to-show-menu .hamburg-menu,
  html[dir="rtl"] body.home-page.midz-scrolled-menu .scroll-to-show-menu .hamburg-menu,
  html[dir="rtl"] body.home-page.menu-open .scroll-to-show-menu .hamburg-menu,
  html[dir="rtl"] .scroll-to-show-menu.is-visible .hamburg-menu,
  body.locale-ar.midz-scrolled-menu .scroll-to-show-menu .hamburg-menu,
  body.locale-ar.menu-open .scroll-to-show-menu .hamburg-menu,
  body.home-page.locale-ar.midz-scrolled-menu .scroll-to-show-menu .hamburg-menu,
  body.home-page.locale-ar.menu-open .scroll-to-show-menu .hamburg-menu {
    display: flex !important;
    transform: scale(1) !important;
    opacity: 1 !important;
    visibility: visible !important;
    pointer-events: auto !important;
  }

  /* Inline 36px menu icon inside header bar — visible when at top of page */
  html[dir="rtl"] body:not(.midz-scrolled-menu) .header-menu-wrap .midz-header-slot-menu.hamburg-menu,
  body.locale-ar:not(.midz-scrolled-menu) .header-menu-wrap .midz-header-slot-menu.hamburg-menu {
    display: inline-flex !important;
    visibility: visible !important;
    opacity: 1 !important;
    pointer-events: auto !important;
    width: 36px !important;
    height: 36px !important;
    min-width: 36px !important;
    min-height: 36px !important;
    border: 1px solid rgba(255, 255, 255, 0.3) !important;
    border-radius: 50% !important;
    background: transparent !important;
    flex-direction: column !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 4px !important;
    cursor: pointer !important;
    margin-right: 8px !important;
  }

  html[dir="rtl"] body:not(.midz-scrolled-menu) .header-menu-wrap .midz-header-slot-menu.hamburg-menu span {
    display: block !important;
    width: 14px !important;
    height: 1px !important;
    background: #ffffff !important;
  }

  /* Fade out top header elements (logo, download icon, inline menu) on scroll down */
  html[dir="rtl"] body.midz-scrolled-menu .header-menu-wrap .logo,
  html[dir="rtl"] body.midz-scrolled-menu .header-menu-wrap .midz-header-slot-download,
  html[dir="rtl"] body.midz-scrolled-menu .header-menu-wrap .midz-language-switch--header,
  html[dir="rtl"] body.midz-scrolled-menu .header-menu-wrap .midz-header-slot-menu,
  body.locale-ar.midz-scrolled-menu .header-menu-wrap .logo,
  body.locale-ar.midz-scrolled-menu .header-menu-wrap .midz-header-slot-download,
  body.locale-ar.midz-scrolled-menu .header-menu-wrap .midz-language-switch--header,
  body.locale-ar.midz-scrolled-menu .header-menu-wrap .midz-header-slot-menu {
    opacity: 0 !important;
    visibility: hidden !important;
    pointer-events: none !important;
    transition: opacity 0.25s ease, visibility 0.25s ease !important;
  }

  /* Arabic drawer panel animation */
  html[lang="ar"][dir="rtl"] .header-sidebar-wrap .header-sidebar-content,
  body.locale-ar .header-sidebar-wrap .header-sidebar-content {
    margin-left: auto !important;
    margin-right: 0 !important;
  }

  html[lang="ar"][dir="rtl"] .header-sidebar-wrap:not(.active) .header-sidebar-content,
  body.locale-ar .header-sidebar-wrap:not(.active) .header-sidebar-content {
    transform: translate3d(100%, 0, 0) !important;
  }

  html[lang="ar"][dir="rtl"] .header-sidebar-wrap.active .header-sidebar-content,
  body.locale-ar .header-sidebar-wrap.active .header-sidebar-content {
    transform: translate3d(0, 0, 0) !important;
  }

  html[lang="ar"][dir="rtl"] .header-sidebar-wrap .close-header-sidebar,
  body.locale-ar .header-sidebar-wrap .close-header-sidebar {
    left: auto !important;
    right: 20px !important;
  }

  html[lang="ar"][dir="rtl"] .header-sidebar-wrap .header-sidebar-content .sidebar-shape,
  body.locale-ar .header-sidebar-wrap .header-sidebar-content .sidebar-shape {
    left: auto !important;
    right: -88px !important;
  }
}

@media (min-width: 641px) and (max-width: 991px) {
  html[lang="ar"][dir="rtl"] .scroll-to-show-menu .hamburg-menu,
  body.locale-ar .scroll-to-show-menu .hamburg-menu {
    left: max(20px, env(safe-area-inset-left, 0px)) !important;
  }

  html[lang="ar"][dir="rtl"] .header-sidebar-wrap .close-header-sidebar,
  body.locale-ar .header-sidebar-wrap .close-header-sidebar {
    left: auto !important;
    right: 22px !important;
  }

  html[lang="ar"][dir="rtl"] .header-sidebar-wrap .header-sidebar-content .sidebar-shape,
  body.locale-ar .header-sidebar-wrap .header-sidebar-content .sidebar-shape {
    left: auto !important;
    right: -100px !important;
  }
}
