/* Custom styles — overrides and enhancements */

/* Ensure hero content is visible immediately */
#hero h1,
#hero p,
#hero a,
#hero .inline-flex,
#hero .grid {
    opacity: 1 !important;
    transform: none !important;
}

/* Smooth focus outlines */
*:focus-visible {
    outline: 2px solid #C0563A;
    outline-offset: 2px;
}

/* Subtle pattern overlay for sections */
.bg-pattern {
    background-image: radial-gradient(circle, rgba(192, 86, 58, 0.05) 1px, transparent 1px);
    background-size: 20px 20px;
}

/* Button hover lift */
a[href="tel:+15094707161"] {
    will-change: transform;
}

a[href="tel:+15094707161"]:hover {
    transform: translateY(-1px);
}

/* Mobile menu animation */
#bar1 { transition: transform 0.3s ease; }
#bar2 { transition: opacity 0.3s ease; }
#bar3 { transition: width 0.3s ease; }

#menu-toggle.active #bar1 {
    transform: translateY(6px) rotate(45deg);
}
#menu-toggle.active #bar2 {
    opacity: 0;
}
#menu-toggle.active #bar3 {
    width: 24px;
}

/* Nav scroll state */
nav.scrolled {
    box-shadow: 0 1px 8px rgba(0,0,0,0.08);
}

/* Selection color */
::selection {
    background: #C0563A;
    color: white;
}
</style>

<sm-file path="script.js">
(function () {
    'use strict';

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

    if (menuToggle && mobileMenu) {
        menuToggle.addEventListener('click', function () {
            menuToggle.classList.toggle('active');
            mobileMenu.classList.toggle('open');
        });

        // Close menu when a link is clicked
        mobileMenu.querySelectorAll('a').forEach(function (link) {
            link.addEventListener('click', function () {
                menuToggle.classList.remove('active');
                mobileMenu.classList.remove('open');
            });
        });
    }

    // Navbar scroll shadow
    const nav = document.querySelector('nav');
    if (nav) {
        window.addEventListener('scroll', function () {
            if (window.scrollY > 10) {
                nav.classList.add('scrolled');
            } else {
                nav.classList.remove('scrolled');
            }
        }, { passive: true });
    }

    // Scroll reveal (below-fold only — progressive enhancement)
    const prefersReducedMotion = window.matchMedia('(prefers-reduced-motion: reduce)').matches;

    if (!prefersReducedMotion && 'IntersectionObserver' in window) {
        const revealElements = document.querySelectorAll('.reveal');

        const observer = new IntersectionObserver(function (entries) {
            entries.forEach(function (entry) {
                if (entry.isIntersecting) {
                    entry.target.classList.add('visible');
                    observer.unobserve(entry.target);
                }
            });
        }, {
            threshold: 0.1,
            rootMargin: '0px 0px -40px 0px'
        });

        revealElements.forEach(function (el) {
            observer.observe(el);
        });
    } else {
        // If JS is disabled or motion is reduced, ensure all elements are visible
        document.querySelectorAll('.reveal').forEach(function (el) {
            el.classList.add('visible');
        });
    }

    // Contact form
    const form = document.getElementById('contact-form');
    const successMsg = document.getElementById('form-success');

    if (form && successMsg) {
        form.addEventListener('submit', function (e) {
            e.preventDefault();
            form.style.display = 'none';
            successMsg.classList.remove('hidden');
        });
    }
})();
</style>
