/* ==========================================================================
   Media: before / completed comparison, construction strip captions,
   gallery and lightbox polish. Loaded after app.css.
   ========================================================================== */

/* ---------- Before / completed comparison ---------- */
.ba { margin: 0 0 clamp(56px, 9vh, 104px); }
.ba-stage {
  --ba: 50%;
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 10;
  max-height: calc(100svh - var(--topbar) - 64px);
  min-height: 240px;
  border-radius: var(--r-card);
  overflow: hidden;
  background: var(--ash);
  isolation: isolate;
  cursor: ew-resize;
  touch-action: pan-y;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}
.ba-stage img {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  object-fit: cover; object-position: 53% 58%;
  pointer-events: none;
  -webkit-user-drag: none;
}
.ba-before { clip-path: inset(0 calc(100% - var(--ba)) 0 0); }
/* Soft top shade so the white labels hold up over bright roofs. */
.ba-stage::after {
  content: ""; position: absolute; inset: 0 0 auto 0; height: 96px; z-index: 1; pointer-events: none;
  background: linear-gradient(180deg, rgba(10, 12, 13, .32), rgba(10, 12, 13, 0));
}

/* Visually hidden but focusable: arrow keys, Home/End and screen readers drive it. */
.ba-range {
  position: absolute; inset: 0; z-index: 1;
  width: 100%; height: 100%; margin: 0;
  opacity: 0; pointer-events: none;
}

.ba-handle {
  position: absolute; top: 0; bottom: 0; left: var(--ba); z-index: 2;
  width: 2px; margin-left: -1px;
  background: rgba(255, 255, 255, .92);
  pointer-events: none;
}
.ba-knob {
  position: absolute; top: 50%; left: 50%;
  width: 48px; height: 48px;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: rgba(252, 252, 251, .94);
  color: var(--carbon);
  font-size: 15px;
  transition: transform var(--t) var(--ease), background-color var(--t);
}
.ba-knob i { margin: 0 -1px; }
.ba-stage:hover .ba-knob, .ba-stage.dragging .ba-knob { background: #fff; }
.ba-stage.dragging .ba-knob { transform: translate(-50%, -50%) scale(1.08); }
.ba-range:focus-visible ~ .ba-handle .ba-knob { outline: 2px solid var(--accent); outline-offset: 3px; }

.ba-label {
  position: absolute; top: 14px; z-index: 2;
  color: #fff; font-size: 15px; font-weight: 600; letter-spacing: -0.005em;
  text-shadow: 0 1px 3px rgba(0, 0, 0, .4), 0 1px 14px rgba(0, 0, 0, .45);
  pointer-events: none;
  transition: opacity var(--t);
}
.ba-l-before { left: 16px; }
.ba-l-after { right: 16px; }
.ba-hide-before .ba-l-before, .ba-hide-after .ba-l-after { opacity: 0; }
.ba figcaption { margin-top: 12px; }

@media (max-width: 760px) {
  .ba-stage { aspect-ratio: 4 / 3; }
  .ba-knob { width: 44px; height: 44px; }
  .ba-label { top: 12px; font-size: 14px; }
  .ba-l-before { left: 14px; }
  .ba-l-after { right: 14px; }
}

/* ---------- Construction strip: photo with caption beneath ---------- */
.strip-head { display: flex; align-items: end; justify-content: space-between; gap: 16px; margin-bottom: 20px; }
.strip-head h3 { font-size: clamp(22px, 2vw, 28px); font-weight: 300; letter-spacing: -0.02em; line-height: 1.2; }
.strip > .strip-item {
  aspect-ratio: auto;
  overflow: visible;
  border-radius: 0;
  background: none;
  display: grid; align-content: start; gap: 10px;
  text-align: left; color: inherit;
}
.strip-img {
  position: relative; display: block;
  aspect-ratio: 4 / 3;
  border-radius: var(--r-card);
  overflow: hidden;
  background: var(--ash);
}
.strip-img img, .strip-img .slot { position: absolute; inset: 0; width: 100%; height: 100%; min-height: 0; }
.strip-img img { object-fit: cover; transition: transform .9s cubic-bezier(.2, .7, .1, 1); }
.strip-cap { font-size: 14px; line-height: 1.45; color: var(--graphite); transition: color var(--t); }
.strip-item:focus-visible { outline: none; }
.strip-item:focus-visible .strip-img { outline: 2px solid var(--accent); outline-offset: -2px; }

/* ---------- Gallery polish ---------- */
.g-item img { transition: transform .9s cubic-bezier(.2, .7, .1, 1); }

@media (hover: hover) and (prefers-reduced-motion: no-preference) {
  .g-item:hover img, .strip-item:hover .strip-img img { transform: scale(1.035); }
}
@media (hover: hover) { .strip-item:hover .strip-cap { color: var(--carbon); } }

/* ---------- Lightbox: image always fits between header and caption bar ---------- */
.lightbox .stage { grid-template-rows: minmax(0, 1fr); grid-template-columns: minmax(0, 1fr); overflow: hidden; }
.lightbox .stage img { width: auto; height: auto; max-width: 100%; max-height: 100%; }
.lightbox .stage .slot { width: min(100%, 960px); height: auto; aspect-ratio: 16 / 10; }
.lightbox footer { padding-bottom: max(12px, env(safe-area-inset-bottom)); }
.lightbox .lb-cap { flex: 1; text-align: center; font-size: 15px; line-height: 1.45; color: rgba(255, 255, 255, .92); }
@media (max-width: 560px) {
  .lightbox footer { display: grid; grid-template-columns: 1fr 1fr; }
  .lightbox .lb-cap { grid-column: 1 / -1; grid-row: 1; padding: 4px 0 6px; }
}
