/* animation.css: shared presets for the AppSitesAnimation* groups (PLAN_ANIMATION.md).
   Presets are selected by [data-anim="name"]; timing comes from the --anim-* custom properties the holders emit.
   Keyframes use the individual transform properties (translate, rotate, scale) so presets compose with a
   parent or drag transform. Pure CSS: works with no JavaScript loaded. */

[data-anim], [data-anim-stagger] > *, [data-anim-sequence] > * {
  animation-duration: var(--anim-duration, 600ms);
  animation-delay: var(--anim-delay, 0ms);
  animation-timing-function: var(--anim-ease, ease);
  animation-iteration-count: var(--anim-count, 1);
  animation-fill-mode: both;
  transform-box: fill-box;
  transform-origin: center;
}

[data-anim="draw"] { stroke-dasharray: var(--anim-length, 100); }
[data-anim="dash-march"] { stroke-dasharray: 8 6; }

@keyframes anim-fade-in { from{opacity:0}to{opacity:1} }
@keyframes anim-fade-out { from{opacity:1}to{opacity:0} }
@keyframes anim-fade-up { from{opacity:0;translate:0 var(--anim-distance,24px)}to{opacity:1;translate:0 0} }
@keyframes anim-fade-down { from{opacity:0;translate:0 calc(var(--anim-distance,24px) * -1)}to{opacity:1;translate:0 0} }
@keyframes anim-fade-left { from{opacity:0;translate:var(--anim-distance,24px) 0}to{opacity:1;translate:0 0} }
@keyframes anim-fade-right { from{opacity:0;translate:calc(var(--anim-distance,24px) * -1) 0}to{opacity:1;translate:0 0} }
@keyframes anim-slide-in-left { from{translate:-100% 0}to{translate:0 0} }
@keyframes anim-slide-in-right { from{translate:100% 0}to{translate:0 0} }
@keyframes anim-slide-in-top { from{translate:0 -100%}to{translate:0 0} }
@keyframes anim-slide-in-bottom { from{translate:0 100%}to{translate:0 0} }
@keyframes anim-slide-out-left { from{translate:0 0}to{translate:-100% 0} }
@keyframes anim-slide-out-right { from{translate:0 0}to{translate:100% 0} }
@keyframes anim-zoom-in { from{opacity:0;scale:var(--anim-scale,0.5)}to{opacity:1;scale:1} }
@keyframes anim-zoom-out { from{opacity:1;scale:1}to{opacity:0;scale:var(--anim-scale,0.5)} }
@keyframes anim-pop { 0%{scale:0.6;opacity:0}70%{scale:1.1;opacity:1}100%{scale:1} }
@keyframes anim-pulse { 0%,100%{scale:1}50%{scale:1.12} }
@keyframes anim-heartbeat { 0%,40%,100%{scale:1}15%{scale:1.2}30%{scale:1} }
@keyframes anim-spin { to{rotate:360deg} }
@keyframes anim-spin-reverse { to{rotate:-360deg} }
@keyframes anim-swing { 0%,100%{rotate:0deg}25%{rotate:var(--anim-angle,12deg)}75%{rotate:calc(var(--anim-angle,12deg) * -1)} }
@keyframes anim-wobble { 0%,100%{translate:0 0;rotate:0deg}25%{translate:-6% 0;rotate:-4deg}75%{translate:5% 0;rotate:3deg} }
@keyframes anim-bounce { 0%,100%{translate:0 0}40%{translate:0 -30%}60%{translate:0 -15%} }
@keyframes anim-shake { 0%,100%{translate:0 0}20%,60%{translate:-8px 0}40%,80%{translate:8px 0} }
@keyframes anim-tada { 0%,100%{scale:1;rotate:0deg}10%,20%{scale:0.9;rotate:-3deg}30%,50%,70%{scale:1.1;rotate:3deg}40%,60%{scale:1.1;rotate:-3deg} }
@keyframes anim-flash { 0%,50%,100%{opacity:1}25%,75%{opacity:0} }
@keyframes anim-float { 0%,100%{translate:0 0}50%{translate:0 -10px} }
@keyframes anim-breathe { 0%,100%{scale:1;opacity:1}50%{scale:1.04;opacity:0.85} }
@keyframes anim-blink { 0%,49%{opacity:1}50%,100%{opacity:0} }
@keyframes anim-shake-error { 0%,100%{translate:0 0}25%{translate:-6px 0}75%{translate:6px 0} }
@keyframes anim-dash-march { to{stroke-dashoffset:calc(var(--anim-length,100) * -1)} }
@keyframes anim-draw { from{stroke-dashoffset:var(--anim-length,100)}to{stroke-dashoffset:0} }

