@import url('https://fonts.googleapis.com/css2?family=Sarabun:wght@300;400;600&family=Mitr:wght@400;600&display=swap');

:root {
    --primary-color: #ff6b6b; /* สีส้มแดง กระตุ้นความหิว */
    --secondary-color: #ffe66d;
    --dark-color: #2d3436;
    --light-color: #f9f9f9;
    --shadow: 0 4px 6px rgba(0,0,0,0.1);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Sarabun', sans-serif;
    background-color: #f0f2f5;
    color: var(--dark-color);
    line-height: 1.6;
}

/* --- Header & Navbar --- */
header {
    background-color: #fff;
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
    position: sticky;
    top: 0;
    z-index: 1000;
}

nav {
    max-width: 1200px;
    margin: 0 auto;
    padding: 1rem 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap; /* สำคัญ: ให้องค์ประกอบตกบรรทัดได้ใน Mobile */
}

.logo {
    font-family: 'Mitr', sans-serif;
    font-size: 1.5rem;
    color: var(--primary-color);
    text-decoration: none;
    font-weight: bold;
    display: flex;
    align-items: center;
}

.logo span {
    color: var(--dark-color);
    margin-left: 5px;
}

/* --- Hamburger Menu Style --- */
.hamburger {
    display: none; /* ซ่อนใน Desktop */
    flex-direction: column;
    cursor: pointer;
    gap: 5px;
}

.hamburger span {
    width: 25px;
    height: 3px;
    background-color: var(--dark-color);
    border-radius: 2px;
    transition: all 0.3s;
}

/* Animation for Hamburger (Optional) */
.hamburger:hover span {
    background-color: var(--primary-color);
}

/* --- Navigation Links --- */
.nav-links {
    display: flex;
    gap: 20px;
    list-style: none;
}

.nav-links a {
    text-decoration: none;
    color: var(--dark-color);
    font-weight: 500;
    transition: color 0.3s;
}

.nav-links a:hover {
    color: var(--primary-color);
}

/* --- Search Bar --- */
.search-container {
    /* ใน Desktop ให้แสดงปกติ */
    width: auto;
}

#searchInput {
    padding: 8px 15px;
    border: 2px solid #eee;
    border-radius: 20px;
    width: 100%;
    max-width: 300px;
    font-family: 'Sarabun', sans-serif;
    transition: border-color 0.3s;
}

#searchInput:focus {
    outline: none;
    border-color: var(--primary-color);
}

/* --- Responsive Navbar (Mobile) --- */
@media (max-width: 768px) {
    .hamburger {
        display: flex; /* แสดงปุ่ม Hamburger */
    }

    .search-container {
        width: 100%; /* ช่องค้นหาเต็มความกว้าง */
        margin: 10px 0;
        order: 3; /* ให้ช่องค้นหาอยู่บรรทัดที่ 2 (ใต้ Logo/Hamburger) */
    }

    .nav-links {
        display: none; /* ซ่อนเมนูปกติไว้ก่อน */
        width: 100%;
        flex-direction: column; /* เรียงเมนูแนวตั้ง */
        text-align: center;
        background-color: #f9f9f9;
        border-radius: 8px;
        padding: 10px 0;
        margin-top: 5px;
        order: 4; /* ให้เมนูอยู่ล่างสุด */
    }

    /* Class ที่จะถูกเพิ่มด้วย JS เมื่อกดปุ่ม Hamburger */
    .nav-links.active {
        display: flex; 
    }

    .nav-links li {
        margin: 10px 0;
        width: 100%;
    }
    
    .nav-links a {
        display: block;
        padding: 5px;
    }
}

/* --- Hero Section --- */
.hero {
    background: linear-gradient(rgba(0,0,0,0.5), rgba(0,0,0,0.5)), url('https://images.unsplash.com/photo-1504674900247-0877df9cc836?ixlib=rb-1.2.1&auto=format&fit=crop&w=1950&q=80');
    background-size: cover;
    background-position: center;
    height: 300px;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    color: white;
    margin-bottom: 2rem;
}

.hero h1 {
    font-family: 'Mitr', sans-serif;
    font-size: 2.5rem;
    margin-bottom: 10px;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.5);
}

/* --- Main Content (Grid) --- */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
    margin-bottom: 4rem;
}

.section-title {
    font-family: 'Mitr', sans-serif;
    margin-bottom: 40px; /* แก้ไข: เพิ่มระยะห่างเป็น 40px เพื่อไม่ให้ Card ชน */
    border-left: 5px solid var(--primary-color);
    padding-left: 15px;
    font-size: 1.5rem;
}

