/* Homepage mobile layer only. Desktop styles remain untouched. */
@media (max-width: 760px) {
    html,
    body {
        width: 100% !important;
        max-width: 100% !important;
        overflow-x: clip !important;
    }

    .re-header,
    .re-hero,
    .re-search,
    .re-section,
    .re-benefits,
    .re-footer,
    .re-copyright {
        max-width: 100% !important;
    }

    .re-hero-inner,
    .re-search,
    .re-section > .container,
    .re-benefits > .container,
    .re-footer-news > .container,
    .re-footer > .container {
        width: calc(100% - 24px) !important;
        max-width: none !important;
        margin-inline: auto !important;
        box-sizing: border-box !important;
    }

    /* قائمة الجوال: زر القائمة نفسه يصبح زر إغلاق عند فتحها */
    .re-menu-toggle {
        position: relative !important;
        z-index: 120 !important;

        min-height: 42px !important;
        cursor: pointer !important;
    }

    body:has(.re-mobile-nav:not([hidden])) .re-menu-toggle {
        font-size: 0 !important;
    }

    body:has(.re-mobile-nav:not([hidden])) .re-menu-toggle::after {
        content: "×";
        display: block;
        font-size: 30px;
        line-height: 1;
        font-weight: 400;
    }

    /* منع أي عنصر عريض من دفع الصفحة إلى اليمين */
    .re-hero-inner,
    .re-hero-copy,
    .re-hero-card-wrap,
    .re-search,
    .re-section-head,
    .re-property-grid,
    .re-type-grid,
    .re-area-grid,
    .re-slider,
    .re-news-inner,
    .re-footer-grid {
        min-width: 0 !important;
        box-sizing: border-box !important;
    }

    .re-hero-copy,
    .re-hero-card-wrap {
        max-width: 100% !important;
    }

    /* أنواع العقارات: 4 فقط، تصنيفان في كل سطر */
    .re-type-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
        gap: 10px !important;
    }

    .re-type-grid .re-type-card {
        min-width: 0 !important;
        width: 100% !important;
        box-sizing: border-box !important;
    }

    .re-type-grid .re-type-card:nth-child(n + 5) {
        display: none !important;
    }

    /* المناطق الأكثر بحثاً: 4 فقط، منطقتان في كل سطر */
    .re-area-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
        gap: 10px !important;
    }

    .re-area-grid > a {
        width: 100% !important;
        min-width: 0 !important;
        box-sizing: border-box !important;
    }

    .re-area-grid > a:nth-child(n + 5) {
        display: none !important;
    }

    /* النشرة البريدية: حجم منطقي للزر */
    .re-news-inner {
        align-items: stretch !important;
        gap: 16px !important;
    }

    .re-news-inner form {
        width: 100% !important;
        max-width: 360px !important;
        margin-inline: auto !important;
        display: flex !important;
        align-items: stretch !important;
        gap: 7px !important;
    }

    .re-news-inner input {
        min-width: 0 !important;
        width: auto !important;
        flex: 1 1 auto !important;
        border-radius: 6px !important;
    }

    .re-news-inner button {
        flex: 0 0 105px !important;
        width: 105px !important;
        margin: 0 !important;
        border-radius: 6px !important;
        padding: 0 10px !important;
        white-space: nowrap !important;
    }
}

@media (max-width: 420px) {
    .re-hero-inner,
    .re-search,
    .re-section > .container,
    .re-benefits > .container,
    .re-footer-news > .container,
    .re-footer > .container {
        width: calc(100% - 20px) !important;
    }

    .re-news-inner button {
        flex-basis: 96px !important;
        width: 96px !important;
        font-size: 11px !important;
    }
}

/* =========================================================
   FINAL MOBILE SAFETY OVERRIDES
   Homepage only — fixes horizontal overflow/alignment.
   Existing homepage rules above are intentionally preserved.
   ========================================================= */
@media (max-width: 760px) {
    html,
    body {
        width: 100vw !important;
        max-width: 100vw !important;
        min-width: 0 !important;
        margin: 0 !important;
        padding-left: 0 !important;
        padding-right: 0 !important;
        overflow-x: hidden !important;
    }

    body {
        position: relative !important;
        left: 0 !important;
        right: 0 !important;
    }

    /* Keep the page itself centered inside the viewport. */
    .re-header,
    .re-hero,
    .re-search,
    .re-section,
    .re-benefits,
    .re-footer-news,
    .re-footer,
    .re-copyright {
        width: 100% !important;
        max-width: 100vw !important;
        margin-left: auto !important;
        margin-right: auto !important;
        box-sizing: border-box !important;
    }

    .re-hero-inner,
    .re-search,
    .re-section > .container,
    .re-benefits > .container,
    .re-footer-news > .container,
    .re-footer > .container {
        width: calc(100vw - 20px) !important;
        max-width: calc(100vw - 20px) !important;
        min-width: 0 !important;
        margin-left: auto !important;
        margin-right: auto !important;
        box-sizing: border-box !important;
    }

    /* Prevent flex/grid children from creating a horizontal page width. */
    .re-hero-inner > *,
    .re-search > *,
    .re-section-head > *,
    .re-news-inner > *,
    .re-footer-grid > * {
        min-width: 0 !important;
        max-width: 100% !important;
        box-sizing: border-box !important;
    }

    /* The mobile menu stays inside the viewport. */
    .re-mobile-nav {
        max-width: 100vw !important;
        box-sizing: border-box !important;
    }

    /*
     * When the menu is open, show a clear X in the existing toggle.
     * This does not change the menu's existing open/close mechanism.
     */
    body:has(.re-mobile-nav:not([hidden])) .re-menu-toggle {
        font-size: 0 !important;
        line-height: 1 !important;
    }

    body:has(.re-mobile-nav:not([hidden])) .re-menu-toggle::after {
        content: "×" !important;
        display: inline-block !important;
        font-size: 30px !important;
        line-height: 42px !important;
        font-weight: 400 !important;
        width: 100% !important;
        height: 100% !important;
        text-align: center !important;
    }
}


/* =========================================================
   FINAL VIEWPORT ALIGNMENT
   Fixes the left-side blank space when navigating on mobile.
   Does not alter desktop styles or the existing homepage sections.
   ========================================================= */
@media (max-width: 760px) {
    html {
        width: 100% !important;
        max-width: 100% !important;
        min-width: 0 !important;
        margin: 0 !important;
        padding: 0 !important;
        overflow-x: hidden !important;
    }

    body {
        width: 100% !important;
        max-width: 100% !important;
        min-width: 0 !important;
        margin: 0 !important;
        padding-left: 0 !important;
        padding-right: 0 !important;
        left: auto !important;
        right: auto !important;
        transform: none !important;
        overflow-x: hidden !important;
    }

    /* Prevent the page shell/header or any full-width section
       from creating a second horizontal viewport. */
    body > * {
        max-width: 100% !important;
        box-sizing: border-box !important;
    }

    .re-header,
    .re-hero,
    .re-search,
    .re-section,
    .re-benefits,
    .re-footer-news,
    .re-footer,
    .re-copyright {
        position: relative !important;
        left: auto !important;
        right: auto !important;
        transform: none !important;
    }

    /* Keep all homepage containers anchored to the viewport. */
    .re-hero-inner,
    .re-search,
    .re-section > .container,
    .re-benefits > .container,
    .re-footer-news > .container,
    .re-footer > .container {
        margin-left: auto !important;
        margin-right: auto !important;
        transform: none !important;
    }
}
