// ── Delete website (footer): flag in localStorage, serve the 404 ─
(function () {
  const button  = document.getElementById('deleteSite');
  const dialog  = document.getElementById('deleteDialog');
  const confirm = document.getElementById('deleteConfirm');
  const cancel  = document.getElementById('deleteCancel');
  if (!button || !dialog) return;

  button.addEventListener('click', () => dialog.showModal());
  cancel.addEventListener('click', () => dialog.close());
  confirm.addEventListener('click', () => {
    try { localStorage.setItem('siteDeleted', '1'); } catch (e) {}
    location.replace('404.html');
  });
  // Click on the backdrop closes too
  dialog.addEventListener('click', (e) => {
    if (e.target === dialog) dialog.close();
  });
})();
