// Data and Logic merged for local browser compatibility (No-Module version)

const barMenu = [
    { name: "Old Fire Mojito", description: "Our signature blend of aged Cuban rum, hand-torn garden mint, and a house-made 'fire-starter' spice syrup.", price: "£11.50" },
    { name: "Havana Nights", description: "A dark, soulful mix of Havana Club 7, vanilla-infused passion fruit, and a whisper of fresh lime.", price: "£10.50" },
    { name: "Persian Rose Petal", description: "A sophisticated fusion of premium gin, organic rose water, and freshly crushed pomegranate seeds.", price: "£11.00" },
    { name: "Smoked Mezcalita", description: "Artisanal Mezcal balanced with agave nectar and finished with a rim of smoked Himalayan sea salt.", price: "£12.50" }
];

const restaurantMenu = [
    { name: "Mirza Ghassemi", description: "Wood-smoked aubergine confit with vine-ripened tomatoes, organic eggs, and slow-roasted garlic.", price: "£7.50" },
    { name: "Kabab-e Barg", description: "The crown jewel: tender lamb fillet skewers, marinated in saffron and charcoal-grilled to perfection.", price: "£18.50" },
    { name: "Fesenjan", description: "A rich, ancient stew of slow-cooked chicken leg in a velvet sauce of ground walnuts and pomegranate molasses.", price: "£16.50" },
    { name: "Bastani Sonati", description: "Traditional saffron ice cream infused with rose water, topped with frozen clotted cream and pistachios.", price: "£6.50" }
];

const galleryImages = [
    { src: "./interior_dining.png", alt: "The Interior Lounge" },
    { src: "./cocktails_bar.png", alt: "Cuban Bar Mixology" },
    { src: "./menu_highlight.png", alt: "Persian Kabab Platter" },
    { src: "./patio_awards.jpg", alt: "The Garden Patio" },
    { src: "./plate_kabab.png", alt: "Authentic Persian Chips and Kabab" },
    { src: "./hero_exterior.png", alt: "Historic 1897 Building" }
];

const reviews = [
    { name: "Sam E", text: "The meat is just so tender and juicy. The chicken and lamb kebabs were awesome and really hit the spot. the freshly baked bread was really nice and different especially with the wild garlicky yoghurt.", stars: 5 },
    { name: "Joe Mulreany", text: "Lovely place to have dinner and some shisha", stars: 5 },
    { name: "Hasan Iqbal", text: "A good selection of Persian food (halal), good service too. Can relax at the shisha place downstairs too", stars: 5 }
];

document.addEventListener('DOMContentLoaded', () => {
    document.body.classList.add('js-enabled');
    initMenu('bar');
    initReviews();
    initGallery();
    initScrollAnimations();
    initBookingForm();
    initNavbar();
});

function initMenu(type) {
    const menuContainer = document.getElementById('menu-content');
    const items = type === 'bar' ? barMenu : restaurantMenu;
    if(!menuContainer) return;

    menuContainer.innerHTML = '';
    items.forEach(item => {
        const card = document.createElement('div');
        card.className = 'menu-card fade-in';
        card.innerHTML = `
            <div class="menu-item-info">
                <h3>${item.name}</h3>
                <p>${item.description}</p>
            </div>
            <div class="menu-item-price">${item.price}</div>
        `;
        menuContainer.appendChild(card);
    });

    document.querySelectorAll('.tab-btn').forEach(btn => {
        btn.classList.toggle('active', btn.dataset.tab === type);
    });

    if(observer) {
        document.querySelectorAll('.menu-card').forEach(el => observer.observe(el));
    }
}

function initReviews() {
    const container = document.getElementById('reviews-container');
    if (!container) return;

    reviews.forEach(review => {
        const div = document.createElement('div');
        div.className = 'review-card fade-in';
        const stars = Array(review.stars).fill('★').join('');
        div.innerHTML = `
            <div class="stars text-gold">${stars}</div>
            <p class="review-text">"${review.text}"</p>
            <p class="review-author text-gold">— ${review.name}</p>
        `;
        container.appendChild(div);
    });
}

function initGallery() {
    const galleryContainer = document.getElementById('gallery-container');
    if(!galleryContainer) return;
    galleryImages.forEach(img => {
        const item = document.createElement('div');
        item.className = 'gallery-item fade-in';
        item.innerHTML = `<img src="${img.src}" alt="${img.alt}">`;
        galleryContainer.appendChild(item);
    });
}

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

    document.querySelectorAll('.fade-in, section').forEach(el => observer.observe(el));
}

function initBookingForm() {
    const form = document.getElementById('booking-form');
    if (!form) return;
    form.addEventListener('submit', (e) => {
        e.preventDefault();
        const btn = form.querySelector('button');
        btn.innerText = 'Transmitting...';
        btn.disabled = true;
        setTimeout(() => {
            alert(`Reserved. Thank you. We will confirm your request shortly.`);
            form.reset();
            btn.innerText = 'Confirm Booking Inquiry';
            btn.disabled = false;
        }, 1500);
    });
}

function initNavbar() {
    const navbar = document.getElementById('navbar');
    window.addEventListener('scroll', () => {
        if (window.scrollY > 100) navbar.classList.add('scrolled');
        else navbar.classList.remove('scrolled');
    });
}

document.querySelectorAll('.tab-btn').forEach(btn => {
    btn.addEventListener('click', () => initMenu(btn.dataset.tab));
});
