class CustomHero extends HTMLElement { constructor() { super(); this.currentIndex = 0; this.facts = [ "La photosynthèse produit environ 130 térawatts d'énergie par an", "Les forêts tropicales produisent 40% de l'oxygène terrestre", "Le phytoplancton produit 50% de l'oxygène de l'atmosphère", "Une feuille peut convertir jusqu'à 6% de l'énergie lumineuse en énergie chimique" ]; } connectedCallback() { this.attachShadow({ mode: 'open' }); this.render(); this.initAnimations(); this.startFactRotation(); this.initScrollIndicator(); } render() { this.shadowRoot.innerHTML = `

La Photosynthèse Décryptée

Explorez le processus biologique fondamental qui transforme la lumière en vie, alimentant les écosystèmes terrestres et produisant l'oxygène que nous respirons.

3.5B
Années d'évolution
99%
Énergie biologique
104-130
PgC/an fixés
↑70%
Oxygène atmosphérique

${this.facts[0]}

Explorer
`; } initAnimations() { // Animation d'entrée const heroContent = this.shadowRoot.querySelector('.hero-content'); const statItems = this.shadowRoot.querySelectorAll('.stat-item'); // Animation séquentielle des éléments setTimeout(() => { heroContent.style.opacity = '0'; heroContent.style.transform = 'translateY(20px)'; heroContent.style.transition = 'all 0.8s ease'; setTimeout(() => { heroContent.style.opacity = '1'; heroContent.style.transform = 'translateY(0)'; }, 100); }, 100); // Animation des statistiques statItems.forEach((item, index) => { item.style.opacity = '0'; item.style.transform = 'translateY(30px)'; item.style.transition = 'all 0.5s ease'; setTimeout(() => { item.style.opacity = '1'; item.style.transform = 'translateY(0)'; }, 300 + (index * 200)); }); } startFactRotation() { const factDisplay = this.shadowRoot.querySelector('#factDisplay'); const factText = this.shadowRoot.querySelector('#factText'); if (!factDisplay || !factText) return; // Afficher le premier fait factDisplay.classList.add('show'); // Changer de fait toutes les 10 secondes setInterval(() => { this.currentIndex = (this.currentIndex + 1) % this.facts.length; // Animation de transition factDisplay.style.opacity = '0'; factDisplay.style.transform = 'translateY(10px)'; setTimeout(() => { factText.textContent = this.facts[this.currentIndex]; factDisplay.style.opacity = '1'; factDisplay.style.transform = 'translateY(0)'; }, 500); }, 10000); } initScrollIndicator() { const scrollIndicator = this.shadowRoot.querySelector('#scrollIndicator'); if (scrollIndicator) { scrollIndicator.addEventListener('click', () => { // Faire défiler vers la section suivante const nextSection = document.querySelector('section'); if (nextSection) { nextSection.scrollIntoView({ behavior: 'smooth', block: 'start' }); } }); } // Cacher l'indicateur lors du défilement window.addEventListener('scroll', () => { if (scrollIndicator) { if (window.scrollY > 100) { scrollIndicator.style.opacity = '0'; scrollIndicator.style.pointerEvents = 'none'; } else { scrollIndicator.style.opacity = '0.7'; scrollIndicator.style.pointerEvents = 'auto'; } } }); } } customElements.define('custom-hero', CustomHero);