document.addEventListener('DOMContentLoaded', () => {
  const video = document.getElementById('first-video');

  const observer = new IntersectionObserver((entries) => {
    entries.forEach((entry) => {
      if (entry.isIntersecting) {
        const source = document.createElement('source');
        source.src = '/rss/videos/couple.mp4';
        source.type = 'video/mp4';
        video.appendChild(source);

        video.load();
        video.play();
        video.playbackRate = 0.7; // Set after loading

        observer.disconnect();
      }
    });
  });

  observer.observe(video);
});
