/* ==========================================================================
   Finish layer: typography, rhythm, photo treatment, and the homepage hero's
   living details (slow zoom, blueprint lines, breathing recessed lights).

   Same rules as motion.css: anything that moves lives under html.motion,
   which motion.js only adds when the visitor has NOT asked for reduced
   motion. Without it, everything below renders as a calm, static page.
   Motion uses transform / opacity, plus stroke-dashoffset for the
   blueprint lines (a few thin SVG strokes, paused when off screen).
   ========================================================================== */

/* --------------------------------------------------------------------------
   Typography — same fonts, tighter display setting, better line breaks.
   -------------------------------------------------------------------------- */
h1, h2 { letter-spacing: -0.022em; text-wrap: balance; }
h3 { letter-spacing: -0.012em; text-wrap: balance; }
.hero h1 { line-height: 1.04; letter-spacing: -0.03em; }
p { text-wrap: pretty; }
.section-head p { max-width: 62ch; }
.section-head h2 + p { margin-top: var(--space-2xs); }
.eyebrow { letter-spacing: 0.16em; }

/* --------------------------------------------------------------------------
   Spacing rhythm — more air above a section's content than inside it, so
   each section reads as one deliberate block.
   -------------------------------------------------------------------------- */
.section-head { margin-bottom: clamp(2.5rem, 2rem + 2vw, 3.75rem); }
.section-head--center { margin-bottom: clamp(2.75rem, 2.2rem + 2.2vw, 4rem); }

/* --------------------------------------------------------------------------
   Photo treatment — one consistent grade and a soft inner edge so real job
   photos from different phones read as one set.
   -------------------------------------------------------------------------- */
.split-media img,
.gallery-item img,
.project-card img,
.ba-item img,
.hero-frame img {
  filter: saturate(1.06) contrast(1.04);
}
.split-media::after,
.ba-item::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  border-radius: inherit;
  box-shadow: inset 0 0 0 1px rgba(7, 13, 31, 0.06), inset 0 -60px 80px -60px rgba(7, 13, 31, 0.28);
}
.ba-item { position: relative; }

/* Lazy photos fade in as they arrive instead of popping. motion.js tags
   only the images it is watching, so with JS off nothing is ever hidden. */
.motion img[data-fade] {
  transition: opacity 700ms var(--ease-out-quart);
}
.motion img[data-fade]:not(.is-loaded) { opacity: 0; }

/* --------------------------------------------------------------------------
   Section eyebrows — the short rule draws in as the section reveals.
   -------------------------------------------------------------------------- */
.motion .eyebrow::before {
  transform-origin: left;
  transition: transform 900ms var(--motion-ease) 120ms;
}
.motion .eyebrow.rv:not(.is-in)::before { transform: scaleX(0); }

/* --------------------------------------------------------------------------
   Header logo — a warm glow breathes behind it once on the first page of a
   visit (the existing logo-intro moment). Opacity only.
   -------------------------------------------------------------------------- */
.brand--logo { position: relative; isolation: isolate; }
.brand--logo::before {
  content: "";
  position: absolute;
  inset: -30% -12%;
  z-index: -1;
  pointer-events: none;
  background: radial-gradient(closest-side at 22% 50%, rgba(255, 138, 61, 0.35), transparent 75%);
  opacity: 0;
}
.motion.logo-intro .brand--logo::before { animation: logo-glow 2200ms var(--ease-out-quart) 200ms; }
@keyframes logo-glow {
  35% { opacity: 1; }
  100% { opacity: 0; }
}

/* --------------------------------------------------------------------------
   Homepage hero stage: photo, dusk tint, blueprint lines and lamp glows
   share one box and one transform, so they zoom together.
   -------------------------------------------------------------------------- */
.hero-stage {
  position: absolute;
  inset: 0;
  transform-origin: 50% 45%;
  container-type: size;
}
.hero-stage img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}
/* Same dusk tint as .hero-media::after (components.css), moved inside the
   stage so the lamp glows and blueprint lines sit above it — lit lamps at
   dusk shine over the scene, they are not dimmed by it. */
.hero-shade {
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(7, 13, 31, 0.55) 0%, rgba(7, 13, 31, 0.55) 40%, rgba(7, 13, 31, 0.94) 100%);
}
.hero-media--stage::after { content: none; }

/* A box with the photo's exact proportions, sized and centered the way
   object-fit: cover sizes the photo. Anything placed in it by percentage
   (or in its 1528×860 viewBox) lands on the same spot of the photo. */
.hero-photo-space {
  position: absolute;
  left: 50%;
  top: 50%;
  width: max(100cqw, 100cqh * 1528 / 860);
  aspect-ratio: 1528 / 860;
  transform: translate(-50%, -50%);
  pointer-events: none;
}
.hero-lines {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
}

