/* ============================================================================
   jitter-motion.css  -  shared motion library for every Frostyh app and site
   ----------------------------------------------------------------------------
   Motion vocabulary recreated from Jitter (https://jitter.video) template
   styles: snappy / elastic / bouncy text, mask + clip reveals, card flip,
   parallax, floating UI cards, count-ups, gooey/glitch accents. Jitter's own
   templates are proprietary and live in their editor, so nothing is imported;
   these are original CSS re-creations of that motion language. Credit: Jitter.

   Framework-agnostic: pair with jitter-motion.js (adds .in when in view, splits
   .j-words, drives parallax + count-ups). Everything is transform/opacity/filter
   only, one-shot, and disabled under prefers-reduced-motion or html[data-lite],
   html[data-perf='1'], html[data-clean] (final state shown, no motion, no rAF).
   ========================================================================== */

:root {
  /* Jitter's feel: a smooth ease-out, a bouncy elastic overshoot, a crisp snap. */
  --j-spring: cubic-bezier(.22, 1, .36, 1);
  --j-elastic: cubic-bezier(.34, 1.56, .64, 1);
  --j-snap: cubic-bezier(.4, 0, .2, 1);
  --j-dur: 720ms;
  --j-dur-sm: 520ms;
  --j-stagger: 70ms;
}

/* ---- base: hidden until .in, then eases to rest. One-shot (no reverse). ---- */
.j-reveal, .j-reveal-l, .j-reveal-r, .j-reveal-scale, .j-reveal-blur, .j-pop {
  opacity: 0; will-change: transform, opacity;
  transition: opacity var(--j-dur) var(--j-spring), transform var(--j-dur) var(--j-spring), filter var(--j-dur) var(--j-spring);
}
.j-reveal       { transform: translate3d(0, 34px, 0); }
.j-reveal-l     { transform: translate3d(-40px, 0, 0); }
.j-reveal-r     { transform: translate3d(40px, 0, 0); }
.j-reveal-scale { transform: scale(.92); }
.j-reveal-blur  { filter: blur(14px); transform: translate3d(0, 16px, 0); }
.j-pop          { transform: scale(.6); transition-timing-function: var(--j-elastic); transition-duration: var(--j-dur-sm); }
.j-reveal.in, .j-reveal-l.in, .j-reveal-r.in, .j-reveal-scale.in, .j-reveal-blur.in, .j-pop.in {
  opacity: 1; transform: none; filter: none;
}

/* ---- clip wipe (Jitter "Color Pills / Card Reveal"): a solid wipe uncovers ---- */
.j-clip { clip-path: inset(0 100% 0 0); opacity: .001; transition: clip-path var(--j-dur) var(--j-snap), opacity 10ms linear; }
.j-clip.in { clip-path: inset(0 0 0 0); opacity: 1; }
.j-clip-up { clip-path: inset(100% 0 0 0); opacity: .001; transition: clip-path var(--j-dur) var(--j-snap), opacity 10ms linear; }
.j-clip-up.in { clip-path: inset(0 0 0 0); opacity: 1; }

/* ---- mask-up text reveal (Jitter "Sliding Text Reveal"): lines rise out of a clip ---- */
.j-mask { overflow: hidden; }
.j-mask > * { display: inline-block; transform: translate3d(0, 110%, 0); transition: transform var(--j-dur) var(--j-spring); will-change: transform; }
.j-mask.in > * { transform: none; }

/* ---- staggered children: each child offset by its --i (set in HTML or by JS) ---- */
.j-stagger > * {
  opacity: 0; transform: translate3d(0, 26px, 0); will-change: transform, opacity;
  transition: opacity var(--j-dur-sm) var(--j-spring), transform var(--j-dur-sm) var(--j-spring);
  transition-delay: calc(var(--i, 0) * var(--j-stagger));
}
.j-stagger.in > * { opacity: 1; transform: none; }

/* ---- kinetic words (Jitter "Bouncy Words / Zero Gravity"): js wraps each word ---- */
.j-words .j-word { display: inline-block; opacity: 0; transform: translate3d(0, 0.5em, 0) rotate(4deg); will-change: transform, opacity;
  transition: opacity 520ms var(--j-elastic), transform 620ms var(--j-elastic); transition-delay: calc(var(--wi, 0) * 42ms); }
