/* css/main.css */
/* --- VARIABLES & RESET --- */
:root {
    --primary-color: #003366; /* Modern Thai Gov Blue */
    --secondary-color: #DAA520; /* Gold */
    --background-color: #f4f7f6;
    --text-color: #333;
    --card-bg-color: #ffffff;
    --header-bg-color: rgba(255, 255, 255, 0.9);
    --border-color: #e0e0e0;
    --font-primary: 'Kanit', sans-serif;
    --font-secondary: 'Sarabun', sans-serif;
    --shadow: 0 4px 12px rgba(0,0,0,0.08);
}

[data-theme="dark"] {
    --primary-color: #58a6ff;
    --secondary-color: #DAA520;
    --background-color: #0d1117;
    --text-color: #c9d1d9;
    --card-bg-color: #161b22;
    --header-bg-color: rgba(22, 27, 34, 0.9);
    --border-color: #30363d;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
    scroll-padding-top: 80px; /* Offset for sticky header */
}

body {
    font-family: var(--font-primary);
    background-color: var(--background-color);
    color: var(--text-color);
    line-height: 1.7;
    transition: background-color 0.3s, color 0.3s;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem 1.5rem;
}

h1, h2, h3, h4 {
    font-family: var(--font-primary);
    font-weight: 700;
    color: var(--primary-color);
}
h2 {
    text-align: center;
    font-size: 2.5rem;
    margin-bottom: 2rem;
}

/* --- LOADER --- */
.loader {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: var(--background-color);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    transition: opacity 0.5s ease;
}
.spinner {
    border: 5px solid var(--border-color);
    border-top: 5px solid var(--primary-color);
    border-radius: 50%;
    width: 50px;
    height: 50px;
    animation: spin 1s linear infinite;
}

/* --- HEADER & NAVBAR --- */
.sticky-header {
    position: sticky;
    top: 0;
    width: 100%;
    z-index: 1000;
    background-color: var(--header-bg-color);
    backdrop-filter: blur(10px);
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
    transition: background-color 0.3s;
}

.navbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    max-width: 1300px;
    margin: 0 auto;
    padding: 0 1.5rem;
    height: 70px;
}

.nav-logo {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.nav-logo img {
    height: 30px;
}
.nav-logo a {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--primary-color);
    text-decoration: none;
}

.nav-menu {
    display: flex;
    list-style: none;
    gap: 1.5rem;
}

.nav-link {
    text-decoration: none;
    color: var(--text-color);
    font-weight: 500;
    padding: 0.5rem 0;
    position: relative;
    transition: color 0.3s;
}

.nav-link::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 0;
    height: 2px;
    background-color: var(--secondary-color);
    transition: width 0.3s ease-out;
}

.nav-link:hover, .nav-link.active {
    color: var(--primary-color);
}
.nav-link:hover::after, .nav-link.active::after {
    width: 100%;
}
.nav-actions {
    display: flex;
    align-items: center;
    gap: 1rem;
}
#theme-toggle {
    background: none;
    border: none;
    cursor: pointer;
}
#theme-toggle img {
    height: 24px;
    transition: transform 0.3s ease;
}
#theme-toggle:hover img {
    transform: rotate(15deg);
}

.hamburger {
    display: none;
    cursor: pointer;
}
.hamburger img {
    height: 30px;
}

/* --- HERO SECTION --- */
.hero-section {
    height: 90vh;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    color: white;
    background: linear-gradient(rgba(0, 51, 102, 0.7), rgba(0, 21, 41, 0.8)), url('assets/images/hero-bg.jpg') no-repeat center center/cover;
    position: relative;
    overflow: hidden;
}

.hero-content {
    max-width: 800px;
    padding: 1rem;
}
.hero-content h1 {
    font-size: 3.5rem;
    margin-bottom: 0.5rem;
    color: #fff;
}
.hero-content h2 {
    font-size: 2rem;
    margin-bottom: 1.5rem;
    color: var(--secondary-color);
    text-align: center;
}
.hero-content p {
    font-size: 1.2rem;
    font-family: var(--font-secondary);
    margin-bottom: 2rem;
}
.cta-button {
    background-color: var(--secondary-color);
    color: var(--primary-color);
    padding: 0.8rem 2.5rem;
    border-radius: 50px;
    text-decoration: none;
    font-weight: 700;
    font-size: 1.1rem;
    transition: transform 0.2s, background-color 0.2s;
    display: inline-block;
}
.cta-button:hover {
    transform: translateY(-3px);
    background-color: #e6b840;
}

