/* ============================================ VAGITON · Main JS GSAP · ScrollTrigger · Lenis · custom anims ============================================ */ (() => { 'use strict'; const reduce = matchMedia('(prefers-reduced-motion: reduce)').matches; const isTouch = matchMedia('(hover: none)').matches; // Failsafe: 1200ms — гарантия что любая секция станет видимой, даже если IO не отработал setTimeout(() => { document.querySelectorAll('.reveal-up, .reveal-init, .recognize__item, .expert__regalia li, .method__step, [data-expert-photo], .hero__title, .hero__photo-wrap, .fade-up, .scale-in, .slide-left, .slide-right, .stagger-cards, .photo-reveal, .section-h2, .paper-fold').forEach(el => { if (!el.classList.contains('is-anim')) el.classList.add('is-anim'); if (el.matches('[data-expert-photo]')) el.classList.add('is-revealed'); }); document.body.classList.add('anims-loaded'); }, 1200); // No-IntersectionObserver fallback: reveal everything immediately if (!('IntersectionObserver' in window)) { document.querySelectorAll('.fade-up, .scale-in, .slide-left, .slide-right, .photo-reveal, .reveal-up, .recognize__item, .expert__regalia li, .method__step, .hero__title').forEach(el => { el.classList.add('is-anim'); }); } /* ----------------------------------- 1. Native scroll (Lenis off — was causing Safari jank) ----------------------------------- */ let lenis = null; // Native smooth scroll for anchor links document.querySelectorAll('a[href^="#"]').forEach(a => { a.addEventListener('click', (e) => { const id = a.getAttribute('href').slice(1); const target = id && document.getElementById(id); if (!target) return; e.preventDefault(); target.scrollIntoView({ behavior: 'smooth', block: 'start' }); }); }); /* ----------------------------------- 2. Header scroll state ----------------------------------- */ const header = document.querySelector('.site-header'); const setHeaderState = () => { if (window.scrollY > 24) header.classList.add('is-scrolled'); else header.classList.remove('is-scrolled'); }; setHeaderState(); window.addEventListener('scroll', setHeaderState, { passive: true }); /* ----------------------------------- 3. Mobile burger ----------------------------------- */ const burger = document.querySelector('.burger'); const mobileMenu = document.querySelector('.mobile-menu'); if (burger && mobileMenu) { burger.addEventListener('click', () => { const open = burger.classList.toggle('is-open'); mobileMenu.classList.toggle('is-open', open); mobileMenu.setAttribute('aria-hidden', String(!open)); burger.setAttribute('aria-expanded', String(open)); document.body.style.overflow = open ? 'hidden' : ''; }); mobileMenu.querySelectorAll('a').forEach(link => { link.addEventListener('click', () => { burger.classList.remove('is-open'); mobileMenu.classList.remove('is-open'); document.body.style.overflow = ''; }); }); } /* ----------------------------------- 4. Hero word-by-word reveal (no SplitText plugin needed) ----------------------------------- */ function splitWords(el) { if (!el) return []; const result = []; el.querySelectorAll('.line').forEach(line => { const text = line.textContent.trim(); const accent = line.querySelector('.accent'); if (accent) { // wrap each word inside .accent const words = accent.textContent.trim().split(/\s+/).map(w => `${w}`).join(' '); accent.innerHTML = words; // wrap text-only siblings if any result.push(...accent.querySelectorAll('.word')); } else { const words = text.split(/\s+/).map(w => `${w}`).join(' '); line.innerHTML = words; result.push(...line.querySelectorAll('.word')); } }); // style words result.forEach(w => { w.style.display = 'inline-block'; w.style.willChange = 'transform, opacity, filter'; }); return result; } /* ----------------------------------- 5. Hero title — line-by-line fade-up (preserves text wrapping) ----------------------------------- */ if (!reduce) { const heroTitle = document.querySelector('.hero__title'); if (heroTitle) { heroTitle.querySelectorAll('.line').forEach((line, i) => { line.style.setProperty('--delay', (i * 0.18) + 's'); }); requestAnimationFrame(() => { heroTitle.classList.add('is-anim'); }); } } /* ----------------------------------- 5b. Universal photo curtain reveal — ALL content images Авто-применяется к ЛЮБОМУ / внутри
/
, кроме лого, иконок (svg) и декоративных (alt="" + aria-hidden). ----------------------------------- */ if (!reduce) { // 1) Явные wrap-классы (если есть в разметке) — приоритет const explicitTargets = [ '.hero__photo-wrap', '.expert__photo-wrap', '.about-hero__photo', '.results__video', '.results__video-poster', '.prog-hero__photo', '.method__visual-photo', '.leadmagnet__pdf-mockup', '.program-card__media', '.equipment-card', '.recognize__photo', '.myth__photo', '.method__step-photo', '.expert__photo' ]; explicitTargets.forEach(sel => { document.querySelectorAll(sel).forEach(el => el.classList.add('photo-reveal')); }); // 2) Универсально: и большие внутри секций — оборачиваем в curtain document.querySelectorAll('main picture, main figure').forEach(el => { if (el.closest('.photo-reveal, .site-header, .site-footer, .nav__list, .mobile-menu, .sticky-cta, .lead-modal')) return; el.classList.add('photo-reveal'); }); document.querySelectorAll('main section img, main .container img').forEach(img => { if (img.closest('.photo-reveal, picture, .site-header, .site-footer, .nav__list, .mobile-menu, .sticky-cta, .lead-modal, figure')) return; if (img.getAttribute('alt') === '' && !img.closest('.hero__avatar-mobile')) return; // skip маленькие/icon SVG const w = img.naturalWidth || img.width || parseInt(img.getAttribute('width') || '0', 10); if (w && w < 120) return; img.classList.add('photo-reveal'); }); // 3) Hero photo — reveal на load (above-the-fold) const heroPhotoWrap = document.querySelector('.hero__photo-wrap'); if (heroPhotoWrap) { requestAnimationFrame(() => setTimeout(() => heroPhotoWrap.classList.add('is-anim'), 200)); } // 4) Все остальные photo-reveal — через IntersectionObserver if ('IntersectionObserver' in window) { const ioPhoto = new IntersectionObserver((entries, ob) => { entries.forEach(e => { if (e.isIntersecting) { setTimeout(() => e.target.classList.add('is-anim'), 80); ob.unobserve(e.target); } }); }, { threshold: 0.12, rootMargin: '0px 0px -8% 0px' }); document.querySelectorAll('.photo-reveal').forEach(el => { if (el === heroPhotoWrap) return; ioPhoto.observe(el); const r = el.getBoundingClientRect(); if (r.top < window.innerHeight * 0.85) { setTimeout(() => el.classList.add('is-anim'), 200); } }); } else { document.querySelectorAll('.photo-reveal').forEach(el => el.classList.add('is-anim')); } } /* ----------------------------------- 5b2. Premium SECTION reveal — auto slide-left/slide-right + stagger Чередует направление по позиции секции (как референс Lovenizer): - 1-я секция → fade-up - 2-я → slide-left для текста + slide-right для фото - 3-я → slide-right для текста + slide-left для фото - и т.д. по чередованию ----------------------------------- */ if (!reduce) { const sections = document.querySelectorAll('main > section, main > .page-block, main > .page-hero'); sections.forEach((sec, idx) => { // Skip hero/marquee/myth/leadmagnet/lead-modal — у них собственные анимации if (sec.matches('.hero, .marquee, .myth, .leadmagnet, .lead-modal, .lead-magnet')) return; // Найдём container или прямые дети const container = sec.querySelector(':scope > .container, :scope > .container--narrow, :scope > .container--wide') || sec; const isOdd = idx % 2 === 1; // Для контейнера: его прямые дети получают fade-up со staggered delay Array.from(container.children).forEach((child, i) => { if (child.classList.contains('photo-reveal')) return; // photo уже своя анимация if (child.tagName === 'SCRIPT' || child.tagName === 'STYLE') return; // Если ребёнок крупный grid/flex с >2 детьми — даём ему свой класс stagger-cards const grandChildren = child.children; if (grandChildren.length >= 2 && grandChildren.length <= 12 && (child.classList.toString().match(/grid|cards|list|row|wrap/i) || getComputedStyle(child).display.match(/grid|flex/))) { child.classList.add('stagger-cards'); } else { // одиночный блок: чередуем slide-left/right if (i === 0) { child.classList.add(isOdd ? 'slide-left' : 'slide-right'); } else { child.classList.add('fade-up'); } child.style.transitionDelay = (i * 0.08) + 's'; } }); }); // Универсальный IntersectionObserver для fade-up/slide-left/slide-right/scale-in/stagger-cards if ('IntersectionObserver' in window) { const ioReveal = new IntersectionObserver((entries, ob) => { entries.forEach(e => { if (e.isIntersecting) { e.target.classList.add('is-anim'); ob.unobserve(e.target); } }); }, { threshold: 0.12, rootMargin: '0px 0px -6% 0px' }); document.querySelectorAll('.fade-up, .slide-left, .slide-right, .scale-in, .stagger-cards').forEach(el => { ioReveal.observe(el); const r = el.getBoundingClientRect(); if (r.top < window.innerHeight * 0.9) { setTimeout(() => el.classList.add('is-anim'), 80); } }); } else { document.querySelectorAll('.fade-up, .slide-left, .slide-right, .scale-in, .stagger-cards').forEach(el => el.classList.add('is-anim')); } } /* ----------------------------------- 5c. Auto-decorate H2s with section-h2 underline + curtain reveal ----------------------------------- */ if (!reduce && 'IntersectionObserver' in window) { document.querySelectorAll('section h2').forEach(h2 => { // Skip if already has class if (h2.classList.contains('hero__title')) return; h2.classList.add('section-h2'); }); const sectionHeadings = document.querySelectorAll('.section-h2'); const ioH = new IntersectionObserver((entries, ob) => { entries.forEach(e => { if (e.isIntersecting) { e.target.classList.add('is-anim'); ob.unobserve(e.target); } }); }, { threshold: 0.4 }); sectionHeadings.forEach(h => ioH.observe(h)); } /* ----------------------------------- 5d. Hero mouse parallax (subtle clouds + photo) ----------------------------------- */ if (!reduce && !isTouch) { const hero = document.querySelector('.hero'); if (hero) { const clouds = hero.querySelectorAll('.cloud'); const photo = hero.querySelector('.hero__photo'); let mx = 0, my = 0, cmx = 0, cmy = 0; hero.addEventListener('mousemove', (e) => { const r = hero.getBoundingClientRect(); mx = (e.clientX - r.left) / r.width - 0.5; my = (e.clientY - r.top) / r.height - 0.5; }); function loop() { cmx += (mx - cmx) * 0.05; cmy += (my - cmy) * 0.05; clouds.forEach((c, i) => { const k = (i + 1) * 8; c.style.transform = `translate3d(${cmx * k}px, ${cmy * k}px, 0)`; }); if (photo) photo.style.transform = `translate3d(${cmx * 6}px, ${cmy * 6}px, 0) scale(1.04)`; requestAnimationFrame(loop); } requestAnimationFrame(loop); } } /* ----------------------------------- 6. Cloud parallax — DISABLED (blur+scroll = Safari jank) Облака теперь static, плавающие через CSS animation float ниже ----------------------------------- */ /* ----------------------------------- 7. Magnetic CTA buttons ----------------------------------- */ // Magnetic CTA — pure CSS transition (no GSAP) if (!reduce && !isTouch) { document.querySelectorAll('.magnetic').forEach(btn => { const strength = 0.3; btn.style.transition = 'transform 0.6s cubic-bezier(0.22, 1, 0.36, 1)'; btn.addEventListener('mousemove', (e) => { const rect = btn.getBoundingClientRect(); const x = (e.clientX - rect.left - rect.width / 2) * strength; const y = (e.clientY - rect.top - rect.height / 2) * strength; btn.style.transform = `translate3d(${x}px, ${y}px, 0)`; }); btn.addEventListener('mouseleave', () => { btn.style.transform = ''; }); }); } /* ----------------------------------- 8. Custom cursor ----------------------------------- */ if (!isTouch) { const cursor = document.querySelector('.cursor-dot'); if (cursor) { let mx = 0, my = 0, cx = 0, cy = 0; window.addEventListener('mousemove', (e) => { mx = e.clientX; my = e.clientY; }); function loop() { cx += (mx - cx) * 0.18; cy += (my - cy) * 0.18; cursor.style.transform = `translate(${cx}px, ${cy}px) translate(-50%, -50%)`; requestAnimationFrame(loop); } loop(); // hover effect const hoverables = 'a, button, .magnetic, [data-tilt]'; document.querySelectorAll(hoverables).forEach(el => { el.addEventListener('mouseenter', () => cursor.classList.add('cursor-dot--hover')); el.addEventListener('mouseleave', () => cursor.classList.remove('cursor-dot--hover')); }); } } /* ----------------------------------- 9. Tilt cards — disabled (was hiding hero photo) ----------------------------------- */ /* ----------------------------------- 10a-paperfold. DISABLED — заменена премиум slide-left/right + fade-up auto-pack из section 5b2. Paper-fold создавал 3D rotation но если IO не успевал — секции оставались opacity:0 (увидено на скрине v59). ----------------------------------- */ // (removed) /* ----------------------------------- 10a-auto. Auto-decorate every block in sections with fade-up Each H2/H3, lead p, list, btn-row, ornament gets reveal animation. ----------------------------------- */ if (!reduce) { // Skip Hero (already animated by char-by-char + curtain) document.querySelectorAll('main > section:not(.hero) :is(h2, h3, h4, p.lead, .eyebrow, .ornament, .btn, .results__doctors-list, .results__doctors-text, .equipment__warning, .programs__bottom, .recognize__bottom, .leadmagnet__visual, .leadmagnet__content, .myth__head, .results__head, .equipment__head, .programs__head, .method__head, .recognize__head, .faq__head)').forEach(el => { // skip if already decorated if (el.classList.contains('fade-up') || el.classList.contains('slide-left') || el.classList.contains('slide-right') || el.classList.contains('scale-in')) return; el.classList.add('fade-up'); }); // Specific slide directions document.querySelectorAll('.expert__visual, .leadmagnet__visual, .results__video').forEach(el => { el.classList.remove('fade-up'); el.classList.add('slide-left'); }); document.querySelectorAll('.expert__content, .leadmagnet__content, .results__quotes').forEach(el => { el.classList.remove('fade-up'); el.classList.add('slide-right'); }); } /* ----------------------------------- 10a-gold. Gold frame on key cards ----------------------------------- */ if (!reduce) { document.querySelectorAll('.program-card, .equipment-card, .results__quote, .method__chip, .recognize__item').forEach(el => { el.classList.add('gold-frame'); }); } /* ----------------------------------- 10a-pre. Inject stagger-cards class to grid-like sections ----------------------------------- */ if (!reduce) { [ '.programs__grid', '.recognize__list', '.method__chips', '.equipment__grid', '.results__quotes', '.expert__regalia', '.faq__list', ].forEach(sel => { document.querySelectorAll(sel).forEach(el => el.classList.add('stagger-cards')); }); } /* ----------------------------------- 10a-pre2. Animate stagger-cards on view ----------------------------------- */ if (!reduce && 'IntersectionObserver' in window) { const ioStag = new IntersectionObserver((entries, ob) => { entries.forEach(e => { if (e.isIntersecting) { e.target.classList.add('is-anim'); ob.unobserve(e.target); } }); }, { threshold: 0.15 }); document.querySelectorAll('.stagger-cards').forEach(el => ioStag.observe(el)); // Also handle .fade-up, .scale-in, .slide-left, .slide-right document.querySelectorAll('.fade-up, .scale-in, .slide-left, .slide-right').forEach(el => ioStag.observe(el)); } /* ----------------------------------- 10a. Reveal-up via IntersectionObserver (light, no GSAP scrollTrigger) ----------------------------------- */ if (!reduce && 'IntersectionObserver' in window) { const revealEls = document.querySelectorAll('.reveal-up'); const io = new IntersectionObserver((entries) => { entries.forEach(e => { if (e.isIntersecting) { e.target.classList.add('is-anim'); io.unobserve(e.target); } }); }, { threshold: 0.12, rootMargin: '0px 0px -8% 0px' }); revealEls.forEach(el => { io.observe(el); const r = el.getBoundingClientRect(); if (r.top < window.innerHeight) el.classList.add('is-anim'); }); } else { document.querySelectorAll('.reveal-up').forEach(el => el.classList.add('is-anim')); } /* ----------------------------------- 10b. Myth auto-slider (5s rotation, no pin = no Safari jank) ----------------------------------- */ const mythSlider = document.getElementById('mythSlider'); const mythNav = document.getElementById('mythNav'); if (mythSlider && mythNav) { const slides = mythSlider.querySelectorAll('.myth__slide'); const dots = mythNav.querySelectorAll('.myth__nav-dot'); let current = 0; let timer = null; const interval = 5500; function show(idx) { slides.forEach((s, i) => s.classList.toggle('is-active', i === idx)); // First, remove is-active from all dots and force reflow dots.forEach((d, i) => { d.classList.remove('is-active'); d.classList.toggle('is-passed', i < idx); }); // Force reflow to reset progress bar (so transition fires from 0) void dots[idx].offsetWidth; // Then activate the current dot — width transitions from 0 to 100% dots[idx].classList.add('is-active'); current = idx; } function next() { const idx = (current + 1) % slides.length; show(idx); } function start() { stop(); // restart progress animation by toggling class timer = setInterval(next, interval); } function stop() { if (timer) { clearInterval(timer); timer = null; } } dots.forEach((d, i) => { d.addEventListener('click', () => { show(i); start(); }); }); // Pause when not visible (perf) if ('IntersectionObserver' in window) { const io = new IntersectionObserver((entries) => { entries.forEach(e => e.isIntersecting ? start() : stop()); }, { threshold: 0.3 }); io.observe(mythSlider); } else { start(); } // Pause on hover mythSlider.addEventListener('mouseenter', stop); mythSlider.addEventListener('mouseleave', start); } /* ----------------------------------- 10b2. Expert section reveals (image clip-path + regalia stagger) Use IntersectionObserver + CSS transitions — robust against scroll-position-on-load ----------------------------------- */ if (!reduce && 'IntersectionObserver' in window) { // Image reveal const expertPhoto = document.querySelector('[data-expert-photo]'); if (expertPhoto) { const io = new IntersectionObserver((entries) => { entries.forEach(e => { if (e.isIntersecting) { expertPhoto.classList.add('is-revealed'); io.disconnect(); } }); }, { threshold: 0.15 }); io.observe(expertPhoto); // safety: if already past viewport, reveal anyway const r = expertPhoto.getBoundingClientRect(); if (r.top < window.innerHeight) expertPhoto.classList.add('is-revealed'); } // Regalia stagger via CSS classes const regaliaList = document.querySelector('.expert__regalia[data-stagger]'); if (regaliaList) { const items = Array.from(regaliaList.children); const io = new IntersectionObserver((entries) => { entries.forEach(e => { if (e.isIntersecting) { items.forEach((li, i) => { li.style.transitionDelay = (i * 60) + 'ms'; li.classList.add('is-anim'); }); io.disconnect(); } }); }, { threshold: 0.15 }); io.observe(regaliaList); const r = regaliaList.getBoundingClientRect(); if (r.top < window.innerHeight) { items.forEach((li, i) => { li.style.transitionDelay = (i * 60) + 'ms'; li.classList.add('is-anim'); }); } } // Recognize items const recogItems = document.querySelectorAll('.recognize__item'); if (recogItems.length) { const io = new IntersectionObserver((entries) => { entries.forEach(e => { if (e.isIntersecting) { e.target.classList.add('is-anim'); io.unobserve(e.target); } }); }, { threshold: 0.1 }); recogItems.forEach((it, i) => { it.style.transitionDelay = (i * 70) + 'ms'; io.observe(it); const r = it.getBoundingClientRect(); if (r.top < window.innerHeight) it.classList.add('is-anim'); }); } } else { // No-anim fallback — show everything document.querySelectorAll('[data-expert-photo]').forEach(el => el.classList.add('is-revealed')); document.querySelectorAll('.expert__regalia li').forEach(el => el.classList.add('is-anim')); document.querySelectorAll('.recognize__item').forEach(el => el.classList.add('is-anim')); } /* ----------------------------------- 10c. Method-step active state (light IntersectionObserver) ----------------------------------- */ if (!reduce && 'IntersectionObserver' in window) { const steps = document.querySelectorAll('.method__step'); if (steps.length) { const io = new IntersectionObserver((entries) => { entries.forEach(e => { if (e.isIntersecting) { e.target.classList.add('is-anim'); io.unobserve(e.target); } }); }, { threshold: 0.2 }); steps.forEach(s => io.observe(s)); } } /* ----------------------------------- 10e. Video player (results section) ----------------------------------- */ const vidPlay = document.getElementById('resultVideoPlay'); const vidEl = document.getElementById('resultVideo'); const vidPoster = document.getElementById('resultVideoPoster'); if (vidPlay && vidEl) { vidPlay.addEventListener('click', () => { vidEl.style.display = 'block'; if (vidPoster) vidPoster.style.display = 'none'; vidPlay.style.display = 'none'; const overlay = document.querySelector('.results__video-overlay'); const cap = document.querySelector('.results__video-caption'); if (overlay) overlay.style.display = 'none'; if (cap) cap.style.display = 'none'; vidEl.play(); }); } /* ----------------------------------- 10g. Number counter (stats animations) ----------------------------------- */ if (!reduce && 'IntersectionObserver' in window) { const counters = document.querySelectorAll('.stat strong, .equipment-card__icon'); counters.forEach(c => { const txt = c.textContent.trim(); const match = txt.match(/^(\d+)([+]?)$/); if (!match) return; const target = parseInt(match[1], 10); const suffix = match[2] || ''; if (target < 2) return; const io = new IntersectionObserver((entries, ob) => { entries.forEach(e => { if (!e.isIntersecting) return; ob.unobserve(c); const dur = 1400; const start = performance.now(); c.textContent = '0' + suffix; function tick(now) { const t = Math.min(1, (now - start) / dur); const eased = 1 - Math.pow(1 - t, 3); const v = Math.round(target * eased); c.textContent = v + suffix; if (t < 1) requestAnimationFrame(tick); } requestAnimationFrame(tick); }); }, { threshold: 0.4 }); io.observe(c); }); } /* ----------------------------------- 10h. Smooth body fade-in on first load ----------------------------------- */ document.body.classList.add('is-loaded'); /* ----------------------------------- 10i. Program-cards 3D tilt on cursor (desktop) ----------------------------------- */ if (!reduce && !isTouch) { document.querySelectorAll('.program-card, .equipment-card, .results__quote').forEach(el => { const max = 4; el.addEventListener('mousemove', (e) => { const r = el.getBoundingClientRect(); const x = (e.clientX - r.left) / r.width - 0.5; const y = (e.clientY - r.top) / r.height - 0.5; el.style.transform = `perspective(1200px) rotateY(${x * max}deg) rotateX(${-y * max}deg) translateY(-6px)`; }); el.addEventListener('mouseleave', () => { el.style.transform = ''; }); }); } })(); /* ----------------------------------- 13. Sticky mobile CTA — appear after scroll>600px ----------------------------------- */ (function(){ const cta = document.querySelector('.sticky-cta'); if (!cta) return; document.body.classList.add('has-sticky-cta'); let last = 0; const onScroll = () => { const y = window.scrollY; if (y > 600 && !cta.classList.contains('is-visible')) cta.classList.add('is-visible'); if (y < 400 && cta.classList.contains('is-visible')) cta.classList.remove('is-visible'); last = y; }; window.addEventListener('scroll', onScroll, {passive: true}); onScroll(); })(); /* ----------------------------------- 14. Proof Lightbox — clickable справки ----------------------------------- */ (function(){ const figs = document.querySelectorAll('.proof-figure[data-lightbox]'); if (!figs.length) return; let lb, lbImg, lbCap, lbClose; function ensureLB(){ if (lb) return; lb = document.createElement('div'); lb.className = 'proof-lightbox'; lb.setAttribute('role','dialog'); lb.setAttribute('aria-modal','true'); lb.setAttribute('aria-label','Просмотр справки'); lb.innerHTML = '' + '' + '
'; document.body.appendChild(lb); lbImg = lb.querySelector('.proof-lightbox__img'); lbCap = lb.querySelector('.proof-lightbox__cap'); lbClose = lb.querySelector('.proof-lightbox__close'); const closeLB = () => { lb.classList.remove('is-open'); document.body.style.overflow = ''; }; lbClose.addEventListener('click', closeLB); lb.addEventListener('click', (e) => { if (e.target === lb) closeLB(); }); document.addEventListener('keydown', (e) => { if (e.key === 'Escape' && lb && lb.classList.contains('is-open')) closeLB(); }); } figs.forEach(fig => { fig.setAttribute('role','button'); fig.setAttribute('tabindex','0'); const open = () => { ensureLB(); lbImg.src = fig.dataset.lightbox; lbImg.alt = fig.dataset.cap || ''; lbCap.textContent = fig.dataset.cap || ''; lb.classList.add('is-open'); document.body.style.overflow = 'hidden'; }; fig.addEventListener('click', open); fig.addEventListener('keydown', (e) => { if (e.key === 'Enter' || e.key === ' ') { e.preventDefault(); open(); }}); }); })();