/* ============================================
   DRAINS FIX — Motion system
   Scroll reveals, parallax, compact header and the
   before/after renovation compare. Loaded after style.css.
   Uses tokens from style.css :root.

   HARD RULE (2026-09-08 incident): nothing that a lead needs
   to read or click may depend on JavaScript to become visible.
   The hidden state is therefore expressed ONLY as
   `:not(.is-visible)` under `html.dfm-io-ok`, a class that
   js/motion.js adds *after* it has proof the IntersectionObserver
   actually fires. Because the hidden state disappears the moment
   `.is-visible` lands, there is no specificity fight to lose.
   The previous version paired `html.dfm-js [data-reveal]{opacity:0}`
   (0,2,1) with `[data-reveal].is-visible{opacity:1}` (0,2,0) — the
   hiding rule outranked the showing rule, so all 60 reveal targets
   on the homepage stayed at opacity 0 forever.
   ============================================ */

:root {
  --reveal-duration: 0.8s;
  --reveal-ease: cubic-bezier(0.16, 1, 0.3, 1);
  --reveal-distance: 32px;
  --ba-header-offset: var(--header-h, 72px);
}

/* ============================================
   REVEAL SYSTEM — [data-reveal]
   ============================================ */
[data-reveal] {
  transition: opacity var(--reveal-duration) var(--reveal-ease),
              transform var(--reveal-duration) var(--reveal-ease),
              filter var(--reveal-duration) var(--reveal-ease);
}

html.dfm-io-ok [data-reveal]:not(.is-visible)         { opacity: 0; }
html.dfm-io-ok [data-reveal="up"]:not(.is-visible)    { transform: translateY(var(--reveal-distance)); }
html.dfm-io-ok [data-reveal="left"]:not(.is-visible)  { transform: translateX(calc(-1 * var(--reveal-distance))); }
html.dfm-io-ok [data-reveal="right"]:not(.is-visible) { transform: translateX(var(--reveal-distance)); }
html.dfm-io-ok [data-reveal="scale"]:not(.is-visible) { transform: scale(0.94); }
html.dfm-io-ok [data-reveal="blur"]:not(.is-visible)  { transform: translateY(14px); filter: blur(14px); }
html.dfm-io-ok [data-reveal=""]:not(.is-visible)      { transform: translateY(var(--reveal-distance)); }

/* Hero content NEVER fades in. It gets a transform-only entrance so a
   stalled observer can at worst leave it 12px low, never invisible. */
html.dfm-io-ok .hero [data-reveal]:not(.is-visible) {
  opacity: 1;
  filter: none;
  transform: translateY(12px);
}

/* A scroll-scrub wrapper is 160vh of layout — never fade one out. */
html.dfm-io-ok .ba-section:not(.is-visible) {
  opacity: 1;
  transform: none;
  filter: none;
}

/* ============================================
   REDUCED MOTION — real media query plus a manual
   toggle class (html.dfm-reduced-motion) for testing.
   ============================================ */
@media (prefers-reduced-motion: reduce) {
  [data-reveal] {
    opacity: 1 !important;
    transform: none !important;
    filter: none !important;
    transition: none !important;
  }
  [data-parallax] { transform: none !important; }
  .hero-media-img { animation: none !important; }
}
html.dfm-reduced-motion [data-reveal] {
  opacity: 1 !important;
  transform: none !important;
  filter: none !important;
  transition: none !important;
}
html.dfm-reduced-motion [data-parallax] { transform: none !important; }
html.dfm-reduced-motion .hero-media-img { animation: none !important; }

/* ============================================
   PARALLAX — [data-parallax="0.2"]  (desktop pointer only)
   No blanket will-change: it was being applied to ~60 nodes and
   cost more GPU memory than the effect is worth.
   ============================================ */
@media (max-width: 1023px), (hover: none) {
  [data-parallax] { transform: none !important; }
}

/* ============================================
   HEADER — compact state (.is-scrolled)
   ============================================ */
.site-header {
  transition: height 0.35s var(--transition-smooth, ease),
              background 0.35s var(--transition-smooth, ease),
              box-shadow 0.35s var(--transition-smooth, ease);
}
.site-header.is-scrolled {
  --header-h: 56px;
  height: var(--header-h);
  background: rgba(10, 22, 40, 0.96);
  box-shadow: 0 4px 24px rgba(10, 22, 40, 0.18);
}
/* backdrop-filter is a per-frame full-viewport GPU blur. Keep it for
   desktop only — on mobile GPUs it was a measurable scroll-jank source. */
@media (hover: hover) and (min-width: 1024px) {
  .site-header.is-scrolled {
    background: rgba(10, 22, 40, 0.94);
    backdrop-filter: blur(24px) saturate(180%);
    -webkit-backdrop-filter: blur(24px) saturate(180%);
  }
}
.site-header.is-scrolled .header-logo img {
  height: 32px;
  transition: height 0.35s var(--transition-smooth, ease);
}
.site-header.is-scrolled .header-nav a { font-size: 0.875rem; }
.site-header.is-scrolled .header-cta { padding: 8px 16px; }

