/* Bump and Beyond "loop" layer (gated by bb_loop_on(); see inc/loop.php).
   Ambient, slow, small loops on decorative pieces only. Everything here needs html.lp-on
   (set by bb-loop.js, never under reduced motion) and .lp-live on the piece (set only
   while it is on screen), so nothing runs offscreen. html.lp-hidden pauses all of it when
   the tab is hidden. Only transform / opacity / scale / clip-path / stroke-dashoffset are
   animated, on absolutely positioned or clipped pieces: no layout, no CLS.
   Reduced motion: the whole block is inside no-preference. */

@media (prefers-reduced-motion: no-preference) {
	html.lp-on { --lp-ps: running; }
	html.lp-on.lp-hidden { --lp-ps: paused; }

	/* ---------- doodles: breathe / float / wiggle / twinkle / heartbeat (4.6s to 7.8s, staggered) ---------- */
	@keyframes lp-breathe { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.045) translateY(-1px); } }
	@keyframes lp-float { 0%, 100% { transform: translateY(0) rotate(0deg); } 50% { transform: translateY(-3px) rotate(1.6deg); } }
	@keyframes lp-wiggle { 0%, 100% { transform: rotate(0deg); } 30% { transform: rotate(-2.4deg); } 70% { transform: rotate(2.4deg); } }
	@keyframes lp-twinkle { 0%, 100% { transform: scale(1) rotate(0deg); opacity: 1; } 50% { transform: scale(.9) rotate(8deg); opacity: .7; } }
	@keyframes lp-beat { 0%, 50%, 100% { transform: scale(1); } 58% { transform: scale(1.08); } 66% { transform: scale(1); } 74% { transform: scale(1.05); } 84% { transform: scale(1); } }

	html.lp-on .bb-dd.lp-live[data-dd="in"][data-lp] svg {
		animation-duration: calc(4.6s + var(--lp-i, 0) * .8s);
		animation-timing-function: ease-in-out;
		animation-iteration-count: infinite;
		animation-delay: calc(var(--lp-i, 0) * -1.1s);
		animation-play-state: var(--lp-ps, running);
	}
	html.lp-on .bb-dd.lp-live[data-dd="in"][data-lp="b"] svg { animation-name: lp-breathe; }
	html.lp-on .bb-dd.lp-live[data-dd="in"][data-lp="f"] svg { animation-name: lp-float; }
	html.lp-on .bb-dd.lp-live[data-dd="in"][data-lp="w"] svg { animation-name: lp-wiggle; }
	html.lp-on .bb-dd.lp-live[data-dd="in"][data-lp="t"] svg { animation-name: lp-twinkle; }
	html.lp-on .bb-dd.lp-live[data-dd="in"][data-lp="h"] svg { animation-name: lp-beat; animation-duration: calc(5.4s + var(--lp-i, 0) * .6s); animation-timing-function: ease-out; }

	/* ---------- step 1 vignette: two cells breathe like a sheet being read ---------- */
	@keyframes lp-cell { 0%, 100% { opacity: 1; } 50% { opacity: .4; } }
	html.lp-on .hk-vig--1.lp-live[data-hk="in"] .hk-g i:nth-child(4),
	html.lp-on .hk-vig--1.lp-live[data-hk="in"] .hk-g i:nth-child(6) { animation: lp-cell 5s ease-in-out infinite; animation-play-state: var(--lp-ps, running); }
	html.lp-on .hk-vig--1.lp-live[data-hk="in"] .hk-g i:nth-child(6) { animation-delay: -2.5s; }

	/* ---------- step 2 vignette: type, hold, erase, pause, then the next essential (7.5s) ----------
	   --lp-n is the character count of the current label (set by bb-loop.js), so the steps match. */
	@keyframes lp-type {
		0%, 4% { clip-path: inset(0 100% 0 0); animation-timing-function: steps(var(--lp-n, 13), end); }
		22%, 68% { clip-path: inset(0 0 0 0); animation-timing-function: steps(var(--lp-n, 13), end); }
		80%, 100% { clip-path: inset(0 100% 0 0); }
	}
	@keyframes lp-caret {
		0%, 4% { left: 0; animation-timing-function: steps(var(--lp-n, 13), end); }
		22%, 68% { left: 100%; animation-timing-function: steps(var(--lp-n, 13), end); }
		80%, 100% { left: 0; }
	}
	html.lp-on .hk-vig--2.lp-live[data-hk="in"] .hk-tx { animation: lp-type 7.5s linear infinite both; animation-play-state: var(--lp-ps, running); }
	html.lp-on .hk-vig--2.lp-live[data-hk="in"] .hk-caret { animation: lp-caret 7.5s linear infinite both, hk-blink 1.06s steps(1, end) infinite; animation-play-state: var(--lp-ps, running), var(--lp-ps, running); }

	/* ---------- step 3 vignette: bar fills, tick draws, hold, resets (8s) ---------- */
	@keyframes lp-fill {
		0%, 3% { transform: scaleX(0); animation-timing-function: cubic-bezier(.16, 1, .3, 1); }
		14%, 86% { transform: scaleX(1); animation-timing-function: ease-in; }
		94%, 100% { transform: scaleX(0); }
	}
	@keyframes lp-tick {
		0%, 20% { scale: .4; opacity: 0; animation-timing-function: cubic-bezier(.16, 1, .3, 1); }
		26%, 86% { scale: 1; opacity: 1; }
		92%, 100% { scale: .4; opacity: 0; }
	}
	@keyframes lp-check { 0%, 22% { stroke-dashoffset: 1; } 31%, 86% { stroke-dashoffset: 0; } 92%, 100% { stroke-dashoffset: 1; } }
	html.lp-on .hk-vig--3.lp-live[data-hk="in"] .hk-track i { animation: lp-fill 8s linear infinite both; animation-play-state: var(--lp-ps, running); transition: none; }
	html.lp-on .hk-vig--3.lp-live[data-hk="in"] .hk-track i:nth-child(2) { animation-delay: .2s; }
	html.lp-on .hk-vig--3.lp-live[data-hk="in"] .hk-track i:nth-child(3) { animation-delay: .4s; }
	html.lp-on .hk-vig--3.lp-live[data-hk="in"] .hk-tick { animation: lp-tick 8s linear infinite both; animation-play-state: var(--lp-ps, running); transition: none; }
	html.lp-on .hk-vig--3.lp-live[data-hk="in"] .hk-tick .hk-ink path { animation: lp-check 8s linear infinite both; animation-play-state: var(--lp-ps, running); transition: none; }

	/* ---------- 12-month strip: Month 4 warms and cools, a soft wave passes along the other bars, the callout arrows nod ---------- */
	@keyframes lp-warm { 0%, 100% { background-color: #B04A30; } 50% { background-color: #C4603F; } }
	@keyframes lp-wave { 0%, 14%, 100% { transform: scaleY(1); } 7% { transform: scaleY(.9); } }
	@keyframes lp-nod { 0%, 100% { translate: 0 0; } 50% { translate: 0 3px; } }
	html.lp-on .hk-spk.lp-live[data-hk="in"] .hk-bar.is-hero { animation: lp-warm 5.6s ease-in-out 2.5s infinite; animation-play-state: var(--lp-ps, running); }
	html.lp-on .hk-spk.lp-live[data-hk="in"] .hk-col:not(:nth-child(1)):not(:nth-child(4)):not(:nth-child(6)) .hk-bar {
		animation: lp-wave 10s ease-in-out calc(3s + var(--i, 0) * 90ms) infinite;
		animation-play-state: var(--lp-ps, running);
	}
	html.lp-on .hk-spk.lp-live[data-hk="in"] .hk-call .hk-ink { animation: lp-nod 4.2s ease-in-out 2s infinite; animation-play-state: var(--lp-ps, running); }

	/* ---------- dark band arrow nudges downward ---------- */
	html.lp-on .hk-arrow.lp-live[data-hk="in"] .hk-ink { animation: lp-nod 4.6s ease-in-out 1.5s infinite; animation-play-state: var(--lp-ps, running); }

	/* ---------- plan-card mini strips refill every 9s ---------- */
	@keyframes lp-refill { 0%, 78%, 100% { transform: scaleX(1); } 84% { transform: scaleX(.12); animation-timing-function: cubic-bezier(.16, 1, .3, 1); } }
	html.lp-on .hk-mini.lp-live[data-hk="in"] .hk-mbar::after { animation: lp-refill 9s ease-in infinite 3s; animation-play-state: var(--lp-ps, running); transition: none; }
	html.lp-on .hk-mini.lp-live[data-hk="in"] .hk-mrow:nth-child(2) .hk-mbar::after { animation-delay: 3.15s; }
	html.lp-on .hk-mini.lp-live[data-hk="in"] .hk-mrow:nth-child(3) .hk-mbar::after { animation-delay: 3.3s; }

	/* ---------- terracotta CTA band: the sheet slides up each time the band comes into view, then peeks (9s) ---------- */
	@keyframes lp-peekin { from { translate: 0 70px; } to { translate: 0 0; } }
	@keyframes lp-peek { 0%, 100% { translate: 0 0; } 50% { translate: 0 -9px; } }
	html.lp-on .e-con.bb-cta-final.lp-live::after {
		animation: lp-peekin 900ms cubic-bezier(.16, 1, .3, 1) both, lp-peek 9s ease-in-out 900ms infinite;
		animation-play-state: var(--lp-ps, running), var(--lp-ps, running);
	}
}
