/* =========================================================
   BabyLife 2.9.8 — legacy builder layout neutralizer
   Xtra / Codevz / WPBakery (Visual Composer) compatibility hardening.
   Presentation only: no content, URL, heading, SEO meta, schema or DB writes.
   ========================================================= */

/* Keep every legacy-builder content root inside the viewport. */
body :is(
  .entry-content,
  .blsc-elementor-content,
  .blsc-existing-home-elementor,
  .woocommerce-Tabs-panel
) {
  min-width: 0;
}

/* Old VC/Xtra rows commonly retain desktop widths, negative offsets or floats.
   The modern theme owns layout now, so legacy rows become safe full-width flow. */
body :is(
  .entry-content,
  .blsc-elementor-content,
  .blsc-existing-home-elementor,
  .woocommerce-Tabs-panel
) :is(
  .vc_row,
  .vc_row-fluid,
  .wpb_row,
  .cz_row,
  .codevz-con-stretch-yes,
  .cz_content_box,
  .cz_content_box_inner
) {
  display: block !important;
  float: none !important;
  clear: both !important;
  width: 100% !important;
  min-width: 0 !important;
  max-width: 100% !important;
  margin-left: 0 !important;
  margin-right: 0 !important;
  left: auto !important;
  right: auto !important;
  inset-inline: auto !important;
  transform: none !important;
  box-sizing: border-box !important;
}

/* The main source of the half-screen bug: legacy 1/2, 1/3, etc. columns.
   Flatten them into document order. This preserves all text/images/links while
   removing dependence on VC/Codevz grid CSS. */
body :is(
  .entry-content,
  .blsc-elementor-content,
  .blsc-existing-home-elementor,
  .woocommerce-Tabs-panel
) :is(
  .vc_column_container,
  .vc_column-inner,
  .wpb_column,
  [class^="vc_col-"],
  [class*=" vc_col-"],
  [class^="cz_col_"],
  [class*=" cz_col_"]
) {
  float: none !important;
  clear: both !important;
  width: 100% !important;
  min-width: 0 !important;
  max-width: 100% !important;
  flex: 0 0 100% !important;
  flex-basis: 100% !important;
  margin-left: 0 !important;
  margin-right: 0 !important;
  left: auto !important;
  right: auto !important;
  box-sizing: border-box !important;
}

/* Internal text/image wrappers should no longer inherit removed-builder widths. */
body :is(
  .entry-content,
  .blsc-elementor-content,
  .blsc-existing-home-elementor,
  .woocommerce-Tabs-panel
) :is(
  .wpb_wrapper,
  .wpb_text_column,
  .cz_title,
  .cz_title_content,
  .cz_wpe_content,
  .cz_image,
  .cz_image_in,
  .cz_grid,
  .cz_grid_items,
  .cz_posts_container,
  .vc_single_image-wrapper
) {
  min-width: 0 !important;
  max-width: 100% !important;
  box-sizing: border-box !important;
}

/* Media remains proportional. Do not stretch small assets, only prevent overflow. */
body :is(
  .entry-content,
  .blsc-elementor-content,
  .blsc-existing-home-elementor,
  .woocommerce-Tabs-panel
) :is(
  .vc_row,
  .wpb_row,
  .wpb_wrapper,
  .cz_row,
  .cz_content_box,
  .cz_wpe_content
) img:not(.emoji):not(.wp-smiley),
body :is(
  .entry-content,
  .blsc-elementor-content,
  .blsc-existing-home-elementor,
  .woocommerce-Tabs-panel
) :is(video, iframe, embed, object) {
  max-width: 100% !important;
  box-sizing: border-box !important;
}

body :is(
  .entry-content,
  .blsc-elementor-content,
  .blsc-existing-home-elementor,
  .woocommerce-Tabs-panel
) :is(
  .vc_row,
  .wpb_row,
  .wpb_wrapper,
  .cz_row,
  .cz_content_box,
  .cz_wpe_content
) img:not(.emoji):not(.wp-smiley),
body :is(
  .entry-content,
  .blsc-elementor-content,
  .blsc-existing-home-elementor,
  .woocommerce-Tabs-panel
) video {
  height: auto !important;
}

