/* Custom styles for Krispy Donut */

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

/* Custom scrollbar */
::-webkit-scrollbar {
    width: 8px;
}
::-webkit-scrollbar-track {
    background: #500724;
}
::-webkit-scrollbar-thumb {
    background: #fbbf24;
    border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
    background: #fcd34d;
}

/* Selection color */
::selection {
    background: #fbbf24;
    color: #500724;
}

/* Navbar scroll state */
.navbar-scrolled {
    background: rgba(48, 5, 22, 0.95) !important;
    backdrop-filter: blur(20px);
    box-shadow: 0 4px 30px rgba(0, 0, 0, 0.3);
}

.navbar-transparent {
    background: transparent !important;
}

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

.mobile-menu-close .mobile-menu-line:nth-child(1) {
    transform: rotate(45deg) translate(5px, 5px);
}
.mobile-menu-close .mobile-menu-line:nth-child(2) {
    opacity: 0;
}
.mobile-menu-close .mobile-menu-line:nth-child(3) {
    transform: rotate(-45deg) translate(5px, -5px);
}

/* Menu card hover */
.menu-card {
    transform: translateY(0);
}

/* Gallery item hover */
.gallery-item {
    cursor: pointer;
}

/* Testimonial card */
.testimonial-card {
    position: relative;
}
.testimonial-card::before {
    content: '"';
    position: absolute;
    top: -10px;
    left: 20px;
    font-family: 'Playfair Display', serif;
    font-size: 6rem;
    color: #fbbf24;
    opacity: 0.15;
    line-height: 1;
}

/* Scroll reveal (progressive enhancement) */
@media (prefers-reduced-motion: no-preference) {
    .reveal {
        opacity: 0;
        transform: translateY(30px);
        transition: opacity 0.8s ease, transform 0.8s ease;
    }
    .reveal.revealed {
        opacity: 1;
        transform: translateY(0);
    }
    .reveal-delay-1 { transition-delay: 0.1s; }
    .reveal-delay-2 { transition-delay: 0.2s; }
    .reveal-delay-3 { transition-delay: 0.3s; }
    .reveal-delay-4 { transition-delay: 0.4s; }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
    html {
        scroll-behavior: auto;
    }
    .reveal {
        opacity: 1 !important;
        transform: none !important;
    }
}

/* Form styles */
.contact-form input,
.contact-form textarea {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.15);
    color: white;
    transition: border-color 0.3s ease, background 0.3s ease;
}
.contact-form input:focus,
.contact-form textarea:focus {
    outline: none;
    border-color: #fbbf24;
    background: rgba(255, 255, 255, 0.08);
}
.contact-form input::placeholder,
.contact-form textarea::placeholder {
    color: rgba(253, 244, 248, 0.4);
}

/* Success message */
.form-success {
    animation: fadeInUp 0.5s ease forwards;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}
</style>

<sm-file path="script.js">
// Navbar scroll behavior
const navbar = document.getElementById('navbar');
const navLogoText = document.getElementById('nav-logo-text');

function updateNavbar() {
    if (window.scrollY > 80) {
        navbar.classList.add('navbar-scrolled');
        navbar.classList.remove('navbar-transparent');
    } else {
        navbar.classList.remove('navbar-scrolled');
        navbar.classList.add('navbar-transparent');
    }
}

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

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

mobileMenuBtn.addEventListener('click', () => {
    isMenuOpen = !isMenuOpen;
    if (isMenuOpen) {
        mobileMenu.classList.add('mobile-menu-open');
        mobileMenuBtn.classList.add('mobile-menu-close');
        document.body.style.overflow = 'hidden';
    } else {
        mobileMenu.classList.remove('mobile-menu-open');
        mobileMenuBtn.classList.remove('mobile-menu-close');
        document.body.style.overflow = '';
    }
});

mobileLinks.forEach(link => {
    link.addEventListener('click', () => {
        isMenuOpen = false;
        mobileMenu.classList.remove('mobile-menu-open');
        mobileMenuBtn.classList.remove('mobile-menu-close');
        document.body.style.overflow = '';
    });
});

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

if (!prefersReducedMotion) {
    const revealElements = document.querySelectorAll('.reveal');
    
    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 -50px 0px'
    });

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

// Contact form handling
const contactForm = document.getElementById('contact-form');
if (contactForm) {
    contactForm.addEventListener('submit', function(e) {
        e.preventDefault();
        
        const formData = new FormData(this);
        const successMsg = document.getElementById('form-success');
        
        // Simulate form submission
        const submitBtn = this.querySelector('button[type="submit"]');
        const originalText = submitBtn.textContent;
        submitBtn.textContent = 'Sending...';
        submitBtn.disabled = true;
        
        setTimeout(() => {
            this.style.display = 'none';
            successMsg.classList.remove('hidden');
            successMsg.classList.add('form-success');
            submitBtn.textContent = originalText;
            submitBtn.disabled = false;
        }, 1000);
    });
}

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

function highlightNav() {
    const scrollY = window.scrollY + 100;
    
    sections.forEach(section => {
        const sectionTop = section.offsetTop;
        const sectionHeight = section.offsetHeight;
        const sectionId = section.getAttribute('id');
        
        if (scrollY >= sectionTop && scrollY < sectionTop + sectionHeight) {
            navLinks.forEach(link => {
                link.classList.remove('text-amber-600');
                if (link.getAttribute('href') === `#${sectionId}`) {
                    link.classList.add('text-amber-600');
                }
            });
        }
    });
}

window.addEventListener('scroll', highlightNav, { passive: true });
highlightNav();
</script>
