/* Gallery labels. Load after product-design; opt-in class only.
   DOM: .lusa-gallery-labelled > .lusa-gallery-labels >
   .lusa-gallery-labels__meta > .lusa-gallery-labels__item
   (__label + __value), plus optional __badge supplied by the template.
   Native .product-flags remains a direct sibling after the labels.
   No stock, promotion, reference or pack content is generated by CSS. */

body#product .product__container > .product__left :is(.product__carousel, .product__no-image).lusa-gallery-labelled {
  position: relative;
  isolation: isolate;
  min-width: 0;
  padding-block-start: 0;
  height: auto;
  aspect-ratio: auto;
}

/* Match the existing gallery surface when the native no-image branch is used. */
body#product .product__container > .product__left .product__no-image.lusa-gallery-labelled {
  border: 1px solid #dce7ed;
  border-radius: .75rem;
  background: #f5f8fa;
}

/* Keep the same two rings and reserve their corner in the labels' padding. */
body#product .product__container > .product__left .lusa-gallery-labelled::before,
body#product .product__container > .product__left .lusa-gallery-labelled::after {
  content: "";
  position: absolute;
  box-sizing: border-box;
  aspect-ratio: 1;
  border: 1px solid rgb(6 78 113 / 22%);
  border-radius: 50%;
  pointer-events: none;
  z-index: 0;
}

body#product .product__container > .product__left .lusa-gallery-labelled::before {
  width: 2.5rem;
  top: .25rem;
  right: .5rem;
}

body#product .product__container > .product__left .lusa-gallery-labelled::after {
  width: 1.75rem;
  top: .75rem;
  right: 1.5rem;
}

body#product .lusa-gallery-labelled > .lusa-gallery-labels {
  position: relative;
  z-index: 1;
  box-sizing: border-box;
  display: flex;
  align-items: center;
  min-width: 0;
  min-height: 3rem;
  padding: .625rem 3.75rem .625rem .875rem;
  border-bottom: 1px solid #e1eaf0;
  color: #143c50;
  line-height: 1.4;
}

body#product .lusa-gallery-labels__meta {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: .375rem .875rem;
  min-width: 0;
  max-width: 100%;
  margin: 0;
  padding: 0;
}

body#product .lusa-gallery-labels__item {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: .125rem .375rem;
  min-width: 0;
  max-width: 100%;
  margin: 0;
}

body#product .lusa-gallery-labels__label {
  min-width: 0;
  margin: 0;
  color: #526978;
  font-size: .75rem;
  font-weight: 400;
  overflow-wrap: anywhere;
}

body#product .lusa-gallery-labels__value {
  min-width: 0;
  max-width: 100%;
  margin: 0;
  color: #143c50;
  font-size: .8125rem;
  font-weight: 650;
  overflow-wrap: anywhere;
}

/* Optional state comes exclusively from HTML; no CSS eligibility inference. */
body#product .lusa-gallery-labels__badge {
  box-sizing: border-box;
  display: inline-flex;
  align-items: center;
  align-self: center;
  max-width: 100%;
  padding: .1875rem .5rem;
  border: 1px solid #d5e0e6;
  border-radius: 999px;
  color: #405967;
  background: #edf2f5;
  font-size: .6875rem;
  font-weight: 600;
  line-height: 1.45;
  white-space: normal;
  overflow-wrap: anywhere;
}

body#product .lusa-gallery-labels__badge--low {
  border-color: #e8d8a9;
  color: #725313;
  background: #fbf3dc;
}

body#product .lusa-gallery-labels__badge--out {
  border-color: #d5e0e6;
  color: #405967;
  background: #edf2f5;
}

body#product .lusa-gallery-labels__badge--backorder {
  border-color: #c6dfe4;
  color: #174f5b;
  background: #e8f3f5;
}

/* Native promotion flags stay real HTML, in their own row before the image.
   Override only positioning/flow; keep each native badge's label and colour. */
body#product .product__container > .product__left .lusa-gallery-labelled > .product-flags {
  position: static;
  inset: auto;
  z-index: auto;
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  gap: .375rem;
  box-sizing: border-box;
  width: 100%;
  max-width: 100%;
  margin: 0;
  padding: .5rem .75rem;
  list-style: none;
  transform: none;
}

body#product .lusa-gallery-labelled > .product-flags > .badge {
  min-width: 0;
  max-width: 100%;
  margin: 0;
  white-space: normal;
  overflow-wrap: anywhere;
}

/* Suppress only a duplicate native stock flag when HTML already supplies it.
   An absent stock badge never hides a native flag or infers availability. */
body#product .lusa-gallery-labelled:has(> .lusa-gallery-labels :is(.lusa-gallery-labels__badge--out, .lusa-gallery-labels__badge--backorder)) > .product-flags > .out_of_stock {
  display: none;
}

/* Do not leave a padded empty flag row when that duplicate was its sole item. */
body#product .lusa-gallery-labelled:has(> .lusa-gallery-labels :is(.lusa-gallery-labels__badge--out, .lusa-gallery-labels__badge--backorder)) > .product-flags:has(> .out_of_stock):not(:has(> :not(.out_of_stock))) {
  display: none;
}

@media (max-width: 22rem) {
  body#product .lusa-gallery-labelled > .lusa-gallery-labels {
    padding-inline-start: .625rem;
  }

  body#product .lusa-gallery-labels__meta {
    column-gap: .625rem;
  }
}
