*, *::before, *::after {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    background-color: #020617;
    color: #e2e8f0;
}

.font-playfair {
    font-family: 'Playfair Display', Georgia, serif;
}

.font-inter {
    font-family: 'Inter', system-ui, sans-serif;
}

/* Custom scrollbar */
::-webkit-scrollbar {
    width: 8px;
}
::-webkit-scrollbar-track {
    background: #020617;
}
::-webkit-scrollbar-thumb {
    background: #1e2f3d;
    border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
    background: #0d9488;
}

/* Selection */
::selection {
    background: rgba(13, 148, 136, 0.3);
    color: #f0fdfa;
}

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

/* Scroll reveal animations */
.reveal {
    opacity: 1;
    transform: none;
    transition: opacity 0.6s cubic-bezier(0.22, 1, 0.36, 1), transform 0.6s cubic-bezier(0.22, 1, 0.36, 1);
}

@media (prefers-reduced-motion: no-preference) {
    .reveal {
        opacity: 0;
        transform: translateY(24px);
    }
    .reveal.revealed {
        opacity: 1;
        transform: translateY(0);
    }
    .reveal:nth-child(2) { transition-delay: 0.08s; }
    .reveal:nth-child(3) { transition-delay: 0.16s; }
    .reveal:nth-child(4) { transition-delay: 0.24s; }
}

/* Mobile menu transitions */
#mobile-menu {
    display: none;
}
#mobile-menu.active {
    display: flex;
}
#mobile-menu.opening {
    opacity: 1;
}
#mobile-menu.closing {
    opacity: 0;
}

/* Header scroll state */
#site-header.scrolled {
    box-shadow: 0 1px 0 rgba(255,255,255,0.05);
}

/* Smooth anchor offset */
section[id] {
    scroll-margin-top: 80px;
}

/* Select styling */
select option {
    background: #0f172a;
    color: #e2e8f0;
}

/* Input autofill */
input:-webkit-autofill,
textarea:-webkit-autofill,
select:-webkit-autofill {
    -webkit-box-shadow: 0 0 0 30px #0f172a inset !important;
    -webkit-text-fill-color: #f8fafc !important;
}
</script-file>
<sm-file path="script.js">
(function () {
    'use strict';

    // Header scroll behavior
    const header = document.getElementById('site-header');
    let lastScroll = 0;

    function onScroll() {
        const currentScroll = window.pageYOffset;
        if (currentScroll > 50) {
            header.classList.add('scrolled');
        } else {
            header.classList.remove('scrolled');
        }
        lastScroll = currentScroll;
    }
    window.addEventListener('scroll', onScroll, { passive: true });
    onScroll();

    // Mobile menu
    const menuBtn = document.getElementById('menu-btn');
    const mobileMenu = document.getElementById('mobile-menu');
    const menuIconOpen = document.getElementById('menu-icon-open');
    const menuIconClose = document.getElementById('menu-icon-close');
    let menuOpen = false;

    function openMenu() {
        menuOpen = true;
        mobileMenu.classList.add('active');
        menuIconOpen.classList.add('hidden');
        menuIconClose.classList.remove('hidden');
        menuBtn.setAttribute('aria-expanded', 'true');
        document.body.style.overflow = 'hidden';
        // Force reflow then add open class for transition
        requestAnimationFrame(() => {
            mobileMenu.classList.add('opening');
            mobileMenu.classList.remove('closing');
        });
    }

    function closeMenu() {
        menuOpen = false;
        mobileMenu.classList.remove('opening');
        mobileMenu.classList.add('closing');
        menuBtn.setAttribute('aria-expanded', 'false');
        document.body.style.overflow = '';
        setTimeout(() => {
            mobileMenu.classList.remove('active');
            menuIconOpen.classList.remove('hidden');
            menuIconClose.classList.add('hidden');
        }, 300);
    }

    menuBtn.addEventListener('click', () => {
        menuOpen ? closeMenu() : openMenu();
    });

    // Close menu on link click
    mobileMenu.querySelectorAll('a').forEach(link => {
        link.addEventListener('click', () => {
            if (menuOpen) closeMenu();
        });
    });

    // Close menu on escape
    document.addEventListener('keydown', (e) => {
        if (e.key === 'Escape' && menuOpen) closeMenu();
    });

    // Scroll reveal
    const prefersReducedMotion = window.matchMedia('(prefers-reduced-motion: reduce)').matches;

    if (!prefersReducedMotion && 'IntersectionObserver' in window) {
        const revealObserver = new IntersectionObserver((entries) => {
            entries.forEach(entry => {
                if (entry.isIntersecting) {
                    entry.target.classList.add('revealed');
                    revealObserver.unobserve(entry.target);
                }
            });
        }, {
            threshold: 0.1,
            rootMargin: '0px 0px -40px 0px'
        });

        document.querySelectorAll('.reveal').forEach(el => {
            revealObserver.observe(el);
        });
    } else {
        // If reduced motion or no observer, show everything immediately
        document.querySelectorAll('.reveal').forEach(el => {
            el.classList.add('revealed');
        });
    }

    // Scroll to top button
    const scrollTopBtn = document.getElementById('scroll-top');
    let scrollTimeout;

    window.addEventListener('scroll', () => {
        clearTimeout(scrollTimeout);
        scrollTimeout = setTimeout(() => {
            if (window.pageYOffset > 600) {
                scrollTopBtn.classList.remove('opacity-0', 'translate-y-4', 'pointer-events-none');
                scrollTopBtn.classList.add('opacity-100', 'translate-y-0', 'pointer-events-auto');
            } else {
                scrollTopBtn.classList.add('opacity-0', 'translate-y-4', 'pointer-events-none');
                scrollTopBtn.classList.remove('opacity-100', 'translate-y-0', 'pointer-events-auto');
            }
        }, 100);
    }, { passive: true });

    scrollTopBtn.addEventListener('click', () => {
        window.scrollTo({ top: 0, behavior: 'smooth' });
    });

    // 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 requiredFields = contactForm.querySelectorAll('[required]');
            let valid = true;
            requiredFields.forEach(field => {
                if (!field.value.trim()) {
                    field.classList.add('border-red-500/50');
                    valid = false;
                } else {
                    field.classList.remove('border-red-500/50');
                }
            });

            // Email validation
            const emailField = document.getElementById('email');
            if (emailField.value && !/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(emailField.value)) {
                emailField.classList.add('border-red-500/50');
                valid = false;
            }

            if (valid) {
                contactForm.style.display = 'none';
                formSuccess.classList.remove('hidden');
            }
        });
    }

    // Smooth scroll for all anchor links
    document.querySelectorAll('a[href^="#"]').forEach(anchor => {
        anchor.addEventListener('click', function (e) {
            const targetId = this.getAttribute('href');
            if (targetId === '#') return;
            const target = document.querySelector(targetId);
            if (target) {
                e.preventDefault();
                target.scrollIntoView({ behavior: 'smooth', block: 'start' });
            }
        });
    });
})();
