// Tiny dependency-free toast notifications, callable from anywhere.
export function toast(msg, type = 'ok', ms = 2600) {
  let c = document.getElementById('amerc-toasts');
  if (!c) { c = document.createElement('div'); c.id = 'amerc-toasts'; document.body.appendChild(c); }
  const t = document.createElement('div');
  t.className = `amerc-toast t-${type}`;
  t.textContent = msg;
  c.appendChild(t);
  requestAnimationFrame(() => t.classList.add('in'));
  setTimeout(() => { t.classList.remove('in'); setTimeout(() => t.remove(), 300); }, ms);
}

export function copyToast(text, label = 'Copied') {
  try { navigator.clipboard.writeText(text).then(() => toast(`${label} ✓`)).catch(() => toast('Copy failed', 'err')); }
  catch { toast('Copy failed', 'err'); }
}
