/* Before/after comparison slider: Our Work and Electrical Panel Replacements */

.compare-section .compare-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.15fr);
  gap: 48px;
  align-items: center;
}

.compare-section .compare-copy .sec-lead {
  margin-top: 12px;
  max-width: 42ch;
}

.compare-frame {
  max-width: 560px;
  width: 100%;
  margin-inline: auto;
}

.compare {
  --compare-pos: 50%;
  position: relative;
  width: 100%;
  aspect-ratio: 4 / 5;
  border-radius: var(--radius, 12px);
  overflow: hidden;
  background: var(--navy, #0B1F33);
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

.compare__img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  object-fit: cover;
  object-position: center;
  display: block;
  pointer-events: none;
}

.compare__after {
  z-index: 1;
}

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

.compare__label {
  position: absolute;
  z-index: 4;
  top: 12px;
  padding: 5px 10px;
  border-radius: 6px;
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  line-height: 1;
  color: #F6F3EC;
  background: rgba(11, 31, 51, 0.72);
  backdrop-filter: blur(4px);
  pointer-events: none;
  transition: opacity 200ms ease;
}

/* Fade labels near their edge: full at >25% away, gone by ~12% from that edge */
.compare__label--before {
  left: 12px;
  opacity: clamp(0, calc((var(--compare-pos-n, 50) - 12) / 13), 1);
}

.compare__label--after {
  right: 12px;
  opacity: clamp(0, calc((88 - var(--compare-pos-n, 50)) / 13), 1);
}

.compare__handle {
  position: absolute;
  z-index: 5;
  top: 0;
  bottom: 0;
  left: var(--compare-pos);
  width: 0;
  transform: translateX(-50%);
  pointer-events: none;
}

.compare__line {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  width: 3px;
  transform: translateX(-50%);
  background: var(--amber, #E3A008);
  box-shadow: 0 0 0 1px rgba(11, 31, 51, 0.25);
}

.compare__knob {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 56px;
  height: 56px;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  border: 3px solid var(--amber, #E3A008);
  background: var(--navy, #0B1F33);
  color: var(--amber, #E3A008);
  display: grid;
  place-items: center;
  box-shadow: 0 4px 14px rgba(7, 16, 24, 0.4), 0 0 0 0 rgba(227, 160, 8, 0.55);
}

.compare__knob svg {
  width: 28px;
  height: 28px;
  display: block;
}

/* Until the first drag, tap, or key press: soft amber pulse on the knob */
.compare:not(.is-touched) .compare__knob {
  animation: compare-pulse 1.8s ease-out infinite;
}

@keyframes compare-pulse {
  0%   { box-shadow: 0 4px 14px rgba(7, 16, 24, 0.4), 0 0 0 0 rgba(227, 160, 8, 0.6); }
  70%  { box-shadow: 0 4px 14px rgba(7, 16, 24, 0.4), 0 0 0 14px rgba(227, 160, 8, 0); }
  100% { box-shadow: 0 4px 14px rgba(7, 16, 24, 0.4), 0 0 0 0 rgba(227, 160, 8, 0); }
}

/* "Drag to compare" pill, attached under the knob and centered on the divider.
   Navy text on amber is about 7.5:1, and the shadow keeps it clear on light or busy photos. */
.compare__hint {
  position: absolute;
  top: calc(50% + 38px);
  left: 50%;
  transform: translateX(-50%);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 12px;
  border-radius: 999px;
  background: var(--amber, #E3A008);
  color: var(--navy, #0B1F33);
  font-family: inherit;
  font-size: 13px;
  font-weight: 700;
  line-height: 1;
  letter-spacing: 0.01em;
  white-space: nowrap;
  box-shadow: 0 4px 14px rgba(7, 16, 24, 0.45), 0 0 0 2px rgba(11, 31, 51, 0.85);
  transition: opacity 250ms ease, visibility 250ms;
}

.compare__hint svg {
  width: 14px;
  height: 14px;
  flex: none;
  display: block;
}

.compare.is-touched .compare__hint {
  opacity: 0;
  visibility: hidden;
}

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

.compare__range:focus-visible {
  opacity: 1;
  outline: 2px solid var(--amber, #E3A008);
  outline-offset: -4px;
  border-radius: var(--radius, 12px);
}

.compare__range::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 56px;
  height: 100%;
  background: transparent;
  cursor: ew-resize;
}

.compare__range::-moz-range-thumb {
  width: 56px;
  height: 100%;
  border: 0;
  background: transparent;
  cursor: ew-resize;
}

.compare__range::-moz-range-track {
  background: transparent;
}

@media (max-width: 900px) {
  .compare-section .compare-layout {
    grid-template-columns: 1fr;
    gap: 28px;
  }

  .compare-frame {
    max-width: 100%;
  }
}

@media (max-width: 480px) {
  .compare__hint {
    font-size: 12px;
    padding: 6px 10px;
    gap: 5px;
  }
}

/* Reduced motion: no pulse and no nudge (compare.js); the pill still shows */
@media (prefers-reduced-motion: reduce) {
  .compare__before,
  .compare__handle,
  .compare__label,
  .compare__hint {
    transition: none;
  }
  .compare:not(.is-touched) .compare__knob {
    animation: none;
  }
}

html[data-theme="dark"] .compare__label {
  background: rgba(7, 16, 24, 0.78);
}

/* Wide variant (2026-10-07): About "At work / After work" team photos, 3:2 like the source files. */
.compare--wide {
  aspect-ratio: 3 / 2;
}
