/* ========================================
   DENTAL BEFORE & AFTER GALLERY CSS
   ======================================== */

/* Grid Layout */
.dba-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 24px;
  max-width: 1400px;
  margin: 0 auto;
  padding: 20px;
}

/* Single Case Card */
.dba-item {
  border-radius: 16px;
  overflow: hidden;
  background: #fff;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.dba-item:hover {
  transform: translateY(-4px);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.12);
}

/* Compare Container — the single positioning context */
.dba-compare-container {
  position: relative;
  width: 100%;
  aspect-ratio: 4 / 3;
  overflow: hidden;
  cursor: ew-resize;
  user-select: none;
  -webkit-user-select: none;
}

/* ── AFTER image: full size, sits in the back ── */
.dba-after-img {
  position: absolute;
  inset: 0;
  z-index: 1;
}

.dba-after-img img {
  width: 100%;
  height: 100% !important;
  object-fit: cover;
  display: block;
}

/* ── BEFORE image: also full size, clipped by its wrapper ──
   The wrapper shrinks in width; the image stays at the
   container's full width so object-fit: cover works correctly. */
.dba-before-img {
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  overflow: hidden;   /* this is what clips the before image */
  z-index: 2;
  /* width is set inline by JS, starts at 50% */
}

.dba-before-img img {
  position: absolute;  /* take img out of wrapper's flow */
  top: 0;
  left: 0;
  width: var(--dba-container-width, 100%); /* updated by JS */
  height: 100% !important;
  object-fit: cover;
  display: block;
  max-width: none;
}

/* Labels */
.dba-label {
  position: absolute;
  top: 12px;
  padding: 6px 14px;
  border-radius: 20px;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  pointer-events: none;
}

/* Before label — top-left, z above the before-img */
.dba-before-img .dba-label {
  left: 12px;
  z-index: 3;
  background: rgba(0, 0, 0, 0.6);
  color: #fff;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

/* After label — top-right, z above after-img but below before */
.dba-after-img .dba-label {
  right: 12px;
  z-index: 3;
  background: rgba(255, 255, 255, 0.9);
  color: #1a1a1a;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

/* Slider Handle */
.dba-slider-control {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 3px;
  background: #fff;
  z-index: 5;
  transform: translateX(-50%);
  box-shadow: 0 0 15px rgba(0, 0, 0, 0.25);
  cursor: ew-resize;
  /* left is set inline by JS */
}

.dba-slider-control::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 44px;
  height: 44px;
  background: #fff;
  border-radius: 50%;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
  border: 3px solid #f0f0f0;
}

.dba-slider-control::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 16px;
  height: 16px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 16 16'%3E%3Cpath fill='none' stroke='%23666' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round' d='M5 3l-4 5 4 5M11 3l4 5-4 5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: center;
  pointer-events: none;
}

/* Responsive */
@media (max-width: 1024px) {
  .dba-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
  }
}

@media (max-width: 640px) {
  .dba-grid {
    grid-template-columns: 1fr;
    gap: 16px;
    padding: 12px;
  }

  .dba-compare-container {
    aspect-ratio: 1 / 1;
  }

  .dba-slider-control::before {
    width: 36px;
    height: 36px;
  }
}

/* Prevent image drag ghost */
.dba-compare-container img {
  -webkit-user-drag: none;
  user-drag: none;
}
