/* ==========================================================================
   Reising — motion layer
   ReactBits-style effects ported to vanilla CSS. Kept in its own file so the
   whole layer can be removed by deleting two <link>/<script> tags.

   Everything animates transform / opacity / clip-path only. Nothing here is
   required for the page to read: without JS the .reveal state never applies
   and content renders at its final position (see the :not(.motion-ready)
   guard below).
   ========================================================================== */

/* Until motion.js confirms it is running, reveals are inert. This is what
   stops a JS failure from leaving the page blank. */
html:not(.motion-ready) .reveal {
  opacity: 1;
  transform: none;
}

/* ── ScrollFloat / reveal-on-enter ─────────────────────────────────────────
   The workhorse. Content rises 18px and fades as it enters. Exponential
   ease-out from an already-legible default, not a bounce. */
.motion-ready .reveal {
  opacity: 0;
  transform: translateY(18px);
  transition:
    opacity 700ms cubic-bezier(0.16, 1, 0.3, 1),
    transform 700ms cubic-bezier(0.16, 1, 0.3, 1);
  will-change: opacity, transform;
}

.motion-ready .reveal.is-in {
  opacity: 1;
  transform: none;
  will-change: auto;
}

/* Grid children stagger off their index rather than a nth-child ladder, so
   the cadence survives content changes. */
.motion-ready .reveal[data-reveal-i="0"] { transition-delay: 0ms; }
.motion-ready .reveal[data-reveal-i="1"] { transition-delay: 90ms; }
.motion-ready .reveal[data-reveal-i="2"] { transition-delay: 180ms; }
.motion-ready .reveal[data-reveal-i="3"] { transition-delay: 270ms; }

/* ── SpotlightCard ─────────────────────────────────────────────────────────
   A gold radial follows the cursor across the card. --mx/--my are written by
   motion.js as percentages; the gradient itself is pure CSS, so there is no
   per-frame style recalculation beyond two custom properties. */
.service-card,
.news-card {
  position: relative;
  isolation: isolate;
}

.service-card::after,
.news-card::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  opacity: 0;
  transition: opacity 320ms ease;
  background: radial-gradient(
    240px circle at var(--mx, 50%) var(--my, 50%),
    rgba(199, 165, 109, 0.16),
    transparent 62%
  );
}

@media (hover: hover) {
  .service-card:hover::after,
  .news-card:hover::after {
    opacity: 1;
  }
}

/* The card lifts on its border and shadow, not on scale — scaling a card
   containing a photograph resamples the image and looks cheap. */
.service-card,
.news-card {
  transition:
    box-shadow 320ms cubic-bezier(0.16, 1, 0.3, 1),
    border-color 320ms ease;
}

@media (hover: hover) {
  .service-card:hover,
  .news-card:hover {
    box-shadow: var(--shadow-lg);
  }
}

/* The photo behind a service card gets a slow push-in. Contained by the
   card's overflow, so nothing reflows. */
.service-media {
  transition: transform 620ms cubic-bezier(0.16, 1, 0.3, 1);
  transform-origin: center;
}

@media (hover: hover) {
  .service-card:hover .service-media {
    transform: scale(1.045);
  }
}

/* ── Text-link draw ────────────────────────────────────────────────────────
   The "Learn More" underline draws from the left instead of appearing. */
.text-link {
  position: relative;
  display: inline-block;
}

.text-link::after {
  content: "";
  position: absolute;
  left: 0;
  bottom: -3px;
  width: 100%;
  height: 1px;
  background: currentColor;
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 380ms cubic-bezier(0.16, 1, 0.3, 1);
}

.text-link:hover::after,
.text-link:focus-visible::after {
  transform: scaleX(1);
}

/* ── CountUp ───────────────────────────────────────────────────────────────
   Tabular figures so the number does not jitter horizontally while counting.
   1865 counting from zero would read as a fake odometer, so motion.js counts
   the year from a near value instead (see COUNT_FROM). */
[data-countup] {
  font-variant-numeric: tabular-nums;
}

/* ── Reduced motion ────────────────────────────────────────────────────────
   Everything resolves to its finished state. This is also the faster path. */
