/* ================= VARIABLES & RESET ================= */
:root {
    --primary-color: #0b2c3d;
    --secondary-color: #123f54;
    --accent-color: #eebf64;
    --text-color: #666;
    --white: #ffffff;
    --font-heading: 'Oswald', sans-serif;
    --font-body: 'Poppins', sans-serif;
}

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

body {
    font-family: var(--font-body);
    color: var(--text-color);
    line-height: 1.6;
    background-color: #f9f9f9;
}

a { text-decoration: none; color: inherit; transition: 0.3s; }
ul { list-style: none; }
img { max-width: 100%; display: block; }

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

/* ================= HEADER ================= */
.site-header {
    background-image: url('../image/banner/banner.png');
    background-size: cover;
    background-position: center;
    position: relative;
    color: var(--white);
    padding-top: 40px;
    padding-bottom: 180; /* Space for torn paper */
    min-height: 600px; 
}

.site-header .overlay {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(11, 44, 61, 0.7); /* Teal overlay */
    z-index: 1;
}

/* .header-top, .hero-content {
    position: relative;
    z-index: 2;
} */

/* แก้ไขส่วนนี้ */
.header-top {
    position: relative;
    z-index: 100; /* ดันให้กล่องเมนูอยู่ชั้นบนสุด สูงกว่าเนื้อหาทุกอย่าง */
    
    /* เพิ่มเติม: จัด Layout ให้สวยงาม */
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 80px;
}

.hero-content {
    position: relative;
    z-index: 1; /* ให้เนื้อหาข้อความอยู่ชั้นล่างปกติ */
    
    /* การจัดกึ่งกลางเดิม */
    text-align: center;
    margin-bottom: 40px;
}

.header-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 100px;
}

.logo {
    font-family: var(--font-heading);
    font-size: 2rem;
    text-transform: uppercase;
    font-weight: 700;
    color: var(--accent-color);
    display: flex;
    align-items: center;
    gap: 10px;
}

/* กำหนดขนาดรูปโลโก้ */
.logo img {
    height: 100px; /* กำหนดความสูงที่ต้องการ (ปรับเลขนี้ได้ตามความเหมาะสม เช่น 40px, 60px) */
    width: auto;  /* ให้ความกว้างปรับตามสัดส่วนอัตโนมัติ */
    object-fit: contain; /* ป้องกันภาพบิดเบี้ยว */
    display: block;
}

.main-nav ul {
    display: flex;
    gap: 40px;
}

.main-nav a {
    color: var(--white);
    font-size: 0.95rem;
    font-weight: 500;
}

.main-nav a:hover, .main-nav a.active {
    color: var(--accent-color);
}

.header-social a {
    color: var(--accent-color);
    margin-left: 10px;
    background: rgba(255,255,255,0.1);
    padding: 8px;
    border-radius: 4px;
}

.hero-content {
    text-align: center;
    margin-bottom: 40px;
}

.page-title {
    font-family: var(--font-heading);
    font-size: 4rem;
    margin-bottom: 10px;
}

.breadcrumb {
    font-size: 1rem;
    opacity: 0.8;
}

/* Torn Paper Effect Generator */
.torn-paper-bottom {
    position: absolute;
    bottom: -1px;
    left: 0;
    width: 100%;
    height: 50px;
    background-color: #f9f9f9; /* Same as body bg */
    z-index: 2;
    /* clip-path: polygon(
        0 40%, 2% 80%, 4% 40%, 6% 80%, 8% 40%, 10% 80%, 
        12% 40%, 14% 80%, 16% 40%, 18% 80%, 20% 40%, 22% 80%, 
        24% 40%, 26% 80%, 28% 40%, 30% 80%, 32% 40%, 34% 80%, 
        36% 40%, 38% 80%, 40% 40%, 42% 80%, 44% 40%, 46% 80%, 
        48% 40%, 50% 80%, 52% 40%, 54% 80%, 56% 40%, 58% 80%, 
        60% 40%, 62% 80%, 64% 40%, 66% 80%, 68% 40%, 70% 80%, 
        72% 40%, 74% 80%, 76% 40%, 78% 80%, 80% 40%, 82% 80%, 
        84% 40%, 86% 80%, 88% 40%, 90% 80%, 92% 40%, 94% 80%, 
        96% 40%, 98% 80%, 100% 40%, 100% 100%, 0 100%
    ); */
}

/* ================= BODY / BLOG GRID ================= */
.main-content {
    padding: 60px 0;
}

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

.blog-card {
    position: relative;
    overflow: hidden;

    background: #fff;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 5px 15px rgba(0,0,0,0.05);
    transition: transform 0.3s;
}

.blog-card:hover {
    transform: translateY(-5px);
}

.blog-image {
    position: relative;
    height: 250px; /* กำหนดความสูงของพื้นที่รูปให้แน่นอน (ปรับเพิ่มลดได้ตามต้องการ) */
    /* overflow: hidden; ป้องกันรูปส่วนเกินล้นออกมา */
    background-color: #f0f0f0; /* สีพื้นหลังรองระหว่างรอรูปโหลด */
}

