/* ==========================================================================
   GALLERY — Before/After Image Comparison Sliders
   ========================================================================== */

.gallery {
  background: var(--bg-2);
  padding: var(--space-section) 0;
}

.gallery__title {
  text-align: center;
}

.gallery__title::after {
  margin-left: auto;
  margin-right: auto;
}

.gallery__subline {
  font-family: var(--font-body);
  font-size: var(--text-body);
  color: var(--text-secondary);
  text-align: center;
  margin-bottom: var(--space-2xl);
}

.gallery__sliders {
  display: flex;
  flex-direction: column;
  gap: var(--space-2xl);
}

/* ==========================================================================
   SLIDER WRAPPER — Centered, max-width constrained
   ========================================================================== */

.ba-slider-wrap {
  max-width: 900px;
  margin: 0 auto;
  width: 100%;
}

/* ==========================================================================
   SLIDER CONTAINER
   ========================================================================== */

.ba-slider {
  position: relative;
  overflow: hidden;
  border-radius: 8px;
  border: 1px solid var(--border);
  aspect-ratio: 16 / 9;
  width: 100%;
  cursor: default;
  user-select: none;
  -webkit-user-select: none;
  transition: border-color var(--duration-micro) var(--ease-micro);
}

.ba-slider:hover {
  border-color: var(--border-accent);
}

.ba-slider.dragging {
  cursor: grabbing;
}

/* ==========================================================================
   AFTER IMAGE — Base layer (full, always visible)
   ========================================================================== */

.ba-after {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* ==========================================================================
   BEFORE IMAGE — Clipping overlay
   ========================================================================== */

.ba-before-wrapper {
  position: absolute;
  inset: 0;
  width: 50%;
  overflow: hidden;
  z-index: 2;
}

.ba-before {
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* ==========================================================================
   DIVIDER LINE + DRAG HANDLE
   ========================================================================== */

.ba-divider {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  width: 2px;
  background: var(--white);
  z-index: 10;
  box-shadow: 0 0 8px rgba(0, 0, 0, 0.5);
  will-change: left;
  transform: translateX(-1px);
}

.ba-handle {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--white);
  border: 2px solid var(--border-light);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: grab;
  z-index: 11;
  transition: box-shadow var(--duration-micro) var(--ease-micro),
              border-color var(--duration-micro) var(--ease-micro);
  color: var(--text-muted);
}

/* Invisible touch padding for mobile */
.ba-handle::before {
  content: '';
  position: absolute;
  inset: -12px;
}

.ba-handle:hover {
  box-shadow: 0 2px 12px rgba(255, 77, 0, 0.3);
  border-color: var(--primary-border);
}

.ba-slider.dragging .ba-handle {
  cursor: grabbing;
  box-shadow: 0 2px 12px rgba(255, 77, 0, 0.4);
  border-color: var(--primary-border);
}

/* ==========================================================================
   LABELS
   ========================================================================== */

.ba-label {
  position: absolute;
  top: 12px;
  z-index: 5;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  padding: 6px 14px;
  border-radius: 4px;
  font-family: var(--font-body);
  font-size: var(--text-small);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-primary);
  pointer-events: none;
  transition: opacity var(--duration-micro) var(--ease-micro);
}

.ba-label--before {
  left: 12px;
}

.ba-label--after {
  right: 12px;
}

/* ==========================================================================
   PLACEHOLDER FALLBACK — Shown when images fail to load
   ========================================================================== */

.ba-placeholder {
  position: absolute;
  inset: 0;
  background: var(--bg-0);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 3;
}

.ba-placeholder span {
  font-family: var(--font-body);
  font-size: var(--text-body);
  color: var(--text-muted);
  font-style: italic;
}

.ba-slider--fallback .ba-placeholder {
  display: flex;
}

.ba-slider--fallback .ba-before-wrapper,
.ba-slider--fallback .ba-divider,
.ba-slider--fallback .ba-label {
  display: none;
}

/* ==========================================================================
   CAPTION
   ========================================================================== */

.ba-caption {
  text-align: center;
  font-family: var(--font-body);
  font-size: var(--text-small);
  color: var(--text-muted);
  margin-top: var(--space-sm);
}

/* ==========================================================================
   RESPONSIVE — Tablet
   ========================================================================== */

@media (max-width: 768px) {
  .ba-slider-wrap {
    max-width: 100%;
  }

  .gallery__sliders {
    gap: var(--space-xl);
  }

  .ba-handle {
    width: 36px;
    height: 36px;
  }

  .ba-label {
    font-size: var(--text-micro);
    padding: 4px 10px;
  }
}

/* ==========================================================================
   RESPONSIVE — Small mobile label auto-hide at extremes
   ========================================================================== */

@media (max-width: 480px) {
  .ba-label--before.ba-label--hidden {
    opacity: 0;
  }

  .ba-label--after.ba-label--hidden {
    opacity: 0;
  }
}
