/* ==========================================================================
   Scroll & motion effects
   Every rule is scoped to html.fx, which is only set when JavaScript runs and the
   visitor has not asked for reduced motion, so content is never hidden without it.
   JS feeds these custom properties:
     --hy  hero scroll offset in px       --hp  hero scroll progress 0..1
     --pp  programs section progress 0..1 (0 = just entering, 1 = just left)
   ========================================================================== */

/* ---------- Hero: page-load entrance ---------- */
html.fx .hero-nav { opacity: 0; translate: 0 -28px;
    transition: background .8s ease, border-color .8s ease, opacity .8s ease .15s, translate 1s cubic-bezier(.2,.75,.15,1) .15s; }
html.fx .arc-inner { opacity: 0; translate: 0 110px;
    transition: transform .6s ease-out, opacity 1s ease .45s, translate 1.5s cubic-bezier(.2,.75,.15,1) .45s; }
html.fx .hero-controls > * { opacity: 0; translate: 0 16px; transition: opacity .8s ease, translate .9s cubic-bezier(.2,.75,.15,1); }
html.fx .hero-controls > :nth-child(1) { transition-delay: .9s; }
html.fx .hero-controls > :nth-child(2) { transition-delay: 1s; }
html.fx .hero-controls > :nth-child(3) { transition-delay: 1.1s; }

html.fx.fx-loaded .hero-nav,
html.fx.fx-loaded .arc-inner,
html.fx.fx-loaded .hero-controls > * { opacity: 1; translate: 0 0; }

/* ---------- Hero: scroll parallax (layers move at different speeds) ---------- */
html.fx .hero-bgs  { translate: 0 calc(var(--hy, 0px) * .45); }              /* background: slowest */
html.fx .hero-copy { translate: 0 calc(var(--hp, 0) * -140px); opacity: calc(1 - var(--hp, 0) * 1.9); }
html.fx .hero-arc  { translate: 0 calc(var(--hp, 0) * -70px); }               /* cards: foreground */

/* ---------- Programs: reveal when scrolled into view ---------- */
html.fx .programs .feature { opacity: 0; scale: .82;
    transition: opacity 1s ease .1s, scale 1.4s cubic-bezier(.2,.8,.2,1) .1s; }
html.fx .programs .seg { opacity: 0; scale: .5; rotate: -16deg;
    transition: transform .7s cubic-bezier(.2,.75,.15,1), filter .5s ease,
                opacity .8s ease calc(var(--d, 0) * 120ms + .25s),
                scale 1.3s cubic-bezier(.2,.8,.2,1) calc(var(--d, 0) * 120ms + .25s),
                rotate 1.3s cubic-bezier(.2,.8,.2,1) calc(var(--d, 0) * 120ms + .25s); }
html.fx .programs .hub { opacity: 0; scale: .3;
    transition: opacity .6s ease .2s, scale 1.1s cubic-bezier(.34,1.56,.64,1) .2s; }
html.fx .programs .guides { opacity: 0; transition: opacity 1.6s ease .3s; }
html.fx .programs .network { opacity: 0; transition: opacity 1.4s ease .9s; }
html.fx .programs .route line { stroke-dasharray: 1; stroke-dashoffset: 1;
    transition: stroke .5s ease, stroke-dashoffset 1.1s cubic-bezier(.6,0,.2,1) 1.1s; }
html.fx .programs .route .node-end,
html.fx .programs .route .seg-label { opacity: 0; transition: fill .5s ease, opacity .6s ease 1.8s; }
html.fx .programs .programs-panel { opacity: 0; translate: 60px 0;
    transition: opacity 1s ease .5s, translate 1.2s cubic-bezier(.2,.75,.15,1) .5s; }

html.fx .programs.in-view .feature,
html.fx .programs.in-view .seg,
html.fx .programs.in-view .hub { opacity: 1; scale: 1; rotate: 0deg; }
html.fx .programs.in-view .guides,
html.fx .programs.in-view .network,
html.fx .programs.in-view .route .node-end,
html.fx .programs.in-view .route .seg-label { opacity: 1; }
html.fx .programs.in-view .route line { stroke-dashoffset: 0; }
html.fx .programs.in-view .programs-panel { opacity: 1; translate: 0 0; }