.blog-image img {
    width: 100%;
    height: 100%;
    
    /* key สำคัญ: ให้รูปขยายเต็มกรอบโดยไม่เสียสัดส่วน */
    object-fit: cover; 
    
    /* key สำคัญ: สั่งให้โฟกัสที่ "ส่วนบน" ของรูปเสมอ */
    object-position: top center; 
    
    transition: transform 0.5s ease;
}

/* เพิ่มลูกเล่น: เมื่อเอาเมาส์ชี้ ให้รูปซูมเข้าเล็กน้อย (เหมือนในเว็บสมัยใหม่) */
.blog-card:hover .blog-image img {
    transform: scale(1.1);
}

.date-badge {
    position: absolute;
    bottom: -10px;
    left: 20px;
    background: var(--accent-color);
    color: var(--white);
    padding: 5px 15px;
    text-align: center;
    border-radius: 4px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
}

.date-badge .day {
    display: block;
    font-size: 1.2rem;
    font-weight: 700;
    line-height: 1;
}

.date-badge .month {
    font-size: 0.8rem;
    text-transform: uppercase;
}

.blog-details {
    padding: 30px 20px 20px;
}

.blog-details h3 {
    font-family: var(--font-heading);
    font-size: 1.4rem;
    color: var(--primary-color);
    margin-bottom: 10px;
}

.blog-details p {
    font-size: 0.9rem;
    margin-bottom: 20px;
    color: #777;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.read-more {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--primary-color);
    display: flex;
    align-items: center;
    gap: 5px;
}

.read-more:hover {
    color: var(--accent-color);
    gap: 10px;
}

/* Overlay สำหรับบัง Card */
/* 1. พื้นหลังเงาดำ (เต็มกรอบ ไม่เอียง) */
.card-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    
    /* พื้นหลังสีดำจางๆ */
    background-color: rgba(0, 0, 0, 0.6); 
    z-index: 20;
    
    /* จัดกึ่งกลาง */
    display: flex;
    justify-content: center;
    align-items: center;
    
    /* ห้ามใส่ transform rotate ตรงนี้ */
    user-select: none;
    pointer-events: none;
}

/* 2. ตัวหนังสือและกรอบ (เอียงเฉพาะตรงนี้) */
.purchased-badge {
    color: #fff;
    font-family: 'Oswald', sans-serif;
    font-size: 2rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 2px;
    
    /* กรอบรอบตัวหนังสือ */
    border: 3px solid #fff;
    padding: 10px 20px;
    
    /* สั่งหมุนเอียงเฉพาะก้อนนี้ */
    transform: rotate(-10deg);
}

/* ลบ content แปลกปลอมที่อาจซ่อนอยู่ */
.card-overlay::before,
.card-overlay::after {
    content: none !important;
    display: none !important;
}

/* เพิ่มให้ Card ที่ยังไม่ซื้อดูจางลง หรือเป็นขาวดำ (Optional) */
.blog-card.locked .blog-image,
.blog-card.locked .blog-details {
    filter: grayscale(100%); /* ทำเป็นขาวดำ */
    opacity: 0.4;
}

/* ป้องกันการกดลิ้งค์ถ้ายังไม่ซื้อ */
.blog-card.locked {
    pointer-events: none; /* ห้ามคลิก */
    user-select: none;    /* ห้ามคลุมดำ */
}



/* ================= FOOTER ================= */
.site-footer {
    background-color: var(--primary-color);
    color: #ccc;
    position: relative;
    padding-top: 80px;
}

.torn-paper-top {
    position: absolute;
    top: -1px;
    left: 0;
    width: 100%;
    height: 50px;
    background-color: #f9f9f9; /* Match body bg */
    transform: rotate(180deg); /* Flip the bottom one */
    /* clip-path: polygon(
        0 40%, 2% 80%, 4% 40%, 6% 80%, 8% 40%, 10% 80%, 
        12% 40%, 14% 80%, 16% 40%, 18% 80%, 20% 40%, 22% 80%, 
        24% 40%, 26% 80%, 28% 40%, 30% 80%, 32% 40%, 34% 80%, 
        36% 40%, 38% 80%, 40% 40%, 42% 80%, 44% 40%, 46% 80%, 
        48% 40%, 50% 80%, 52% 40%, 54% 80%, 56% 40%, 58% 80%, 
        60% 40%, 62% 80%, 64% 40%, 66% 80%, 68% 40%, 70% 80%, 
        72% 40%, 74% 80%, 76% 40%, 78% 80%, 80% 40%, 82% 80%, 
        84% 40%, 86% 80%, 88% 40%, 90% 80%, 92% 40%, 94% 80%, 
        96% 40%, 98% 80%, 100% 40%, 100% 100%, 0 100%
    ); */
}

