(function() { 'use strict'; // Mobile Menu const mobileMenuToggle = document.querySelector('.mobile-menu-toggle'); const mainNav = document.querySelector('.main-nav'); if (mobileMenuToggle && mainNav) { mobileMenuToggle.addEventListener('click', function() { const isOpen = mainNav.classList.toggle('open'); this.classList.toggle('open'); this.setAttribute('aria-expanded', isOpen); document.body.style.overflow = isOpen ? 'hidden' : ''; }); mainNav.querySelectorAll('.nav-link').forEach(function(link) { link.addEventListener('click', function() { mainNav.classList.remove('open'); mobileMenuToggle.classList.remove('open'); mobileMenuToggle.setAttribute('aria-expanded', 'false'); document.body.style.overflow = ''; }); }); document.addEventListener('click', function(e) { if (mainNav.classList.contains('open') && !mainNav.contains(e.target) && !mobileMenuToggle.contains(e.target)) { mainNav.classList.remove('open'); mobileMenuToggle.classList.remove('open'); mobileMenuToggle.setAttribute('aria-expanded', 'false'); document.body.style.overflow = ''; } }); document.addEventListener('keydown', function(e) { if (e.key === 'Escape' && mainNav.classList.contains('open')) { mainNav.classList.remove('open'); mobileMenuToggle.classList.remove('open'); mobileMenuToggle.setAttribute('aria-expanded', 'false'); document.body.style.overflow = ''; mobileMenuToggle.focus(); } }); } // Check for reduced motion preference const prefersReducedMotion = window.matchMedia('(prefers-reduced-motion: reduce)').matches; // Scroll Reveal Animation const observerOptions = { root: null, rootMargin: '0px 0px -80px 0px', threshold: 0.1 }; const revealObserver = new IntersectionObserver(function(entries) { entries.forEach(function(entry) { if (entry.isIntersecting) { entry.target.classList.add('revealed'); revealObserver.unobserve(entry.target); } }); }, observerOptions); if (!prefersReducedMotion) { document.querySelectorAll('.reveal-fade, .reveal-slide').forEach(function(el) { revealObserver.observe(el); }); } else { document.querySelectorAll('.reveal-fade, .reveal-slide').forEach(function(el) { el.classList.add('revealed'); }); } // Count Up Animation for Stats function countUp(element, target, duration) { if (prefersReducedMotion) { element.textContent = target; return; } let start = 0; const increment = target / (duration / 16); const timer = setInterval(function() { start += increment; if (start >= target) { element.textContent = target; clearInterval(timer); } else { element.textContent = Math.floor(start); } }, 16); } const statsObserver = new IntersectionObserver(function(entries) { entries.forEach(function(entry) { if (entry.isIntersecting) { const statNumbers = entry.target.querySelectorAll('.stat-number[data-count]'); statNumbers.forEach(function(stat) { const target = parseInt(stat.getAttribute('data-count'), 10); countUp(stat, target, 2000); }); statsObserver.unobserve(entry.target); } }); }, { threshold: 0.5 }); const heroStats = document.querySelector('.hero-stats'); if (heroStats) { statsObserver.observe(heroStats); } // Layer animation observer const layerObserver = new IntersectionObserver(function(entries) { entries.forEach(function(entry) { if (entry.isIntersecting) { entry.target.classList.add('animate'); layerObserver.unobserve(entry.target); } }); }, { threshold: 0.3 }); const layersVisual = document.querySelector('.layers-visual'); if (layersVisual && !prefersReducedMotion) { layerObserver.observe(layersVisual); } // Header scroll effect const header = document.querySelector('.site-header'); let lastScrollY = 0; function updateHeader() { const currentScrollY = window.scrollY; if (currentScrollY > 50) { header.classList.add('scrolled'); } else { header.classList.remove('scrolled'); } lastScrollY = currentScrollY; } window.addEventListener('scroll', updateHeader, { passive: true }); // 3D Tilt Effect for Cards if (!prefersReducedMotion) { document.querySelectorAll('[data-tilt]').forEach(function(card) { card.addEventListener('mousemove', function(e) { const rect = card.getBoundingClientRect(); const x = e.clientX - rect.left; const y = e.clientY - rect.top; const centerX = rect.width / 2; const centerY = rect.height / 2; const rotateX = (y - centerY) / 20; const rotateY = (centerX - x) / 20; card.style.transform = `perspective(1000px) rotateX(${rotateX}deg) rotateY(${rotateY}deg) translateY(-10px)`; }); card.addEventListener('mouseleave', function() { card.style.transform = 'perspective(1000px) rotateX(0) rotateY(0) translateY(0)'; }); }); } // Parallax effect for particles if (!prefersReducedMotion) { window.addEventListener('scroll', function() { const particles = document.querySelectorAll('.particle'); const scrollY = window.scrollY; particles.forEach(function(particle, index) { const speed = 0.05 + (index * 0.02); particle.style.transform = `translateY(${scrollY * speed}px)`; }); }, { passive: true }); } // Feature progress bars animation const featureObserver = new IntersectionObserver(function(entries) { entries.forEach(function(entry) { if (entry.isIntersecting) { entry.target.classList.add('revealed'); } }); }, { threshold: 0.5 }); document.querySelectorAll('.tech-features li').forEach(function(li) { featureObserver.observe(li); }); // Form handling const contactForm = document.querySelector('.contact-form form'); if (contactForm) { contactForm.addEventListener('submit', function(e) { e.preventDefault(); const requiredFields = this.querySelectorAll('[required]'); let isValid = true; requiredFields.forEach(function(field) { if (!field.value.trim()) { isValid = false; field.style.borderColor = '#ef4444'; field.style.boxShadow = '0 0 0 3px rgba(239, 68, 68, 0.15)'; } else { field.style.borderColor = ''; field.style.boxShadow = ''; } }); if (!isValid) { return; } const submitBtn = this.querySelector('button[type="submit"]'); const originalText = submitBtn.textContent; submitBtn.textContent = 'שולח...'; submitBtn.disabled = true; submitBtn.style.opacity = '0.7'; setTimeout(function() { submitBtn.textContent = 'נשלח בהצלחה!'; submitBtn.style.background = 'linear-gradient(135deg, #22c55e, #16a34a)'; submitBtn.style.opacity = '1'; setTimeout(function() { submitBtn.textContent = originalText; submitBtn.style.background = ''; submitBtn.disabled = false; contactForm.reset(); }, 2500); }, 1500); }); contactForm.querySelectorAll('input, textarea, select').forEach(function(field) { field.addEventListener('input', function() { this.style.borderColor = ''; this.style.boxShadow = ''; }); }); } // Smooth scroll for anchor links document.querySelectorAll('a[href^="#"]').forEach(function(anchor) { anchor.addEventListener('click', function(e) { const targetId = this.getAttribute('href'); if (targetId === '#') return; const targetElement = document.querySelector(targetId); if (targetElement) { e.preventDefault(); targetElement.scrollIntoView({ behavior: prefersReducedMotion ? 'auto' : 'smooth' }); targetElement.setAttribute('tabindex', '-1'); targetElement.focus(); } }); }); // Ripple effect on buttons document.querySelectorAll('.btn-glow').forEach(function(btn) { btn.addEventListener('click', function(e) { const ripple = this.querySelector('.btn-ripple'); if (ripple) { ripple.style.transform = 'scale(0)'; ripple.style.opacity = '0'; setTimeout(function() { ripple.style.transform = ''; ripple.style.opacity = ''; }, 10); } }); }); // Add staggered animation delay to grid items if (!prefersReducedMotion) { document.querySelectorAll('.expertise-grid .expertise-card, .products-grid .product-card, .advantages-grid .advantage-item, .industries-grid .industry-card').forEach(function(card, index) { card.style.transitionDelay = (index * 0.1) + 's'; }); } // Logo cards hover glow effect document.querySelectorAll('.client-logo-card').forEach(function(card) { card.addEventListener('mouseenter', function() { this.style.filter = 'brightness(1.1)'; }); card.addEventListener('mouseleave', function() { this.style.filter = ''; }); }); })();