/* Custom styles for Brian Cross Real Estate site */

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

/* Geometric shapes in hero */
.geo {
    position: absolute;
    opacity: 0.12;
    pointer-events: none;
}

.geo-1 {
    top: 10%;
    left: 5%;
    width: 120px;
    height: 120px;
    background: #fbbf24;
    border-radius: 24px;
    transform: rotate(45deg);
    animation: float-slow 8s ease-in-out infinite;
}

.geo-2 {
    top: 25%;
    right: 10%;
    width: 80px;
    height: 80px;
    background: #a855f7;
    border-radius: 50%;
    animation: float-medium 6s ease-in-out infinite;
}

.geo-3 {
    bottom: 20%;
    left: 15%;
    width: 60px;
    height: 60px;
    background: #fbbf24;
    clip-path: polygon(50% 0%, 0% 100%, 100% 100%);
    animation: float-slow 7s ease-in-out infinite reverse;
}

.geo-4 {
    top: 60%;
    right: 5%;
    width: 100px;
    height: 100px;
    border: 3px solid rgba(251, 191, 36, 0.3);
    border-radius: 20px;
    transform: rotate(30deg);
    animation: float-medium 9s ease-in-out infinite;
}

.geo-5 {
    top: 5%;
    left: 40%;
    width: 50px;
    height: 50px;
    background: rgba(168, 85, 247, 0.4);
    border-radius: 12px;
    transform: rotate(60deg);
    animation: float-slow 5s ease-in-out infinite;
}

.geo-6 {
    bottom: 10%;
    right: 25%;
    width: 40px;
    height: 40px;
    background: #fbbf24;
    border-radius: 50%;
    animation: float-medium 4s ease-in-out infinite reverse;
}

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

@keyframes float-medium {
    0%, 100% { transform: translateY(0px); }
    50% { transform: translateY(-15px); }
}

/* Navbar scroll effect */
#site-header.scrolled {
    background: rgba(59, 7, 100, 0.95);
    backdrop-filter: blur(12px);
    box-shadow: 0 4px 30px rgba(0, 0, 0, 0.2);
}

/* Service cards */
.service-card {
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

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

/* Area cards */
.area-card {
    transition: transform 0.3s ease;
}

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

/* Scroll reveal animations */
.reveal {
    opacity: 1;
    transform: translateY(0);
    transition: opacity 0.6s ease, transform 0.6s ease;
}

.reveal.revealed {
    opacity: 1;
    transform: translateY(0);
}

@media (prefers-reduced-motion: no-preference) {
    .reveal {
        opacity: 0;
        transform: translateY(30px);
    }
    .reveal.revealed {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Custom scrollbar */
::-webkit-scrollbar {
    width: 8px;
}
::-webkit-scrollbar-track {
    background: #3b0764;
}
::-webkit-scrollbar-thumb {
    background: #a855f7;
    border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
    background: #c084fc;
}

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

<sm-file path="script.js">
// Mobile menu toggle
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');
const mobileLinks = document.querySelectorAll('.mobile-link');

menuBtn.addEventListener('click', () => {
    const isOpen = !mobileMenu.classList.contains('hidden');
    mobileMenu.classList.toggle('hidden');
    menuIconOpen.classList.toggle('hidden');
    menuIconClose.classList.toggle('hidden');
});

mobileLinks.forEach(link => {
    link.addEventListener('click', () => {
        mobileMenu.classList.add('hidden');
        menuIconOpen.classList.remove('hidden');
        menuIconClose.classList.add('hidden');
    });
});

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

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

// Scroll reveal (progressive enhancement — only when JS runs)
if (window.matchMedia('(prefers-reduced-motion: no-preference)').matches) {
    const revealElements = document.querySelectorAll('.reveal');
    const observer = new IntersectionObserver((entries) => {
        entries.forEach(entry => {
            if (entry.isIntersecting) {
                entry.target.classList.add('revealed');
                observer.unobserve(entry.target);
            }
        });
    }, {
        threshold: 0.1,
        rootMargin: '0px 0px -50px 0px'
    });

    revealElements.forEach(el => observer.observe(el));
}

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

contactForm.addEventListener('submit', (e) => {
    e.preventDefault();

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

    if (!firstName || !email) {
        return;
    }

    // Show success
    contactForm.style.display = 'none';
    formSuccess.classList.remove('hidden');
});

// Active nav link highlighting
const sections = document.querySelectorAll('section[id]');
const navLinks = document.querySelectorAll('nav a[href^="#"]');

window.addEventListener('scroll', () => {
    let current = '';
    sections.forEach(section => {
        const sectionTop = section.offsetTop - 100;
        if (window.pageYOffset >= sectionTop) {
            current = section.getAttribute('id');
        }
    });

    navLinks.forEach(link => {
        link.classList.remove('text-amber-400');
        if (link.getAttribute('href') === `#${current}`) {
            link.classList.add('text-amber-400');
        }
    });
}, { passive: true });