/* Grid Layout */
.menu-grid {
    display: grid;
    grid-template-columns: repeat(1, 1fr); /* Mobile */
    gap: 25px;
}

@media (min-width: 576px) {
    .menu-grid {
        grid-template-columns: repeat(2, 1fr); /* Tablet small */
    }
}

@media (min-width: 992px) {
    .menu-grid {
        grid-template-columns: repeat(3, 1fr); /* Laptop */
    }
}

@media (min-width: 1200px) {
    .menu-grid {
        grid-template-columns: repeat(4, 1fr); /* Desktop */
    }
}

/* --- Card Design --- */
.card {
    background: #fff;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: var(--shadow);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    cursor: pointer; /* เมาส์เป็นรูปนิ้วเมื่อชี้การ์ด */
    display: flex;
    flex-direction: column;
    height: 100%;
}

.card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 20px rgba(0,0,0,0.15);
}

.card-img-container {
    height: 200px;
    overflow: hidden;
}

.card-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.5s ease;
}

.card:hover .card-img {
    transform: scale(1.1);
}

.card-body {
    padding: 15px;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
}

.card-title {
    font-family: 'Mitr', sans-serif;
    font-size: 1.1rem;
    margin-bottom: 10px;
    color: var(--dark-color);
}

.card-desc {
    font-size: 0.9rem;
    color: #666;
    margin-bottom: 15px;
    
    /* CSS สำหรับตัดคำที่ยาวเกิน 2 บรรทัด */
    display: -webkit-box;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.card-btn {
    margin-top: auto;
    /* ย้ายปุ่มไปชิดขวา */
    align-self: flex-end; 
    padding: 5px 15px;
    background-color: var(--primary-color);
    color: white;
    border: none;
    border-radius: 20px;
    font-size: 0.8rem;
    /* เปลี่ยนเคอร์เซอร์เป็นรูปนิ้ว */
    cursor: pointer; 
}

/* --- Modal (Popup) --- */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.7);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 2000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.modal-content {
    background: white;
    width: 90%;
    max-width: 700px;
    max-height: 90vh;
    border-radius: 15px;
    overflow-y: auto;
    position: relative;
    transform: scale(0.7);
    transition: transform 0.3s ease;
}

.modal-overlay.active .modal-content {
    transform: scale(1);
}

.close-btn {
    position: absolute;
    top: 15px;
    right: 15px;
    background: rgba(0,0,0,0.5);
    color: white;
    border: none;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    cursor: pointer;
    z-index: 10;
}

.modal-header img {
    width: 100%;
    height: 250px;
    object-fit: cover;
}

.modal-body {
    padding: 25px;
}

.modal-body h2 {
    font-family: 'Mitr', sans-serif;
    color: var(--primary-color);
    margin-bottom: 15px;
}

.recipe-section {
    margin-bottom: 20px;
}

.recipe-section h3 {
    font-size: 1.1rem;
    margin-bottom: 10px;
    background: #eee;
    padding: 5px 10px;
    border-radius: 5px;
    display: inline-block;
}

.recipe-list {
    list-style-position: inside;
    padding-left: 10px;
}

.recipe-list li {
    margin-bottom: 5px;
}

.source-link {
    margin-top: 20px;
    font-size: 0.8rem;
    color: #666;
}

/* --- Footer --- */
footer {
    background-color: var(--dark-color);
    color: white;
    padding: 30px 20px;
}

.footer-content {
    max-width: 1200px;
    margin: 0 auto;
    display: grid;
    grid-template-columns: 1fr;
    gap: 20px;
}

@media (min-width: 768px) {
    .footer-content {
        grid-template-columns: 1fr 1fr;
    }
}

.footer-section h3 {
    font-family: 'Mitr', sans-serif;
    margin-bottom: 15px;
    color: var(--primary-color);
}

.ref-list {
    list-style: none;
    font-size: 0.85rem;
}

.ref-list li {
    margin-bottom: 8px;
}

.ref-list a {
    color: #bbb;
    text-decoration: none;
}

.ref-list a:hover {
    color: white;
    text-decoration: underline;
}

.copyright {
    text-align: center;
    margin-top: 30px;
    padding-top: 20px;
    border-top: 1px solid #444;
    font-size: 0.9rem;
}

.no-result {
    text-align: center;
    display: none;
    margin-top: 20px;
}