/** * Ophiro Hero Effects * Parallax and visual enhancements for the hero section */ ( function() { 'use strict'; const hero = document.getElementById( 'o-hero' ); if ( ! hero ) return; const heroBg = hero.querySelector( '.o-hero__bg' ); const heroContent = hero.querySelector( '.o-hero__content' ); // Subtle parallax on hero background let heroTicking = false; function updateHeroParallax() { const scrollY = window.pageYOffset; const heroHeight = hero.offsetHeight; if ( scrollY < heroHeight ) { const progress = scrollY / heroHeight; if ( heroBg ) { heroBg.style.transform = 'translateY(' + ( scrollY * 0.3 ) + 'px) scale(' + ( 1 + progress * 0.05 ) + ')'; heroBg.style.opacity = 1 - ( progress * 0.6 ); } if ( heroContent ) { heroContent.style.transform = 'translateY(' + ( scrollY * 0.15 ) + 'px)'; heroContent.style.opacity = 1 - ( progress * 1.2 ); } } } window.addEventListener( 'scroll', function() { if ( ! heroTicking ) { window.requestAnimationFrame( function() { updateHeroParallax(); heroTicking = false; } ); heroTicking = true; } } ); // Typing effect for hero title (subtle) const heroTitle = hero.querySelector( '.o-hero__title' ); if ( heroTitle ) { heroTitle.style.opacity = '0'; heroTitle.style.transform = 'translateY(20px)'; heroTitle.style.transition = 'opacity 1s ease, transform 1s ease'; setTimeout( function() { heroTitle.style.opacity = '1'; heroTitle.style.transform = 'translateY(0)'; }, 300 ); } // Fade in hero subtitle const heroSubtitle = hero.querySelector( '.o-hero__subtitle' ); if ( heroSubtitle ) { heroSubtitle.style.opacity = '0'; heroSubtitle.style.transform = 'translateY(15px)'; heroSubtitle.style.transition = 'opacity 1s ease 0.3s, transform 1s ease 0.3s'; setTimeout( function() { heroSubtitle.style.opacity = '1'; heroSubtitle.style.transform = 'translateY(0)'; }, 300 ); } // Fade in CTA buttons const heroCta = hero.querySelector( '.o-hero__cta-group' ); if ( heroCta ) { heroCta.style.opacity = '0'; heroCta.style.transform = 'translateY(15px)'; heroCta.style.transition = 'opacity 1s ease 0.6s, transform 1s ease 0.6s'; setTimeout( function() { heroCta.style.opacity = '1'; heroCta.style.transform = 'translateY(0)'; }, 300 ); } // Gold shimmer effect on scroll const goldElements = document.querySelectorAll( '.o-gold' ); if ( goldElements.length ) { let shimmerFrame; function shimmerGold() { const time = Date.now() * 0.001; const intensity = 0.85 + Math.sin( time * 2 ) * 0.15; goldElements.forEach( function( el ) { el.style.opacity = intensity; } ); shimmerFrame = requestAnimationFrame( shimmerGold ); } // Only run shimmer when hero is visible const heroObserver = new IntersectionObserver( function( entries ) { entries.forEach( function( entry ) { if ( entry.isIntersecting ) { shimmerGold(); } else { if ( shimmerFrame ) { cancelAnimationFrame( shimmerFrame ); } } } ); } ); heroObserver.observe( hero ); } } )();