/* Custom styles for Courteney Selcouth Tattoo */

/* Smooth scrolling */
html {
    scroll-behavior: smooth;
}

/* Scroll reveal base — always visible by default, JS adds animation */
.scroll-reveal {
    opacity: 1;
    transform: none;
}

/* Scroll reveal animation (progressive enhancement) */
@media (prefers-reduced-motion: no-preference) {
    .scroll-reveal.animated {
        animation: fadeSlideUp 0.6s ease forwards;
    }
    .scroll-reveal[data-delay="1"] { animation-delay: 0.1s; }
    .scroll-reveal[data-delay="2"] { animation-delay: 0.2s; }
    .scroll-reveal[data-delay="3"] { animation-delay: 0.3s; }
    .scroll-reveal[data-delay="4"] { animation-delay: 0.4s; }
    .scroll-reveal[data-delay="5"] { animation-delay: 0.5s; }
    .scroll-reveal[data-delay="6"] { animation-delay: 0.6s; }
}

@keyframes fadeSlideUp {
    from {
        opacity: 0;
        transform: translateY(24px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Navbar scroll state */
.navbar-scrolled {
    background: rgba(2, 6, 23, 0.95) !important;
    backdrop-filter: blur(12px);
    box-shadow: 0 1px 0 rgba(255, 255, 255, 0.05);
}

/* Geometric shape decorations */
.geo-diamond {
    position: absolute;
    width: 16px;
    height: 16px;
    background: #14b8a6;
    transform: rotate(45deg);
    opacity: 0.3;
}

/* Custom scrollbar */
::-webkit-scrollbar {
    width: 8px;
}
::-webkit-scrollbar-track {
    background: #0f172a;
}
::-webkit-scrollbar-thumb {
    background: #14b8a6;
    border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
    background: #2dd4bf;
}

/* Focus visible styles */
*:focus-visible {
    outline: 2px solid #14b8a6;
    outline-offset: 2px;
}

/* Mobile menu transition */
#mobile-menu {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
}
#mobile-menu.open {
    max-height: 300px;
}

/* Service card hover glow */
.group:hover .group-hover\:scale-110 {
    transform: scale(1.1);
}
</style>
<sm-file path="script.js">
(function () {
    'use strict';

    // ── Navbar scroll behavior ──
    const navbar = document.getElementById('navbar');
    let lastScroll = 0;

    function handleNavbarScroll() {
        const currentScroll = window.pageYOffset;
        if (currentScroll > 60) {
            navbar.classList.add('navbar-scrolled');
        } else {
            navbar.classList.remove('navbar-scrolled');
        }
        lastScroll = currentScroll;
    }

    window.addEventListener('scroll', handleNavbarScroll, { passive: true });

    // ── Mobile menu toggle ──
    const menuBtn = document.getElementById('mobile-menu-btn');
    const mobileMenu = document.getElementById('mobile-menu');

    menuBtn.addEventListener('click', function () {
        const isOpen = mobileMenu.classList.toggle('open');
        menuBtn.setAttribute('aria-expanded', isOpen);
    });

    // Close mobile menu on link click
    document.querySelectorAll('.mobile-link').forEach(function (link) {
        link.addEventListener('click', function () {
            mobileMenu.classList.remove('open');
            menuBtn.setAttribute('aria-expanded', 'false');
        });
    });

    // ── Scroll reveal (progressive enhancement) ──
    // Only animate if user prefers motion and JS is running
    const prefersReducedMotion = window.matchMedia('(prefers-reduced-motion: reduce)').matches;

    if (!prefersReducedMotion) {
        const revealElements = document.querySelectorAll('.scroll-reveal');

        function revealOnScroll() {
            const windowHeight = window.innerHeight;
            revealElements.forEach(function (el, index) {
                const elementTop = el.getBoundingClientRect().top;
                const revealPoint = 100;

                if (elementTop < windowHeight - revealPoint) {
                    el.classList.add('animated');
                    el.dataset.delay = (index % 6);
                }
            });
        }

        // Run on load and scroll
        window.addEventListener('scroll', revealOnScroll, { passive: true });
        revealOnScroll(); // Check on initial load
    }

    // ── Contact form ──
    const contactForm = document.getElementById('contact-form');
    const formSuccess = document.getElementById('form-success');

    if (contactForm) {
        contactForm.addEventListener('submit', function (e) {
            e.preventDefault();

            // Basic validation
            const name = document.getElementById('name').value.trim();
            const email = document.getElementById('email').value.trim();
            const message = document.getElementById('message').value.trim();

            if (!name || !email || !message) {
                return;
            }

            // Show success
            formSuccess.classList.remove('hidden');
            contactForm.reset();

            // Hide success after 5 seconds
            setTimeout(function () {
                formSuccess.classList.add('hidden');
            }, 5000);
        });
    }

    // ── Smooth scroll for anchor links ──
    document.querySelectorAll('a[href^="#"]').forEach(function (anchor) {
        anchor.addEventListener('click', function (e) {
            const targetId = anchor.getAttribute('href');
            if (targetId === '#') return;

            const target = document.querySelector(targetId);
            if (target) {
                e.preventDefault();
                const navHeight = navbar.offsetHeight;
                const targetPosition = target.getBoundingClientRect().top + window.pageYOffset - navHeight - 20;

                window.scrollTo({
                    top: targetPosition,
                    behavior: 'smooth'
                });
            }
        });
    });
})();
</style>