/* ============================================
   HERO — media layer
   ============================================ */
.hero--reno { min-height: min(100vh, 900px); display: flex; align-items: center; }
@supports (height: 1svh) {
  .hero--reno { min-height: min(100svh, 900px); }
}
.hero-media {
  position: absolute;
  /* Oversized vertically so the [data-parallax] translateY never
     exposes the .hero background at the top/bottom edge. */
  top: -15%;
  bottom: -15%;
  left: 0;
  right: 0;
  overflow: hidden;
  z-index: 0;
}
.hero-media-img {
  position: absolute;
  inset: -6% -6%;
  width: 112%;
  height: 112%;
  /* Undo the site-wide `img{max-width:100%;height:auto}` reset. */
  max-width: none;
  max-height: none;
  object-fit: cover;
  opacity: 0.88;
  filter: contrast(1.05);
  transform-origin: 50% 50%;
}
/* Ken Burns is a continuous composite of a full-bleed photo. Desktop only. */
@media (hover: hover) and (min-width: 1024px) and (prefers-reduced-motion: no-preference) {
  .hero-media-img {
    will-change: transform;
    animation: hero-ken-burns 20s ease-in-out infinite alternate;
  }
}
@keyframes hero-ken-burns {
  from { transform: scale(1); }
  to   { transform: scale(1.08); }
}
.hero-media-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, transparent 55%, rgba(10,22,40,0.9) 100%),
              linear-gradient(90deg, rgba(10,22,40,0.9) 0%, rgba(10,22,40,0.78) 40%, rgba(10,22,40,0.4) 76%, rgba(10,22,40,0.15) 100%);
}
.hero--reno .hero-pattern { z-index: 1; opacity: 0.015; }
.hero--reno .container { z-index: 2; }
.hero--reno::after { display: none; }

@media (max-width: 767px) {
  .hero--reno { min-height: 85vh; }
  .hero-media-overlay {
    background: linear-gradient(180deg, rgba(10,22,40,0.35) 0%, rgba(10,22,40,0.94) 100%),
                linear-gradient(90deg, rgba(10,22,40,0.92) 0%, rgba(10,22,40,0.8) 55%, rgba(10,22,40,0.45) 100%);
  }
}

.hero-eyebrow {
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--cyan);
  margin-bottom: 18px;
}
.hero-position {
  color: rgba(255,255,255,0.82);
  font-size: clamp(1.0625rem, 1.9vw, 1.1875rem);
  max-width: 620px;
  margin: 18px 0 32px;
}
.hero-quiet-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: rgba(255,255,255,0.72);
  font-size: 0.9375rem;
  font-weight: 600;
  border-bottom: 1px solid rgba(255,255,255,0.3);
  padding-bottom: 2px;
  transition: color 0.2s, border-color 0.2s;
}
.hero-quiet-link:hover { color: var(--white); border-color: rgba(255,255,255,0.6); }
.hero-quiet-link span { transition: transform 0.2s; }
.hero-quiet-link:hover span { transform: translateY(2px); }

/* ============================================
   BEFORE / AFTER COMPARE — .ba-section

   BASE STATE (this block) is the no-JavaScript state and it is
   deliberately the *safe* one: normal document flow, a 4:3 stage,
   both photos loaded, the wipe parked at a 50/50 split. Everything
   below only ever upgrades that.

   Custom properties are set by js/motion.js as PLAIN, PRE-COMPUTED
   strings — never `calc()` around a `var()` inside `clip-path`,
   which WebKit evaluates inconsistently:
     --ba-progress  0..1 number   (state; read by the test gate)
     --ba-clip      "43.00%"      (right inset of the after layer)
     --ba-pos       "57.00%"      (divider x position)
   ============================================ */
.ba-intro .section-header { margin-bottom: 24px; }

.ba-section { position: relative; }

.ba-stage {
  position: relative;
  aspect-ratio: 4 / 3;
  overflow: hidden;
  background: var(--navy);
  cursor: ew-resize;
  /* Horizontal drags scrub; vertical drags still scroll the page. */
  touch-action: pan-y;
  -webkit-user-select: none;
  user-select: none;
  --ba-progress: 0.5;
  --ba-clip: 50%;
  --ba-pos: 50%;
}
@supports not (aspect-ratio: 4 / 3) {
  .ba-stage { height: 75vw; }
}

.ba-layer {
  position: absolute;
  inset: 0;
  background-image: var(--ba-src);
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
}
/* Smaller renditions for phones — roughly a third of the bytes. */
@media (max-width: 900px) {
  .ba-layer { background-image: var(--ba-src-sm, var(--ba-src)); }
}
.ba-layer--before { z-index: 1; }
.ba-layer--after {
  z-index: 2;
  clip-path: inset(0 var(--ba-clip, 50%) 0 0);
  will-change: clip-path;
}

