/**
 * Staging OC — Before/After comparison component
 *
 * Design tokens mirror the site's editorial palette (cream / warm ink / taupe /
 * gold, Cormorant Garamond + Inter) used on the homepage and city pages, so the
 * component reads as native inside a case study.
 *
 * Everything is scoped under .soc-ba / .soc-ba-group so nothing leaks into the
 * Beaver Builder theme or page-level styles.
 */

.soc-ba-group {
  --soc-ba-gap: 30px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--soc-ba-gap);
  margin: 2.75rem 0 3.25rem;
  align-items: start;
}

/* wpautop inserts stray <br> / empty <p> between the nested shortcodes; as grid
   items they broke the 2x2 layout, so hide them. */
.soc-ba-group br { display: none; }
.soc-ba-group > p:empty { display: none; }

/* A single comparison shouldn't stretch the full content width. */
.soc-ba-group--1 {
  grid-template-columns: minmax(0, 520px);
  justify-content: center;
}

/* Hero layout: feature the first comparison (centered, capped width), then lay
   the remaining comparisons out in a supporting row beneath it. */
.soc-ba-group--hero {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}
.soc-ba-group--hero > .soc-ba:first-child {
  grid-column: 1 / -1;
  max-width: 560px;
  margin-left: auto;
  margin-right: auto;
}

/* Collapse to a single column on phones. */
@media (max-width: 700px) {
  .soc-ba-group,
  .soc-ba-group--hero {
    grid-template-columns: 1fr;
  }
}

.soc-ba {
  /* Position of the wipe. JS updates this; CSS does the rest. */
  --soc-ba-pos: 50%;

  --soc-ba-cream: #faf6ed;
  --soc-ba-cream-2: #f0eadb;
  --soc-ba-ink: #1f1d1a;
  --soc-ba-body: #3d3935;
  --soc-ba-taupe: #8a7355;
  --soc-ba-gold: #c9a96e;
  --soc-ba-muted: #7a716a;
  --soc-ba-ratio: 3 / 4;

  margin: 0;
  font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
}

.soc-ba__frame {
  position: relative;
  aspect-ratio: var(--soc-ba-ratio);
  overflow: hidden;
  border-radius: 4px;
  background: var(--soc-ba-cream-2);
  box-shadow: 0 18px 42px -26px rgba(31, 29, 26, 0.55);
  /* Let vertical scrolling through the component still work on touch. */
  touch-action: pan-y;
}

.soc-ba__layer {
  position: absolute;
  inset: 0;
  margin: 0;
}

.soc-ba__layer img,
.soc-ba__layer picture {
  display: block;
  width: 100%;
  height: 100%;
}

.soc-ba__layer img {
  object-fit: cover;
}

/* The "before" sits on top and is wiped away from the right edge.
   clip-path avoids any image squashing as the divider moves. */
.soc-ba__layer--before {
  clip-path: inset(0 calc(100% - var(--soc-ba-pos)) 0 0);
  z-index: 2;
}

/* ---- Labels ---- */

.soc-ba__tag {
  position: absolute;
  top: 12px;
  z-index: 3;
  padding: 6px 13px;
  border-radius: 100px;
  font-size: 0.66rem;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--soc-ba-cream);
  pointer-events: none;
  white-space: nowrap;
}

.soc-ba__tag--before {
  left: 12px;
  background: rgba(31, 29, 26, 0.74);
}

.soc-ba__tag--after {
  right: 12px;
  background: rgba(138, 115, 85, 0.92);
}

/* ---- Divider + handle ---- */

.soc-ba__divider {
  position: absolute;
  top: 0;
  bottom: 0;
  left: var(--soc-ba-pos);
  width: 2px;
  margin-left: -1px;
  z-index: 4;
  background: rgba(250, 246, 237, 0.92);
  box-shadow: 0 0 0 1px rgba(31, 29, 26, 0.16);
  pointer-events: none;
}

.soc-ba__handle {
  position: absolute;
  top: 50%;
  left: var(--soc-ba-pos);
  transform: translate(-50%, -50%);
  z-index: 5;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--soc-ba-cream);
  border: 1px solid var(--soc-ba-taupe);
  box-shadow: 0 6px 18px -6px rgba(31, 29, 26, 0.6);
  color: var(--soc-ba-taupe);
  pointer-events: none;
}

.soc-ba__handle svg {
  width: 18px;
  height: 18px;
  display: block;
}

/* ---- The actual control ----
   A native range input stretched over the frame. This gives us pointer drag,
   touch drag, click-to-jump, and full keyboard support (arrows / Home / End)
   plus screen-reader semantics for free. It's visually hidden; the handle and
   divider above are the visible affordance. */

.soc-ba__range {
  position: absolute;
  inset: 0;
  z-index: 6;
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0;
  opacity: 0;
  cursor: ew-resize;
  background: transparent;
  -webkit-appearance: none;
  appearance: none;
}

.soc-ba__range::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 44px;
  height: 44px;
  border: 0;
}

.soc-ba__range::-moz-range-thumb {
  width: 44px;
  height: 44px;
  border: 0;
  opacity: 0;
}

/* Keyboard focus lands on the invisible range — surface it on the handle. */
.soc-ba__range:focus-visible {
  outline: none;
}

.soc-ba__range:focus-visible ~ .soc-ba__handle {
  outline: 3px solid var(--soc-ba-gold);
  outline-offset: 3px;
}

/* ---- Caption ---- */

.soc-ba__caption {
  margin-top: 0.85rem;
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-size: 1.2rem;
  font-weight: 500;
  line-height: 1.3;
  color: var(--soc-ba-ink);
}

.soc-ba__hint {
  display: block;
  margin-top: 0.25rem;
  font-family: 'Inter', system-ui, sans-serif;
  font-size: 0.68rem;
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--soc-ba-muted);
}

/* ---- Fallback: no JS ----
   Until JS marks the component ready, render a clean labeled side-by-side
   pair instead of a broken slider. */

.soc-ba:not(.soc-ba--ready) .soc-ba__frame {
  aspect-ratio: auto;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 3px;
  background: transparent;
  box-shadow: none;
  overflow: visible;
}

.soc-ba:not(.soc-ba--ready) .soc-ba__layer {
  position: relative;
  inset: auto;
  clip-path: none;
  aspect-ratio: var(--soc-ba-ratio);
  overflow: hidden;
  border-radius: 4px;
  box-shadow: 0 14px 32px -22px rgba(31, 29, 26, 0.55);
}

.soc-ba:not(.soc-ba--ready) .soc-ba__layer--before {
  order: -1;
}

.soc-ba:not(.soc-ba--ready) .soc-ba__tag--after {
  right: auto;
  left: calc(50% + 12px);
}

.soc-ba:not(.soc-ba--ready) .soc-ba__range,
.soc-ba:not(.soc-ba--ready) .soc-ba__divider,
.soc-ba:not(.soc-ba--ready) .soc-ba__handle {
  display: none;
}

@media (prefers-reduced-motion: reduce) {
  .soc-ba,
  .soc-ba * {
    transition: none !important;
  }
}

/* Print: show both halves rather than a half-wiped image. */
@media print {
  .soc-ba .soc-ba__frame {
    display: grid;
    grid-template-columns: 1fr 1fr;
    aspect-ratio: auto;
  }
  .soc-ba .soc-ba__layer {
    position: relative;
    inset: auto;
    clip-path: none;
  }
  .soc-ba .soc-ba__range,
  .soc-ba .soc-ba__divider,
  .soc-ba .soc-ba__handle {
    display: none;
  }
}
