/*!
 * CBD Danmark Design 0.2.0 - live adjustments (every visitor, single product pages).
 * Each block is scoped to a body class that PHP adds only when that adjustment is switched on
 * (Appearance -> CBD Design -> Live adjustments). !important is used only where WooCommerce,
 * flexslider or Astra write inline styles (slide widths, viewport height/overflow, transforms).
 */

/* ---- Breadcrumb and category links above the title (markup stays in the page) ---- */
body.cbd-live-nobc.single-product .woocommerce-breadcrumb {
  display: none !important;
}
body.cbd-live-nocat.single-product .summary .single-product-category {
  display: none !important;
}

/* ---- More room under "Se din pris med ViaBill" (tablet/desktop only) ---- */
@media (min-width: 545px) {
  body.cbd-live-viabill.single-product .summary .viabill-pricetag-wrap {
    margin-bottom: 18px;
  }
}

/* ---- Square gallery: the whole image on white, never cropped ---- */
body.cbd-live-square.single-product .woocommerce-product-gallery__image > a {
  display: block;
  aspect-ratio: 1 / 1;
  background: #fff;
  overflow: hidden;
}
body.cbd-live-square.single-product .woocommerce-product-gallery__image > a img {
  display: block;
  width: 100% !important;
  height: 100% !important;
  max-height: none;
  object-fit: contain !important;
  object-position: center;
  background: #fff;
}
body.cbd-live-square.single-product .woocommerce-product-gallery__image > a picture {
  display: block;
  width: 100%;
  height: 100%;
}

/* Thumbnails: square, lighter, the selected one clearly marked. */
body.cbd-live-square.single-product .ast-single-product-thumbnails .ast-woocommerce-product-gallery__image {
  box-sizing: border-box;
  aspect-ratio: 1 / 1;
  height: auto;
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  overflow: hidden;
  cursor: pointer;
  opacity: 0.72;
  transition: opacity 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}
body.cbd-live-square.single-product .ast-single-product-thumbnails .ast-woocommerce-product-gallery__image:hover,
body.cbd-live-square.single-product .ast-single-product-thumbnails .ast-woocommerce-product-gallery__image.flex-active-slide {
  opacity: 1;
}
body.cbd-live-square.single-product .ast-single-product-thumbnails .ast-woocommerce-product-gallery__image.flex-active-slide {
  border-color: #1e293b;
  box-shadow: inset 0 0 0 1px #1e293b;
}
body.cbd-live-square.single-product .ast-single-product-thumbnails .ast-woocommerce-product-gallery__image picture {
  display: block;
  width: 100%;
  height: 100%;
}
body.cbd-live-square.single-product .ast-single-product-thumbnails .ast-woocommerce-product-gallery__image img {
  display: block;
  width: 100% !important;
  height: 100% !important;
  object-fit: contain !important;
  object-position: center;
  border: 0;
  outline: 0;
  box-shadow: none;
  background: #fff;
}
@media (prefers-reduced-motion: reduce) {
  body.cbd-live-square.single-product .ast-single-product-thumbnails .ast-woocommerce-product-gallery__image {
    transition: none;
  }
}

/* ---- Phones/tablets: native swipe gallery that shows the edge of the next image ----
   Only on a gallery live.js has set up (.cbd-swipe-on), so a blocked script never freezes it. */
