/* =====================================================================
   Print Box Global: scroll story motion (paired with js/story.js)
   Rules: only transform/opacity animate (GPU, no layout shift); content
   that is visible on first load is never hidden (Core Web Vitals / SEO);
   without JS or with "reduce motion" everything is simply visible.
   ===================================================================== */

/* ---- 1. Story progress bar (top of the page) ---- */
.story-progress{position:fixed;top:0;left:0;right:0;height:4px;z-index:1080;pointer-events:none;background:transparent}
/* updated by story.js only while the page is scrolling (a CSS scroll-timeline is re-checked on every frame) */
.story-progress span{display:block;height:100%;background:linear-gradient(90deg,var(--orange),#F59A5B);transform-origin:0 50%;transform:scaleX(0);border-radius:0 4px 4px 0}

/* ---- 2. Scroll reveals (classes added by story.js only to content below the fold) ---- */
.rv{transition:opacity .75s cubic-bezier(.2,.7,.2,1),transform .85s cubic-bezier(.2,.7,.2,1);transition-delay:var(--rv-d,0ms)}
.rv:not(.rv-in){opacity:0;transform:translate3d(0,34px,0) scale(.985)}
/* sideways entrances only on wide screens (on phones they would push the page wider than the screen) */
@media(min-width:992px){
  .rv.rv-left:not(.rv-in){transform:translate3d(-48px,0,0) rotate(-1.5deg)}
  .rv.rv-right:not(.rv-in){transform:translate3d(48px,0,0)}
}
.rv.rv-zoom:not(.rv-in){transform:scale(.9) rotate(-2deg)}
.rv.rv-fade:not(.rv-in){transform:none}

/* Heading underline "draws" itself when its block arrives.
   isolation keeps the underline (z-index:-1) behind the word but above tinted section backgrounds,
   where it used to disappear. */
h1 em,h2 em{isolation:isolate}
h2 em::after{transform-origin:0 50%;transition:transform .9s cubic-bezier(.65,0,.25,1) .25s}
.rv:not(.rv-in) h2 em::after,h2.rv:not(.rv-in) em::after{transform:scaleX(0)}

/* Icons pop a little after their card lands */
.feature.rv i,.stats-band>.rv i,.hero-trust>.rv i{transition:transform .6s cubic-bezier(.3,1.6,.5,1) calc(var(--rv-d,0ms) + .2s)}
.feature.rv:not(.rv-in) i,.stats-band>.rv:not(.rv-in) i,.hero-trust>.rv:not(.rv-in) i{transform:scale(.4) rotate(-20deg)}

/* ---- 3. "How it works" as a timeline: a line fills across the 4 steps ---- */
@media(min-width:992px){
  .process{position:relative}
  .process::before,.process::after{content:'';position:absolute;left:12.5%;right:12.5%;top:calc(1.75rem + 28px);height:4px;border-radius:4px;z-index:0;pointer-events:none}
  .process::before{background:var(--line2)}
  .process::after{background:linear-gradient(90deg,var(--orange),var(--ink));transform-origin:0 50%;transition:transform 1.8s cubic-bezier(.65,0,.25,1) .2s}
  .story-on .process:not(.story-lit)::after{transform:scaleX(0)}
  .process .st{z-index:1}
}
.process .st::before{transition:transform .55s cubic-bezier(.3,1.6,.5,1) calc(var(--rv-d,0ms) + .15s)}
.process .st.rv:not(.rv-in)::before{transform:scale(.3)}

/* ---- 4. Opening entrance (CSS only; moves but never fades, so nothing waits to be "painted") ---- */
@keyframes storyRise{from{transform:translate3d(0,26px,0)}to{transform:none}}
@keyframes storySticker{0%{transform:rotate(-14deg) scale(.55)}70%{transform:rotate(1deg) scale(1.06)}100%{transform:rotate(-2deg) scale(1)}}
.hero .hero-in>div:first-child>*{animation:storyRise .9s cubic-bezier(.2,.7,.2,1) both}
.hero .hero-in>div:first-child>*:nth-child(2){animation-delay:.08s}
.hero .hero-in>div:first-child>*:nth-child(3){animation-delay:.16s}
.hero .hero-in>div:first-child>*:nth-child(4){animation-delay:.24s}
.hero .hero-in>div:first-child>*:nth-child(5){animation-delay:.32s}
.hero h1 em{animation:storySticker .9s cubic-bezier(.3,1.4,.5,1) .45s both}
.page-hero .container>*{animation:storyRise .8s cubic-bezier(.2,.7,.2,1) both}
.page-hero .container>*:nth-child(2){animation-delay:.08s}
.page-hero .container>*:nth-child(3){animation-delay:.16s}

/* ---- 5. Chapter rail (home page, wide screens) ---- */
.story-rail{position:fixed;left:18px;top:50%;transform:translateY(-50%);z-index:1030;display:none;flex-direction:column;gap:6px;padding:10px 8px;border-radius:999px;background:rgba(255,255,255,.96);box-shadow:0 10px 30px rgba(28,26,58,.12);border:1px solid var(--line);opacity:0;transition:opacity .4s}
.story-rail.show{opacity:1}
@media(min-width:1400px){.story-rail{display:flex}}
.story-rail button{position:relative;display:flex;align-items:center;justify-content:center;width:26px;height:26px;border:0;background:none;padding:0;border-radius:50%;cursor:pointer}
.story-rail button i{display:block;width:8px;height:8px;border-radius:50%;background:var(--line2);transition:transform .3s,background .3s}
.story-rail button:hover i{background:var(--orange-d)}
.story-rail button.on i{background:var(--orange);transform:scale(1.6);box-shadow:0 0 0 4px rgba(229,112,37,.18)}
.story-rail button span{position:absolute;left:36px;top:50%;transform:translate(-6px,-50%);white-space:nowrap;background:var(--ink);color:#fff;font:700 .78rem var(--font-body);padding:.35rem .7rem;border-radius:999px;opacity:0;pointer-events:none;transition:opacity .25s,transform .25s}
.story-rail button span b{color:var(--orange);margin-right:.35rem}
.story-rail button:hover span,.story-rail button:focus-visible span,.story-rail button.on.flash span{opacity:1;transform:translate(0,-50%)}
.story-rail button:focus-visible{outline:2px solid var(--orange);outline-offset:2px}

/* ---- 6. (Scroll-linked drift effects removed for performance: browsers re-check them on every frame.) ---- */

/* ---- Safety ---- */
@media (prefers-reduced-motion:reduce){
  .rv,.rv:not(.rv-in){opacity:1!important;transform:none!important;transition:none!important}
  .story-rail button i,.story-rail button span{transition:none}
  h2 em::after,.process::after{transition:none!important;transform:none!important}
}
@media print{.rv{opacity:1!important;transform:none!important}.story-progress,.story-rail{display:none!important}}
