// Анимации появления элементов при скролле
document.addEventListener('DOMContentLoaded', () => {
  const targets = document.querySelectorAll(
    '.section__header, .section__title, .bento__card, .about__left, .about__right, .service, .contact, .stats__item, .skill-tag'
  );

  targets.forEach(el => el.classList.add('fade-in'));

  const observer = new IntersectionObserver(
    entries => {
      entries.forEach(entry => {
        if (entry.isIntersecting) {
          entry.target.classList.add('visible');
          observer.unobserve(entry.target);
        }
      });
    },
    { threshold: 0.15 }
  );

  targets.forEach(el => observer.observe(el));

  // Скрытие/показ навигации при скролле
  const nav = document.querySelector('.nav');
  let lastScrollY = 0;

  window.addEventListener('scroll', () => {
    const currentScrollY = window.scrollY;
    if (currentScrollY > lastScrollY && currentScrollY > 100) {
      nav.style.transform = 'translateX(-50%) translateY(-100px)';
    } else {
      nav.style.transform = 'translateX(-50%) translateY(0)';
    }
    nav.style.transition = 'transform 0.4s ease';
    lastScrollY = currentScrollY;
  });
});