@media (max-width: 921px) {
  body.cbd-live-swipe.single-product .woocommerce-product-gallery.cbd-swipe-on > .flex-viewport {
    height: auto !important;
    overflow-x: auto !important;
    overflow-y: hidden !important;
    scroll-snap-type: x mandatory;
    overscroll-behavior-x: contain;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  body.cbd-live-swipe.single-product .woocommerce-product-gallery.cbd-swipe-on > .flex-viewport::-webkit-scrollbar {
    display: none;
  }
  body.cbd-live-swipe.single-product .woocommerce-product-gallery.cbd-swipe-on > .flex-viewport > .woocommerce-product-gallery__wrapper {
    display: flex !important;
    gap: 8px;
    width: auto !important;
    margin: 0 !important;
    transform: none !important;
    transition: none !important;
  }
  body.cbd-live-swipe.single-product .woocommerce-product-gallery.cbd-swipe-on > .flex-viewport > .woocommerce-product-gallery__wrapper > .woocommerce-product-gallery__image {
    box-sizing: border-box;
    flex: 0 0 86% !important;
    width: auto !important;
    max-width: none !important;
    float: none !important;
    margin: 0 !important;
    position: relative;
    border: 1px solid #e8ebef;
    border-radius: 12px;
    overflow: hidden;
    scroll-snap-align: start;
    scroll-snap-stop: always;
  }
  body.cbd-live-swipe.single-product .woocommerce-product-gallery.cbd-swipe-on > .flex-viewport > .woocommerce-product-gallery__wrapper > .woocommerce-product-gallery__image:only-child {
    flex-basis: 100% !important;
  }

  /* Thumbnail strip: a plain horizontal scroller instead of the arrow carousel. */
  body.cbd-live-swipe.single-product .woocommerce-product-gallery.cbd-swipe-on .ast-single-product-thumbnails .flex-viewport {
    height: auto !important;
    overflow-x: auto !important;
    overflow-y: hidden !important;
    overscroll-behavior-x: contain;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  body.cbd-live-swipe.single-product .woocommerce-product-gallery.cbd-swipe-on .ast-single-product-thumbnails .flex-viewport::-webkit-scrollbar {
    display: none;
  }
  body.cbd-live-swipe.single-product .woocommerce-product-gallery.cbd-swipe-on .ast-single-product-thumbnails .woocommerce-product-gallery-thumbnails__wrapper {
    display: flex !important;
    gap: 8px;
    width: auto !important;
    transform: none !important;
    transition: none !important;
  }
  body.cbd-live-swipe.single-product .woocommerce-product-gallery.cbd-swipe-on .ast-single-product-thumbnails .ast-woocommerce-product-gallery__image {
    flex: 0 0 60px !important;
    width: 60px !important;
    margin: 0 !important;
    float: none !important;
  }
  body.cbd-live-swipe.single-product .woocommerce-product-gallery.cbd-swipe-on .ast-single-product-thumbnails .flex-direction-nav {
    display: none !important;
  }
}

/* ---- Campaign label + countdown (black, white text) ---- */
.single-product .summary .cbd-bf {
  box-sizing: border-box;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 16px;
  margin: 14px 0 20px;
  padding: 12px 16px;
  background: #000;
  color: #fff;
  border-radius: 12px;
  line-height: 1.25;
}
.single-product .summary .cbd-bf[hidden] {
  display: none !important;
}
.single-product .summary .cbd-bf p {
  margin: 0;
  padding: 0;
  color: inherit;
}
.single-product .summary .cbd-bf__label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: max(0.9375rem, 15px);
  font-weight: 700;
  letter-spacing: 0.01em;
}
.single-product .summary .cbd-bf__bolt {
  font-size: 1.1em;
  line-height: 1;
}
.single-product .summary .cbd-bf__timer {
  display: flex;
  align-items: center;
  gap: 5px;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.single-product .summary .cbd-bf__lead {
  margin-right: 3px;
  font-size: max(0.8125rem, 13px);
  color: rgba(255, 255, 255, 0.75);
}
.single-product .summary .cbd-bf__seg {
  display: inline-flex;
  align-items: baseline;
  gap: 1px;
  min-width: 2.6em;
  justify-content: center;
  padding: 4px 6px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.14);
}
.single-product .summary .cbd-bf__seg[hidden] {
  display: none !important;
}
.single-product .summary .cbd-bf__seg b {
  font-size: max(1rem, 16px);
  font-weight: 700;
  color: #fff;
}
.single-product .summary .cbd-bf__seg i {
  font-style: normal;
  font-size: max(0.75rem, 12px);
  color: rgba(255, 255, 255, 0.75);
}

/* After the campaign end on a cached page: no countdown, no crossed-out price, no sale flash. */
body.cbd-bf-ended .cbd-bf {
  display: none !important;
}
body.cbd-bf-ended.single-product .summary .price del,
body.cbd-bf-ended.single-product .summary .price del + .screen-reader-text,
body.cbd-bf-ended.single-product .cbd-bf-hide {
  display: none !important;
}
body.cbd-bf-ended.single-product .summary .price ins {
  text-decoration: none;
}
