/* Pap'pote — « Fresque » motion layer (pairs with motion.js). Tokens only: --fq-dur, --fq-ease, --fq-motion-scale.
   No colour, no !important. Every hide-before-reveal rule sits under html.fq-motion, a class motion.js adds only when
   motion is allowed (no prefers-reduced-motion, no data-a11y="large"): without JS everything is in its final state.
   Hover-only effects (.fq-roll, .fq-arrows, .fq-float) are pure CSS, gated by the media query + large mode instead. */

/* ---------- 1. [data-reveal]: rise + fade once visible; data-reveal-delay="1..6" = 80 ms steps ---------- */
html.fq-motion [data-reveal]:not(.is-in) { opacity: 0; transform: translateY(calc(24px * var(--fq-motion-scale))); }
/* an animation (fill: backwards) rather than a transition, so the element's own transitions / transforms are untouched */
html.fq-motion [data-reveal].is-in { animation: fq-m-rise var(--fq-dur) var(--fq-ease) backwards; }
html.fq-motion [data-reveal-delay="1"] { animation-delay: 80ms; }
html.fq-motion [data-reveal-delay="2"] { animation-delay: 160ms; }
html.fq-motion [data-reveal-delay="3"] { animation-delay: 240ms; }
html.fq-motion [data-reveal-delay="4"] { animation-delay: 320ms; }
html.fq-motion [data-reveal-delay="5"] { animation-delay: 400ms; }
html.fq-motion [data-reveal-delay="6"] { animation-delay: 480ms; }
@keyframes fq-m-rise { from { opacity: 0; transform: translateY(calc(24px * var(--fq-motion-scale))); } }

/* ---------- 2. [data-split]: words never break, letters rise with an 12 ms stagger (360 ms cap; each letter ≤ 400 ms) ---------- */
.fq-w { white-space: nowrap; }
html.fq-motion .fq-ch { display: inline-block; }
html.fq-motion [data-split] .fq-ch:not([data-rotate] *):not(.fq-roll *) {
  opacity: 0;
  transform: translateY(calc(.6em * var(--fq-motion-scale)));
  transition: opacity var(--fq-dur) var(--fq-ease), transform var(--fq-dur) var(--fq-ease);
  transition-delay: min(calc(var(--i, 0) * 12ms), 360ms);
}
html.fq-motion [data-split].is-in .fq-ch:not([data-rotate] *):not(.fq-roll *),
html.fq-motion [data-reveal].is-in [data-split] .fq-ch:not([data-rotate] *):not(.fq-roll *) { opacity: 1; transform: none; }

/* ---------- 3. .fq-roll: two stacked labels in a one-line window, both slide up on hover / focus-visible ---------- */
.fq-roll { display: inline-block; position: relative; height: 1.2em; line-height: 1.2; overflow: hidden; vertical-align: bottom; white-space: nowrap; }
.fq-roll-a, .fq-roll-b { display: block; }
.fq-roll .fq-ch { display: inline-block; }

/* ---------- 4. [data-rotate]: phrases share one grid cell; letters blur out / blur in (16 ms stagger) ---------- */
[data-rotate] > :not(:first-child) { display: none; } /* static: first phrase only (full list lives in the .fq-sr sibling) */
html.fq-motion [data-rotate] { display: inline-grid; }
html.fq-motion [data-rotate] > * { display: inline-block; grid-area: 1 / 1; }
html.fq-motion [data-rotate] .fq-ch {
  opacity: 0;
  filter: blur(calc(8px * var(--fq-motion-scale)));
  transition: opacity var(--fq-dur) var(--fq-ease), filter var(--fq-dur) var(--fq-ease);
  transition-delay: min(calc(var(--i, 0) * 12ms), 400ms);
}
html.fq-motion [data-rotate] > .is-on .fq-ch {
  opacity: 1;
  filter: blur(0);
  transition-delay: calc(min(calc(var(--i, 0) * 16ms), 360ms) + 120ms);
}

/* ---------- 5. [data-count]: JS only (text), keep digits from jittering while they change ---------- */
[data-count] { font-variant-numeric: tabular-nums; }

/* ---------- 6. [data-draw]: an SVG path draws itself (JS sets --len = getTotalLength()) ---------- */
html.fq-motion [data-draw] {
  stroke-dasharray: var(--len, 0);
  stroke-dashoffset: var(--len, 0);
  transition: stroke-dashoffset var(--fq-dur) var(--fq-ease);
}
html.fq-motion [data-draw].is-in,
html.fq-motion [data-reveal].is-in [data-draw] { stroke-dashoffset: 0; }

