/* ─── Custom Properties ─── */
:root {
    --midnight-950: #020814;
    --midnight-900: #0a1628;
    --midnight-800: #0f2136;
    --mint-400: #5eead4;
    --mint-500: #34d399;
    --mint-300: #6ee7b7;
}

/* ─── Base ─── */
* { box-sizing: border-box; }

body {
    font-family: 'Lora', Georgia, serif;
    background-color: var(--midnight-950);
    color: #fff;
    overflow-x: hidden;
}

.font-playfair { font-family: 'Playfair Display', Georgia, serif; }
.font-lora { font-family: 'Lora', Georgia, serif; }
.font-cormorand { font-family: 'Cormorant Garamond', Georgia, serif; }

/* ─── Hero Gradient ─── */
.hero-gradient {
    background: radial-gradient(ellipse at 30% 50%, #0f2136 0%, transparent 60%),
                radial-gradient(ellipse at 70% 50%, #0a2a25 0%, transparent 50%),
                radial-gradient(ellipse at 50% 80%, #0d3b30 0%, transparent 40%),
                linear-gradient(180deg, var(--midnight-950) 0%, #050d1a 50%, var(--midnight-950) 100%);
}

/* ─── Hero Pattern ─── */
.hero-pattern {
    background-image: radial-gradient(circle, rgba(94, 234, 212, 0.08) 1px, transparent 1px);
    background-size: 40px 40px;
}

/* ─── Hero Glows ─── */
.hero-glow-1 { background: radial-gradient(circle, rgba(94, 234, 212, 0.3), transparent 70%); top: 10%; left: -10%; }
.hero-glow-2 { background: radial-gradient(circle, rgba(52, 211, 153, 0.2), transparent 70%); bottom: 10%; right: -5%; }
.hero-glow-3 { background: radial-gradient(circle, rgba(110, 231, 183, 0.15), transparent 70%); top: 50%; left: 50%; transform: translate(-50%, -50%); }

/* ─── Hero Animations ─── */
@keyframes float {
    0%, 100% { transform: translateY(0) rotate(0deg); }
    50% { transform: translateY(-15px) rotate(3deg); }
}

@keyframes float-reverse {
    0%, 100% { transform: translateY(0) rotate(45deg); }
    50% { transform: translateY(12px) rotate(42deg); }
}

@keyframes pulse-glow {
    0%, 100% { opacity: 0.4; transform: scale(1); }
    50% { opacity: 0.8; transform: scale(1.1); }
}

.hero-badge { animation: heroFadeUp 0.8s ease forwards 0.2s; }
.hero-title { animation: heroFadeUp 0.9s ease forwards 0.4s; }
.hero-subtitle { animation: heroFadeUp 0.9s ease forwards 0.6s; }
.hero-ctas { animation: heroFadeUp 0.9s ease forwards 0.8s; }
.hero-scroll { animation: heroFadeUp 0.9s ease forwards 1.2s; }

.hero-ornament-1 { animation: float 6s ease-in-out infinite; }
.hero-ornament-2 { animation: float-reverse 8s ease-in-out infinite; }
.hero-ornament-3 { animation: pulse-glow 4s ease-in-out infinite; }
.hero-ornament-4 { animation: pulse-glow 5s ease-in-out infinite 1s; }

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

.hero-scroll-line {
    animation: scrollLine 2s ease-in-out infinite;
}

@keyframes scrollLine {
    0% { opacity: 0; transform: scaleY(0); transform-origin: top; }
    50% { opacity: 1; transform: scaleY(1); transform-origin: top; }
    51% { transform-origin: bottom; }
    100% { opacity: 0; transform: scaleY(0); transform-origin: bottom; }
}

/* ─── Buttons ─── */
.btn-primary {
    position: relative;
    overflow: hidden;
}

.btn-primary::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.15), transparent);
    transition: left 0.5s ease;
}

.btn-primary:hover::before { left: 100%; }

.btn-secondary::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(94, 234, 212, 0.05), transparent);
    transition: left 0.5s ease;
}

.btn-secondary:hover::before { left: 100%; }

/* ─── Service Cards ─── */
.service-card {
    transition: transform 0.4s ease, border-color 0.4s ease, box-shadow 0.4s ease;
}

.service-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 20px 60px rgba(94, 234, 212, 0.06);
}

/* ─── Testimonial Cards ─── */
.testimonial-card {
    transition: transform 0.4s ease, border-color 0.4s ease;
}

.testimonial-card:hover {
    transform: translateY(-4px);
}

/* ─── Gallery ─── */
.gallery-item {
    overflow: hidden;
    border-radius: 0;
}

.gallery-item img {
    transition: transform 0.7s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.gallery-item:hover img {
    transform: scale(1.08);
}

/* ─── Navbar ─── */
.nav-scrolled {
    background: rgba(2, 8, 20, 0.92) !important;
    backdrop-filter: blur(20px);
    border-bottom: 1px solid rgba(94, 234, 212, 0.08);
}

/* ─── Mobile Menu ─── */
.mobile-menu-open #mobile-menu {
    opacity: 1 !important;
    pointer-events: all !important;
}

