/* Case study pages only (loaded by single-case_study.php).
   1. Vertical video stills keep their shape.
   2. Scroll motion. Everything here keys off html.csm-js, which an inline head script
      adds only when JavaScript runs and the visitor has not asked for reduced motion.
      Below the fold, case-study.js adds .csm-el to elements before they scroll in, so
      nothing on screen ever blinks out. The hero has a CSS fallback that shows it after
      2.5s even if the script never runs. */

/* ── 1. Portrait rows: stills from vertical videos fill their own shape ── */
.cs-img-grid--portrait .cs-img-cell img{aspect-ratio:var(--cs-ar,.5625);height:auto}
.cs-img-3col.cs-img-grid--portrait{gap:20px}
@media(max-width:768px){
  /* A swipeable strip on phones instead of three tall stills stacked */
  .cs-img-grid--portrait{display:flex!important;overflow-x:auto;scroll-snap-type:x mandatory;gap:12px;margin:0 -20px;padding:0 20px 18px;scrollbar-width:none}
  .cs-img-grid--portrait::-webkit-scrollbar{display:none}
  .cs-img-grid--portrait .cs-img-cell{flex:0 0 68%;scroll-snap-align:center}
}

/* ── 2. Scroll motion ─────────────────────────────────────────────────── */
:root{--csm-ease:cubic-bezier(.16,1,.3,1)}

/* Reading progress */
.csm-progress{position:fixed;left:0;top:0;right:0;height:3px;z-index:100000;pointer-events:none;background:var(--orange);transform:scaleX(0);transform-origin:0 50%}

/* Hero: the title rises word by word, then the rest follows */
html.csm-js .cs-hero .cs-h1,
html.csm-js .cs-hero .cs-sector-tag,
html.csm-js .cs-hero .cs-intro,
html.csm-js .cs-hero .cs-hero-visit,
html.csm-js .cs-hero .cs-hero-stat{opacity:0;animation:csm-failsafe .01s 2.5s forwards}
@keyframes csm-failsafe{to{opacity:1}}
html.csm-js .csm-ready .cs-h1{opacity:1;animation:none}
.csm-w{display:inline-block;overflow:hidden;vertical-align:top;padding-bottom:.08em;margin-bottom:-.08em}
.csm-w > span{display:inline-block;translate:0 105%;transition:translate 1s var(--csm-ease)}
.csm-ready .csm-w > span{translate:0 0}
html.csm-js .csm-ready .cs-sector-tag,
html.csm-js .csm-ready .cs-intro,
html.csm-js .csm-ready .cs-hero-visit,
html.csm-js .csm-ready .cs-hero-stat{animation:csm-up .9s var(--csm-ease) both}
html.csm-js .csm-ready .cs-sector-tag{animation-delay:.05s}
html.csm-js .csm-ready .cs-hero-visit{animation-delay:.35s}
html.csm-js .csm-ready .cs-intro{animation-delay:.45s}
html.csm-js .csm-ready .cs-hero-stat:nth-child(1){animation-delay:.6s}
html.csm-js .csm-ready .cs-hero-stat:nth-child(2){animation-delay:.7s}
html.csm-js .csm-ready .cs-hero-stat:nth-child(3){animation-delay:.8s}
@keyframes csm-up{from{opacity:0;translate:0 22px}to{opacity:1;translate:0 0}}

/* Generic rise for text and cards */
.csm-el{opacity:0;translate:0 26px;transition:opacity .9s var(--csm-ease),translate .9s var(--csm-ease)}
.csm-el.csm-in{opacity:1;translate:0 0}

/* Images and videos rise and settle from slightly smaller */
.csm-media{opacity:0;translate:0 72px;scale:.94;transition:opacity 1.1s var(--csm-ease),translate 1.3s var(--csm-ease),scale 1.3s var(--csm-ease)}
.csm-media.csm-in{opacity:1;translate:0 0;scale:1}
/* After the reveal, full width images drift a little against the scroll (transform only) */
.csm-float{will-change:transform}

/* Section labels: the orange rule draws in from the left */
html.csm-js .cs-prose-label{position:relative;border-top-color:transparent}
html.csm-js .cs-prose-label::after{content:'';position:absolute;left:0;right:0;top:-2px;height:2px;background:var(--orange);transform:scaleX(1);transform-origin:0 50%;transition:transform 1s var(--csm-ease) .1s}
.csm-line-wait::after{transform:scaleX(0)!important}

/* Results band: the stats lift in one after another */
.cs-results-section .cs-result-block.csm-el{translate:0 40px}

/* Quote mark grows in */
.cs-quote-mark.csm-el{translate:0 0;scale:.6;transition:opacity .8s var(--csm-ease),scale 1s var(--csm-ease)}
.cs-quote-mark.csm-el.csm-in{scale:1}

/* Captions follow their image */
.cs-img-caption.csm-el{translate:0 10px;transition-delay:.35s}

@media(prefers-reduced-motion:reduce){
  .csm-el,.csm-media,.csm-w > span{opacity:1!important;translate:none!important;scale:none!important;transition:none!important}
  .csm-progress{display:none}
}
