/* PATCH-044J — Flexible page sections */
.asala-flex-sections {
    --asala-flex-brown: #8f431d;
    --asala-flex-deep: #261610;
    --asala-flex-ivory: #fbf7f1;
    --asala-flex-soft: #f5f1ed;
    --asala-flex-muted: #746a64;
    --asala-flex-gap: clamp(14px, 1.8vw, 24px);
    direction: rtl;
    width: 100%;
}

.asala-flex-section {
    position: relative;
    width: 100%;
    margin: 0;
    color: var(--asala-flex-deep);
}

.asala-flex-section--white { background: #fff; }
.asala-flex-section--ivory { background: var(--asala-flex-ivory); }
.asala-flex-section--soft { background: var(--asala-flex-soft); }
.asala-flex-section--dark { background: #241711; color: #fff; }

.asala-flex-section--space-compact { padding-block: clamp(28px, 4vw, 48px); }
.asala-flex-section--space-normal { padding-block: clamp(44px, 6vw, 76px); }
.asala-flex-section--space-large { padding-block: clamp(60px, 8vw, 104px); }
.asala-flex-section--banner,
.asala-flex-section--banner_slider { padding-block: 0; }

.asala-flex-container {
    width: min(1280px, calc(100% - 40px));
    margin-inline: auto;
}

.asala-flex-heading {
    display: flex;
    align-items: end;
    justify-content: space-between;
    gap: 24px;
    margin-bottom: clamp(24px, 3vw, 38px);
}

.asala-flex-heading-copy { min-width: 0; max-width: 760px; }
.asala-flex-eyebrow {
    display: block;
    margin-bottom: 8px;
    color: var(--asala-flex-brown);
    font-size: clamp(13px, 1.2vw, 16px);
    font-weight: 700;
    letter-spacing: .01em;
}
.asala-flex-title {
    margin: 0;
    color: inherit;
    font-size: clamp(26px, 2.65vw, 42px);
    line-height: 1.28;
    font-weight: 800;
}
.asala-flex-description {
    margin-top: 10px;
    color: var(--asala-flex-muted);
    font-size: clamp(14px, 1.15vw, 17px);
    line-height: 1.9;
}
.asala-flex-description p { margin: 0; }
.asala-flex-section--dark .asala-flex-description { color: rgba(255,255,255,.78); }
.asala-flex-section--dark .asala-flex-eyebrow { color: #e0b59c; }

.asala-flex-heading-link,
.asala-flex-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    padding: 10px 22px;
    border-radius: 7px;
    background: var(--asala-flex-brown);
    color: #fff !important;
    text-decoration: none !important;
    font-weight: 800;
    white-space: nowrap;
    transition: transform .2s ease, background-color .2s ease;
}
.asala-flex-heading-link:hover,
.asala-flex-button:hover { background: #6f3217; transform: translateY(-1px); }

/* Products */
.asala-flex-products-track.products {
    --asala-cols: var(--asala-flex-cols-desktop, 4);
    gap: var(--asala-flex-gap) !important;
    margin: 0 !important;
    padding: 0 !important;
    list-style: none !important;
}
.asala-flex-products-track.products::before,
.asala-flex-products-track.products::after { display: none !important; }

.asala-flex-products-track.products[data-layout="grid"] {
    display: grid !important;
    grid-template-columns: repeat(var(--asala-cols), minmax(0, 1fr));
}

.asala-flex-products-track.products[data-layout="rail"] {
    display: grid !important;
    grid-auto-flow: column;
    grid-auto-columns: calc((100% - (var(--asala-cols) - 1) * var(--asala-flex-gap)) / var(--asala-cols));
    grid-template-rows: minmax(0, 1fr);
    overflow-x: auto;
    overflow-y: hidden;
    scroll-snap-type: x proximity;
    overscroll-behavior-inline: contain;
    scrollbar-width: thin;
    padding-bottom: 8px !important;
}

.asala-flex-products-track.products > li.product {
    float: none !important;
    width: auto !important;
    max-width: none !important;
    min-width: 0 !important;
    margin: 0 !important;
    clear: none !important;
    scroll-snap-align: start;
}

/* Banner */
.asala-flex-banner {
    position: relative;
    isolation: isolate;
    min-height: var(--asala-banner-desktop-height, 440px);
    overflow: hidden;
    background: #e9e1da;
}
.asala-flex-banner--contained { border-radius: 18px; }
.asala-flex-banner-picture,
.asala-flex-banner-picture img {
    position: absolute;
    inset: 0;
    display: block;
    width: 100%;
    height: 100%;
}
.asala-flex-banner-picture img { object-fit: cover; object-position: center; }
.asala-flex-banner-shade {
    position: absolute;
    inset: 0;
    z-index: 1;
    background: rgba(0,0,0,var(--asala-banner-overlay,.28));
}
.asala-flex-banner-content {
    position: relative;
    z-index: 2;
    width: min(1280px, calc(100% - 40px));
    min-height: var(--asala-banner-desktop-height, 440px);
    margin-inline: auto;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: flex-start;
    padding-block: 42px;
}
.asala-flex-banner--contained .asala-flex-banner-content { width: calc(100% - 64px); }
.asala-flex-banner--center .asala-flex-banner-content { align-items: center; text-align: center; }
.asala-flex-banner--left .asala-flex-banner-content { align-items: flex-end; text-align: left; direction: ltr; }
.asala-flex-banner--light { color: #fff; }
.asala-flex-banner--light .asala-flex-description { color: rgba(255,255,255,.88); max-width: 620px; }
.asala-flex-banner--light .asala-flex-eyebrow { color: #f4d8c8; }
.asala-flex-banner--dark { color: #241711; }
.asala-flex-banner--dark .asala-flex-description { color: #514842; max-width: 620px; }
.asala-flex-banner-content .asala-flex-title { max-width: 760px; font-size: clamp(30px, 3.6vw, 58px); }
.asala-flex-banner-content .asala-flex-button { margin-top: 22px; }

/* Image grid */
.asala-flex-image-grid {
    display: grid;
    grid-template-columns: repeat(var(--asala-image-cols, 3), minmax(0, 1fr));
    gap: var(--asala-flex-gap);
}
.asala-flex-image-card {
    position: relative;
    display: block;
    min-height: clamp(280px, 34vw, 520px);
    overflow: hidden;
    border-radius: 14px;
    background: #eee6df;
    color: #fff !important;
    text-decoration: none !important;
    isolation: isolate;
}
.asala-flex-image-card picture,
.asala-flex-image-card img { display: block; width: 100%; height: 100%; }
.asala-flex-image-card picture { position: absolute; inset: 0; }
.asala-flex-image-card img { object-fit: cover; transition: transform .35s ease; }
.asala-flex-image-card::after {
    content: "";
    position: absolute;
    inset: 45% 0 0;
    z-index: 1;
    background: linear-gradient(to bottom, transparent, rgba(17,9,5,.7));
    pointer-events: none;
}
.asala-flex-image-card:hover img { transform: scale(1.025); }
.asala-flex-image-card-copy {
    position: absolute;
    z-index: 2;
    inset-inline: 20px;
    bottom: 20px;
    display: block;
}
.asala-flex-image-card-copy small,
.asala-flex-image-card-copy strong { display: block; }
.asala-flex-image-card-copy small { margin-bottom: 3px; font-size: 13px; opacity: .88; }
.asala-flex-image-card-copy strong { font-size: clamp(19px, 2vw, 28px); line-height: 1.35; }

/* Split story */
.asala-flex-split {
    display: grid;
    grid-template-columns: minmax(0, 1.06fr) minmax(0, .94fr);
    min-height: 460px;
    overflow: hidden;
    border-radius: 18px;
    background: rgba(255,255,255,.74);
    box-shadow: 0 14px 40px rgba(48,26,17,.06);
}
.asala-flex-section--dark .asala-flex-split { background: rgba(255,255,255,.06); box-shadow: none; }
.asala-flex-split--image-left .asala-flex-split-media { order: 2; }
.asala-flex-split--image-left .asala-flex-split-copy { order: 1; }
.asala-flex-split-media,
.asala-flex-split-media img { display: block; width: 100%; height: 100%; }
.asala-flex-split-media img { object-fit: cover; min-height: 460px; }
.asala-flex-split-copy {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: flex-start;
    padding: clamp(30px, 5vw, 72px);
}
.asala-flex-split-copy .asala-flex-description { max-width: 560px; }
.asala-flex-split-copy .asala-flex-button { margin-top: 22px; }

@media (max-width: 899px) {
    .asala-flex-container { width: min(100% - 32px, 900px); }
    .asala-flex-products-track.products { --asala-cols: var(--asala-flex-cols-tablet, 3); }
    .asala-flex-split { grid-template-columns: 1fr 1fr; min-height: 400px; }
    .asala-flex-split-media img { min-height: 400px; }
    .asala-flex-split-copy { padding: 28px; }
}

@media (max-width: 699px) {
    .asala-flex-section--space-compact { padding-block: 24px; }
    .asala-flex-section--space-normal { padding-block: 38px; }
    .asala-flex-section--space-large { padding-block: 52px; }
    .asala-flex-section--banner,
    .asala-flex-section--banner_slider { padding-block: 0; }
    .asala-flex-container { width: calc(100% - 28px); }

    .asala-flex-heading { align-items: flex-start; gap: 14px; }
    .asala-flex-heading-link { min-height: 38px; padding: 8px 13px; font-size: 13px; }
    .asala-flex-title { font-size: clamp(23px, 7vw, 31px); }
    .asala-flex-description { font-size: 14px; line-height: 1.8; }

    .asala-flex-products-track.products { --asala-cols: var(--asala-flex-cols-mobile, 2); --asala-flex-gap: 12px; }
    .asala-flex-products-track.products[data-layout="rail"] {
        grid-auto-columns: calc((100% - (var(--asala-cols) - 1) * var(--asala-flex-gap)) / var(--asala-cols));
        scroll-snap-type: x mandatory;
    }

    .asala-flex-banner { min-height: var(--asala-banner-mobile-height, 420px); }
    .asala-flex-banner--contained { border-radius: 14px; }
    .asala-flex-banner-content {
        min-height: var(--asala-banner-mobile-height, 420px);
        width: calc(100% - 32px);
        padding-block: 28px;
    }
    .asala-flex-banner--contained .asala-flex-banner-content { width: calc(100% - 32px); }
    .asala-flex-banner-content .asala-flex-title { font-size: clamp(28px, 9vw, 40px); }
    .asala-flex-banner--left .asala-flex-banner-content { direction: rtl; text-align: right; align-items: flex-start; }

    .asala-flex-image-grid {
        grid-template-columns: repeat(var(--asala-image-cols-mobile, 1), minmax(0, 1fr));
        gap: 12px;
    }
    .asala-flex-image-card { min-height: min(118vw, 500px); border-radius: 12px; }
    .asala-flex-image-grid[style*="--asala-image-cols-mobile:2"] .asala-flex-image-card { min-height: 64vw; }
    .asala-flex-image-card-copy { inset-inline: 14px; bottom: 14px; }

    .asala-flex-split,
    .asala-flex-split--image-left { grid-template-columns: 1fr; min-height: 0; border-radius: 14px; }
    .asala-flex-split-media,
    .asala-flex-split--image-left .asala-flex-split-media { order: 1; }
    .asala-flex-split-copy,
    .asala-flex-split--image-left .asala-flex-split-copy { order: 2; }
    .asala-flex-split-media img { min-height: 0; aspect-ratio: 4 / 3; object-fit: cover; }
    .asala-flex-split-copy { padding: 26px 22px 30px; }
}

@media (prefers-reduced-motion: reduce) {
    .asala-flex-image-card img,
    .asala-flex-heading-link,
    .asala-flex-button { transition: none !important; }
}

/* =========================================================
   PATCH-045M — multi-image banners + auto-advancing product rails
   ========================================================= */
.asala-flex-banner-slides{position:absolute;inset:0;z-index:0}.asala-flex-banner .asala-banner-rotator-slide{opacity:0;z-index:0;pointer-events:none;transition:opacity .45s ease}.asala-flex-banner .asala-banner-rotator-slide.is-active{opacity:1;z-index:1}.asala-flex-banner .asala-banner-rotator-slide.is-leaving{opacity:1;z-index:0;transition:none}.asala-flex-banner-dots{position:absolute;z-index:4;left:50%;bottom:16px;transform:translateX(-50%)}
.asala-flex-products-track.products[data-layout="rail"]{scroll-behavior:smooth}.asala-flex-products-track.products[data-layout="rail"]>li.product{scroll-snap-stop:always}
@media(prefers-reduced-motion:reduce){.asala-flex-banner .asala-banner-rotator-slide{transition:none!important}.asala-flex-products-track.products[data-layout="rail"]{scroll-behavior:auto!important}}

/* =========================================================
   PATCH-045O — Static square promotional banner tiles
   Flexible-section "Banner image" now matches the Arabian Oud-style
   promotional tile composition: same square image on all devices,
   no autoplay, 3 columns on desktop, 1 column on phones.
   ========================================================= */
.asala-flex-static-banner-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: clamp(12px, 1.6vw, 20px);
    direction: rtl;
}

.asala-flex-static-banner-card {
    position: relative;
    min-width: 0;
    margin: 0;
    overflow: hidden;
    aspect-ratio: 1 / 1;
    border-radius: 12px;
    background: #f2ece7;
    box-shadow: 0 8px 24px rgba(42, 27, 18, .055);
}

.asala-flex-static-banner-card img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
}

/* The user's rule: desktop presentation is considered complete only from
   three images upward. One/two-image sections remain available on phones. */
@media (min-width: 900px) {
    .asala-flex-section--banner-desktop-incomplete {
        display: none !important;
    }
}

@media (min-width: 700px) and (max-width: 899px) {
    .asala-flex-static-banner-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 699px) {
    .asala-flex-static-banner-grid {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .asala-flex-static-banner-card {
        width: 100%;
        border-radius: 11px;
    }
}


/* =========================================================
   PATCH-047I — Rotating banner desktop geometry
   Target canvas: 1500 × 500 px (3:1). The section remains fluid below
   1500px while preserving 3:1. Phone geometry remains unchanged.
   ========================================================= */
@media (min-width: 700px) {
    .asala-flex-section--banner_slider .asala-flex-container {
        width: min(1500px, calc(100% - 40px));
    }

    .asala-flex-section--banner_slider .asala-flex-banner {
        width: 100%;
        min-height: 0;
        aspect-ratio: 3 / 1;
    }
}

/* PATCH-047O — Phone-only section geometry; reserve space before images load. */
@media (max-width: 699px) {
    .asala-flex-section--banner_slider .asala-flex-banner {
        width: 100%;
        min-height: 0;
        aspect-ratio: 4 / 5;
    }

    .asala-flex-section--banner_slider .asala-flex-banner--mobile-wide {
        aspect-ratio: 8 / 5;
    }
}

/* PATCH-047Q: per-device viewport breakout, including classic scrollbar width.
   The existing container still owns headings and contained-mode geometry. */
@media (min-width: 700px) {
    .asala-info-page__article:has(.asala-flex-section--banner_slider .asala-flex-banner--desktop-full) {
        overflow: visible;
    }
    .asala-flex-section--banner_slider .asala-flex-banner--desktop-full {
        width: var(--asala-banner-screen-width, 100vw);
        max-width: none;
        margin-left: calc((100% - var(--asala-banner-screen-width, 100vw)) / 2 + var(--asala-banner-screen-shift, 0px));
        margin-right: calc((100% - var(--asala-banner-screen-width, 100vw)) / 2 - var(--asala-banner-screen-shift, 0px));
        border-radius: 0;
    }
}
@media (max-width: 699px) {
    .asala-info-page__article:has(.asala-flex-section--banner_slider .asala-flex-banner--phone-full) {
        overflow: visible;
    }
    .asala-flex-section--banner_slider .asala-flex-banner--phone-full {
        width: var(--asala-banner-screen-width, 100vw);
        max-width: none;
        margin-left: calc((100% - var(--asala-banner-screen-width, 100vw)) / 2 + var(--asala-banner-screen-shift, 0px));
        margin-right: calc((100% - var(--asala-banner-screen-width, 100vw)) / 2 - var(--asala-banner-screen-shift, 0px));
        border-radius: 0;
    }
}

/* PATCH-047AO — canonical Latest Products cards; preserve configured layouts. */
html body#asala-page .asala-flex-section--products .asala-flex-products-track.products {
    --asala-card-column-width: calc((100% - (var(--asala-cols) - 1) * var(--asala-flex-gap)) / var(--asala-cols));
    width: 100% !important;
    max-width: none !important;
    margin-inline: auto !important;
    align-items: stretch;
}
html body#asala-page .asala-flex-section--products .asala-flex-products-track.products[data-layout="rail"] {
    grid-template-columns: none !important;
    grid-auto-columns: var(--asala-card-column-width);
    justify-content: safe center;
}
html body#asala-page .asala-flex-section--products .asala-flex-products-track.products > li.product.asala-loop-product-item {
    width: auto !important;
    max-width: none;
}
/* Both reference and flexible subtitles use a compact catalog style. Text is
   still read from the product's optional card-subtitle field. */
html body#asala-page .asala-home-products-grid-v3 .asala-loop-product-item .asala-loop-card .asala-loop-subtitle {
    font-family: Tahoma, Arial, sans-serif !important;
    font-size: 13px !important;
    font-weight: 500 !important;
    line-height: 1.6 !important;
    color: #746a64 !important;
}
@media (max-width: 767px) {
    html body#asala-page .asala-home-products-grid-v3 .asala-loop-product-item .asala-loop-card .asala-loop-subtitle { font-size: 12px !important; }
}
    html body#asala-page .asala-flex-section--products .asala-flex-products-track.products[data-layout="grid"] {
        display: flex !important;
        flex-wrap: wrap;
        justify-content: center;
    }
    html body#asala-page .asala-flex-section--products .asala-flex-products-track.products[data-layout="grid"] > li.product.asala-loop-product-item {
        flex: 0 1 var(--asala-card-column-width);
        width: var(--asala-card-column-width) !important;
        max-width: 340px;
    }
