/* Lamont Motel — Custom Styles */

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

/* Custom scrollbar */
::-webkit-scrollbar {
    width: 8px;
}
::-webkit-scrollbar-track {
    background: #f5f1e8;
}
::-webkit-scrollbar-thumb {
    background: #9cc79a;
    border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
    background: #72ab6e;
}

/* Room card hover effect */
.room-card {
    transform: translateY(0);
}
.room-card:hover {
    transform: translateY(-4px);
}

/* Navbar scroll state */
.nav-scrolled {
    background: rgba(253, 252, 248, 0.95) !important;
    backdrop-filter: blur(12px);
    box-shadow: 0 1px 20px rgba(45, 86, 44, 0.08);
}

/* Mobile menu animation */
#mobile-menu {
    animation: slideDown 0.3s ease-out;
}
@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

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

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

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
    html {
        scroll-behavior: auto;
    }
    .reveal {
        opacity: 1;
        transform: none;
        transition: none;
    }
    .room-card:hover {
        transform: none;
    }
    img {
        transition: none;
    }
}

/* Focus styles for accessibility */
a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
    outline: 2px solid #72ab6e;
    outline-offset: 2px;
    border-radius: 4px;
}

/* Date input styling */
input[type="date"] {
    color: #2d562c;
}
input[type="date"]::-webkit-calendar-picker-indicator {
    filter: invert(35%) sepia(30%) saturate(400%) hue-rotate(95deg);
    cursor: pointer;
}
</style>
<sm-file path="script.js">
// Lamont Motel — Interactive Scripts

document.addEventListener('DOMContentLoaded', function () {

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

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

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

    // ── 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');
    let menuOpen = false;

    menuBtn.addEventListener('click', function () {
        menuOpen = !menuOpen;
        mobileMenu.classList.toggle('hidden', !menuOpen);
        menuIconOpen.classList.toggle('hidden', menuOpen);
        menuIconClose.classList.toggle('hidden', !menuOpen);
    });

    // Close mobile menu on link click
    document.querySelectorAll('.mobile-link').forEach(function (link) {
        link.addEventListener('click', function () {
            menuOpen = false;
            mobileMenu.classList.add('hidden');
            menuIconOpen.classList.remove('hidden');
            menuIconClose.classList.add('hidden');
        });
    });

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

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

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

        revealElements.forEach(function (el) {
            revealObserver.observe(el);
        });
    }

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

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

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

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

            // Simulate submission
            contactForm.style.opacity = '0.5';
            contactForm.style.pointerEvents = 'none';

            setTimeout(function () {
                contactForm.classList.add('hidden');
                formSuccess.classList.remove('hidden');
                formSuccess.classList.add('animate-fade-in');
            }, 800);
        });
    }

    // ── Set minimum date for check-in to today ─────────────────────────────
    const checkinInput = document.getElementById('checkin');
    if (checkinInput) {
        const today = new Date();
        const yyyy = today.getFullYear();
        const mm = String(today.getMonth() + 1).padStart(2, '0');
        const dd = String(today.getDate()).padStart(2, '0');
        checkinInput.setAttribute('min', yyyy + '-' + mm + '-' + dd);
    }

    // ── 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 - 20;

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

});
