/* Before/after comparison slider. The whole control is driven by --pos,
   set by the range input (see before_after_controller.js). The "before"
   layer sits on top, clipped to the left portion of the frame. */

@property --pos {
  syntax: "<percentage>";
  inherits: true;
  initial-value: 46%;
}

.ba {
  --pos: 46%;
  position: relative;
  aspect-ratio: 4 / 3;
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-deep);
  border: var(--border-hard);
  background: var(--paper-card);
  /* pan-y keeps vertical swipes scrolling the page on touchscreens;
     horizontal drags still reach the range input. none would trap scroll. */
  touch-action: pan-y;
}

@keyframes ba-hint {
  0% { --pos: 46%; }
  45% { --pos: 62%; }
  100% { --pos: 46%; }
}

@media (prefers-reduced-motion: no-preference) {
  .ba-hero {
    animation: ba-hint 1.8s cubic-bezier(0.4, 0, 0.2, 1) 900ms 1;
  }
}

.ba img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  user-select: none;
  -webkit-user-drag: none;
}

/* Stacked "after" layers behind the style switcher */

.ba-swap {
  opacity: 0;
  transition: opacity 450ms ease;
}

.ba-swap.is-active {
  opacity: 1;
}

/* Style switcher tabs above the hero slider */

.style-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin-bottom: var(--space-3);
}

.style-tab {
  font-family: var(--font-body);
  font-weight: 600;
  font-size: var(--text-sm);
  padding: 0.5em 1.1em;
  border-radius: var(--radius-pill);
  border: 1px solid var(--line-strong);
  background: transparent;
  color: var(--ink-soft);
  cursor: pointer;
  transition: background-color 150ms ease, color 150ms ease, border-color 150ms ease;
}

.style-tab:hover {
  color: var(--ink);
}

.style-tab.is-active {
  background: var(--ink);
  border-color: var(--ink);
  color: var(--paper);
}

/* Compact variant for proof-wall cards */

.ba-sm {
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-soft);
}

.ba-sm .ba-handle {
  width: 2.125rem;
  height: 2.125rem;
  font-size: 0.75rem;
}

.ba .ba-before {
  position: absolute;
  inset: 0;
  clip-path: inset(0 calc(100% - var(--pos)) 0 0);
}

/* Divider line and handle, purely decorative */

.ba-divider {
  position: absolute;
  inset-block: 0;
  left: var(--pos);
  width: 2px;
  margin-left: -1px;
  background: var(--paper-card);
  box-shadow: 0 0 0 1px rgba(64, 48, 30, 0.18);
  pointer-events: none;
}

.ba-handle {
  position: absolute;
  top: 50%;
  left: var(--pos);
  transform: translate(-50%, -50%);
  width: 2.75rem;
  height: 2.75rem;
  border-radius: 50%;
  background: var(--paper-card);
  border: 1px solid var(--line-strong);
  box-shadow: var(--shadow-soft);
  display: grid;
  place-items: center;
  pointer-events: none;
  color: var(--accent);
  font-size: 0.9rem;
  letter-spacing: 0.08em;
}

/* The real control: a full-surface range input, visually silent */

.ba input[type="range"] {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  cursor: ew-resize;
}

.ba input[type="range"]:focus-visible ~ .ba-handle {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

/* Corner labels */

.ba-label {
  position: absolute;
  bottom: var(--space-3);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  background: rgba(16, 16, 16, 0.82);
  color: var(--paper);
  padding: var(--space-1) var(--space-3);
  border-radius: var(--radius-sm);
  pointer-events: none;
}

.ba-label-before { left: var(--space-3); }
.ba-label-after { right: var(--space-3); }

/* The proof cards carry the same corner labels one size down: which
   side is the photo should never live only in body copy 400px away. */
.ba-sm .ba-label {
  bottom: var(--space-2);
  font-size: 0.625rem;
  padding: 2px 6px;
}

.ba-sm .ba-label-before { left: var(--space-2); }
.ba-sm .ba-label-after { right: var(--space-2); }

.ba-caption {
  margin-top: var(--space-3);
  font-size: var(--text-sm);
  color: var(--ink-soft);
  font-style: italic;
  text-align: center;
}
