/* ==========================================================================
   1. GLOBAL RESET & FONTS (ตั้งค่าเริ่มต้นและฟอนต์)
   ========================================================================== */
@import url('https://fonts.googleapis.com/css2?family=Sarabun:wght@300;400;600;700&display=swap');

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Sarabun', sans-serif;
}

body {
    background-color: #f5f5f7;
    color: #333;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

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

.page-title {
    margin-bottom: 25px;
    border-bottom: 2px solid #800000;
    padding-bottom: 10px;
}

/* ==========================================================================
   2. MOURNING PAGE STYLE (หน้าแสดงความอาลัย - index.html *แก้ไขรูปอยู่ในขอบสมส่วน*)
   ========================================================================== */
.mourning-page {
    background-color: #1a1a1a;
    color: #ffffff;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100dvh;
    text-align: center;
    padding: 20px;
}

.mourning-container {
    /* สัดส่วนกล่องกว้าง 380px ซึ่งพอดีเป๊ะกับแนวตั้งของรูปต้นฉบับ 908.jpg */
    max-width: auto; 
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    margin: auto 0;
}

.royal-image {
    /* 1. เปลี่ยนมาคุมความกว้างแทนความสูง เพื่อให้เป็นแนวนอน */
    width: 100%;
    height: auto; 
    
    /* 2. แก้สัดส่วนเป็นแนวนอน (กว้าง 4 ส่วน : สูง 3 ส่วน) */
    aspect-ratio: 16 / 9; 
    
    /* 3. เปลี่ยนจาก max-height เป็น max-width เพื่อจำกัดความกว้างสูงสุดบนจอใหญ่ */
    max-width: auto;
}

.mourning-container h2 {
    margin: 0 0 12px 0;
    font-weight: 600;
    font-size: 1.6rem;
    color: #ffffff;
}

.mourning-container p {
    color: #ccc;
    line-height: 1.7;
    margin-bottom: 25px;
    font-size: 1rem;
}

.enter-btn {
    display: inline-block;
    padding: 12px 30px;
    background-color: #333;
    color: #fff;
    text-decoration: none;
    border: 1px solid #d4af37;
    border-radius: 5px;
    font-size: 1.05rem;
    transition: 0.3s ease;
}

.enter-btn:hover {
    background-color: #d4af37;
    color: #000;
}

/* ==========================================================================
   3. RESPONSIVE NAVIGATION BAR (แถบเมนูหลัก)
   ========================================================================== */
.navbar {
    background-color: #800000;
    color: white;
    position: sticky;
    top: 0;
    z-index: 1000;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

.nav-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    max-width: 1200px;
    margin: 0 auto;
    padding: 15px 20px;
}

.nav-logo {
    color: #d4af37;
    font-size: 1.5rem;
    font-weight: bold;
    text-decoration: none;
}

.nav-menu {
    display: flex;
    list-style: none;
}

.nav-menu li a {
    color: white;
    text-decoration: none;
    padding: 10px 15px;
    display: block;
    transition: 0.3s ease;
}

.nav-menu li a:hover, 
.nav-menu li a.active {
    color: #d4af37;
}

.menu-toggle {
    display: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: white;
}

/* ==========================================================================
   4. HOME PAGE BACKGROUND & HERO (รูปพื้นหลังชั้นหนังสือเบลอหน้าแรก)
   ========================================================================== */
.home-page-bg {
    background: linear-gradient(rgba(0, 0, 0, 0.45), rgba(0, 0, 0, 0.45)), 
                url('https://images.unsplash.com/photo-1507842217343-583bb7270b66?q=80&w=1920') no-repeat center center fixed;
    background-size: cover;
}

.hero-section-clean {
    text-align: center;
    padding: 40px 20px 20px 20px;
    color: white;
    text-shadow: 0 2px 8px rgba(0, 0, 0, 0.6);
}

.hero-section-clean h1 {
    font-size: 2.2rem;
    font-weight: 700;
    margin-bottom: 8px;
}

.hero-section-clean p {
    font-size: 1.1rem;
    color: #e2e8f0;
}

/* ==========================================================================
   5. HISTORY SECTION WITH GLASSMORPHISM (กล่องขาวโปร่งแสงหน้าแรก)
   ========================================================================== */
.history-section {
    margin-top: 20px;
    margin-bottom: 40px;
}

.glass-panel {
    background: rgba(255, 255, 255, 0.92); 
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    border-radius: 12px;
    padding: 40px;
}

.history-title-inside {
    border-bottom: 2px solid #800000;
    padding-bottom: 12px;
    margin-bottom: 25px;
}

.history-title-inside h2 {
    color: #800000;
    font-size: 1.7rem;
    font-weight: 700;
}

.history-card p {
    margin-bottom: 20px;
    text-indent: 2em;
    text-align: justify;
    color: #222;
    font-size: 1.05rem;
    line-height: 1.9;
}

.highlight-text {
    font-size: 1.1rem !important;
    font-weight: 600;
    color: #000 !important;
    border-left: 4px solid #d4af37;
    padding-left: 18px;
    text-indent: 0 !important;
    background: rgba(212, 175, 55, 0.08);
    padding: 15px 20px;
    border-radius: 0 8px 8px 0;
}

.book-category-list {
    list-style: none;
    padding: 0;
    margin: 25px 0;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 12px;
}

.book-category-list li {
    background: rgba(128, 0, 0, 0.04);
    border-left: 3px solid #800000;
    padding: 12px 18px;
    border-radius: 0 6px 6px 0;
    font-size: 1rem;
    color: #333;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.vol-text {
    color: #64748b;
    font-size: 0.9rem;
    font-weight: bold;
    background: #fff;
    padding: 2px 10px;
    border-radius: 12px;
    border: 1px solid #e2e8f0;
}

/* ==========================================================================
   6. GRID LAYOUT & CARDS (หน้าข่าวสารและหน้าบริการ)
   ========================================================================== */
.grid-layout {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.card {
    background: white;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 4px 6px rgba(0,0,0,0.05);
    transition: transform 0.3s ease;
}

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

.card img {
    width: 100%;
    height: 200px;
    object-fit: cover;
}

.card-body {
    padding: 20px;
}

.card-body h3 {
    margin-bottom: 10px;
    color: #800000;
}

.date {
    font-size: 0.85rem;
    color: #777;
    display: block;
    margin-top: 15px;
}

.service-card {
    text-align: center;
    padding: 35px 20px;
}

.service-icon {
    font-size: 3rem;
    color: #800000;
    margin-bottom: 15px;
}

/* ==========================================================================
   7. COMMANDER SECTION (หน้าทำเนียบผู้บังคับบัญชา)
   ========================================================================== */
.commander-group-title {
    text-align: center;
    margin: 40px 0 20px 0;
}

.commander-group-title h3 {
    color: #800000;
    font-size: 1.4rem;
    background-color: #eef0f2;
    display: inline-block;
    padding: 8px 24px;
    border-radius: 20px;
    border-left: 4px solid #d4af37;
}

.commander-section {
    display: flex;
    justify-content: center;
    gap: 30px;
    flex-wrap: wrap;
    margin-bottom: 30px;
}

.centralize {
    justify-content: center !important;
    margin-bottom: 20px;
}

.commander-card {
    background: white;
    padding: 25px 20px;
    text-align: center;
    border-radius: 8px;
    box-shadow: 0 4px 8px rgba(0,0,0,0.05);
    width: 280px;
    border: 1px solid #e1e1e1;
}

.chief-card {
    border: 2px solid #d4af37 !important;
    transform: scale(1.02);
    box-shadow: 0 6px 12px rgba(128, 0, 0, 0.1);
}

.commander-img {
    width: 100%;
    height: auto;
    border-radius: 5px;
    margin-bottom: 15px;
    object-fit: cover;
}

.commander-card h3 {
    color: #222;
    font-size: 1.15rem;
    margin-top: 5px;
}

.position {
    color: #800000; 
    font-size: 0.95rem;
    font-weight: 600;
    margin-top: 8px;
}

.section-divider {
    border: 0;
    height: 1px;
    background: linear-gradient(to right, rgba(0,0,0,0), rgba(128,0,0,0.3), rgba(0,0,0,0));
    margin: 40px 0;
}

/* ==========================================================================
   8. ABOUT PAGE (หน้าเกี่ยวกับห้องสมุด)
   ========================================================================== */
.about-content {
    background: white;
    padding: 30px;
    border-radius: 8px;
    line-height: 1.8;
    box-shadow: 0 4px 6px rgba(0,0,0,0.05);
}

.about-content h3 {
    margin: 25px 0 10px 0;
    color: #800000;
    border-left: 3px solid #d4af37;
    padding-left: 10px;
}

.about-content ul {
    padding-left: 20px;
    margin-top: 10px;
}

/* ==========================================================================
   9. FOOTER (ส่วนท้ายเว็บไซต์)
   ========================================================================== */
footer {
    background-color: #222;
    color: #bbb;
    text-align: center;
    padding: 15px;
    font-size: 0.9rem;
    margin-top: auto;
}

/* ==========================================================================
   10. CROSS-PLATFORM RESPONSIVE MEDIA QUERIES (รองรับทุกขนาดหน้าจอ)
   ========================================================================== */
@media (max-width: 768px) {
    .menu-toggle {
        display: block; 
    }

    .nav-menu {
        display: none; 
        flex-direction: column;
        width: 100%;
        position: absolute;
        top: 60px;
        left: 0;
        background-color: #800000;
        box-shadow: 0 4px 10px rgba(0,0,0,0.15);
    }

    .nav-menu.active {
        display: flex; 
    }

    .nav-menu li {
        text-align: center;
        border-bottom: 1px solid #991f1f;
    }

    .nav-menu li a {
        padding: 15px 0;
    }

    .hero-section-clean {
        padding: 30px 15px 10px 15px;
    }

    .hero-section-clean h1 {
        font-size: 1.6rem;
    }

    .glass-panel {
        padding: 20px;
    }

    .history-card p {
        text-indent: 1em;
    }

    .book-category-list {
        grid-template-columns: 1fr;
    }

    .commander-card {
        width: 100%;
        max-width: 320px;
    }
    
    .chief-card {
        transform: scale(1); 
    }

    /* ปรับปรุงกล่องหน้าแรกบนมือถือให้หดกระชับ */
    .mourning-container {
        max-width: 290px;
    }
    .mourning-container h2 {
        font-size: 1.3rem;
    }
    .mourning-container p {
        font-size: 0.9rem;
    }
}