/* Elementor can still remember a 50% host column around an obsolete Codevz/VC
   widget. The tiny frontend detector adds these classes only when legacy markup
   is actually present, so healthy native Elementor sections are untouched. */
body .elementor-container.blsc-legacy-builder-parent,
body .e-con-inner.blsc-legacy-builder-parent,
body .e-con.blsc-legacy-builder-parent {
  flex-wrap: wrap !important;
  min-width: 0 !important;
  max-width: 100% !important;
}

body :is(.elementor-column, .e-con, .elementor-widget).blsc-legacy-builder-host {
  width: 100% !important;
  min-width: 0 !important;
  max-width: 100% !important;
  flex: 0 0 100% !important;
  flex-basis: 100% !important;
  margin-left: 0 !important;
  margin-right: 0 !important;
  left: auto !important;
  right: auto !important;
}

/* Empty sibling columns left behind by the old builder are suppressed only
   when JS has positively identified a legacy host in the same row. */
body .blsc-legacy-builder-parent > .blsc-legacy-builder-empty {
  display: none !important;
}

/* CSS-only fallback for modern browsers if JS is delayed by an optimizer. */
@supports selector(:has(*)) {
  body .blsc-elementor-content .elementor-column:has(
    .vc_row, .wpb_row, .wpb_column, [class*="vc_col-"], [class*="cz_"], [class*="codevz"], [class*="xtra"]
  ) {
    width: 100% !important;
    max-width: 100% !important;
    flex: 0 0 100% !important;
  }

  body .blsc-elementor-content .elementor-container:has(
    > .elementor-column .vc_row,
    > .elementor-column .wpb_row,
    > .elementor-column [class*="cz_"],
    > .elementor-column [class*="codevz"],
    > .elementor-column [class*="xtra"]
  ) {
    flex-wrap: wrap !important;
  }
}

/* Long legacy inline values must never create page-level horizontal scroll. */
body :is(
  .entry-content,
  .blsc-elementor-content,
  .blsc-existing-home-elementor,
  .woocommerce-Tabs-panel
) :is(
  .vc_row,
  .wpb_row,
  .wpb_column,
  .vc_column_container,
  [class^="vc_col-"],
  [class*=" vc_col-"],
  .cz_row,
  .cz_content_box,
  [class^="cz_col_"],
  [class*=" cz_col_"]
) [style*="width:"] {
  max-width: 100% !important;
}

@media (max-width: 900px) {
  body :is(
    .entry-content,
    .blsc-elementor-content,
    .blsc-existing-home-elementor,
    .woocommerce-Tabs-panel
  ) :is(
    .vc_row,
    .wpb_row,
    .cz_row,
    .vc_column_container,
    .wpb_column,
    [class^="vc_col-"],
    [class*=" vc_col-"],
    [class^="cz_col_"],
    [class*=" cz_col_"]
  ) {
    padding-left: min(16px, 3vw) !important;
    padding-right: min(16px, 3vw) !important;
  }
}

@media (max-width: 767px) {
  body :is(
    .entry-content,
    .blsc-elementor-content,
    .blsc-existing-home-elementor,
    .woocommerce-Tabs-panel
  ) :is(
    .vc_row,
    .wpb_row,
    .cz_row,
    .vc_column_container,
    .wpb_column,
    [class^="vc_col-"],
    [class*=" vc_col-"],
    [class^="cz_col_"],
    [class*=" cz_col_"]
  ) {
    padding-left: 0 !important;
    padding-right: 0 !important;
  }

  body :is(
    .entry-content,
    .blsc-elementor-content,
    .blsc-existing-home-elementor,
    .woocommerce-Tabs-panel
  ) iframe {
    width: 100% !important;
  }
}