/* One 60s loop (--hero-loop), so the phases never overlap:
     0–11s    blueprint lines draw across the still photo
     11–20s   the drawing holds
     20–23s   the drawing fades away, then is hidden
     23–58s   slow Ken Burns push-in and back
     58–60s   rest, then the blueprint draws again
   The lamps breathe throughout. The drawing is never on screen while the
   photo scales: an SVG inside a scaling layer is re-rasterized every
   frame, which is what cost frames (measured). */
:root { --hero-loop: 60s; }
.motion .hero-stage {
  will-change: transform;
  animation: hero-settle 1400ms var(--motion-ease) backwards,
             hero-zoom var(--hero-loop) ease-in-out infinite;
}
@keyframes hero-zoom {
  0%, 38% { transform: scale(1); }
  67% { transform: scale(1.07); }
  96%, 100% { transform: scale(1); }
}

/* Blueprint lines — traced on the real house edges. Faint by design.
   Static (fully drawn) when motion is off. */
.bp {
  stroke: #a9c8ff;
  stroke-width: 1.4;
  stroke-opacity: 0.42;
}
.bp--faint { stroke-opacity: 0.22; stroke-dasharray: 0.006 0.008; }
.bp--dim { stroke-opacity: 0.32; }
.hero-blueprint { opacity: 0.75; }

/* Each line draws over 4.4s (7.3% of the loop) after its own delay, stays
   drawn while visible, and resets only while the drawing is hidden. */
.motion .bp:not(.bp--faint) {
  stroke-dasharray: 1;
  animation: bp-draw var(--hero-loop) cubic-bezier(0.45, 0, 0.2, 1) var(--d, 0s) infinite both;
}
.motion .bp--faint { animation: bp-fade var(--hero-loop) ease-in-out var(--d, 0s) infinite both; }
@keyframes bp-draw {
  0% { stroke-dashoffset: 1; }
  7.3%, 60% { stroke-dashoffset: 0; }
  61%, 100% { stroke-dashoffset: 1; }
}
@keyframes bp-fade {
  0% { opacity: 0; }
  6.7%, 60% { opacity: 1; }
  61%, 100% { opacity: 0; }
}
.motion .hero-lines { animation: bp-show var(--hero-loop) ease-in-out infinite; }
@keyframes bp-show {
  0%, 33% { opacity: 1; visibility: visible; }
  38% { opacity: 0; visibility: visible; }
  38.5%, 100% { opacity: 0; visibility: hidden; }
}
/* Draw order: construction lines first, then the house, then the
   dimension line (document order in index.html). */
.bp:nth-child(1) { --d: 0s; }
.bp:nth-child(2) { --d: 0.6s; }
.bp:nth-child(3) { --d: 1.2s; }
.bp:nth-child(4) { --d: 1.6s; }
.bp:nth-child(5) { --d: 1.9s; }
.bp:nth-child(6) { --d: 2.6s; }
.bp:nth-child(7) { --d: 3.8s; }
.bp:nth-child(8) { --d: 4.4s; }
.bp:nth-child(9) { --d: 5s; }
.bp:nth-child(10) { --d: 5.4s; }
.bp:nth-child(11) { --d: 5.8s; }
.bp:nth-child(12) { --d: 6.2s; }
.bp:nth-child(13) { --d: 7s; }

/* Recessed lights — warm halos centered on the five real fixtures
   (photo-pixel centers measured from hero-exterior.jpg), each breathing on
   its own slow, offset cycle. Plain elements, so the fade is GPU-only. */
.lamp {
  --r: 34;
  position: absolute;
  left: calc(var(--x) / 1528 * 100%);
  top: calc(var(--y) / 860 * 100%);
  width: calc(var(--r) * 2 / 1528 * 100%);
  aspect-ratio: 1;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: radial-gradient(closest-side,
    rgba(255, 246, 224, 1) 0%,
    rgba(255, 226, 168, 0.75) 18%,
    rgba(255, 200, 116, 0.22) 50%,
    rgba(255, 200, 116, 0) 100%);
  /* Normal blending: "screen" looked the same here but cost ~5 fps (measured). */
  opacity: 0.6;
}
.lamp:nth-of-type(1) { --x: 601.4; --y: 219.6; --d: 0s; }
.lamp:nth-of-type(2) { --x: 919.1; --y: 221.8; --d: -2.4s; }
.lamp:nth-of-type(3) { --x: 308.5; --y: 342.8; --r: 38; --d: -4.1s; }
.lamp:nth-of-type(4) { --x: 1230.1; --y: 353; --r: 40; --d: -1.3s; }
.lamp:nth-of-type(5) { --x: 1504.8; --y: 354.3; --r: 40; --d: -5.6s; }
.motion .lamp {
  will-change: opacity;
  animation: lamp-breathe 9s ease-in-out var(--d, 0s) infinite;
}
@keyframes lamp-breathe {
  0%, 100% { opacity: 0.28; }
  50% { opacity: 0.9; }
}

/* Off screen: stop spending frames on the hero (motion.js sets the class). */
.hero.is-offscreen .hero-stage,
.hero.is-offscreen .hero-lines,
.hero.is-offscreen .bp,
.hero.is-offscreen .lamp { animation-play-state: paused; }