/* Rail sizing only; card presentation comes from the shared canonical rules. */
@media (min-width: 1024px) {
    html body#asala-page .asala-flex-section--products .asala-flex-products-track.products[data-layout="rail"] {
        grid-auto-columns: min(340px, var(--asala-card-column-width));
    }
}

/* PATCH-047AP — opt-in external section gaps; grid prevents margin collapse.
   Zero defaults leave all existing section spacing unchanged. */
.asala-flex-sections {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    row-gap: 0;
}
.asala-flex-sections > .asala-flex-section {
    min-width: 0;
    margin-block-start: var(--asala-flex-before-desktop, 0px);
    margin-block-end: var(--asala-flex-after-desktop, 0px);
}
@media (min-width: 700px) and (max-width: 1023px) {
    .asala-flex-sections > .asala-flex-section {
        margin-block-start: var(--asala-flex-before-tablet, 0px);
        margin-block-end: var(--asala-flex-after-tablet, 0px);
    }
}
@media (max-width: 699px) {
    .asala-flex-sections > .asala-flex-section {
        margin-block-start: var(--asala-flex-before-mobile, 0px);
        margin-block-end: var(--asala-flex-after-mobile, 0px);
    }
}

/* "Banner image" (static) — current square-tile mode is the default.
   New horizontal/automatic modes show even a single banner on desktop. */
