document.addEventListener('DOMContentLoaded', function() { // Theme toggle functionality const themeToggleBtn = document.getElementById('theme-toggle'); if (themeToggleBtn) { themeToggleBtn.addEventListener('click', function() { if (document.documentElement.classList.contains('dark')) { document.documentElement.classList.remove('dark'); localStorage.setItem('theme', 'light'); } else { document.documentElement.classList.add('dark'); localStorage.setItem('theme', 'dark'); } }); } // Check for saved theme preference or use preferred color scheme if (localStorage.getItem('theme') === 'dark' || (!localStorage.getItem('theme') && window.matchMedia('(prefers-color-scheme: dark)').matches)) { document.documentElement.classList.add('dark'); } else { document.documentElement.classList.remove('dark'); } // Simulate loading anime data (in a real app, this would be an API call) setTimeout(() => { const loadingElements = document.querySelectorAll('.loading-skeleton'); loadingElements.forEach(el => el.classList.remove('loading-skeleton')); }, 1500); }); // Video player modal functionality function openVideoModal(videoId) { const modal = document.getElementById('video-modal'); modal.classList.remove('hidden'); document.body.classList.add('overflow-hidden'); } function closeVideoModal() { const modal = document.getElementById('video-modal'); modal.classList.add('hidden'); document.body.classList.remove('overflow-hidden'); }