/**
 * Xemry v3.9.13 — single-product viewport overflow containment.
 * Fixes the missing Xemry Landing Product Pages + Elementor paths that the
 * v3.9.12 description-only patch did not cover.  No global theme changes.
 */

/* Safe last line of defense. `clip` does not create a new scroll container,
   unlike `overflow: hidden`, so sticky and vertical page scrolling survive.
   The actual content-width fixes below run first. */
html:has(> body.single-product) {
  overflow-x: clip !important;
  max-width: 100%;
}
body.single-product {
  margin-inline: 0 !important;
  width: 100%;
  max-width: 100%;
  overflow-x: clip !important;
}

/* Standard WooCommerce, parent Luania, this child theme, Elementor containers.
   Allow flex and grid children to shrink rather than honor min-content widths. */
body.single-product :is(
  #page, .site, .site-content, #content, .content-area,
  .site-main, main, .luania-main, .shell, .content-wide,
  .woocommerce, .woocommerce div.product, .product.type-product,
  .luania-product-main, .woocommerce-product-gallery,
  .summary.entry-summary, .xm-product-details, .xm-product-reviews,
  .xm-product-category-sections, .xm-products-grid, .xm-cat-body,
  .elementor, .elementor-section, .elementor-container,
  .elementor-column, .elementor-widget-wrap, .elementor-widget,
  .elementor-widget-container, .e-con, .e-con-inner,
  .wp-block-group, .wp-block-columns, .wp-block-column
) {
  box-sizing: border-box;
  min-inline-size: 0 !important;
  max-inline-size: 100%;
}

/* Companion landing plugin can use xlp-* classes not present in the theme's
   ordinary .luania-product-main markup. Exclude moving slider tracks/slides. */
body.single-product [class*="xlp-"]:not([class*="track"]):not([class*="slide"]):not([class*="carousel"]):not([class*="rail"]):not([class*="marquee"]) {
  box-sizing: border-box;
  min-inline-size: 0 !important;
  max-inline-size: 100%;
}
body.single-product :is(
  .luania-product-main, .xlp-product-main, .xlp-product-layout,
  .xlp-product-grid, .xlp-product-container,
  .elementor-container, .e-con-inner
) > * {
  min-inline-size: 0;
  box-sizing: border-box;
}

/* Preserve desktop two-column presentation but permit both columns to shrink.
   Fix the upstream 350px minimum in product-bundle.css at intermediate widths. */
@media (min-width: 901px) {
  body.xm-refined.single-product .luania-product-main {
    grid-template-columns: minmax(0, 1.06fr) minmax(0, .94fr) !important;
  }
  body.single-product :is(.xlp-product-layout, .xlp-product-main) {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) !important;
  }
}
@media (max-width: 900px) {
  body.xm-refined.single-product .luania-product-main {
    display: flex !important;
    flex-direction: column !important;
    align-items: stretch !important;
    grid-template-columns: minmax(0,1fr) !important;
    inline-size: 100%;
    min-inline-size: 0 !important;
  }
  body.xm-refined.single-product .luania-product-main > :is(.woocommerce-product-gallery, .summary.entry-summary) {
    flex: 0 1 auto !important;
    min-inline-size: 0 !important;
    max-inline-size: 100% !important;
    inline-size: 100% !important;
    margin-inline: 0 !important;
  }
  body.single-product :is(.xlp-product-main, .xlp-product-layout, .xlp-product-grid) {
    grid-template-columns: minmax(0,1fr) !important;
  }
}

/* Never allow fixed-width supplier markup or text to expand the viewport. */
body.single-product :is(
  .entry-content, .woocommerce-product-details__short-description,
  .woocommerce-Tabs-panel, .woocommerce-Tabs-panel--description,
  .xm-full-description-content, .xm-admin-arabic-copy,
  .xm-accordion-body, .xlp-description, .xlp-tab-content,
  .xlp-product-description, .product-description,
  .elementor-widget-text-editor, .wp-block-post-content
) {
  min-inline-size: 0 !important;
  max-inline-size: 100%;
  overflow-wrap: anywhere;
  word-break: normal;
}
body.single-product :is(
  .entry-content, .woocommerce-product-details__short-description,
  .woocommerce-Tabs-panel, .xm-full-description-content,
  .xm-admin-arabic-copy, .xm-accordion-body,
  .xlp-description, .xlp-tab-content, .xlp-product-description,
  .elementor-widget-text-editor
) :is(div, section, article, figure, p, ul, ol, dl, blockquote) {
  box-sizing: border-box;
  min-inline-size: 0 !important;
  max-inline-size: 100% !important;
  overflow-wrap: anywhere;
}
body.single-product :is(main, .site-main, #content) :is(img, video, iframe, embed, object) {
  box-sizing: border-box;
  max-inline-size: 100% !important;
}
body.single-product :is(main, .site-main, #content) img {
  block-size: auto;
}
/* Elementor HTML/widgets can nest a fixed pixel width directly below the
   widget container without a WooCommerce description class. */
