/* VDS.RENT — scroll choreography (agent «motion»; BRIEF.md § 12 MOTION). Shared file: assets/js/motion.js marks the targets.
   Everything here is gated by html.motion, which the head gate (partials/head.html) sets synchronously only for real visitors:
   never under navigator.webdriver / headless Chrome / the system-WebKit snap tool (unless ?motion=1), never with
   prefers-reduced-motion. Without html.motion this file changes nothing, so every QA screenshot stays the static page.
   Only opacity and the individual 'translate' property are animated (existing 'transform's stay untouched), the keyframes
   have no 'to' (an element ends on its own computed values), and motion.js removes every trace after the reveal.
   Kinds:  rise  — headings, text, small pieces: 28 px, 900 ms, expo-out
           inner — the content of a card / of the first screen: 18 px, 1000 ms, expo-out
           block — a surface (card, panel, big render, map): it barely moves — 10 px and a long soft fade, 1100–1300 ms
           row   — table / list rows: 10 px, soft, 900 ms
           glow  — a first-screen render lights up slowly (opacity, 1.6 s);  fade  — opacity only;  line — a headline line slides up from under its mask (its mask fades in: lfade);  hdr — the header */
html.motion {
  --mo-ease: cubic-bezier(0.16, 1, 0.3, 1);       /* text: quick start, long settle */
  --mo-soft: cubic-bezier(0.25, 0.6, 0.3, 1);     /* surfaces: gentle start, long tail */
  --mo-dy: 28px; --mo-dy-in: 18px; --mo-dy-bl: 10px;
  --mo-d-rise: 900ms; --mo-d-in: 1000ms; --mo-d-bl: 1100ms; --mo-d-img: 1300ms; --mo-d-row: 900ms;
  --mo-d-fade: 850ms; --mo-d-line: 1100ms; --mo-d-lf: 650ms; --mo-d-hdr: 1200ms; --mo-d-glow: 1600ms;
}
@media (max-width: 600px) {
  html.motion { --mo-dy: 18px; --mo-dy-in: 12px; --mo-dy-bl: 8px;
    --mo-d-rise: 650ms; --mo-d-in: 750ms; --mo-d-bl: 800ms; --mo-d-img: 900ms; --mo-d-row: 700ms; --mo-d-fade: 800ms; --mo-d-line: 950ms; --mo-d-lf: 550ms; --mo-d-hdr: 1000ms; --mo-d-glow: 1300ms; }
}

/* until motion.js has marked its targets (DOMContentLoaded) the content of <main> and of the footer waits; the section
   backgrounds stay, so nothing flashes. The head gate drops html.motion after 3 s if motion.js never arrives. */
html.motion:not(.mo-ready) main > .sec > *,
html.motion:not(.mo-ready) main > :not(.sec),
html.motion:not(.mo-ready) .site-footer > .sec > *,
html.motion:not(.mo-ready) body[data-page="index"] .hdr { opacity: 0 !important; }

/* a target before its reveal: 0.001, not 0 — the browser still paints it (and decodes its images) ahead of time, so the
   first frames of a reveal never wait for paint or decode. Page transitions are off while it is a target (a CSS
   transition on opacity would otherwise beat the animation and pop the element in). */
html.motion [data-mo] { transition: none !important; }
html.motion [data-mo]:not(.mo-in) { opacity: 0.001 !important; }
html.motion [data-mo="line"]:not(.mo-in) { opacity: 1 !important; translate: 0 calc(100% + 0.4em); }
html.motion [data-mo].mo-arm, html.motion [data-mo].mo-in { will-change: opacity, transform; }
html.motion [data-mo="fade"].mo-arm, html.motion [data-mo="fade"].mo-in,
html.motion [data-mo="hdr"].mo-arm, html.motion [data-mo="hdr"].mo-in,
html.motion [data-mo="lfade"].mo-arm, html.motion [data-mo="lfade"].mo-in,
html.motion [data-mo="glow"].mo-arm, html.motion [data-mo="glow"].mo-in { will-change: opacity; }
html.motion [data-mo="line"].mo-arm, html.motion [data-mo="line"].mo-in { will-change: transform; }

/* the reveal: one animation per element; --mo-delay is set by motion.js */
html.motion [data-mo].mo-in { animation: mo-rise var(--mo-d-rise) var(--mo-ease) var(--mo-delay, 0ms) backwards; }
html.motion [data-mo="inner"].mo-in { animation-name: mo-inner; animation-duration: var(--mo-d-in); }
html.motion [data-mo="block"].mo-in { animation-name: mo-block; animation-duration: var(--mo-d-bl); animation-timing-function: var(--mo-soft); }
html.motion [data-mo="img"].mo-in { animation-name: mo-img; animation-duration: var(--mo-d-img); animation-timing-function: var(--mo-soft); }
html.motion [data-mo="row"].mo-in { animation-name: mo-block; animation-duration: var(--mo-d-row); animation-timing-function: var(--mo-soft); }
html.motion [data-mo="fade"].mo-in { animation-name: mo-fade; animation-duration: var(--mo-d-fade); animation-timing-function: var(--mo-soft); }
html.motion [data-mo="hdr"].mo-in { animation-name: mo-fade; animation-duration: var(--mo-d-hdr); animation-timing-function: var(--mo-soft); }
html.motion [data-mo="line"].mo-in { animation-name: mo-line; animation-duration: var(--mo-d-line); }
html.motion [data-mo="lfade"].mo-in { animation-name: mo-fade; animation-duration: var(--mo-d-lf); animation-timing-function: var(--mo-soft); }
html.motion [data-mo="glow"].mo-in { animation-name: mo-glow; animation-duration: var(--mo-d-glow); animation-timing-function: cubic-bezier(0.33, 0, 0.2, 1); }

/* the opacity is complete early (27–50 % of the time), the motion keeps its long settle: a piece is there while it is
   still in the bottom quarter of the window (no empty band), and drifts calmly into place */
@keyframes mo-rise  { from { opacity: 0; translate: 0 var(--mo-dy); } 50% { opacity: 1; } }
@keyframes mo-inner { from { opacity: 0; translate: 0 var(--mo-dy-in); } 50% { opacity: 1; } }
@keyframes mo-block { from { opacity: 0; translate: 0 var(--mo-dy-bl); } 27% { opacity: 1; } }
@keyframes mo-img   { from { opacity: 0; translate: 0 var(--mo-dy-bl); } 28% { opacity: 1; } }
@keyframes mo-fade  { from { opacity: 0; } 35% { opacity: 1; } }
@keyframes mo-line  { from { translate: 0 calc(100% + 0.4em); } }
@keyframes mo-glow  { from { opacity: 0; } }

/* a headline split into lines for its entrance: each line is its own mask (the padding keeps accents and descenders inside
   the clip, the negative margin keeps the layout exactly as it was; a flex column, so no margin collapses); motion.js
   checks the layout is identical and puts the original text back afterwards */
html.motion .mo-lns { display: flex; flex-direction: column; }
html.motion .mo-ln { display: block; overflow: hidden; padding: 0.2em 0.3em 0.25em; margin: -0.2em -0.3em -0.25em; }
html.motion .mo-ln__i { display: block; }

/* safety nets: a reduced-motion switch mid-visit and printing show everything at once */
@media (prefers-reduced-motion: reduce) {
  html.motion [data-mo] { opacity: 1 !important; translate: none !important; animation: none !important; }
}
@media print {
  html.motion [data-mo], html.motion main > .sec > *, html.motion .site-footer > .sec > * { opacity: 1 !important; translate: none !important; animation: none !important; }
}