[data-anim="fade-in"], [data-anim-stagger="fade-in"] > *, [data-anim-sequence="fade-in"] > * { animation-name: anim-fade-in; }
[data-anim="fade-out"], [data-anim-stagger="fade-out"] > *, [data-anim-sequence="fade-out"] > * { animation-name: anim-fade-out; }
[data-anim="fade-up"], [data-anim-stagger="fade-up"] > *, [data-anim-sequence="fade-up"] > * { animation-name: anim-fade-up; }
[data-anim="fade-down"], [data-anim-stagger="fade-down"] > *, [data-anim-sequence="fade-down"] > * { animation-name: anim-fade-down; }
[data-anim="fade-left"], [data-anim-stagger="fade-left"] > *, [data-anim-sequence="fade-left"] > * { animation-name: anim-fade-left; }
[data-anim="fade-right"], [data-anim-stagger="fade-right"] > *, [data-anim-sequence="fade-right"] > * { animation-name: anim-fade-right; }
[data-anim="slide-in-left"], [data-anim-stagger="slide-in-left"] > *, [data-anim-sequence="slide-in-left"] > * { animation-name: anim-slide-in-left; }
[data-anim="slide-in-right"], [data-anim-stagger="slide-in-right"] > *, [data-anim-sequence="slide-in-right"] > * { animation-name: anim-slide-in-right; }
[data-anim="slide-in-top"], [data-anim-stagger="slide-in-top"] > *, [data-anim-sequence="slide-in-top"] > * { animation-name: anim-slide-in-top; }
[data-anim="slide-in-bottom"], [data-anim-stagger="slide-in-bottom"] > *, [data-anim-sequence="slide-in-bottom"] > * { animation-name: anim-slide-in-bottom; }
[data-anim="slide-out-left"], [data-anim-stagger="slide-out-left"] > *, [data-anim-sequence="slide-out-left"] > * { animation-name: anim-slide-out-left; }
[data-anim="slide-out-right"], [data-anim-stagger="slide-out-right"] > *, [data-anim-sequence="slide-out-right"] > * { animation-name: anim-slide-out-right; }
[data-anim="zoom-in"], [data-anim-stagger="zoom-in"] > *, [data-anim-sequence="zoom-in"] > * { animation-name: anim-zoom-in; }
[data-anim="zoom-out"], [data-anim-stagger="zoom-out"] > *, [data-anim-sequence="zoom-out"] > * { animation-name: anim-zoom-out; }
[data-anim="pop"], [data-anim-stagger="pop"] > *, [data-anim-sequence="pop"] > * { animation-name: anim-pop; }
[data-anim="pulse"], [data-anim-stagger="pulse"] > *, [data-anim-sequence="pulse"] > * { animation-name: anim-pulse; }
[data-anim="heartbeat"], [data-anim-stagger="heartbeat"] > *, [data-anim-sequence="heartbeat"] > * { animation-name: anim-heartbeat; }
[data-anim="spin"], [data-anim-stagger="spin"] > *, [data-anim-sequence="spin"] > * { animation-name: anim-spin; }
[data-anim="spin-reverse"], [data-anim-stagger="spin-reverse"] > *, [data-anim-sequence="spin-reverse"] > * { animation-name: anim-spin-reverse; }
[data-anim="swing"], [data-anim-stagger="swing"] > *, [data-anim-sequence="swing"] > * { animation-name: anim-swing; }
[data-anim="wobble"], [data-anim-stagger="wobble"] > *, [data-anim-sequence="wobble"] > * { animation-name: anim-wobble; }
[data-anim="bounce"], [data-anim-stagger="bounce"] > *, [data-anim-sequence="bounce"] > * { animation-name: anim-bounce; }
[data-anim="shake"], [data-anim-stagger="shake"] > *, [data-anim-sequence="shake"] > * { animation-name: anim-shake; }
[data-anim="tada"], [data-anim-stagger="tada"] > *, [data-anim-sequence="tada"] > * { animation-name: anim-tada; }
[data-anim="flash"], [data-anim-stagger="flash"] > *, [data-anim-sequence="flash"] > * { animation-name: anim-flash; }
[data-anim="float"], [data-anim-stagger="float"] > *, [data-anim-sequence="float"] > * { animation-name: anim-float; }
[data-anim="breathe"], [data-anim-stagger="breathe"] > *, [data-anim-sequence="breathe"] > * { animation-name: anim-breathe; }
[data-anim="blink"], [data-anim-stagger="blink"] > *, [data-anim-sequence="blink"] > * { animation-name: anim-blink; }
[data-anim="shake-error"], [data-anim-stagger="shake-error"] > *, [data-anim-sequence="shake-error"] > * { animation-name: anim-shake-error; }
[data-anim="dash-march"], [data-anim-stagger="dash-march"] > *, [data-anim-sequence="dash-march"] > * { animation-name: anim-dash-march; }
[data-anim="draw"], [data-anim-stagger="draw"] > *, [data-anim-sequence="draw"] > * { animation-name: anim-draw; }

