document.addEventListener('DOMContentLoaded', () => {

    // --- Timeline Animation Fallback --- //
    const isAnimationTimelineSupported = CSS.supports('animation-timeline', 'view()');

    if (!isAnimationTimelineSupported) {
        // Tambahkan class ke body jika fallback diperlukan
        document.body.classList.add('js-timeline');

        const timelineItems = document.querySelectorAll('.timeline li');

        if (timelineItems.length > 0) {
            const observer = new IntersectionObserver((entries, observer) => {
                entries.forEach(entry => {
                    if (entry.isIntersecting) {
                        entry.target.classList.add('is-visible');
                        observer.unobserve(entry.target); // Hentikan observasi setelah animasi berjalan
                    }
                });
            }, { 
                threshold: 0.3 // Picu saat 30% elemen terlihat
            });

            timelineItems.forEach(item => {
                observer.observe(item);
            });
        }
    }

    // --- Fallback for other animated sections ---
    const animatedSections = document.querySelectorAll('.about'); // Tambahkan section lain jika perlu
    if (!isAnimationTimelineSupported) {
        animatedSections.forEach(section => {
            const observer = new IntersectionObserver((entries) => {
                entries.forEach(entry => {
                    if (entry.isIntersecting) {
                        entry.target.classList.add('in-view');
                    } else {
                        entry.target.classList.remove('in-view');
                    }
                });
            }, { threshold: 0.25 });

            observer.observe(section);
        });
    }
});


function copyDscUsername() {
    const textToCopy = "@sean372id";
    navigator.clipboard.writeText(textToCopy)
        .then(() => {
            alert('Text copied to clipboard: ' + textToCopy);
        }).catch((error) => {
            alert('Failed to copy text: ' + error);
        });
}