/* =====================================================================
   Entrance animations — recreated from frame-by-frame measurements of
   the original site (see capture/AUDIT.md §7).

   • Animations only run when <html> has the "motion" class, which is set
     only if the visitor has NOT asked for reduced motion.
   • Each animation waits (paused, in its first frame) until its section
     ("band") scrolls into view; main.js then adds .is-in to the band.
   • --d on an element = its start delay in ms (the original staggered
     elements in reading order).
   ===================================================================== */

/* Paused (holding the first frame) until the section has been triggered. !important because the
   per-animation "animation:" shorthands below would otherwise reset the play state. */
.motion [data-band]:not(.is-in) [data-anim],
.motion [data-band]:not(.is-in) [data-anim] .ch,
.motion [data-band]:not(.is-in) [data-anim] .wd,
.motion [data-band]:not(.is-in) [data-anim]::after,
.motion [data-band]:not(.is-in) .scribble__stroke,
.motion [data-band]:not(.is-in) .scribble__cover { animation-play-state: paused !important; }

/* A · Rise: fade in while moving up 80px (485ms). "drop" comes from above. */
.motion [data-anim="rise"] { animation: tt-rise 485ms var(--ease-rise) var(--d, 0ms) both; }
.motion [data-anim="rise-fast"] { animation: tt-rise 300ms var(--ease-rise) var(--d, 0ms) both; }
.motion [data-anim="drop"] { animation: tt-drop 490ms var(--ease-rise) var(--d, 0ms) both; }
@keyframes tt-rise { from { opacity: 0; translate: 0 80px; } to { opacity: 1; translate: 0 0; } }
@keyframes tt-drop { from { opacity: 0; translate: 0 -80px; } to { opacity: 1; translate: 0 0; } }

/* B · Merge: two copies slide in from opposite sides by their own width (1400ms). */
.motion [data-anim="merge"] { position: relative; animation: tt-from-left 1400ms var(--ease-out-cubic) var(--d, 0ms) both; }
.motion [data-anim="merge"]::after { content: attr(data-text); position: absolute; inset: 0; animation: tt-from-right-2x 1400ms var(--ease-out-cubic) var(--d, 0ms) both; pointer-events: none; }
.motion [data-anim="merge-left"] { animation: tt-from-left 1400ms var(--ease-out-cubic) var(--d, 0ms) both; }
.motion [data-anim="merge-right"] { animation: tt-from-right 1400ms var(--ease-out-cubic) var(--d, 0ms) both; }
@keyframes tt-from-left { from { translate: -100% 0; opacity: 0; } 1.2% { opacity: 1; } to { translate: 0 0; opacity: 1; } }
@keyframes tt-from-right { from { translate: 100% 0; } to { translate: 0 0; } }
/* the ::after copy sits on the main layer, which itself starts 100% to the left */
@keyframes tt-from-right-2x { from { translate: 200% 0; } 99.5% { opacity: 1; } to { translate: 0 0; opacity: 0; } }
[data-anim="merge"]:not(.motion *)::after { content: none; }

/* C · Pan in from the left by own width (1400ms); C2 · slide 80px from the left (480ms) */
.motion [data-anim="pan"] { animation: tt-from-left 1420ms var(--ease-out-cubic) var(--d, 0ms) both; }
.motion [data-anim="slide"] { animation: tt-slide 480ms var(--ease-rise) var(--d, 0ms) both; }
@keyframes tt-slide { from { opacity: 0; translate: -80px 0; } to { opacity: 1; translate: 0 0; } }

/* D · Baseline reveal: rises from its own bottom edge, clipped to its box (≈485ms) */
.motion [data-anim="baseline"] { animation: tt-baseline 485ms var(--ease-out-expo) var(--d, 0ms) both; }
@keyframes tt-baseline { from { translate: 0 100%; clip-path: inset(0 0 100% 0); } to { translate: 0 0; clip-path: inset(0 0 0 0); } }

/* E · Breathe: fade in (535ms) while scaling 0.90 → 1.03 → 1.00 over 4s */
.motion [data-anim="breathe"] { animation: tt-fade 535ms var(--ease-out-quad) calc(var(--d, 0ms) + 65ms) both, tt-breathe 4s linear var(--d, 0ms) both; }
@keyframes tt-fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes tt-breathe { 0% { scale: 0.9; } 50% { scale: 1.03; } 100% { scale: 1; } }

/* Text: letters pop in one by one with a springy overshoot (Canva code 19). main.js wraps letters in .ch */
[data-anim="letters"] .w { display: inline-block; white-space: nowrap; }
[data-anim="letters"] .ch { display: inline-block; }
.motion [data-anim="letters"] .ch { animation: tt-pop 500ms linear calc(var(--d, 0ms) + var(--i) * var(--stagger, 59ms)) both; }
@keyframes tt-pop {
  0% { scale: 0; } 3.2% { scale: 0.072; } 6.6% { scale: 0.251; } 10% { scale: 0.449; } 13.2% { scale: 0.636; }
  16.6% { scale: 0.8; } 20% { scale: 0.927; } 23.2% { scale: 1.03; } 26.6% { scale: 1.102; } 30% { scale: 1.143; }
  33.2% { scale: 1.164; } 36.6% { scale: 1.165; } 40% { scale: 1.153; } 43.2% { scale: 1.132; } 46.6% { scale: 1.108; }
  50% { scale: 1.08; } 53.2% { scale: 1.054; } 56.6% { scale: 1.032; } 60% { scale: 1.013; } 63.2% { scale: 0.998; }
  66.6% { scale: 0.987; } 70% { scale: 0.981; } 73.2% { scale: 0.978; } 76.6% { scale: 0.977; } 80% { scale: 0.979; }
  86.6% { scale: 0.985; } 93.2% { scale: 0.992; } 100% { scale: 1; }
}
/* Text: words fade in from the centre of the text outwards, 50ms apart (Canva code 20) */
.motion [data-anim="words-center"] .wd { animation: tt-fade 180ms linear calc(var(--d, 0ms) + var(--i) * 50ms) both; }
/* Text: words appear in reading order, very quickly (Canva code 18) */
.motion [data-anim="words"] .wd { animation: tt-fade 60ms linear calc(var(--d, 0ms) + var(--i) * 11.3ms) both; }

/* F · Flyer scribble reveal (Home). Our own SVG brush-stroke mask (partials/scribble.njk). */
.scribble { position: relative; }
.scribble__cover { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; display: none; }
.motion .scribble__cover { display: block; animation: tt-cover-out 70ms linear calc(var(--d, 0ms) + 700ms) both; }
.motion .scribble__stroke { stroke-dasharray: 1 1; stroke-dashoffset: 1; animation: tt-draw var(--seg-dur) cubic-bezier(0.3, 0.15, 0.55, 1) calc(var(--d, 0ms) + var(--seg-delay)) both; }
@keyframes tt-draw { 0% { stroke-dashoffset: 1; opacity: 0; } 0.5% { opacity: 1; } 100% { stroke-dashoffset: 0; opacity: 1; } }
@keyframes tt-cover-out { from { opacity: 1; } to { opacity: 0; visibility: hidden; } }
/* Reduced motion: a simple fade instead of the scribble */
html.js:not(.motion) [data-anim="scribble"] { opacity: 0; transition: opacity 600ms ease-out; }
html.js:not(.motion) .is-in [data-anim="scribble"] { opacity: 1; }
