document.addEventListener('DOMContentLoaded', function(){ //document.ready
  /*smooth scrolling to links*/
  document.querySelectorAll('a[href^="#"]').forEach(anchor => {
    anchor.addEventListener('click', function (e) {
        e.preventDefault();

        const targetId = this.getAttribute('href');
        const targetElement = document.querySelector(targetId);

        if (targetElement) {
            targetElement.scrollIntoView({
                behavior: 'smooth',
                block: 'start'
            });
        }
    });
  });

  /*countdown*/
  const targetDate = new Date("2026-05-08T00:00:00");

  const h1 = document.getElementById("h1");
  const h2 = document.getElementById("h2");
  const m1 = document.getElementById("m1");
  const m2 = document.getElementById("m2");
  const s1 = document.getElementById("s1");
  const s2 = document.getElementById("s2");

  function updateCountdown() {
    const now = new Date();
    let diff = targetDate - now;

    if (diff < 0) {
      diff = 0;
      h1.textContent = '0';
      h2.textContent = '0';
      m1.textContent = '0';
      m2.textContent = '0';
      s1.textContent = '0';
      s2.textContent = '0';
      return;
    }

    const totalSeconds = Math.floor(diff / 1000);
    const days = Math.floor(totalSeconds / 86400); // 86400 seconds in 24 hours
    const hours = Math.floor((totalSeconds / 3600) % 24);
    const minutes = Math.floor((totalSeconds / 60) % 60);
    const seconds = totalSeconds % 60;

    const totalHours = days * 24 + hours;
    
    const h = String(totalHours).padStart(2, "0");
    const m = String(minutes).padStart(2, "0");
    const s = String(seconds).padStart(2, "0");

    h1.textContent = h[0];
    h2.textContent = h[1];
    m1.textContent = m[0];
    m2.textContent = m[1];
    s1.textContent = s[0];
    s2.textContent = s[1];
  }

  updateCountdown();
  setInterval(updateCountdown, 1000);

});