.j-words.in .j-word { opacity: 1; transform: none; }
/* space between wrapped words is preserved by a trailing normal space in JS */

/* ---- floating UI card: soft lift on hover, the Jitter "Bento / Floating" look ---- */
.j-float { transition: transform 420ms var(--j-spring), box-shadow 420ms var(--j-spring); }
@media (hover: hover) { .j-float:hover { transform: translateY(-6px); } }

/* ---- card flip (Jitter "Card Flip"): add .flipped to turn ---- */
.j-flip { perspective: 1200px; }
.j-flip > .j-flip-inner { position: relative; transition: transform 720ms var(--j-spring); transform-style: preserve-3d; }
.j-flip.flipped > .j-flip-inner { transform: rotateY(180deg); }
.j-flip .j-flip-front, .j-flip .j-flip-back { backface-visibility: hidden; }
.j-flip .j-flip-back { position: absolute; inset: 0; transform: rotateY(180deg); }

/* ---- progress fill + count-up (Jitter "Animated Progress Bar", bar charts) ---- */
.j-bar { overflow: hidden; }
.j-bar > i { display: block; height: 100%; width: 0; transition: width 900ms var(--j-snap); }
.j-bar.in > i { width: var(--j-to, 100%); }

/* ---- parallax: js translates by data-j-parallax factor on scroll ---- */
[data-j-parallax] { will-change: transform; }

/* ---- looping accents (background only; paused when the tab/window is hidden) ---- */
.j-spin { animation: j-spin 18s linear infinite; }
.j-drift { animation: j-drift 24s ease-in-out infinite alternate; }
@keyframes j-spin { to { transform: rotate(360deg); } }
@keyframes j-drift { to { transform: translate3d(3%, -2%, 0) scale(1.05); } }
:root.hidden-win .j-spin, :root.hidden-win .j-drift, .j-paused .j-spin, .j-paused .j-drift { animation-play-state: paused; }

/* ---- glitch / gooey accents (opt-in, used sparingly) ---- */
.j-gooey { filter: url(#j-goo); }
.j-glitch.in { animation: j-glitch 520ms steps(2) 1; }
@keyframes j-glitch { 0%,100% { transform: none; } 20% { transform: translate(-2px, 1px); } 40% { transform: translate(2px, -1px); } 60% { transform: translate(-1px, -1px); } 80% { transform: translate(1px, 1px); } }

/* ---- kill switch: reduced motion, perf, lite, clean -> show final state, no motion ---- */
@media (prefers-reduced-motion: reduce) {
  .j-reveal, .j-reveal-l, .j-reveal-r, .j-reveal-scale, .j-reveal-blur, .j-pop,
  .j-clip, .j-clip-up, .j-mask > *, .j-stagger > *, .j-words .j-word, .j-bar > i {
    opacity: 1 !important; transform: none !important; filter: none !important; clip-path: none !important; width: var(--j-to, 100%); transition: none !important;
  }
  .j-spin, .j-drift { animation: none !important; }
}
:root[data-lite] .j-reveal, :root[data-lite] .j-reveal-l, :root[data-lite] .j-reveal-r, :root[data-lite] .j-reveal-scale, :root[data-lite] .j-reveal-blur, :root[data-lite] .j-pop,
:root[data-lite] .j-clip, :root[data-lite] .j-clip-up, :root[data-lite] .j-mask > *, :root[data-lite] .j-stagger > *, :root[data-lite] .j-words .j-word,
:root[data-perf='1'] .j-reveal, :root[data-perf='1'] .j-reveal-blur, :root[data-perf='1'] .j-stagger > *, :root[data-perf='1'] .j-words .j-word, :root[data-perf='1'] .j-mask > *,
:root[data-clean] .j-reveal, :root[data-clean] .j-stagger > *, :root[data-clean] .j-words .j-word {
  opacity: 1 !important; transform: none !important; filter: none !important; clip-path: none !important; transition: none !important;
}
:root[data-lite] .j-spin, :root[data-lite] .j-drift, :root[data-perf='1'] .j-spin, :root[data-perf='1'] .j-drift { animation: none !important; }
