// Validasi nomor HP dan random-kan posisi kunang-kunang & animasi bintang jatuh
document.addEventListener("DOMContentLoaded", () => {
    // Validasi nomor HP
    document.addEventListener("submit", function(event) {
        const noHpInput = document.querySelector("input[name='no_hp']");
        if (!noHpInput) return;

        const noHp = noHpInput.value.trim();
        if (!/^[0-9+]+$/.test(noHp)) {
            alert("Nomor HP hanya boleh angka atau tanda + 🙏");
            event.preventDefault();
        }
    });

    // Randomkan posisi awal kunang-kunang
    document.querySelectorAll(".firefly").forEach(ff => {
        ff.style.left = Math.random() * 90 + "%";
        ff.style.top  = Math.random() * 80 + "%";
        ff.style.animationDuration = (5 + Math.random() * 4) + "s";
    });

    // Aktifkan animasi shooting star (delay diatur via inline style di HTML)
    document.querySelectorAll(".shooting-star").forEach(star => {
        const delay = star.style.animationDelay || "0s";
        star.style.animation = `shooting 5s linear infinite`;
        star.style.animationDelay = delay;
    });
});