.mobile-menu-open .menu-line:nth-child(1) {
    transform: rotate(45deg) translate(5px, 5px);
}

.mobile-menu-open .menu-line:nth-child(2) {
    opacity: 0;
}

.mobile-menu-open .menu-line:nth-child(3) {
    width: 6rem;
    transform: rotate(-45deg) translate(5px, -5px);
}

.mobile-link {
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.4s ease, transform 0.4s ease, color 0.3s ease;
}

.mobile-menu-open .mobile-link {
    opacity: 1;
    transform: translateY(0);
}

.mobile-menu-open .mobile-link:nth-child(1) { transition-delay: 0.1s; }
.mobile-menu-open .mobile-link:nth-child(2) { transition-delay: 0.15s; }
.mobile-menu-open .mobile-link:nth-child(3) { transition-delay: 0.2s; }
.mobile-menu-open .mobile-link:nth-child(4) { transition-delay: 0.25s; }
.mobile-menu-open .mobile-link:nth-child(5) { transition-delay: 0.3s; }

/* ─── Back to Top ─── */
#back-to-top {
    transition: opacity 0.3s ease, transform 0.3s ease;
}

#back-to-top.show {
    opacity: 1;
    pointer-events: all;
}

#back-to-top:hover {
    transform: translateY(-2px);
}

/* ─── Decorative Divider ─── */
.divider-mint {
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(94, 234, 212, 0.3), transparent);
}

/* ─── Scrollbar ─── */
::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-track { background: var(--midnight-950); }
::-webkit-scrollbar-thumb { background: rgba(94, 234, 212, 0.2); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: rgba(94, 234, 212, 0.4); }

/* ─── Selection ─── */
::selection {
    background: rgba(94, 234, 212, 0.2);
    color: var(--mint-400);
}
</style>

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

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

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

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

    // ─── Mobile menu ───
    const menuBtn = document.getElementById('menu-btn');
    const mobileMenu = document.getElementById('mobile-menu');
    const mobileLinks = document.querySelectorAll('.mobile-link');
    let menuOpen = false;

    menuBtn.addEventListener('click', function () {
        menuOpen = !menuOpen;
        document.body.classList.toggle('mobile-menu-open', menuOpen);
        menuBtn.setAttribute('aria-expanded', menuOpen);
    });

    mobileLinks.forEach(function (link) {
        link.addEventListener('click', function () {
            menuOpen = false;
            document.body.classList.remove('mobile-menu-open');
            menuBtn.setAttribute('aria-expanded', 'false');
        });
    });

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

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

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

        revealElements.forEach(function (el) {
            revealObserver.observe(el);
        });
    } else {
        document.querySelectorAll('.reveal').forEach(function (el) {
            el.classList.add('visible');
        });
    }

    // ─── Back to top ───
    const backToTop = document.getElementById('back-to-top');

    window.addEventListener('scroll', function () {
        if (window.pageYOffset > 600) {
            backToTop.classList.add('show');
        } else {
            backToTop.classList.remove('show');
        }
    }, { passive: true });

    backToTop.addEventListener('click', function () {
        window.scrollTo({ top: 0, behavior: 'smooth' });
    });

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

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

            const formData = new FormData(form);
            const data = {};
            formData.forEach(function (value, key) { data[key] = value; });

            if (data.name && data.email) {
                form.querySelectorAll('button[type="submit"]').forEach(function (btn) {
                    btn.disabled = true;
                    btn.innerHTML = '<svg class="w-5 h-5 animate-spin" fill="none" viewBox="0 0 24 24"><circle class="opacity-25" cx="12" cy="12" r="10" stroke="currentColor" stroke-width="4"></circle><path class="opacity-75" fill="currentColor" d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"></path></svg> Sending...';
                });

                setTimeout(function () {
                    form.reset();
                    formSuccess.classList.remove('hidden');
                    form.querySelectorAll('button[type="submit"]').forEach(function (btn) {
                        btn.disabled = false;
                        btn.innerHTML = '<svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="1.5" d="M12 19l9 2-9-18-9 18 9-2zm0 0v-8"/></svg> Send Request';
                    });

                    setTimeout(function () {
                        formSuccess.classList.add('hidden');
                    }, 5000);
                }, 1200);
            }
        });
    }

    // ─── Smooth scroll for anchor links ───
    document.querySelectorAll('a[href^="#"]').forEach(function (anchor) {
        anchor.addEventListener('click', function (e) {
            const targetId = this.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;

                window.scrollTo({
                    top: targetPosition,
                    behavior: 'smooth'
                });
            }
        });
    });

    // ─── Hero ornament visibility ───
    document.querySelectorAll('.hero-ornament').forEach(function (el) {
        el.style.opacity = '1';
    });
})();
</script>
