/* ==========================================================================
   SHOWPIECE 2 — Before / After reveal
   --------------------------------------------------------------------------
   Content: every .compare-item holds a .compare-before image, a .compare-after
   image, two .compare-label elements and its own caption in the HTML.
   With no JS the two photos simply sit side by side.
   assets/js/showpiece-compare.js wraps them in a draggable stage, adds the
   handle and a keyboard-accessible range input. Add another .compare-item and
   it works automatically.
   ========================================================================== */

.compare-list {
  display: flex;
  flex-direction: column;
  gap: clamp(64px, 8vw, 112px);
}

.compare-item {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

/* no-JS fallback: before and after side by side */
.compare-item > .compare-before,
.compare-item > .compare-after {
  flex: 1 1 300px;
  min-width: 0;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  border-radius: var(--radius);
}

.compare-caption {
  flex-basis: 100%;
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 10px 32px;
  margin-top: 12px;
}

.compare-title {
  font-size: clamp(1.3rem, 2.2vw, 1.8rem);
  letter-spacing: -0.02em;
}

.compare-text {
  flex: 1 1 320px;
  max-width: 60ch;
  color: var(--color-muted);
}

.compare-label {
  display: inline-flex;
  align-items: center;
  padding: 7px 14px;
  border: 1px solid var(--color-line);
  border-radius: 999px;
  background: rgba(7, 17, 12, 0.62);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  line-height: 1.2;
}

.compare-label-after {
  color: var(--color-primary);
  border-color: rgba(34, 224, 122, 0.45);
}

/* ---- Enhanced ---- */
.compare-item.is-enhanced { display: flex; flex-direction: column; gap: 0; }

.compare-stage {
  --compare-pos: 50%;
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  border-radius: var(--radius);
  background: var(--color-surface);
  cursor: ew-resize;
  touch-action: pan-y;
  user-select: none;
  -webkit-user-select: none;
  box-shadow: 0 50px 100px -70px rgba(34, 224, 122, 0.35);
}

.compare-stage .compare-before,
.compare-stage .compare-after {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 0;
  pointer-events: none;
  -webkit-user-drag: none;
}

.compare-stage .compare-before {
  z-index: 1;
  clip-path: inset(0 calc(100% - var(--compare-pos)) 0 0);
}

.compare-stage .compare-label {
  position: absolute;
  top: 20px;
  z-index: 2;
}
.compare-stage .compare-label-before { left: 20px; }
.compare-stage .compare-label-after { right: 20px; }

.compare-handle {
  position: absolute;
  top: 0;
  bottom: 0;
  left: var(--compare-pos);
  z-index: 3;
  width: 0;
  pointer-events: none;
}

.compare-handle::before {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: -1px;
  width: 2px;
  background: var(--color-primary);
  box-shadow: 0 0 18px rgba(34, 224, 122, 0.9);
}

.compare-knob {
  position: absolute;
  top: 50%;
  left: 0;
  width: 66px;
  height: 66px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  border: 2px solid var(--color-primary);
  border-radius: 50%;
  background: rgba(7, 17, 12, 0.55);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  box-shadow: 0 0 0 7px rgba(34, 224, 122, 0.14), 0 0 36px rgba(34, 224, 122, 0.5);
  transform: translate(-50%, -50%);
  transition: transform 0.35s var(--ease-out), box-shadow 0.35s;
}

.compare-knob::before,
.compare-knob::after {
  content: "";
  width: 9px;
  height: 9px;
  border-left: 2px solid var(--color-text);
  border-bottom: 2px solid var(--color-text);
}
.compare-knob::before { transform: rotate(45deg); }
.compare-knob::after { transform: rotate(-135deg); }

.compare-stage:hover .compare-knob,
.compare-stage.is-dragging .compare-knob {
  transform: translate(-50%, -50%) scale(1.08);
  box-shadow: 0 0 0 10px rgba(34, 224, 122, 0.18), 0 0 48px rgba(34, 224, 122, 0.65);
}

/* keyboard / screen-reader control (created by JS) */
.compare-range {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: 0;
  opacity: 0;
  pointer-events: none;
}

.compare-stage:has(.compare-range:focus-visible) .compare-knob {
  outline: 2px solid var(--color-accent);
  outline-offset: 6px;
}

@media (max-width: 767px) {
  .compare-stage { aspect-ratio: 4 / 3; }
  .compare-knob { width: 54px; height: 54px; gap: 8px; }
  .compare-stage .compare-label { top: 14px; }
  .compare-stage .compare-label-before { left: 14px; }
  .compare-stage .compare-label-after { right: 14px; }
}