/* --- OVERVIEW SECTION --- */
.overview-section .container {
    display: grid;
    grid-template-areas: 
        "info timeline"
        "stats stats";
    gap: 2rem;
}
#infographic-container {
    grid-area: info;
    background: var(--card-bg-color);
    padding: 2rem;
    border-radius: 12px;
    box-shadow: var(--shadow);
}
.infographic-title {
    color: var(--primary-color);
    margin-bottom: 1rem;
    text-align: center;
}
.infographic-points {
    list-style: none;
}
.infographic-points li {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1rem;
    font-family: var(--font-secondary);
}
.infographic-points .icon {
    font-size: 1.5rem;
}
.timeline-container {
    grid-area: timeline;
}
.timeline {
    position: relative;
    padding-left: 2rem;
    border-left: 3px solid var(--primary-color);
}
.timeline-item {
    margin-bottom: 2rem;
    position: relative;
}
.timeline-item::before {
    content: '';
    position: absolute;
    left: -2.7rem;
    top: 0.2rem;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--background-color);
    border: 3px solid var(--primary-color);
}
.timeline-year {
    font-weight: 700;
    color: var(--primary-color);
    font-size: 1.2rem;
}
.stats-container {
    grid-area: stats;
    display: flex;
    justify-content: space-around;
    background: var(--card-bg-color);
    padding: 2rem;
    border-radius: 12px;
    box-shadow: var(--shadow);
    text-align: center;
}
.stat-item .stat-number {
    font-size: 3rem;
    font-weight: 700;
    color: var(--secondary-color);
}

/* --- CHAPTERS SECTION --- */
.chapters-section {
    background-color: var(--card-bg-color);
    padding: 4rem 0;
}
.tabs {
    display: flex;
    gap: 2rem;
}
.tab-buttons {
    flex: 0 0 250px;
    display: flex;
    flex-direction: column;
}
.tab-btn {
    width: 100%;
    padding: 1rem;
    border: none;
    background: transparent;
    border-right: 3px solid transparent;
    text-align: left;
    font-family: var(--font-primary);
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.3s;
    color: var(--text-color);
}
.tab-btn.active {
    background: var(--background-color);
    border-right-color: var(--secondary-color);
    font-weight: 700;
    color: var(--primary-color);
}
.tab-content {
    flex: 1;
}
.chapter-content {
    display: none;
}
.chapter-content.active {
    display: block;
    animation: fadeIn 0.5s;
}
.visual-card {
    background: var(--background-color);
    padding: 1.5rem;
    border-radius: 8px;
    margin-bottom: 1.5rem;
    border-left: 5px solid var(--primary-color);
}
.chapter-content h3 {
    margin-bottom: 1rem;
}
.article-list {
    margin: 1.5rem 0;
}
.article-item {
    margin-bottom: 1rem;
    padding-left: 1.5rem;
    position: relative;
}
.article-item::before {
    content: '•';
    color: var(--secondary-color);
    font-weight: bold;
    display: inline-block;
    position: absolute;
    left: 0;
}
.article-item strong {
    color: var(--primary-color);
}

