/* Kian Derm Before & After: scoped styles, no Elementor/theme dependency. */
.kdba-comparison,
.kdba-comparison * {
  box-sizing: border-box;
}
.kdba-comparison {
  width: 100%;
  min-width: 0;
  /* Prevent fixed-height Elementor flex containers from compressing the image into a strip. */
  flex-shrink: 0 !important;
  display: block;
  height: auto !important;
  max-height: none !important;
  margin: 0;
  padding: 0;
  border: 0;
  font-family: inherit;
  color: #193e35;
}
/* v1.0.2: Real in-flow image establishes the height of every comparison.
   Unlike an absolutely positioned image + pseudo-element spacer, this survives
   Elementor's nested flex/grid wrappers and responsive layout overrides. */
.kdba-stage {
  position: relative;
  display: block;
  width: 100%;
  height: auto !important;
  max-height: none !important;
  aspect-ratio: auto !important;
  isolation: isolate;
  overflow: hidden;
  border-radius: 12px;
  background: #e6eeeb;
  flex-shrink: 0 !important;
  -webkit-user-select: none;
  user-select: none;
}
.kdba-stage::before { content: none !important; display: none !important; }
/* Before photo participates in document flow and physically reserves height. */
.kdba-photo--before {
  position: relative !important;
  inset: auto !important;
  display: block;
  width: 100%;
  height: auto !important;
  margin: 0;
  padding: 0;
  z-index: 0;
}
.kdba-photo--before > .kdba-photo__image {
  position: relative !important;
  inset: auto !important;
  display: block !important;
  width: 100% !important;
  height: auto !important;
  max-width: none !important;
  margin: 0 !important;
  padding: 0 !important;
  border: 0 !important;
  box-shadow: none !important;
  aspect-ratio: 4 / 5;
  object-fit: cover;
  object-position: center;
}
.kdba-ratio-1-1 .kdba-photo--before > .kdba-photo__image { aspect-ratio: 1 / 1; }
.kdba-ratio-3-4 .kdba-photo--before > .kdba-photo__image { aspect-ratio: 3 / 4; }
.kdba-ratio-16-9 .kdba-photo--before > .kdba-photo__image { aspect-ratio: 16 / 9; }
/* After photo is overlaid, clipped by the slider, and tracks the in-flow image. */
.kdba-photo--after {
  position: absolute;
  inset: 0;
  z-index: 1;
  display: block;
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0;
  -webkit-clip-path: inset(0 0 0 var(--kdba-position, 50%));
  clip-path: inset(0 0 0 var(--kdba-position, 50%));
}
.kdba-photo--after > .kdba-photo__image {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  max-width: none;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  box-shadow: none;
  object-fit: cover;
  object-position: center;
}
.kdba-label {
  position: absolute;
  top: 14px;
  z-index: 2;
  display: inline-block;
  max-width: calc(50% - 20px);
  overflow: hidden;
  padding: 7px 11px;
  border-radius: 5px;
  background: rgb(20 53 46 / 84%);
  color: #fff;
  font-size: 11px;
  line-height: 1.25;
  font-weight: 700;
  letter-spacing: .05em;
  text-transform: uppercase;
  text-overflow: ellipsis;
  white-space: nowrap;
  direction: ltr;
  pointer-events: none;
}
.kdba-label--before { left: 14px; }
.kdba-label--after { right: 14px; }
.kdba-divider {
  position: absolute;
  top: 0;
  left: var(--kdba-position, 50%);
  z-index: 3;
  width: 2px;
  height: 100%;
  transform: translateX(-50%);
  background: #fff;
  box-shadow: 0 0 0 1px rgb(0 0 0 / 12%);
  pointer-events: none;
}
.kdba-handle {
  position: absolute;
  top: 50%;
  left: 50%;
  display: grid;
  place-items: center;
  width: 64px;
  height: 42px;
  transform: translate(-50%, -50%);
  border-radius: 999px;
  background: #fff;
  color: #2d705c;
  box-shadow: 0 3px 17px rgb(11 36 30 / 24%);
}
.kdba-handle svg { display: block; }
.kdba-range {
  position: absolute;
  inset: 0;
  z-index: 5;
  width: 100%;
  height: 100%;
  margin: 0 !important;
  padding: 0 !important;
  border: 0 !important;
  border-radius: 0 !important;
  background: transparent !important;
  appearance: none;
  -webkit-appearance: none;
  opacity: .001;
  cursor: ew-resize;
  touch-action: pan-y;
}
.kdba-range::-webkit-slider-runnable-track {
  width: 100%;
  height: 100%;
  background: transparent;
  border: 0;
  cursor: ew-resize;
}
.kdba-range::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 48px;
  height: 48px;
  margin-top: 0;
  border: 0;
  background: transparent;
  cursor: ew-resize;
}
.kdba-range::-moz-range-track {
  height: 100%;
  background: transparent;
  border: 0;
  cursor: ew-resize;
}
.kdba-range::-moz-range-thumb {
  width: 48px;
  height: 48px;
  border: 0;
  background: transparent;
  cursor: ew-resize;
}
.kdba-stage:focus-within { outline: 3px solid #377d67; outline-offset: 3px; }
.kdba-overlay-title {
  position: absolute;
  left: 50%;
  bottom: 14px;
  z-index: 2;
  display: block;
  max-width: calc(100% - 28px);
  padding: 10px 18px;
  transform: translateX(-50%);
  border-radius: 4px;
  background: rgb(15 59 51 / 91%);
  color: #fff;
  font-size: clamp(12px, 1.1vw, 15px);
  font-weight: 600;
  line-height: 1.4;
  text-align: center;
  pointer-events: none;
}
.kdba-caption {
  padding: 11px 2px 0;
  margin: 0;
  color: #546b64;
  font-size: 13px;
  line-height: 1.55;
  text-align: center;
}
.kdba-gallery {
  display: grid;
  grid-template-columns: repeat(var(--kdba-columns, 3), minmax(0, 1fr));
  align-items: start;
  grid-auto-rows: max-content;
  height: auto !important;
  gap: clamp(14px, 2vw, 26px);
  width: 100%;
}
.kdba-gallery__item { min-width: 0; min-height: 0; align-self: start; height: auto !important; flex-shrink: 0 !important; }
@media (max-width: 900px) {
  .kdba-gallery { grid-template-columns: repeat(min(2, var(--kdba-columns, 3)), minmax(0, 1fr)); }
}
@media (max-width: 620px) {
  .kdba-gallery { grid-template-columns: minmax(0, 1fr); }
  .kdba-label { top: 10px; padding: 7px 9px; }
  .kdba-label--before { left: 10px; }
  .kdba-label--after { right: 10px; }
  .kdba-overlay-title { bottom: 10px; }
}

/* Keep Elementor's gallery widget in normal page flow. Scoped to KDBA only. */
@supports selector(:has(*)) {
  html body .elementor-element.elementor-widget-shortcode:has(.kdba-gallery),
  html body .elementor-element.elementor-widget-kdba_comparison:has(.kdba-gallery) {
    position: relative !important;
    top: auto !important;
    bottom: auto !important;
    left: auto !important;
    right: auto !important;
    float: none !important;
    height: auto !important;
    max-height: none !important;
    overflow: visible !important;
  }
  .elementor-widget-shortcode:has(.kdba-gallery) > .elementor-widget-container,
  .elementor-widget-kdba_comparison:has(.kdba-gallery) > .elementor-widget-container,
  .elementor-widget-shortcode:has(.kdba-gallery) .elementor-shortcode {
    position: relative !important;
    height: auto !important;
    max-height: none !important;
    overflow: visible !important;
  }
  html body .elementor-element.e-con:has(.kdba-gallery) {
    position: relative !important;
    top: auto !important;
    bottom: auto !important;
    left: auto !important;
    right: auto !important;
    height: auto !important;
    max-height: none !important;
    overflow: visible !important;
  }
}
/* A single-column stack of true block elements is more resilient to theme
   flex/grid overrides on phones than a multi-row CSS grid. */
@media (max-width: 620px) {
  .kdba-gallery {
    display: block !important;
    position: relative !important;
    height: auto !important;
    max-height: none !important;
    overflow: visible !important;
  }
  .kdba-gallery__item {
    position: relative !important;
    display: block !important;
    width: 100% !important;
    height: auto !important;
    max-height: none !important;
    clear: both !important;
    float: none !important;
    margin: 0 0 24px !important;
  }
  .kdba-gallery__item:last-child { margin-bottom: 0 !important; }
}