/* Stagger: each direct child of a [data-anim-stagger] container runs the container's preset, delayed by its
   position times --anim-step (nth-child covers the first 12 children; no JavaScript, no per-item data). */
[data-anim-stagger] > * { animation-delay: calc(var(--anim-delay, 0ms) + var(--anim-i, 0) * var(--anim-step, 100ms)); }
[data-anim-stagger] > :nth-child(1) { --anim-i: 0; }
[data-anim-stagger] > :nth-child(2) { --anim-i: 1; }
[data-anim-stagger] > :nth-child(3) { --anim-i: 2; }
[data-anim-stagger] > :nth-child(4) { --anim-i: 3; }
[data-anim-stagger] > :nth-child(5) { --anim-i: 4; }
[data-anim-stagger] > :nth-child(6) { --anim-i: 5; }
[data-anim-stagger] > :nth-child(7) { --anim-i: 6; }
[data-anim-stagger] > :nth-child(8) { --anim-i: 7; }
[data-anim-stagger] > :nth-child(9) { --anim-i: 8; }
[data-anim-stagger] > :nth-child(10) { --anim-i: 9; }
[data-anim-stagger] > :nth-child(11) { --anim-i: 10; }
[data-anim-stagger] > :nth-child(12) { --anim-i: 11; }

/* Hover holders play only while hovered or focused. */
[data-anim-on="hover"]:not(:hover):not(:focus-within) { animation: none; }

/* Scroll spacers so samples carry no inline style. */
[data-anim-spacer="tall"] { height: 30vh; }
[data-anim-spacer="short"] { height: 12vh; }

/* Reveal holders: scroll-driven where the browser supports view timelines (the animation progresses as the element
   enters the viewport); elsewhere the preset simply plays on load. */
@supports (animation-timeline: view()) {
  [data-anim-on="inview"] { animation-timeline: view(); animation-range: entry 0% cover 35%; animation-duration: auto; }
}