.ba-divider {
  position: absolute;
  top: 0;
  bottom: 0;
  left: var(--ba-pos, 50%);
  width: 2px;
  background: rgba(255,255,255,0.9);
  box-shadow: 0 0 12px rgba(0,0,0,0.4);
  z-index: 3;
  transform: translateX(-50%);
  pointer-events: none;
}
.ba-handle {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: var(--white);
  color: var(--navy);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-lift, 0 10px 30px rgba(0,0,0,0.3));
  cursor: ew-resize;
  pointer-events: auto;
  touch-action: pan-y;
}
.ba-handle:focus-visible {
  outline: 3px solid var(--cyan);
  outline-offset: 3px;
}
.ba-handle svg { width: 22px; height: 22px; }

.ba-label {
  position: absolute;
  top: 20px;
  z-index: 4;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--white);
  background: rgba(10,22,40,0.55);
  padding: 6px 14px;
  border-radius: 999px;
  pointer-events: none;
}
.ba-label--before { left: 20px; }
.ba-label--after { right: 20px; }

/* "Drag to compare" affordance */
.ba-hint {
  position: absolute;
  left: 50%;
  bottom: 14px;
  transform: translateX(-50%);
  z-index: 5;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--white);
  background: rgba(10,22,40,0.62);
  padding: 7px 14px;
  border-radius: 999px;
  pointer-events: none;
  transition: opacity 0.3s ease;
  white-space: nowrap;
}
.ba-stage.is-dragged .ba-hint { opacity: 0; }

.ba-caption {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 4;
  padding: 28px 24px 32px;
  background: linear-gradient(0deg, rgba(10,22,40,0.85) 0%, transparent 100%);
  pointer-events: none;
}
.ba-caption-inner {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 0 24px;
  position: absolute;
  left: 0;
  right: 0;
  bottom: 48px;
}
.ba-caption-before { opacity: calc(1 - var(--ba-progress, 0.5)); }
.ba-caption-after  { opacity: var(--ba-progress, 0.5); }
.ba-caption-title {
  font-family: var(--font-display);
  font-weight: 800;
  color: var(--white);
  font-size: clamp(1.0625rem, 1.8vw, 1.375rem);
  margin-bottom: 6px;
  max-width: none;
}
.ba-caption-body {
  color: rgba(255,255,255,0.78);
  font-size: 0.9375rem;
  max-width: 60ch;
}

/* --- Desktop upgrade: sticky, scroll-scrubbed ------------------
   Only with a fine pointer AND JavaScript present. Touch devices
   keep the normal-flow stage above and drive progress by drag +
   a one-shot auto-animate (see js/motion.js) — a sticky scrub is
   both unreliable and disorienting on a phone. */
@media (hover: hover) and (pointer: fine) {
  html.dfm-js .ba-section { height: 160vh; }
  html.dfm-js .ba-stage {
    position: sticky;
    top: var(--ba-header-offset);
    aspect-ratio: auto;
    height: min(70vh, 640px);
  }
}
@supports (height: 1svh) {
  @media (hover: hover) and (pointer: fine) {
    html.dfm-js .ba-stage { height: min(70svh, 640px); }
  }
}

/* Touch: keep the eight renovation photos from competing with the hero
   for bandwidth on a slow connection. Off-screen sections are skipped
   entirely (and their backgrounds not fetched) until they approach the
   viewport. Not applied to the desktop wrapper — the containment it
   implies would break the sticky stage inside it. */
@media (hover: none) {
  .ba-section {
    content-visibility: auto;
    contain-intrinsic-size: auto 75vw;
  }
}

@media (max-width: 767px) {
  .ba-caption-body { display: none; }
  .ba-handle { width: 44px; height: 44px; }
  .ba-caption { padding: 20px 18px 24px; }
  .ba-caption-inner { padding: 0 18px; bottom: 44px; }
}

/* ============================================
   SERVICE AREA STRIP SECTION (dark)
   ============================================ */
.ba-areas .service-area-strip {
  justify-content: center;
  margin-top: 8px;
  border-top-color: rgba(255,255,255,0.12);
}
.ba-areas .service-area-strip-label { color: var(--white); }
.ba-areas .service-area-strip a { color: rgba(255,255,255,0.6); }
.ba-areas .service-area-strip a:hover { color: var(--cyan); }
.ba-areas .service-area-strip-more { color: var(--cyan) !important; }

/* ============================================
   REVIEWS — horizontal snap-scroll carousel
   ============================================ */
.reviews-carousel {
  display: flex;
  gap: 20px;
  overflow-x: auto;
  scroll-snap-type: x proximity;
  padding: 8px 4px 20px;
  margin-top: 48px;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
}
.reviews-carousel .review-card {
  flex: 0 0 320px;
  scroll-snap-align: start;
}
@media (max-width: 767px) {
  .reviews-carousel .review-card { flex-basis: 84vw; }
}
.reviews-carousel .review-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  object-fit: cover;
}
