/**
 * Before/After Comparison Section – CSS
 * ITSWEBER CMS Plugin
 */

/* ────────────────────────────────────────────────────────────────────────────
   Section Wrapper & Header
   ──────────────────────────────────────────────────────────────────────────── */

.before-after-section {
  position: relative;
  padding: 4rem 0;
}

.before-after-section.section--scheme-alt {
  background: var(--color-bg-alt, #f5f5f5);
}

.before-after-section.section--scheme-primary {
  background: var(--color-primary-light, #e8f1ff);
}

.before-after-section.section--scheme-dark {
  background: var(--color-dark, #1a1a1a);
}

.before-after-section.section--text-black {
  color: #000;
}

.before-after-section.section--text-white {
  color: #fff;
}

.before-after-section.section--text-theme {
  color: var(--color-primary, #0066cc);
}

/* Header Section */
.bas-header {
  text-align: center;
  margin-bottom: 3rem;
}

.bas-label {
  display: inline-block;
  font-size: 0.9rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--color-primary, #0066cc);
  font-weight: 600;
  margin-bottom: 0.5rem;
}

.bas-title {
  font-size: 2.25rem;
  font-weight: 700;
  line-height: 1.2;
  margin: 0;
  color: inherit;
}

@media (max-width: 768px) {
  .bas-title {
    font-size: 1.75rem;
  }
}

/* ────────────────────────────────────────────────────────────────────────────
   Grid Layout – Responsive
   ──────────────────────────────────────────────────────────────────────────── */

.bas-grid {
  display: grid;
  gap: 2rem;
  margin-top: 2rem;
}

.before-after-section.bas--cols-1 .bas-grid {
  grid-template-columns: 1fr;
  max-width: 600px;
  margin-left: auto;
  margin-right: auto;
}

.before-after-section.bas--cols-2 .bas-grid {
  grid-template-columns: repeat(2, 1fr);
}

.before-after-section.bas--cols-3 .bas-grid {
  grid-template-columns: repeat(3, 1fr);
}

@media (max-width: 1024px) {
  .before-after-section.bas--cols-3 .bas-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 640px) {
  .before-after-section.bas--cols-2 .bas-grid,
  .before-after-section.bas--cols-3 .bas-grid {
    grid-template-columns: 1fr;
  }
}

/* ────────────────────────────────────────────────────────────────────────────
   Individual Item Container
   ──────────────────────────────────────────────────────────────────────────── */

.bas-item {
  display: flex;
  flex-direction: column;
}

/* ────────────────────────────────────────────────────────────────────────────
   Slider Container – Image Comparison
   ──────────────────────────────────────────────────────────────────────────── */

.ba-slider-container {
  position: relative;
  width: 100%;
  aspect-ratio: 4 / 3;
  overflow: hidden;
  border-radius: 12px;
  background: #f0f0f0;
  user-select: none;
  cursor: col-resize;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

/* After Image – Background Layer */
.ba-after {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
  object-position: center;
}

/* Before Image – Top Layer, Clipped */
.ba-before {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
  object-position: center;
  clip-path: inset(0 50% 0 0);
  transition: clip-path 0.05s ease-out;
}

/* ────────────────────────────────────────────────────────────────────────────
   Handle – Drag Slider
   ──────────────────────────────────────────────────────────────────────────── */

.ba-handle {
  position: absolute;
  top: 0;
  left: 50%;
  width: 4px;
  height: 100%;
  transform: translateX(-50%);
  pointer-events: all;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
}

.ba-handle:hover {
  width: 6px;
}

.ba-handle-line {
  position: absolute;
  width: 4px;
  height: 100%;
  background: linear-gradient(to right,
    rgba(255, 255, 255, 0.8) 0%,
    rgba(255, 255, 255, 1) 50%,
    rgba(255, 255, 255, 0.8) 100%
  );
  box-shadow: 0 0 8px rgba(0, 0, 0, 0.3);
}

.ba-handle::before,
.ba-handle::after {
  content: '';
  position: absolute;
  width: 50px;
  height: 50px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.95);
  border: 3px solid rgba(255, 255, 255, 1);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
}

.ba-handle::before {
  content: '‹';
  font-size: 1.75rem;
  font-weight: bold;
  color: #333;
  line-height: 1;
}

.ba-handle::after {
  content: '›';
  font-size: 1.75rem;
  font-weight: bold;
  color: #333;
  line-height: 1;
  display: none;
}

/* Labels on Images */
.ba-labels {
  position: absolute;
  width: 100%;
  height: 100%;
  pointer-events: none;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: 1rem;
  box-sizing: border-box;
}

.ba-label {
  font-size: 0.875rem;
  font-weight: 600;
  padding: 0.5rem 0.875rem;
  border-radius: 4px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background: rgba(0, 0, 0, 0.5);
  color: white;
  backdrop-filter: blur(4px);
}

.ba-label-before {
  position: relative;
  align-self: flex-start;
}

.ba-label-after {
  position: absolute;
  right: 1rem;
  top: 1rem;
  opacity: 0.7;
}

/* ────────────────────────────────────────────────────────────────────────────
   Item Content – Title & Description Below Slider
   ──────────────────────────────────────────────────────────────────────────── */

.bas-item-content {
  margin-top: 1rem;
}

.bas-item-title {
  font-size: 1.25rem;
  font-weight: 600;
  margin: 0 0 0.5rem 0;
  color: inherit;
}

.bas-item-description {
  font-size: 0.95rem;
  line-height: 1.5;
  margin: 0;
  color: inherit;
  opacity: 0.85;
}

/* ────────────────────────────────────────────────────────────────────────────
   Touch & Mobile Optimization
   ──────────────────────────────────────────────────────────────────────────── */

@media (hover: none) and (pointer: coarse) {
  .ba-slider-container {
    cursor: grab;
  }

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

  .ba-handle {
    width: 8px;
  }

  .ba-handle-line {
    width: 8px;
  }
}

/* ────────────────────────────────────────────────────────────────────────────
   Accessibility & Keyboard Support
   ──────────────────────────────────────────────────────────────────────────── */

.ba-slider-container:focus-visible {
  outline: 2px solid var(--color-primary, #0066cc);
  outline-offset: 2px;
}

/* ────────────────────────────────────────────────────────────────────────────
   Responsive Adjustments
   ──────────────────────────────────────────────────────────────────────────── */

@media (max-width: 768px) {
  .before-after-section {
    padding: 3rem 0;
  }

  .bas-header {
    margin-bottom: 2rem;
  }

  .bas-label {
    font-size: 0.8rem;
  }

  .bas-title {
    font-size: 1.5rem;
  }

  .bas-grid {
    gap: 1.5rem;
  }

  .ba-slider-container {
    aspect-ratio: 3 / 2;
    border-radius: 8px;
  }

  .ba-label {
    font-size: 0.75rem;
    padding: 0.375rem 0.625rem;
  }

  .ba-handle {
    width: 6px;
  }

  .ba-handle:hover {
    width: 8px;
  }

  .ba-handle-line {
    width: 6px;
  }

  .ba-handle::before,
  .ba-handle::after {
    width: 40px;
    height: 40px;
    border-width: 2px;
    font-size: 1.5rem;
  }
}

@media (max-width: 480px) {
  .before-after-section {
    padding: 2rem 0;
  }

  .bas-grid {
    gap: 1rem;
  }

  .bas-item-title {
    font-size: 1.1rem;
  }

  .bas-item-description {
    font-size: 0.9rem;
  }

  .ba-slider-container {
    aspect-ratio: 1 / 1;
    border-radius: 6px;
  }

  .ba-label {
    font-size: 0.7rem;
    padding: 0.25rem 0.5rem;
  }

  .ba-labels {
    padding: 0.75rem;
  }

  .ba-handle::before,
  .ba-handle::after {
    width: 36px;
    height: 36px;
    font-size: 1.25rem;
  }
}

/* ────────────────────────────────────────────────────────────────────────────
   Reduced Motion Support
   ──────────────────────────────────────────────────────────────────────────── */

@media (prefers-reduced-motion: reduce) {
  .ba-before {
    transition: none;
  }

  .ba-handle,
  .ba-label {
    transition: none;
  }
}

/* ────────────────────────────────────────────────────────────────────────────
   Print Styles
   ──────────────────────────────────────────────────────────────────────────── */

@media print {
  .ba-slider-container {
    aspect-ratio: auto;
    height: 400px;
  }

  .ba-handle,
  .ba-labels {
    display: none !important;
  }

  .ba-before {
    clip-path: none !important;
  }
}
