/*
 * Maternity edition — reveal motion ("rv-").
 *
 * A chart or block carries data-rv="pending" until it scrolls into view;
 * core/reveal.js then sets data-rv="shown" and the marked children animate.
 * Per-element delay: style="--rv-d: 120ms". Line draw length: --rv-len.
 * prefers-reduced-motion turns every reveal off.
 */

:is(rect, circle, ellipse, path, polygon, g).rv-grow-x,
:is(rect, circle, ellipse, path, polygon, g).rv-grow-y,
:is(rect, circle, ellipse, path, polygon, g).rv-pop { transform-box: fill-box; }

.rv-grow-x { transform-origin: 0%; }
.rv-grow-y { transform-origin: 50% 100%; }
.rv-pop { transform-origin: 50%; }
.rv-draw { stroke-dasharray: var(--rv-len, none); }

[data-rv="pending"] .rv-grow-x { transform: scaleX(0) !important; }
[data-rv="pending"] .rv-grow-y { transform: scaleY(0) !important; }
[data-rv="pending"] .rv-pop { opacity: 0 !important; transform: scale(.5) !important; }
[data-rv="pending"] .rv-settle { opacity: 0 !important; transform: translateY(6px) !important; }
[data-rv="pending"] .rv-fade { opacity: 0 !important; }
[data-rv="pending"] .rv-draw { stroke-dashoffset: var(--rv-len, 0); }

[data-rv="shown"] .rv-grow-x { animation: rv-grow-x var(--rv-dur) var(--rv-ease) var(--rv-d, 0s) backwards; }
[data-rv="shown"] .rv-grow-y { animation: rv-grow-y var(--rv-dur) var(--rv-ease) var(--rv-d, 0s) backwards; }
[data-rv="shown"] .rv-pop { animation: rv-pop var(--rv-dur) var(--rv-ease) var(--rv-d, 0s) backwards; }
[data-rv="shown"] .rv-settle { animation: rv-settle var(--rv-dur) var(--rv-ease) var(--rv-d, 0s) backwards; }
[data-rv="shown"] .rv-fade { animation: rv-fade var(--rv-dur) var(--rv-ease) var(--rv-d, 0s) backwards; }
[data-rv="shown"] .rv-draw { animation: rv-draw var(--rv-dur-draw) var(--rv-ease) var(--rv-d, 0s) backwards; }

@keyframes rv-grow-x { from { transform: scaleX(0); } }
@keyframes rv-grow-y { from { transform: scaleY(0); } }
@keyframes rv-pop { from { opacity: 0; transform: scale(.5); } }
@keyframes rv-settle { from { opacity: 0; transform: translateY(6px); } }
@keyframes rv-fade { from { opacity: 0; } }
@keyframes rv-draw { from { stroke-dashoffset: var(--rv-len, 0); } }

@media (prefers-reduced-motion: reduce) {
  [data-rv] * { animation: none !important; }
  html { transition: none; }
}