/* ---------- Programs: scroll parallax ---------- */
/* Photos drift inside their frames, and the line network and guides turn as you scroll. */
html.fx .programs .px-img { translate: 0 calc((var(--pp, .5) - .5) * -70px); }
html.fx .programs .network-spin { rotate: calc((var(--pp, .5) - .5) * 28deg); }
html.fx .programs .guides circle,
html.fx .programs .guides line { rotate: calc((var(--pp, .5) - .5) * -36deg); }
html.fx .programs .ring-stage { translate: 0 calc((var(--pp, .5) - .5) * -40px); }

/* ---------- Programs: soft spotlight that follows the pointer ---------- */
html.fx .programs::before { content: ""; position: absolute; inset: 0; pointer-events: none; z-index: 0;
    background: radial-gradient(520px circle at var(--gx, 30%) var(--gy, 40%),
        color-mix(in srgb, var(--pc) 9%, transparent), transparent 70%);
    transition: background .5s ease; }
html.fx .programs .ring-stage { position: relative; z-index: 1; }

/* ==========================================================================
   Reusable page-wide effects
   ========================================================================== */

/* data-reveal="up|down|left|right|zoom|fade", optional data-reveal-delay="1..6" (120ms steps). */
html.fx [data-reveal] { opacity: 0; transition: opacity .9s ease, translate 1.1s cubic-bezier(.2,.75,.15,1), scale 1.1s cubic-bezier(.2,.75,.15,1);
    transition-delay: calc(var(--rd, 0) * 120ms); }
html.fx [data-reveal="up"]    { translate: 0 40px; }
html.fx [data-reveal="down"]  { translate: 0 -40px; }
html.fx [data-reveal="left"]  { translate: -60px 0; }
html.fx [data-reveal="right"] { translate: 60px 0; }
html.fx [data-reveal="zoom"]  { scale: .88; }
html.fx [data-reveal].is-revealed { opacity: 1; translate: 0 0; scale: 1; }

/* data-parallax="0.2": the element drifts at its own speed as it passes through the screen (JS sets --py). */
html.fx [data-parallax] { translate: 0 var(--py, 0px); will-change: translate; }

/* Reading progress bar along the top of the page */
.scroll-progress { position: fixed; top: 0; left: 0; right: 0; height: 3px; z-index: 1000; pointer-events: none;
    transform-origin: left; transform: scaleX(var(--page-p, 0));
    background: linear-gradient(90deg, #b4232a, #f3c47a); box-shadow: 0 0 12px rgba(243,196,122,.6); }
html:not(.fx) .scroll-progress { display: none; }

/* Back-to-top button */
.to-top { position: fixed; right: clamp(16px, 3vw, 32px); bottom: clamp(16px, 3vw, 32px); z-index: 900;
    width: 52px; height: 52px; border-radius: 50%; border: 1px solid rgba(26,20,18,.1); cursor: pointer;
    display: grid; place-items: center; color: #fff; background: #1a1412;
    box-shadow: 0 16px 30px -12px rgba(26,20,18,.55);
    opacity: 0; translate: 0 20px; scale: .8; pointer-events: none;
    transition: opacity .4s ease, translate .5s cubic-bezier(.2,.75,.15,1), scale .5s cubic-bezier(.34,1.56,.64,1), background .25s; }
.to-top.is-visible { opacity: 1; translate: 0 0; scale: 1; pointer-events: auto; }
.to-top:hover { background: #b4232a; }
.to-top svg { position: relative; z-index: 1; }
/* Ring around the button fills with page progress */
.to-top .to-top-ring { position: absolute; inset: -4px; width: calc(100% + 8px); height: calc(100% + 8px); rotate: -90deg; }
.to-top .to-top-ring circle { fill: none; stroke: #f3c47a; stroke-width: 2.5; stroke-dasharray: 1; stroke-dashoffset: calc(1 - var(--page-p, 0)); }