.asala-flex-section--banner.asala-flex-section--format-wide_1536_533 .asala-flex-container,
.asala-flex-section--banner.asala-flex-section--format-auto .asala-flex-container {
    width: min(1536px, calc(100% - 40px));
}
.asala-flex-static-banner-grid--format-wide_1536_533,
.asala-flex-static-banner-grid--format-auto {
    grid-template-columns: minmax(0, 1fr);
}
.asala-flex-static-banner-grid--format-wide_1536_533 .asala-flex-static-banner-card {
    aspect-ratio: 1536 / 533;
}
.asala-flex-static-banner-grid--format-wide_1536_533 .asala-flex-static-banner-card img {
    object-fit: contain;
}
.asala-flex-static-banner-grid--format-auto .asala-flex-static-banner-card {
    aspect-ratio: auto;
    height: auto;
}
.asala-flex-static-banner-grid--format-auto .asala-flex-static-banner-card img {
    width: 100%;
    height: auto;
    object-fit: contain;
}
@media (min-width: 700px) and (max-width: 899px) {
    .asala-flex-static-banner-grid--format-wide_1536_533,
    .asala-flex-static-banner-grid--format-auto {
        grid-template-columns: minmax(0, 1fr);
    }
}

/* "Rotating banner" — the selected canvas ratio applies responsively.
   Automatic mode uses the first image for each viewport to reserve stable
   slide height. "contain" preserves later images with differing ratios. */
@media (min-width: 700px) {
    .asala-flex-section--banner_slider.asala-flex-section--format-wide_1536_533 .asala-flex-container,
    .asala-flex-section--banner_slider.asala-flex-section--format-auto .asala-flex-container {
        width: min(1536px, calc(100% - 40px));
    }
    .asala-flex-section--banner_slider .asala-flex-banner.asala-flex-banner--format-wide_1536_533 {
        aspect-ratio: 1536 / 533;
    }
    .asala-flex-section--banner_slider .asala-flex-banner.asala-flex-banner--format-auto {
        aspect-ratio: var(--asala-banner-auto-desktop-ratio, 3 / 1);
    }
}
@media (max-width: 699px) {
    .asala-flex-section--banner_slider .asala-flex-banner.asala-flex-banner--format-wide_1536_533 {
        aspect-ratio: 1536 / 533;
    }
    .asala-flex-section--banner_slider .asala-flex-banner.asala-flex-banner--format-auto {
        aspect-ratio: var(--asala-banner-auto-mobile-ratio, 4 / 5);
    }
}
.asala-flex-banner--format-wide_1536_533 .asala-flex-banner-picture img,
.asala-flex-banner--format-auto .asala-flex-banner-picture img {
    object-fit: contain;
}