.footer-content {
    display: grid;
    grid-template-columns: 2fr 1fr 1fr 1fr;
    gap: 40px;
    padding-bottom: 40px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.footer-col h4 {
    color: var(--white);
    margin-bottom: 20px;
    font-family: var(--font-heading);
}

.footer-col ul li {
    margin-bottom: 10px;
}

.footer-col ul li a:hover {
    color: var(--accent-color);
    padding-left: 5px;
}

.footer-col .logo {
    margin-bottom: 15px;
}

.location {
    margin-top: 20px;
    color: var(--accent-color);
}

.footer-bottom {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 20px;
}

.contact-info span {
    margin-right: 20px;
    font-size: 0.9rem;
}

.contact-info i {
    color: var(--accent-color);
    margin-right: 5px;
}

.copyright {
    text-align: center;
    background: #082230;
    padding: 15px;
    font-size: 0.8rem;
}

.mobile-menu-btn {
    display: none;
    font-size: 1.5rem;
    color: var(--white);
    cursor: pointer;
}

/* ================= RESPONSIVE ================= */
@media (max-width: 992px) {
    .footer-content {
        grid-template-columns: 1fr 1fr;
    }
}

@media (max-width: 768px) {
    /* 1. สั่งซ่อนโลโก้รูปม้า */
    .logo {
        display: none !important;
    }
    .mobile-menu-btn {
        display: block;
        font-size: 2rem; /* ปรับขนาดให้กดง่ายขึ้น */
        cursor: pointer;
        color : #eebf64;
        /* ไม่ต้องกำหนด float: left; เพราะ Flexbox ของ .header-top จะดันไปซ้ายเอง */    
    }

    /* 3. (Optional) ปรับระยะห่างของ header ให้สวยงามขึ้นในมือถือ */
    .header-top {
        margin-bottom: 20px !important; /* แก้จากค่าเดิม (80-100px) ให้เหลือน้อยๆ */
        padding-top: 10px; /* ปรับระยะห่างจากขอบบนสุดของจอ (ถ้าต้องการ) */
        position: relative; 
    }
    
    .main-nav {
        /* 1. จัดตำแหน่งให้ลอยอยู่เหนือเนื้อหาอื่น */
        position: absolute;
        top: 100%; /* ให้เริ่มต่อจากขอบล่างของแถบเมนูพอดี */
        left: 0;
        width: 100%;
        
        /* 2. ใส่สีพื้นหลังทึบ (ใช้สีเดียวกับธีม) เพื่อไม่ให้เห็นตัวหนังสือข้างหลัง */
        background-color: #0b2c3d; /* หรือใช้ var(--primary-color) */
        
        /* 3. สั่งให้อยู่ชั้นบนสุด */
        z-index: 9999;
        
        /* 4. การทำ Animation (ความสมูท) */
        max-height: 0;       /* เริ่มต้น: สูง 0 (ปิดอยู่) */
        opacity: 0;          /* เริ่มต้น: โปร่งใส */
        overflow: hidden;    /* ซ่อนเนื้อหาที่เกิน */
        transition: all 0.4s ease-in-out; /* เอฟเฟกต์ค่อยๆ เลื่อน 0.4 วินาที */
        
        /* จัดระเบียบเงาและขอบ */
        box-shadow: 0 10px 20px rgba(0,0,0,0.2);
        border-top: 1px solid rgba(255,255,255,0.1);
    }
    
    /* เมื่อมีคลาส .active (ถูกกดเปิด) */
    .main-nav.active {
        display: block;      /* ยืนยันการแสดงผล */
        max-height: 500px;   /* กำหนดความสูงสูงสุดเผื่อไว้ (ให้มากกว่าเนื้อหาจริง) */
        opacity: 1;          /* ปรากฏชัดเจน */
        padding: 20px 0;     /* เพิ่มช่องว่างบนล่างเมื่อเปิด */
    }

    /* จัดระเบียบรายการเมนูข้างในให้นิ่ง */
    .main-nav ul {
        flex-direction: column;
        gap: 0;
        text-align: center;
        padding: 0;
        margin: 0;
    }

    .main-nav ul li a {
        display: block;
        padding: 15px 0;
        border-bottom: 1px solid rgba(255,255,255,0.05);
    }

    .page-title { 
        font-size: 2.5rem; 
        margin-top: 0;      /* ดันขึ้นไปอีก */
        margin-bottom: 5px; /* ลดช่องว่างระหว่างหัวข้อกับ Breadcrumb */
        line-height: 1.1;
    }
    
    .footer-content {
        grid-template-columns: 1fr;
        text-align: center;
    }

    .footer-bottom {
        flex-direction: column;
        gap: 20px;
        text-align: center;
    }
    
    .contact-info span {
        display: block;
        margin-right: 0;
        margin-bottom: 10px;
    }

        /* 1. ลดความสูงของ Header ลง */
    .site-header {
        min-height: auto; /* ยกเลิกการบังคับสูง 600px */
        padding-bottom: 60px; /* ลดระยะด้านล่างลง */
    }

    /* 2. ดันเนื้อหา (Blog & Article) ให้ชิดขึ้น */
    .hero-content {
        position: relative;
        top: 30px;
        margin-bottom: 100px; /*ลดระยะห่างจากด้านล่าง*/
    }

    /* 3. ดันบล็อกคอร์สเรียนขึ้นมาอีก */
    .main-content {
        padding-top: 0px; /* ลดระยะห่างด้านบนของส่วนเนื้อหา */
    }
}