/* State effects driven by animation.js (it only flips data-anim-state on [data-anim-target]). */
[data-anim-fx] { transition: grid-template-rows var(--anim-duration, 300ms) var(--anim-ease, ease), rotate var(--anim-duration, 300ms) var(--anim-ease, ease); }
[data-anim-fx="collapse"] { display: grid; grid-template-rows: 1fr; }
[data-anim-fx="collapse"][data-anim-state="closed"] { grid-template-rows: 0fr; }
[data-anim-fx="collapse"] > [data-anim-inner] { overflow: hidden; min-height: 0; }
[data-anim-fx="rotate"][data-anim-state="open"] { rotate: 180deg; }
[data-anim-fx="playpause"][data-anim-state="paused"] { animation-play-state: paused; }

/* RevealJs: the preset waits (paused at its first frame) until animation.js sets the state to "in". */
[data-anim-trigger="inview"][data-anim-state="idle"] { animation-play-state: paused; }
[data-anim-trigger="inview"][data-anim-state="in"] { animation-play-state: running; }
[data-anim-trigger="inview"] { transition: none; }

/* Sequence: each child of [data-anim-sequence] waits (paused at its first frame) until animation.js sets its state to
   "in", which it does for the first child on load and for each next sibling when the previous one ends. */
[data-anim-sequence] > :not([data-anim-state="in"]) { animation-play-state: paused; }

/* Accordion (CSS only): the content of an opened details element animates in. */
[data-anim-fx="accordion"] > summary { cursor: pointer; }
[data-anim-fx="accordion"][open] > div { animation: anim-fade-down var(--anim-duration, 300ms) var(--anim-ease, ease) both; }

/* Tabs crossfade (CSS only): radio inputs select, the matching panel fades in. Up to four tabs. */
[data-anim-tabs] > input { position: absolute; opacity: 0; pointer-events: none; }
[data-anim-tabs] > label { display: inline-block; padding: 4px 12px; cursor: pointer; border-bottom: 2px solid transparent; }
[data-anim-tabs] > input:checked + label { border-bottom-color: currentColor; font-weight: 600; }
[data-anim-tabs] > input:focus-visible + label { outline: 2px solid currentColor; }
[data-anim-panels] > * { display: none; }
[data-anim-tabs] > input:nth-of-type(1):checked ~ [data-anim-panels] > :nth-child(1),
[data-anim-tabs] > input:nth-of-type(2):checked ~ [data-anim-panels] > :nth-child(2),
[data-anim-tabs] > input:nth-of-type(3):checked ~ [data-anim-panels] > :nth-child(3),
[data-anim-tabs] > input:nth-of-type(4):checked ~ [data-anim-panels] > :nth-child(4) {
  display: block; animation: anim-fade-in var(--anim-duration, 400ms) ease both;
}

/* Scroll progress bar (CSS only, where view/scroll timelines exist; elsewhere it stays full width and still). */
@keyframes anim-grow-x { from { scale: 0 1; } to { scale: 1 1; } }
[data-anim-scroll="progress"] { position: sticky; top: 0; height: 4px; background: currentColor; transform-origin: 0 50%; }
@supports (animation-timeline: scroll()) {
  [data-anim-scroll="progress"] { animation: anim-grow-x linear both; animation-timeline: scroll(root); }
}

/* Progress bar and ring: filled once, when animation.js flips the holder to "in" (RevealJs rules above pause it first). */
@keyframes anim-fill-x { from { scale: 0 1; } to { scale: var(--anim-fill, 1) 1; } }
@keyframes anim-ring-fill { from { stroke-dashoffset: var(--anim-length, 100); } to { stroke-dashoffset: var(--anim-to, 0); } }
[data-anim="fill-x"] { animation-name: anim-fill-x; transform-origin: 0 50%; height: 100%; background: currentColor; }
[data-anim="ring-fill"] { animation-name: anim-ring-fill; }
[data-anim="ring-fill"] > * { stroke-dasharray: var(--anim-length, 100); }
[data-anim-bar] { height: 10px; border: 1px solid currentColor; border-radius: 5px; overflow: hidden; }

