<div class="image-container custom-cursor">
<a href="/projectes/escola-gem/">
<img src="/wp-content/uploads/2025/06/home.webp" alt="Vestuaris Escola GEM" class="hover-image">
<span class="name-overlay">Vestuaris Escola Gem</span>
</a>
<span class="name-overlay-responsive">Vestuaris Escola Gem</span>
</div>
const hoverImages = document.querySelectorAll('.hover-image');
const offsetDistanceX = 15;
const offsetDistanceY = 0;
hoverImages.forEach(image => {
image.addEventListener('mousemove', e => {
const nameOverlay = image.nextElementSibling;
const boundingRect = image.getBoundingClientRect();
const offsetX = e.clientX - boundingRect.left + window.scrollX + offsetDistanceX;
const offsetY = e.clientY - boundingRect.top + window.scrollY + offsetDistanceY;
nameOverlay.style.left = `${offsetX}px`;
nameOverlay.style.top = `${offsetY}px`;
});
image.addEventListener('mouseenter', () => {
const nameOverlay = image.nextElementSibling;
nameOverlay.classList.add('show');
});
image.addEventListener('mouseleave', () => {
const nameOverlay = image.nextElementSibling;
nameOverlay.classList.remove('show');
});
});