/* --- INTERACTIVE SECTION --- */
.interactive-section {
    padding: 4rem 0;
}
#quiz-container, #game-container {
    background: var(--card-bg-color);
    padding: 2rem;
    border-radius: 12px;
    box-shadow: var(--shadow);
    margin-bottom: 2rem;
}
.quiz-question {
    font-size: 1.2rem;
    font-weight: 500;
    margin-bottom: 1.5rem;
}
.quiz-options {
    list-style: none;
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
}
.quiz-option {
    background: var(--background-color);
    padding: 1rem;
    border-radius: 8px;
    cursor: pointer;
    border: 2px solid var(--border-color);
    transition: all 0.2s;
}
.quiz-option:hover {
    border-color: var(--primary-color);
}
.quiz-option.selected {
    background: #cce5ff;
    border-color: #007bff;
}
.quiz-option.correct { background-color: #d4edda; border-color: #28a745; }
.quiz-option.incorrect { background-color: #f8d7da; border-color: #dc3545; }
#quiz-result { text-align: center; }

.drag-drop-area {
    display: flex;
    justify-content: space-between;
    gap: 2rem;
    margin-top: 1.5rem;
}
.drag-categories, .drag-items {
    width: 48%;
    padding: 1rem;
    min-height: 250px;
    background: var(--background-color);
    border-radius: 8px;
}
.drag-category {
    padding: 1rem;
    border: 2px dashed var(--border-color);
    border-radius: 8px;
    margin-bottom: 1rem;
}
.drag-category.over {
    border-color: var(--primary-color);
}
.drag-item {
    background: var(--card-bg-color);
    padding: 0.8rem;
    border-radius: 8px;
    box-shadow: var(--shadow);
    margin-bottom: 0.5rem;
    cursor: grab;
}
#check-game-btn {
    display: block;
    margin: 1.5rem auto 0;
    padding: 0.7rem 2rem;
    background-color: var(--primary-color);
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
}
#game-feedback { text-align: center; margin-top: 1rem; font-weight: bold; }

.progress-tracker { text-align: center; }
#quiz-progress { width: 50%; }

/* --- FEATURES SECTION --- */
.features-section {
    background-color: var(--card-bg-color);
    padding: 4rem 0;
}
.feature-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
}
.feature-card {
    padding: 2rem;
    background: var(--background-color);
    border-radius: 12px;
}
.search-bar { display: flex; margin-top: 1rem; }
#search-input { flex-grow: 1; padding: 0.7rem; border: 1px solid var(--border-color); border-radius: 8px 0 0 8px; }
#search-btn { padding: 0.7rem 1.5rem; background: var(--primary-color); color: white; border: none; border-radius: 0 8px 8px 0; cursor: pointer; }
#search-results { margin-top: 1rem; }
.glossary-item {
    margin-bottom: 1rem;
}
.glossary-item strong {
    color: var(--primary-color);
}

/* --- FAQ SECTION --- */
.faq-section { padding: 4rem 0; }
.faq-item {
    background: var(--card-bg-color);
    margin-bottom: 1rem;
    border-radius: 8px;
    box-shadow: var(--shadow);
    overflow: hidden;
}
.faq-question {
    width: 100%;
    background: transparent;
    border: none;
    padding: 1.5rem;
    font-family: var(--font-primary);
    font-size: 1.1rem;
    font-weight: 500;
    text-align: left;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: var(--text-color);
}
.faq-question::after {
    content: '+';
    font-size: 1.5rem;
    transition: transform 0.3s;
}
.faq-item.active .faq-question::after {
    transform: rotate(45deg);
}
.faq-answer {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease-out;
}
.faq-answer p {
    padding: 0 1.5rem 1.5rem;
}


/* --- FOOTER --- */
.footer {
    background-color: var(--primary-color);
    color: white;
    text-align: center;
    padding: 1.5rem;
}

/* --- UTILITY CLASSES --- */
.hidden { display: none !important; }

/* --- MODAL --- */
.modal {
    position: fixed;
    z-index: 2000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0,0,0,0.6);
    display: none;
    align-items: center;
    justify-content: center;
}
.modal-content {
    background-color: var(--card-bg-color);
    padding: 2rem;
    border-radius: 12px;
    width: 90%;
    max-width: 600px;
    text-align: center;
    position: relative;
}
.close-button {
    color: #aaa;
    position: absolute;
    top: 10px;
    right: 20px;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
}
@media print {
    body * {
        visibility: hidden;
    }
    #certificate-modal, #certificate-modal * {
        visibility: visible;
    }
    #certificate-modal {
        position: absolute;
        left: 0;
        top: 0;
    }
}