/* Three Rivers motion system.
   Rules for all motion on the site:
   - Animate only opacity and transform (here the individual translate and scale properties, so hover
     effects that use transform keep working), so layout never shifts.
   - Anything that starts on its own finishes within 5 seconds (WCAG 2.2.2 Pause, Stop, Hide).
   - Content is in the HTML from the start; motion only changes how it appears.
   - Visitors who ask for reduced motion see the final state immediately.
   Scroll effects use CSS scroll-driven animations (Chrome, Edge, Safari 26+); /static/motion.js gives
   other browsers the same reveals. Without either, content simply shows. */
:root{
  --dur-fast:160ms;   /* hovers, focus, small state changes */
  --dur-base:420ms;   /* reveals, page transitions */
  --dur-slow:900ms;   /* hero entrances */
  --ease:cubic-bezier(.22,.61,.36,1); /* one calm ease-out curve for the whole site */
  --rise:18px;        /* how far revealed content travels */
}

/* ---------- 1. Page transitions (cross-document View Transitions) ---------- */
@view-transition{navigation:auto}
.site-header{view-transition-name:site-header}
::view-transition-old(root),::view-transition-new(root){animation-duration:280ms;animation-timing-function:var(--ease)}

/* ---------- 2. Entrances above the fold (time-based, under 1.5 seconds) ---------- */
@keyframes tr-up{from{opacity:0;translate:0 var(--rise)}to{opacity:1;translate:none}}
:is(.hero,.page-head,.post-head) .wrap>*{animation:tr-up var(--dur-slow) var(--ease) both}
:is(.hero,.page-head,.post-head) .wrap>*:nth-child(2){animation-delay:120ms}
:is(.hero,.page-head,.post-head) .wrap>*:nth-child(3){animation-delay:240ms}
:is(.hero,.page-head,.post-head) .wrap>*:nth-child(n+4){animation-delay:360ms}
.post-hero{animation:tr-up var(--dur-slow) var(--ease) 200ms both}

/* ---------- 3. Hero photo: a slow push that settles in 5 seconds, then stops ---------- */
/* The photo moves to its own layer so it can scale without repainting the page. */
.photo-hero{isolation:isolate;background:var(--navy-deep)}
.photo-hero::before,.photo-hero::after{display:block;content:"";position:absolute;inset:0;z-index:-1;opacity:1;filter:none;mask-image:none;-webkit-mask-image:none}
.photo-hero::before{background:url(/static/photos/capitol.jpg) center 40%/cover no-repeat;
  background-image:image-set(url(/static/photos/capitol.avif) type("image/avif"),url(/static/photos/capitol.webp) type("image/webp"),url(/static/photos/capitol.jpg) type("image/jpeg"));
  transform-origin:60% 40%;animation:tr-push 4.5s var(--ease) both}
.photo-hero::after{background:linear-gradient(100deg,rgba(6,23,51,.94) 0%,rgba(10,35,80,.82) 45%,rgba(10,35,80,.35) 100%)}
@keyframes tr-push{from{scale:1.07}to{scale:1}}
@media (max-width:860px){.photo-hero::before{background-position:60% center}}

/* ---------- 4. Reveal on scroll ---------- */
/* Applied to existing page parts by selector, so page files need no extra classes. Add class="reveal"
   to anything else. Keep this list in step with REVEAL in /static/motion.js. */
@keyframes tr-reveal{from{opacity:0;translate:0 var(--rise)}to{opacity:1;translate:none}}
@supports (animation-timeline:view()){
  :is(.reveal,
      .center-h,.row-head,.practice article,.post-card,.split-photo,.split .body,
      .approach h2,.approach-cols>div,.photo-cta .wrap,
      .svc,.bio>*,.two-col>*,.post .prose>:is(h2,figure,blockquote),.author,
      .tool-card,.cg-card){
    animation:tr-reveal linear both;animation-timeline:view();animation-range:entry 5% entry 65%}
  /* Short stagger across a row of cards */
  :is(.post-grid,.practice,.tool-grid,.approach-cols)>:nth-child(3n+2){animation-range:entry 12% entry 72%}
  :is(.post-grid,.practice,.tool-grid,.approach-cols)>:nth-child(3n+3){animation-range:entry 19% entry 79%}
}
/* Fallback (motion.js adds .js-motion only where scroll-driven animation is missing) */
.js-motion .tr-pending{opacity:0;translate:0 var(--rise);transition:opacity var(--dur-base) var(--ease),translate var(--dur-base) var(--ease)}
.js-motion .tr-pending.in{opacity:1;translate:none}

