// small helpers: toggle nav, smooth scroll, contact form mailto fallback document.addEventListener('DOMContentLoaded', function () { // set year const yearEl = document.getElementById('year'); if (yearEl) yearEl.textContent = new Date().getFullYear();
// nav toggle for small screens const btn = document.querySelector('.nav-toggle'); const navLinks = document.querySelector('.nav-links'); if (btn && navLinks) { btn.addEventListener('click', () => { navLinks.style.display = navLinks.style.display === 'flex' ? 'none' : 'flex'; navLinks.style.flexDirection = 'column'; }); }
// smooth scroll for in-page links document.querySelectorAll('a[href^="#"]').forEach(a => { a.addEventListener('click', function (e) { const target = document.querySelector(this.getAttribute('href')); if (target) { e.preventDefault(); target.scrollIntoView({ behavior: 'smooth', block: 'start' }); } }); }); });
// contact form handler: uses mailto fallback so messages go to your email
function handleContact(e) {
e.preventDefault();
const form = e.target;
const name = encodeURIComponent(form.name.value.trim());
const email = encodeURIComponent(form.email.value.trim());
const message = encodeURIComponent(form.message.value.trim());
const subject = encodeURIComponent(Website message from ${name});
const body = encodeURIComponent(Name: ${name}\nEmail: ${email}\n\n${message});
const mailto = mailto:abuuafham@gmail.com?subject=${subject}&body=${body};
// open mail client
window.location.href = mailto;
}