body.single-product .elementor-widget-container > :not(.swiper-wrapper):not(.slick-track):not(.splide__list),
body.single-product .elementor-widget-html :is(div, section, article, figure),
body.single-product .elementor-widget-text-editor :is(div, section, article, figure) {
  max-inline-size: 100% !important;
  min-inline-size: 0 !important;
  box-sizing: border-box;
  overflow-wrap: anywhere;
}
body.single-product :is(.wp-block-embed, .wp-block-video, .wp-block-image, .wp-block-gallery) {
  max-inline-size: 100%;
  min-inline-size: 0;
}

/* HTML descriptions: fit content instead of creating a second horizontal
   scrollbar. Tables remain tables (headers/column relationships preserved). */
body.single-product :is(
  .xm-full-description-content, .xm-admin-arabic-copy,
  .woocommerce-Tabs-panel, .entry-content, .xlp-description,
  .xlp-product-description, .elementor-widget-text-editor
) :is(table, pre) {
  max-inline-size: 100% !important;
  min-inline-size: 0 !important;
}
body.single-product :is(
  .xm-full-description-content, .xm-admin-arabic-copy,
  .woocommerce-Tabs-panel, .entry-content, .xlp-description,
  .xlp-product-description, .elementor-widget-text-editor
) table {
  display: table;
  inline-size: 100% !important;
  table-layout: fixed;
  border-collapse: collapse;
}
body.single-product :is(
  .xm-full-description-content, .xm-admin-arabic-copy,
  .woocommerce-Tabs-panel, .entry-content, .xlp-description,
  .xlp-product-description, .elementor-widget-text-editor
) :is(td, th) {
  min-inline-size: 0 !important;
  overflow-wrap: anywhere;
  white-space: normal;
}
body.single-product :is(
  .xm-full-description-content, .xm-admin-arabic-copy,
  .woocommerce-Tabs-panel, .entry-content, .xlp-description,
  .xlp-product-description, .elementor-widget-text-editor
) pre {
  white-space: pre-wrap !important;
  overflow-wrap: anywhere;
}

/* Details, attribute selectors, reviews, image galleries, upsells and cards. */
body.single-product :is(
  .woocommerce-product-gallery, .woocommerce-product-gallery .flex-viewport,
  .woocommerce-product-gallery__wrapper, .woocommerce-product-gallery__image,
  .xlp-gallery, .xlp-gallery-main, .xlp-gallery-thumbs,
  .xlp-product-summary, .xm-review-inner, .woocommerce-Reviews,
  form.cart, .variations_form, .single_variation_wrap,
  .woocommerce-variation-add-to-cart, .xm-product-accordions,
  .woocommerce .related, .woocommerce .upsells,
  .woocommerce ul.products, .xm-products-grid
) {
  min-inline-size: 0 !important;
  max-inline-size: 100% !important;
  box-sizing: border-box;
}
body.single-product :is(form.cart, .variations_form, .single_variation_wrap, .woocommerce-variation-add-to-cart) :is(input, select, textarea, button) {
  min-inline-size: 0;
  max-inline-size: 100%;
  box-sizing: border-box;
}
body.single-product :is(.woocommerce-product-gallery, .xlp-gallery, .xlp-gallery-main) :is(.flex-viewport, .swiper, .swiper-container, .slick-list, .splide__track) {
  max-inline-size: 100%;
  overflow: hidden;
}
/* Do NOT limit the dimensions of .slick-track/.swiper-wrapper/flexslider slides;
   their oversize inner tracks are necessary for touch/swipe animations. */
body.single-product :is(.woocommerce ul.products, .xm-products-grid, .xlp-products-grid) > li,
body.single-product :is(.woocommerce ul.products, .xm-products-grid, .xlp-products-grid) > div {
  min-inline-size: 0;
  max-inline-size: 100%;
}

/* Site header must not stretch just because product-specific JS/widgets load. */
@media(max-width: 720px) {
  body.single-product .xm-header-shell { min-inline-size: 0; max-inline-size: 100%; }
  body.single-product .xm-header-actions { min-inline-size: 0; }
  body.single-product .woocommerce ul.products,
  body.single-product .xm-products-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  }
  body.single-product :is(.summary.entry-summary, .xm-accordion-body, .xm-cat-body) {
    min-inline-size: 0;
    max-inline-size: 100%;
  }
}
