/* motion.css (prefix mo-): reveals, header progress, parallax, process story, marquee.
   Hidden "before reveal" states live under html.mo (set by /js/boot.js only when motion is welcome). */
:root{--mo-ease:cubic-bezier(.2,.7,.2,1)}

/* ===== failsafe: if motion.js never runs (html never gets .mo-live) everything shows after 2.5 s ===== */
@keyframes mo-failsafe{to{opacity:1;transform:none;visibility:visible;clip-path:none}}
@keyframes mo-failsafe-img{to{scale:1}}
html.mo:not(.mo-live) [data-reveal=""],html.mo:not(.mo-live) [data-reveal="image"],html.mo:not(.mo-live) [data-reveal-stagger]>*{animation:mo-failsafe 0s 2.5s forwards}
html.mo:not(.mo-live) [data-reveal="lines"]{visibility:hidden;animation:mo-failsafe 0s 2.5s forwards}
html.mo:not(.mo-live) [data-reveal="image"] img{animation:mo-failsafe-img 0s 2.5s forwards}

/* Hidden states carry no transition (so they apply instantly); the transition sits on the revealed
   state, and .mo-done (added after the animation) hands the element back to the page's own styles. */

/* ===== [data-reveal]: fade + rise ===== */
html.mo [data-reveal=""]:not(.mo-in):not(.mo-done){opacity:0;transform:translateY(26px)}
html.mo [data-reveal=""].mo-in:not(.mo-done){transition:opacity .8s var(--mo-ease),transform .8s var(--mo-ease);transition-delay:calc(var(--mo-b,0)*90ms)}

/* ===== [data-reveal="lines"]: masked line-by-line rise ===== */
/* the mask is a clip-path that reaches past the line box: accents and descenders survive tight line-heights
   and, unlike overflow+padding+negative margins, the line spacing stays exactly the heading's own */
.mo-line{display:block;clip-path:inset(-.14em -.08em -.24em)}
.mo-line-inner{display:block}
html.mo [data-reveal="lines"]:not(.mo-in) .mo-line-inner{transform:translateY(calc(100% + .5em))}
html.mo [data-reveal="lines"].mo-in:not(.mo-done) .mo-line-inner{transition:transform .9s var(--mo-ease);transition-delay:calc((var(--mo-b,0) + var(--mo-i,0))*90ms)}

/* ===== [data-reveal="image"]: clip-path + counter-scale (scale/translate are individual properties so parallax can own translate) ===== */
html.mo [data-reveal="image"]:not(.mo-in){clip-path:inset(12% 0 12% 0)}
html.mo [data-reveal="image"].mo-in:not(.mo-done){clip-path:inset(0);transition:clip-path 1.2s var(--mo-ease)}
html.mo [data-reveal="image"].mo-done{clip-path:none}
html.mo [data-reveal="image"]:not(.mo-in) img{scale:1.12}
html.mo [data-reveal="image"].mo-in:not(.mo-done) img{transition:scale 1.2s var(--mo-ease)}

/* ===== [data-reveal-stagger]: children rise one after another ===== */
html.mo [data-reveal-stagger]:not(.mo-in):not(.mo-done)>*{opacity:0;transform:translateY(26px)}
html.mo [data-reveal-stagger].mo-in:not(.mo-done)>*{transition:opacity .8s var(--mo-ease),transform .8s var(--mo-ease);transition-delay:calc((var(--mo-b,0) + var(--mo-i,0))*80ms)}

/* ===== counters ===== */
[data-count]{font-variant-numeric:tabular-nums}

/* ===== header: scroll progress + scrolled shadow (height untouched) ===== */
header .scroll-progress{position:absolute;left:0;right:0;bottom:-1px;height:2px;background:var(--orange);transform-origin:left center;transform:scaleX(0);pointer-events:none;will-change:transform}
html.mo header{transition:box-shadow .3s ease}
header.mo-scrolled{box-shadow:0 6px 24px rgba(7,29,55,.08)}

/* ===== parallax: image is 118% tall, 9% headroom above and below, driven by --mo-py ===== */
@media (min-width:760px){
html.mo figure.photo-band img[data-parallax]{position:relative;top:-9%;width:100%;height:118%;object-fit:cover;display:block;translate:0 var(--mo-py,0px);will-change:translate}
}