/* Play, pause, reverse a looping animation inside a Toggle with effect playpause (descendant form). */
[data-anim-fx="playpause"][data-anim-state="paused"] [data-anim] { animation-play-state: paused; }
[data-anim-fx="playpause"][data-anim-state="reversed"] [data-anim] { animation-direction: reverse; }

/* Flip card: Toggle effect flip rotates the inner box, two faces, back face pre-rotated. */
[data-anim-fx="flip"] { perspective: 600px; }
[data-anim-fx="flip"] > [data-anim-inner] { position: relative; transform-style: preserve-3d; transition: rotate var(--anim-duration, 600ms) var(--anim-ease, ease); }
[data-anim-fx="flip"][data-anim-state="back"] > [data-anim-inner] { rotate: y 180deg; }
[data-anim-face] { backface-visibility: hidden; }
[data-anim-face="back"] { position: absolute; inset: 0; rotate: y 180deg; }

/* Reveal around a Stagger: the staggered children wait until the wrapper is in view. */
[data-anim-trigger="inview"][data-anim-state="idle"] [data-anim-stagger] > * { animation-play-state: paused; }

/* Timeline: every track is paused and positioned by --anim-time, which animation.js sets from the scrub input. */
[data-anim-timeline] [data-anim] {
  animation-play-state: paused;
  animation-delay: calc(var(--anim-offset, 0ms) - var(--anim-time, 0ms));
  animation-iteration-count: 1;
}

/* Presence: added items enter, removed items leave (animation.js flips the state, then removes the node on animationend). */
[data-anim-presence] [data-anim-item] { animation-duration: var(--anim-duration, 300ms); animation-fill-mode: both; animation-timing-function: ease; }
[data-anim-presence] [data-anim-item][data-anim-state="entering"] { animation-name: anim-fade-down; }
[data-anim-presence] [data-anim-item][data-anim-state="leaving"] { animation-name: anim-fade-out; pointer-events: none; }

/* Filter: items fade and shrink out of the layout and back (discrete display transition). */
[data-anim-filter] [data-anim-item] {
  transition: opacity var(--anim-duration, 300ms), scale var(--anim-duration, 300ms), display var(--anim-duration, 300ms) allow-discrete;
}
[data-anim-filter] [data-anim-item][data-anim-state="out"] { display: none; opacity: 0; scale: 0.8; }
@starting-style { [data-anim-filter] [data-anim-item][data-anim-state="in"] { opacity: 0; scale: 0.8; } }

/* Carousel: all slides share one grid cell; the active one (state in) is visible, the others wait on the right. */
[data-anim-carousel] { display: grid; overflow: hidden; }
[data-anim-carousel] > * { grid-area: 1 / 1; transition: opacity var(--anim-duration, 500ms) var(--anim-ease, ease), translate var(--anim-duration, 500ms) var(--anim-ease, ease); }
[data-anim-carousel] > [data-anim-state="idle"] { opacity: 0; translate: 100% 0; pointer-events: none; }
[data-anim-carousel] > [data-anim-state="in"] { opacity: 1; translate: 0 0; }

@media (prefers-reduced-motion: reduce) {
  [data-anim], [data-anim-stagger] > *, [data-anim-sequence] > * { animation-duration: 1ms; animation-iteration-count: 1; animation-delay: 0ms; }
  [data-anim-carousel] > *, [data-anim-filter] [data-anim-item], [data-anim-fx] { transition-duration: 1ms; }
}

/* Trigger controls paint above animating content: a rotating or sliding sibling must never intercept their click. */
[data-anim-toggle] { position: relative; z-index: 1; }
