/* Motion foundation (partials/motion.js). Base rules here describe the finished,
   static page; motion.js only animates toward that state, so no-JS and reduced
   motion render complete. `.has-motion` on <html> marks the animated path. */

/* Smooth scroll ------------------------------------------------------------ */

/* Lenis owns in-page scrolling when it runs; native smooth scrolling would
   fight its per-frame writes. Without Lenis, styles.css keeps scroll-behavior. */
html.lenis,
html.lenis body {
  height: auto;
}

html.lenis {
  scroll-behavior: auto;
}

.lenis:not(.lenis-autoToggle).lenis-stopped {
  overflow: clip;
}

.lenis [data-lenis-prevent] {
  overscroll-behavior: contain;
}

.lenis.lenis-smooth iframe {
  pointer-events: none;
}

/* Heading line reveals ----------------------------------------------------- */

/* The heading's lines carry the rise; its reveal container only fades. */
.js .split-host[data-reveal] {
  transform: none;
}

/* flow-root keeps the last mask's negative margin inside the heading box. */
.is-split {
  display: flow-root;
}

/* Give each mask room for descenders and italic overhang, then take it back. */
.split-line-mask {
  display: block;
  padding: 0 .08em .12em 0;
  margin: 0 -.08em -.12em 0;
}

/* Lines are spans (valid inside h2) and must be blocks for transforms to apply. */
.split-line {
  display: block;
}

/* Contour through-line ----------------------------------------------------- */

.hero-contours path:nth-child(2) { animation-delay: .87s; }
.hero-contours path:nth-child(3) { animation-delay: .99s; }
.hero-contours path:nth-child(4) { animation-delay: 1.11s; }

/* A zero-height seam between two sections; the drawing straddles the join
   (or sits just inside the next section with --into). */
.contour-seam {
  position: relative;
  z-index: 4;
  height: 0;
  pointer-events: none;
  color: var(--forest);
}

.contour-seam svg {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: clamp(96px, 11vw, 168px);
  overflow: visible;
  transform: translateY(-50%);
}

.contour-seam--into svg {
  height: clamp(70px, 8vw, 124px);
  transform: translateY(-4%);
}

.contour-seam--flip svg {
  transform: translateY(-50%) scaleX(-1);
}

.contour-seam path {
  fill: none;
  stroke: currentColor;
  stroke-width: 1;
  stroke-dasharray: 1;
  stroke-dashoffset: 0;
  vector-effect: non-scaling-stroke;
  opacity: .2;
}

.contour-seam path:nth-child(2) {
  opacity: .13;
}

.contour-seam path.is-clay {
  stroke: var(--clay);
  opacity: .34;
}

.contour-seam--dark {
  color: var(--cream);
}

.contour-seam--dark path {
  opacity: .14;
}

.contour-seam--dark path:nth-child(2) {
  opacity: .09;
}

/* Curved edge: the forest section above bows gently into the light one below. */
.section-arc {
  position: relative;
  z-index: 3;
  height: 0;
  pointer-events: none;
}

.section-arc::before {
  position: absolute;
  top: -1px;
  left: 0;
  width: 100%;
  height: clamp(26px, 4.4vw, 68px);
  content: "";
  background: var(--forest);
  -webkit-mask: radial-gradient(53% 100% at 50% 0, #000 calc(100% - 1.5px), transparent 100%);
  mask: radial-gradient(53% 100% at 50% 0, #000 calc(100% - 1.5px), transparent 100%);
}

/* Micro-interactions ------------------------------------------------------- */

/* Magnetic CTAs: `translate` composes with each button's own hover transform. */
.has-magnet {
  translate: calc(var(--mag-x, 0) * 1px) calc(var(--mag-y, 0) * 1px);
}

/* Underline: on hover it withdraws to the right and redraws from the left. */
@media (hover: hover) and (pointer: fine) {
  .has-motion .text-link:hover::after {
    animation: link-redraw .62s var(--ease) both;
  }

  .has-motion .button:hover > span,
  .has-motion .header-apply:hover > span,
  .has-motion .contact-apply:hover > i {
    transition-duration: .45s;
    transition-timing-function: cubic-bezier(.34, 1.56, .64, 1);
  }
}

@keyframes link-redraw {
  0% { transform: scaleX(1); transform-origin: right; }
  45% { transform: scaleX(0); transform-origin: right; }
  46% { transform: scaleX(0); transform-origin: left; }
  100% { transform: scaleX(1); transform-origin: left; }
}

/* Cursor spotlights. contact-apply isolates so the glow sits under its text. */
.contact-apply.has-spot {
  position: relative;
  isolation: isolate;
}

.contact-apply.has-spot::before,
.estimate-result.has-spot .estimate-panel::after {
  position: absolute;
  inset: 0;
  content: "";
  pointer-events: none;
  opacity: 0;
  transition: opacity .5s var(--ease);
}

.contact-apply.has-spot::before {
  z-index: -1;
  background: radial-gradient(260px circle at var(--spot-x, 50%) var(--spot-y, 50%), rgba(255, 255, 255, .26), transparent 70%);
}

.estimate-result.has-spot .estimate-panel::after {
  background: radial-gradient(420px circle at var(--spot-x, 50%) var(--spot-y, 50%), rgba(242, 238, 228, .075), rgba(196, 93, 61, .035) 45%, transparent 72%);
}

.contact-apply.has-spot:hover::before,
.estimate-result.has-spot:hover .estimate-panel::after {
  opacity: 1;
}

@media (prefers-reduced-motion: reduce) {
  .has-magnet {
    translate: none;
  }

  .contour-seam path {
    stroke-dashoffset: 0;
  }
}
