// ui-jamaah.js — update DOM for jamaah cards
export function updateJamaahCards(data = {}) {
  const ids = ["subuh","dzuhur","ashar","maghrib","isya","luar_waktu","pria","wanita","total"];
  ids.forEach(id => {
    const el = document.querySelector(`.jamaah-card p#${id}`);
    if (!el) return;
    const val = data[id] !== undefined ? data[id] : (el.textContent || "0");
    animateNumberChange(el, String(val));
  });
}

function animateNumberChange(element, newValue) {
  if (!element) return;
  if (element.textContent === String(newValue)) return;
  element.style.transition = "transform .18s ease";
  element.style.transform = "scale(1.06)";
  setTimeout(()=> {
    element.textContent = newValue;
    element.style.transform = "";
  }, 160);
}