/* ---------- 5. Photo bands: light parallax tied to scroll ---------- */
@supports (animation-timeline:view()){
  .approach,.photo-cta{isolation:isolate;overflow:hidden}
  .approach{background:var(--navy-deep)}
  .photo-cta{background:var(--navy-deep)}
  .approach::before,.photo-cta::before{display:block;content:"";position:absolute;inset:-14% 0;z-index:-1;opacity:1;filter:none;
    animation:tr-drift linear both;animation-timeline:view()}
  .approach::before{background:linear-gradient(rgba(6,23,51,.88),rgba(6,23,51,.88)),url(/static/photos/interior.jpg) center/cover no-repeat;
    background-image:linear-gradient(rgba(6,23,51,.88),rgba(6,23,51,.88)),image-set(url(/static/photos/interior.avif) type("image/avif"),url(/static/photos/interior.webp) type("image/webp"),url(/static/photos/interior.jpg) type("image/jpeg"))}
  .photo-cta::before{background:linear-gradient(rgba(10,35,80,.86),rgba(6,23,51,.92)),url(/static/photos/skyline.jpg) center/cover no-repeat;
    background-image:linear-gradient(rgba(10,35,80,.86),rgba(6,23,51,.92)),image-set(url(/static/photos/skyline.avif) type("image/avif"),url(/static/photos/skyline.webp) type("image/webp"),url(/static/photos/skyline.jpg) type("image/jpeg"))}
}
@keyframes tr-drift{from{translate:0 -9%}to{translate:0 9%}}

/* ---------- 6. Header: gains depth and a slightly smaller logo once the page scrolls ---------- */
@supports (animation-timeline:scroll()){
  .site-header::before{content:"";position:absolute;inset:0;z-index:-1;pointer-events:none;box-shadow:0 8px 24px -16px rgba(6,23,51,.35);opacity:0;animation:tr-head linear both;animation-timeline:scroll(root);animation-range:0 160px}
  .site-header .brand img{transform-origin:left center;animation:tr-logo linear both;animation-timeline:scroll(root);animation-range:0 160px}
}
@keyframes tr-head{to{opacity:1}}
@keyframes tr-logo{to{scale:.88}}

/* ---------- 7. Reading progress on articles ---------- */
@supports (animation-timeline:scroll()){
  body:has(.post-head) .site-header::after{content:"";position:absolute;left:0;right:0;bottom:-1px;height:2px;background:var(--gold);
    transform-origin:left;scale:0 1;animation:tr-progress linear both;animation-timeline:scroll(root)}
}
@keyframes tr-progress{to{scale:1 1}}

/* ---------- 8. Hover and keyboard focus ---------- */
/* Every hover effect on a card also shows when a link inside it has keyboard focus. */
.post-card:focus-within{box-shadow:var(--shadow);transform:translateY(-2px)}
.post-card:focus-within .thumb img{transform:scale(1.03)}
.practice article.has-photo:focus-within .practice-img img{transform:scale(1.04)}
.practice article:focus-within{background:var(--mist)}
.practice article:focus-within::before{transform:scaleY(1)}
.svc-photo:focus-within .svc-img img{transform:scale(1.03)}
.tool-card:focus-visible{transform:translateY(-3px);box-shadow:0 2px 4px rgba(6,23,51,.08),0 20px 40px -14px rgba(6,23,51,.32)}
.practice h3 a{background:linear-gradient(var(--gold),var(--gold)) 0 100%/0 1.5px no-repeat;transition:background-size .3s var(--ease)}
.practice article:is(:hover,:focus-within) h3 a{background-size:100% 1.5px}
.split-photo img{transition:transform .8s var(--ease)}
.split:hover .split-photo img{transform:scale(1.03)}
:focus-visible{outline:2px solid var(--gold);outline-offset:3px}