/* ===== #process: scroll-highlighted story ===== */
.process-steps{list-style:none;margin:0;padding:0}
.process-thumb{background-image:url('/assets/instrumentation-workflow.jpg');background-image:image-set(url('/assets/instrumentation-workflow.webp') type('image/webp'),url('/assets/instrumentation-workflow.jpg') type('image/jpeg'));background-size:500% auto;background-position:var(--pos) center;background-repeat:no-repeat;background-color:var(--navy)}
.process-frame{background-image:url('/assets/instrumentation-workflow.jpg');background-image:image-set(url('/assets/instrumentation-workflow.webp') type('image/webp'),url('/assets/instrumentation-workflow.jpg') type('image/jpeg'));background-size:500% auto;background-position:var(--pos) center;background-repeat:no-repeat}
.process-frame::after{content:'';position:absolute;inset:0;background:linear-gradient(180deg,rgba(4,21,39,.05),rgba(4,21,39,.55))}
.process-step h4{font-size:clamp(34px,3.6vw,56px);font-weight:500;letter-spacing:-1.6px;line-height:1.05;margin:0 0 14px}
.process-step h4::before{content:'';display:block;width:36px;height:3px;margin-bottom:18px;background:var(--orange)}
.process-tags{margin:0 0 14px;font-size:11px;font-weight:600;letter-spacing:1.4px;line-height:1.5;text-transform:uppercase;color:var(--sim-ink,#1f7fa6)}
.process-step>p:last-child{margin:0;max-width:440px;font-size:17px;line-height:1.6;color:var(--ink-soft)}

@media (min-width:900px){
.process-body{display:grid;grid-template-columns:1.05fr 1fr;gap:6%;align-items:start}
.process-visual{position:sticky;top:120px;height:min(68vh,620px);overflow:hidden;border-radius:0;background:var(--navy)}
.process-frame{position:absolute;inset:0;opacity:0;z-index:0}
.process-frame.is-active{opacity:1;z-index:1}
.process-progress{position:absolute;left:0;right:0;bottom:0;z-index:2;height:3px;background:rgba(255,255,255,.2)}
.process-progress i{display:block;height:100%;background:var(--orange);transform-origin:left center;transform:scaleX(.2)}
.process-step{display:flex;flex-direction:column;justify-content:center;min-height:50vh;padding:6vh 0;border-top:1px solid var(--line)}
.process-thumb{display:none}
.process-step h4::before{width:0}
.process-step.is-active h4::before{width:36px}

/* crossfade: the incoming frame fades in on top, the outgoing one is dropped only once it is covered */
html.mo .process-frame{transform:scale(1.06);transition:opacity 0s linear .7s,transform 1.4s var(--mo-ease)}
html.mo .process-frame.is-active{transform:none;transition:opacity .7s ease,transform 1.4s var(--mo-ease)}
html.mo .process-progress i{transition:transform .6s var(--mo-ease)}
html.mo .process-step{transition:opacity .5s ease}
html.mo.mo-live .process-step:not(.is-active){opacity:.28}
html.mo .process-step h4::before{transition:width .7s var(--mo-ease) .1s}
}

@media (max-width:899.98px){
.process-visual{display:none}
.process-step{padding:30px 0;border-top:1px solid var(--line)}
.process-thumb{aspect-ratio:16/9;margin-bottom:18px;border-radius:0}
html.mo [data-reveal="step"]:not(.mo-in):not(.mo-done){opacity:0;transform:translateY(26px)}
html.mo [data-reveal="step"].mo-in:not(.mo-done){transition:opacity .8s var(--mo-ease),transform .8s var(--mo-ease)}
}

/* ===== marquee ===== */
.sensor-marquee{position:relative;overflow:hidden;margin-top:70px;padding:26px 0;border-top:1px solid var(--line);border-bottom:1px solid var(--line)}
.sensor-marquee .resource-caption{margin:0;font-size:clamp(26px,3.2vw,48px);font-weight:500;letter-spacing:-1px;line-height:1.2;color:var(--ink)}
.sensor-marquee .resource-caption::before{display:none}
/* motion on: the original paragraph stays for screen readers, the visible band is aria-hidden copies */
.sensor-marquee.mo-marquee>p.resource-caption:not(.mo-marquee-item){position:absolute;width:1px;height:1px;margin:-1px;overflow:hidden;clip:rect(0 0 0 0);white-space:nowrap}
.mo-marquee-window{overflow:hidden;-webkit-mask-image:linear-gradient(90deg,transparent,#000 5%,#000 95%,transparent);mask-image:linear-gradient(90deg,transparent,#000 5%,#000 95%,transparent)}
.mo-marquee-track{display:flex;width:max-content;animation:mo-marquee var(--mo-dur,40s) linear infinite;will-change:transform}
.mo-marquee-item{flex:none;white-space:nowrap}
.mo-dot{display:inline-block;margin:0 .5em;color:var(--orange);font-weight:700}
@keyframes mo-marquee{to{transform:translate3d(-50%,0,0)}}
.sensor-marquee:hover .mo-marquee-track,.sensor-marquee:focus-within .mo-marquee-track,.sensor-marquee.mo-marquee-off .mo-marquee-track{animation-play-state:paused}

/* ===== belt and braces for reduced motion (boot.js already withholds .mo) ===== */
@media (prefers-reduced-motion:reduce){
.mo-marquee-track{animation:none}
.process-frame,.process-step,.process-progress i,.process-step h4::before{transition:none!important}
}