/* ---------- 7. [data-grow]: bars grow from the bottom, 60 ms stagger (JS sets --i on each child) ---------- */
html.fq-motion [data-grow] > * {
  transform: scaleY(0);
  transform-origin: 50% 100%;
  transition: transform var(--fq-dur) var(--fq-ease);
  transition-delay: calc(var(--i, 0) * 60ms);
}
html.fq-motion [data-grow].is-in > * { transform: none; }

/* ---------- 8. [data-gauge="0.62"]: the .fq-needle turns from -90deg to (-90 + 180 * v)deg ---------- */
[data-gauge] .fq-needle {
  transform-box: fill-box; /* SVG needles pivot on their own box too */
  transform-origin: 50% 100%;
  transform: rotate(calc(-90deg + 180deg * var(--v, 0)));
}
html.fq-motion [data-gauge] .fq-needle { transform: rotate(-90deg); transition: transform var(--fq-dur) var(--fq-ease); }
html.fq-motion [data-gauge].is-in .fq-needle { transform: rotate(calc(-90deg + 180deg * var(--v, 0))); }

/* ---------- 9. .fq-arrows: two arrows in a 1em window; the first leaves right, the second comes in from the left ---------- */
.fq-arrows { display: inline-block; position: relative; flex: none; width: 1em; height: 1em; overflow: hidden; vertical-align: -.125em; }
.fq-arrows > * { position: absolute; left: 0; top: 0; width: 1em; height: 1em; }
.fq-arrows > * + * { transform: translateX(-110%); }

/* ---------- 3, 9, 10: hover / ambient effects, only when motion is welcome ---------- */
@media (prefers-reduced-motion: no-preference) {
  html:not([data-a11y="large"]) .fq-roll:not(.is-split) > *,
  html:not([data-a11y="large"]) .fq-roll .fq-ch { transition: transform var(--fq-dur) var(--fq-ease); }
  html:not([data-a11y="large"]) .fq-roll .fq-ch { transition-delay: min(calc(var(--i, 0) * 14ms), 300ms); }
  html:not([data-a11y="large"]) a:hover .fq-roll:not(.is-split) > *,
  html:not([data-a11y="large"]) button:hover .fq-roll:not(.is-split) > *,
  html:not([data-a11y="large"]) a:focus-visible .fq-roll:not(.is-split) > *,
  html:not([data-a11y="large"]) button:focus-visible .fq-roll:not(.is-split) > * { transform: translateY(-100%); }
  html:not([data-a11y="large"]) a:hover .fq-roll .fq-ch,
  html:not([data-a11y="large"]) button:hover .fq-roll .fq-ch,
  html:not([data-a11y="large"]) a:focus-visible .fq-roll .fq-ch,
  html:not([data-a11y="large"]) button:focus-visible .fq-roll .fq-ch { transform: translateY(-1.2em); }

  html:not([data-a11y="large"]) .fq-arrows > * { transition: transform var(--fq-dur) var(--fq-ease); }
  html:not([data-a11y="large"]) .fq-arrows > * + * { transition-delay: 60ms; }
  html:not([data-a11y="large"]) a:hover .fq-arrows > :first-child,
  html:not([data-a11y="large"]) button:hover .fq-arrows > :first-child,
  html:not([data-a11y="large"]) a:focus-visible .fq-arrows > :first-child,
  html:not([data-a11y="large"]) button:focus-visible .fq-arrows > :first-child { transform: translateX(110%); }
  html:not([data-a11y="large"]) a:hover .fq-arrows > * + *,
  html:not([data-a11y="large"]) button:hover .fq-arrows > * + *,
  html:not([data-a11y="large"]) a:focus-visible .fq-arrows > * + *,
  html:not([data-a11y="large"]) button:focus-visible .fq-arrows > * + * { transform: none; }

  html:not([data-a11y="large"]) .fq-float {
    animation: fq-m-float 6s ease-in-out infinite alternate;
    animation-delay: var(--fq-float-delay, 0s);
  }
}
@keyframes fq-m-float { from { transform: translateY(0); } to { transform: translateY(calc(-8px * var(--fq-motion-scale))); } }
