(function() {
var flame = document.getElementById('cart-flame');
if (!flame) return;
// Utility to trigger the flame burst
function burstFlame() {
flame.classList.remove('ignite');
// Force reflow to restart animation if triggered rapidly
void flame.offsetWidth;
flame.classList.add('ignite');
setTimeout(function() {
flame.classList.remove('ignite');
}, 900);
}
// Listen for changes to the cart count span
var cartCountSpan = document.querySelector('[data-count]');
if (cartCountSpan) {
var lastCount = cartCountSpan.textContent;
var observer = new MutationObserver(function() {
if (cartCountSpan.textContent !== lastCount) {
lastCount = cartCountSpan.textContent;
burstFlame();
}
});
observer.observe(cartCountSpan, { childList: true, subtree: true });
}
})();