/* ======================================================
   ไฟล์: css/style.css (ฉบับสมบูรณ์ + แก้บั๊ก + Responsive ครบ)
   ====================================================== */

/* --- ตั้งค่าพื้นฐาน --- */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Sarabun', sans-serif;
    line-height: 1.6;
    color: #333;
    background-color: #f9f9f9;
}

a { text-decoration: none; color: inherit; }
ul { list-style: none; }

/* Container หลัก */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

/* ซ่อน Top Bar */
.top-bar {
    display: none;
}

/* ======================================================
   HEADER & NAVBAR (ลอย + โปร่งใส)
   ====================================================== */
.main-header {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    background-color: transparent; /* เริ่มต้นใส */
    box-shadow: none;
    transition: all 0.4s ease;
    padding: 30px 0;
    z-index: 2000;
}

.navbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* สไตล์โลโก้ (ตอนปกติ - พื้นใส) */
.main-header .logo h1 {
    color: #fff;
    font-size: 1.8rem;
    text-shadow: 0 2px 10px rgba(0,0,0,0.5);
}
.main-header .logo span { color: #ffd700; }
.main-header .logo p { color: rgba(255,255,255,0.8); font-size: 0.7rem; letter-spacing: 1px; }

/* สไตล์เมนู (ตอนปกติ - พื้นใส) */
.menu { display: flex; gap: 30px; }
.menu a {
    font-weight: 600;
    color: #fff;
    text-shadow: 0 2px 10px rgba(0,0,0,0.5);
    transition: 0.3s;
}
.menu a:hover, .menu a.active {
    color: #ffd700;
}

/* ปุ่ม Hamburger (ซ่อนไว้ใน Desktop) */
.menu-toggle {
    display: none; /* ★ สำคัญ: ซ่อนในจอคอม */
    font-size: 1.5rem;
    cursor: pointer;
    color: #fff;
}

/* สไตล์ Header ตอนเลื่อนลง (Scrolled State - พื้นขาว) */
.main-header.scrolled {
    background-color: #fff;
    box-shadow: 0 2px 20px rgba(0,0,0,0.1);
    padding: 15px 0;
}
.main-header.scrolled .logo h1 { color: #3333CC; text-shadow: none; }
.main-header.scrolled .logo p { color: #666; }
.main-header.scrolled .menu a { color: #333; text-shadow: none; }
.main-header.scrolled .menu a:hover { color: #3333CC; }
.main-header.scrolled .menu-toggle { color: #333; }


/* ======================================================
   HERO SECTION (BANNER)
   ====================================================== */
.hero {
    background: linear-gradient(rgba(0,0,0,0), rgba(0,0,0,0)), url('../image/banner/sea4K.png');
    background-size: cover;
    background-position: center 100%;
    height: 600px;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    color: white;
}
.hero h2 { font-size: 3rem; margin-bottom: 20px; }


/* ======================================================
   SECTION & GENERAL STYLES
   ====================================================== */
section { padding: 60px 0; }

.section-title {
    text-align: center;
    margin-bottom: 60px;
    font-size: 2rem;
    color: #3333CC;
    position: relative;
}
.section-title::after {
    content: '';
    display: block;
    width: 60px;
    height: 4px;
    background: #d4a017;
    margin: 10px auto;
}

/* ปุ่มทั่วไป */
.btn {
    display: inline-block;
    background: #d4a017;
    color: white;
    padding: 12px 30px;
    border-radius: 5px;
    font-weight: bold;
}
.btn:hover { background: #b88a10; }


/* ======================================================
   COURSES GRID (ส่วนหัวข้อทะเล)
   ====================================================== */
.courses {
    padding-top: 60px;    /* เพิ่มระยะด้านบน (เดิม 60px) */
    padding-bottom: 100px; /* เพิ่มระยะด้านล่าง */
    /* background-color: #fff; หรือใส่สีพื้นหลังจางๆ เช่น #f9f9f9 */
}

.courses .grid-container {
    display: grid !important;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 30px;
}


/* ปรับกล่องรูปภาพ */
.topic-img-box {
    /* ใหม่: ให้เต็มความกว้าง */
    width: 100%;
    height: 180px; /* กำหนดความสูงตามชอบ */
    margin: 0 0 20px 0; /* ลบ margin auto ออก */
    border-radius: 10px 10px 0 0; /* มนเฉพาะมุมบนซ้าย-ขวา */
    overflow: hidden;
    
    /* ลบ box-shadow เดิมออก เพราะรูปจะชิดขอบ */
    box-shadow: none; 
}

.topic-img-box img {
    width: 100%;
    height: 100%;
    object-fit: cover; /* บังคับให้รูปเต็มวงกลมโดยไม่เบี้ยว */
    transition: transform 0.5s ease; /* เพิ่มลูกเล่นขยายตอนชี้ */
}

/* ปรับ Card ให้รองรับ Link (เอาขีดเส้นใต้ออก) */
.topic-card {
    text-decoration: none;
    color: inherit;
    display: block; /* ให้ลิงก์คลุมทั้งกล่อง */
}

.card {
    background: white;
    padding: 0 0 30px 0; /* บน 0, ขวา 0, ล่าง 30, ซ้าย 0 */
    text-align: left; /* จัดข้อความชิดซ้าย (ตามรูปตัวอย่าง 2) หรือ center ก็ได้ */
    overflow: hidden; /* เพื่อให้รูปไม่ล้นมุมมน */
    border-radius: 10px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.05);
    transition: transform 0.3s;
    border-bottom: 4px solid transparent;
}
.card h3, .card p {
    padding: 0 20px; /* เว้นระยะซ้ายขวา */
}

.card h3 {
    margin-top: 15px; /* ดันลงมาจากรูปหน่อย */
}

.card:hover {
    transform: translateY(-10px);
    border-bottom: 4px solid #d4a017;
}
/* (แถม) Effect ตอนชี้เมาส์ */
.card:hover .topic-img-box img {
    transform: scale(1.1); /* ขยายรูปนิดนึง */
}
.icon-box {
    font-size: 3rem;
    color: #3333CC;
    margin-bottom: 20px;
}


/* ======================================================
   NEWS SECTION (ข่าวสาร)
   ====================================================== */
.news-section { background-color: #f0f4f0; }

.grid-news {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 30px;
}

.news-card {
    background: white;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 3px 10px rgba(0,0,0,0.1);
}
.news-img { height: 200px; width: 100%; background: #ccc; }
.news-content { padding: 20px; overflow: hidden; }
.news-content .date { font-size: 0.8rem; color: #888; }

.news-content h4 { 
    margin: 10px 0; color: #3333CC; font-size: 1.1rem;
    overflow-wrap: break-word; word-break: break-word;
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.news-content p {
    color: #666; font-size: 0.95rem;
    overflow-wrap: break-word; word-break: break-word;
    display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}


/* ======================================================
   ABOUT SECTION (เกี่ยวกับเรา)
   ====================================================== */
.about-section { background-color: #fff; padding: 80px 0; }
.about-container { display: flex; align-items: center; gap: 50px; }
.about-content { flex: 1; }
.sub-head { color: #4a6fa5; font-weight: bold; font-size: 0.9rem; display: block; margin-bottom: 5px; }

.dots-separator { display: flex; gap: 5px; margin-bottom: 15px; }
.dots-separator span { width: 6px; height: 6px; background-color: #2b70c9; border-radius: 50%; }
.dots-separator span:nth-child(1) { width: 20px; border-radius: 5px; }

.about-content h2 { font-size: 2.2rem; color: #333; line-height: 1.3; margin-bottom: 20px; }
.desc-text { color: #666; margin-bottom: 30px; text-indent: 2em; text-align: justify; }

.btn-brown {
    display: inline-block; background-color: #a0522d; color: white;
    padding: 12px 30px; border-radius: 50px; font-weight: bold; transition: 0.3s;
}
.btn-brown:hover { background-color: #8a4321; transform: translateX(5px); }

.about-image { flex: 1; }
.about-image img { width: 100%; border-radius: 10px; box-shadow: 0 10px 30px rgba(0,0,0,0.1); }


/* ======================================================
   ARTICLES SECTION (บทความ - แก้ไข Grid)
   ====================================================== */
.articles-section {
    position: relative;
    padding: 80px 0;
    background-color: #fff;
    overflow: hidden;
}

/* วงกลมตกแต่ง (ใส่กลับมาถ้าต้องการ) */
.deco-circle-bg {
    position: absolute; top: -50px; left: -100px; width: 400px; height: 400px;
    background-color: #fbeebb; border-radius: 50%; z-index: 0;
}
.deco-circle-bottom {
    position: absolute; bottom: -100px; right: -100px; width: 300px; height: 300px;
    background-color: #fbeebb; border-radius: 50%; z-index: 0;
}

.articles-header {
    display: flex; justify-content: space-between; align-items: center;
    margin-bottom: 40px; position: relative; z-index: 1;
}
.articles-title { font-size: 3rem; font-weight: 800; font-style: italic; color: #1a1a1a; font-family: 'Times New Roman', serif; }

.btn-all-articles {
    background-color: #1a2b4c; color: white; padding: 10px 25px;
    border-radius: 30px; font-weight: bold; font-size: 0.9rem; text-transform: uppercase; transition: 0.3s;
}
.btn-all-articles:hover { background-color: #c94b38; }

/* Grid Layout */
.articles-layout {
    display: grid;
    grid-template-columns: 1.2fr 1fr;
    gap: 50px;
    position: relative; z-index: 1;
}

/* Featured Article */
.featured-article {
    position: relative;
    overflow: hidden;
    padding-bottom: 60px;
    border-radius: 10px;
    margin-bottom: 0;
}

.featured-img { width: 100%; height: 400px; overflow: hidden; border-radius: 10px; }
.featured-img img { width: 100%; height: 100%; object-fit: cover; transition: 0.5s; }
.featured-article:hover .featured-img img { transform: scale(1.05); }

.featured-card {
    position: absolute;
    bottom: 15px; left: 50%; transform: translateX(-50%);
    width: 90%; background: white; padding: 25px;
    border-radius: 10px; box-shadow: 0 10px 30px rgba(0,0,0,0.1);
    transition: transform 0.5s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.5s ease;
    z-index: 10;
}
.featured-card.video-playing { transform: translate(-50%, 150%); opacity: 0; pointer-events: none; }

.featured-card h3 { font-size: 1.4rem; color: #1a2b4c; margin: 10px 0; line-height: 1.4; }
.featured-card p { color: #666; font-size: 0.95rem; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

/* Side List */
.side-articles-list { display: flex; flex-direction: column; gap: 30px; }
.side-item { display: flex; flex-direction: column; }

.item-header { display: flex; align-items: center; gap: 15px; margin-bottom: 10px; }
.article-date-badge { background-color: #c94b38; color: white; font-size: 0.75rem; padding: 5px 15px; border-radius: 20px; font-weight: bold; white-space: nowrap; }
.red-line { flex-grow: 1; height: 2px; background-color: #c94b38; opacity: 0.5; }

.side-item h4 { font-size: 1.1rem; color: #1a2b4c; margin-bottom: 8px; }
.side-item p { font-size: 0.9rem; color: #777; margin-bottom: 10px; }

.read-more-link { color: #c94b38; font-weight: bold; font-size: 0.9rem; display: flex; align-items: center; gap: 8px; transition: 0.3s; }
.read-more-link i { background: #c94b38; color: white; width: 20px; height: 20px; border-radius: 50%; display: flex; justify-content: center; align-items: center; font-size: 0.7rem; transition: 0.3s; }
.read-more-link:hover { color: #1a2b4c; }
.read-more-link:hover i { background: #1a2b4c; }



/* ======================================================
   FOOTER
   ====================================================== */
footer { background: #222; color: #ddd; padding-top: 50px; }
.footer-content { display: flex; flex-wrap: wrap; justify-content: space-between; padding-bottom: 40px; }
.footer-col { flex: 1; min-width: 250px; margin-bottom: 20px; }
.footer-col h3 { color: white; margin-bottom: 20px; border-left: 3px solid #d4a017; padding-left: 10px; }
.footer-col ul li { margin-bottom: 10px; }
.footer-col ul li a:hover { color: #d4a017; }
.copyright { background: #111; text-align: center; padding: 20px; font-size: 0.8rem; }


/* ======================================================
   RESPONSIVE (รองรับทุกขนาดหน้าจอ) - นำกลับมาครบแล้ว
   ====================================================== */

/* 1. Mobile Only (< 768px) */
@media screen and (max-width: 767px) {
    /* Navbar Hamburger */
    .menu {
        /* display: none; */
        display: flex; 
        flex-direction: column;
        position: absolute;
        top: 100%;
        left: 0;
        width: 100%;
        background: white;
        padding: 20px;
        box-shadow: 0 5px 10px rgba(0,0,0,0.1);
        text-align: center;
        
        /* --- ส่วนที่ทำให้สมูท (Smooth Animation) --- */
        max-height: 0;          /* ความสูงเริ่มต้นเป็น 0 (ปิด) */
        opacity: 0;             /* โปร่งใส (มองไม่เห็น) */
        overflow: hidden;       /* ซ่อนเนื้อหาที่เกิน */
        transform: translateY(-20px); /* ดันขึ้นไปนิดนึง */
        transition: all 0.4s ease-in-out; /* สั่งให้ทุกอย่างค่อยๆ เปลี่ยนใน 0.4 วิ */
        /* --------------------------------------- */
    }
    .menu a { 
        color: #333; 
        text-shadow: none; 
        padding: 15px 0;      /* เพิ่มพื้นที่กดให้ง่ายขึ้น */
        border-bottom: 1px solid #eee; /* เส้นคั่นบางๆ */
        display: block;
    }
    .menu.active {
        /* display: flex; <-- ลบออก */
        
        /* --- ค่าตอนเปิด --- */
        max-height: 500px;    /* กำหนดความสูงให้มากพอที่จะโชว์เมนูครบ */
        opacity: 1;           /* ชัดเจน */
        transform: translateY(0); /* เลื่อนกลับมาที่เดิม */
        /* ---------------- */
    }
    .menu-toggle { 
        display: block; 
        color: #fff; 
        cursor: pointer;
        transition: 0.3s;
    }
    
    /* Layout */
    .hero { height: 350px; }
    .hero h2 { font-size: 2rem; }
    .about-container { flex-direction: column; gap: 30px; }
    .about-image { order: -1; }
    .footer-content { flex-direction: column; text-align: center; }
    .footer-col h3 { border-left: none; border-bottom: 3px solid #d4a017; display: inline-block; padding-bottom: 5px; }
    
    /* Articles */
    .articles-layout { grid-template-columns: 1fr; }
    .articles-header { flex-direction: column; align-items: flex-start; gap: 20px; }
}

/* 2. Tablet Portrait & Mobile Landscape (768px - 991px) */
@media screen and (min-width: 768px) and (max-width: 991px) {
    .container { max-width: 720px; }
    .hero h2 { font-size: 2.5rem; }
    .about-container { gap: 30px; }
    .desc-text { text-align: left; }
    
    /* Articles Grid ปรับเป็นแนวตั้ง */
    .articles-layout { grid-template-columns: 1fr; }
    
    /* Navbar */
    .menu a { font-size: 0.9rem; }
}

/* 3. Laptop (992px - 1199px) */
@media screen and (min-width: 992px) and (max-width: 1199px) {
    .container { max-width: 960px; }
    .grid-container { gap: 20px; }
}

/* 4. Desktop (1200px - 1399px) */
@media screen and (min-width: 1200px) and (max-width: 1399px) {
    .container { max-width: 1140px; }
}

/* 5. Large Screens (2K/4K >= 1400px) */
@media screen and (min-width: 1400px) {
    .container { max-width: 1320px; }
    body { font-size: 18px; }
    .hero { height: 700px; }
}