@media (prefers-reduced-motion: reduce) {html:not(.force-motion).motion-ready .reveal,
  html:not(.force-motion).motion-ready .reveal.is-in {
    opacity: 1 !important;
    transform: none !important;
    transition: none !important;
  }html:not(.force-motion) .service-card,
  html:not(.force-motion) .news-card,
  html:not(.force-motion) .service-media,
  html:not(.force-motion) .text-link::after {
    transition: none !important;
  }html:not(.force-motion) .service-card:hover .service-media {
    transform: none;
  }html:not(.force-motion) .service-card::after,
  html:not(.force-motion) .news-card::after {
    display: none;
  }
}

/* ══════════════════════════════════════════════════════════════════════════
   PAGE-LEVEL MOTION
   Production-calibrated: present, not performative. Everything animates
   transform/opacity only. Scroll-linked pieces use native scroll timelines,
   so they run on the compositor with no scroll listener; browsers without
   support simply get the static layout.

   Disabling follows the project convention (see DESIGN.md, The Motion-On
   Rule): motion is on by default and yields to html:not(.force-motion)
   under prefers-reduced-motion.
   ══════════════════════════════════════════════════════════════════════════ */

/* ── 1. scroll progress rail ─────────────────────────────────────────────── */
.scroll-rail {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 2px;
  z-index: 60;                 /* above the sticky header (z-30) */
  background: var(--gold);
  transform: scaleX(0);
  transform-origin: 0 50%;
  pointer-events: none;
}

@supports (animation-timeline: scroll()) {
  .scroll-rail {
    animation: railFill linear both;
    animation-timeline: scroll(root block);
  }
}

@keyframes railFill {
  from { transform: scaleX(0); }
  to   { transform: scaleX(1); }
}

/* ── 2. purpose photo parallax ───────────────────────────────────────────── */
.purpose-image-wrap {
  overflow: hidden;
}

@supports (animation-timeline: view()) {
  @media (min-width: 901px) {
    .purpose-image-wrap img {
      /* scaled so the drift never exposes an edge */
      animation: purposeDrift linear both;
      animation-timeline: view();
      animation-range: entry 0% exit 100%;
    }
  }
}

@keyframes purposeDrift {
  from { transform: translateY(-26px) scale(1.08); }
  to   { transform: translateY(26px)  scale(1.08); }
}

/* ── 3. practice-bar tick draw ─────────────────────────────────────────────
   Driven by a native view timeline, not by the JS reveal class. That keeps it
   independent of IntersectionObserver: with `both` fill the tick is collapsed
   before the band enters and drawn after it, and a browser without scroll
   timelines simply shows the tick, never a permanently invisible one. */
.practice-name::before {
  transform-origin: left center;
}

@supports (animation-timeline: view()) {
  .practice-name::before {
    animation: tickDraw 1ms linear both;
    animation-timeline: view();
    animation-range: entry 12% entry 62%;
  }
}

@keyframes tickDraw {
  from { transform: scaleX(0); }
  to   { transform: scaleX(1); }
}

/* ── 4. section heading rules ──────────────────────────────────────────────
   Same approach as the ticks: view-timeline driven, so no JS dependency. */
.intro-grid h2::after,
.section-title-wrap h2::after,
.purpose-copy h2::after {
  content: "";
  display: block;
  height: 1px;
  margin-top: 20px;
  background: var(--line-dark);
  transform-origin: left center;
}

@supports (animation-timeline: view()) {
  .intro-grid h2::after,
  .section-title-wrap h2::after,
  .purpose-copy h2::after {
    animation: ruleDraw 1ms linear both;
    animation-timeline: view();
    animation-range: entry 15% entry 70%;
  }
}

@keyframes ruleDraw {
  from { transform: scaleX(0); }
  to   { transform: scaleX(1); }
}

/* ── reduced motion ──────────────────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  html:not(.force-motion) .scroll-rail { display: none; }
  html:not(.force-motion) .purpose-image-wrap img { animation: none; transform: none; }
  html:not(.force-motion) .practice-name::before,
  html:not(.force-motion) .intro-grid h2::after,
  html:not(.force-motion) .section-title-wrap h2::after,
  html:not(.force-motion) .purpose-copy h2::after {
    animation: none;
    transform: scaleX(1);
  }
}