/* ---------- 9. Reduced motion ---------- */
@media (prefers-reduced-motion:reduce){
  @view-transition{navigation:none}
  *,*::before,*::after{animation:none!important;transition-duration:1ms!important;scroll-behavior:auto!important}
  .js-motion .tr-pending{opacity:1!important;translate:none!important}
  .site-header .brand img{scale:none}
}

/* ---------- 10. Signature: "The Confluence" (Phase 2) ---------- */
/* Three lines that start apart and join into one: drawn once in the hero (time-based, done in 3.4 seconds)
   and again above the three Confluence columns as they scroll into view. SVG strokes are drawn with
   stroke-dashoffset; nothing around them moves. Paths use pathLength="1", so 1 means "not drawn". */
.rivers{position:absolute;inset:0;width:100%;height:100%;z-index:0;pointer-events:none;overflow:visible}
.rivers .r{fill:none;stroke:url(#rv-fade);stroke-width:1.5;vector-effect:non-scaling-stroke;stroke-linecap:round;stroke-dasharray:1;stroke-dashoffset:0}
.rivers .r1,.rivers .r3{opacity:.45}
.rivers .r2{opacity:.6}
.rivers .r4{stroke:var(--gold);stroke-width:2.5;opacity:.85}
@keyframes tr-draw{from{stroke-dashoffset:1}to{stroke-dashoffset:0}}
.rivers .r{animation:tr-draw 1.9s var(--ease) both}
.rivers .r1{animation-delay:.5s}.rivers .r2{animation-delay:.65s}.rivers .r3{animation-delay:.8s}
.rivers .r4{animation-duration:1.1s;animation-delay:2.25s}
/* Phones and small tablets: the headline fills the width, so the lines run along the bottom of the hero. */
@media (max-width:1000px){.rivers{top:auto;height:110px}}

.approach h2{margin-bottom:28px}
.confluence{display:block;width:100%;height:110px;overflow:visible}
.confluence .c{fill:none;stroke:var(--gold);stroke-width:2;vector-effect:non-scaling-stroke;stroke-dasharray:1;stroke-dashoffset:0;opacity:.9}
@supports (animation-timeline:view()){
  .confluence{view-timeline-name:--confluence}
  .confluence .c{animation:tr-draw linear both;animation-timeline:--confluence}
  .confluence .c1{animation-range:entry 30% cover 42%}
  .confluence .c2{animation-range:entry 45% cover 48%}
  .confluence .c3{animation-range:entry 60% cover 54%}
}
@media (max-width:860px){.confluence{display:none}.approach h2{margin-bottom:40px}}
@media (prefers-reduced-motion:reduce){.rivers .r,.confluence .c{stroke-dashoffset:0!important}}

/* ---------- 11. Phones: smaller copies of the full-width photos (Phase 4 performance pass) ---------- */
@media (max-width:860px){
  .photo-hero::before{background-image:image-set(url(/static/photos/capitol-m.avif) type("image/avif"),url(/static/photos/capitol-m.webp) type("image/webp"),url(/static/photos/capitol-m.jpg) type("image/jpeg"))}
  .approach::before{background-image:linear-gradient(rgba(6,23,51,.88),rgba(6,23,51,.88)),image-set(url(/static/photos/interior-m.avif) type("image/avif"),url(/static/photos/interior-m.webp) type("image/webp"),url(/static/photos/interior-m.jpg) type("image/jpeg"))}
  .photo-cta::before{background-image:linear-gradient(rgba(10,35,80,.86),rgba(6,23,51,.92)),image-set(url(/static/photos/skyline-m.avif) type("image/avif"),url(/static/photos/skyline-m.webp) type("image/webp"),url(/static/photos/skyline-m.jpg) type("image/jpeg"))}
}
