/* 
   Vietnam Herbicide Operations - Historical Archive Style 
   Palette: Dark Olive, Muted Khaki, Warm Gray, Off-White
*/

:root {
    --bg-color: #f4f4f0;
    /* Warm off-white paper */
    --text-color: #2b2b2b;
    /* Charcoal */
    --accent-color: #8c9c5e;
    /* Faded Olive */
    --accent-dark: #5c6b3f;
    /* Darker Olive */
    --highlight: #d47e48;
    /* Rust Orange (sparingly) */
    --border-color: #dcdcd9;
    /* Subtle divider */
    --card-bg: #ffffff;
    --font-heading: 'Times New Roman', Times, serif;
    /* Classic Serif */
    --font-body: 'Roboto', 'Arial', sans-serif;
    /* Readable Sans */
    --header-height: auto;
}

html {
    box-sizing: border-box;
}

*,
*:before,
*:after {
    box-sizing: inherit;
}

body,
html {
    margin: 0;
    padding: 0;
    height: 100%;
    font-family: var(--font-body);
    background-color: var(--bg-color);
    color: var(--text-color);
    line-height: 1.6;
}

h1,
h2,
h3,
h4 {
    font-family: var(--font-heading);
    font-weight: normal;
    margin-top: 0;
    color: #1a1a1a;
}

/* --- Header --- */
.site-header {
    background-color: #fff;
    border-bottom: 1px solid #d1d1d1;
    padding: 20px 40px;
}

.header-inner {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    flex-wrap: wrap;
    gap: 20px;
}

.site-identity h1 {
    font-size: 28px;
    margin-bottom: 5px;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    color: var(--text-color);
}

.site-identity .subtitle {
    font-size: 15px;
    color: #666;
    margin: 0;
    max-width: 600px;
    font-style: italic;
    font-family: var(--font-heading);
}

.lang-switcher button {
    background: none;
    border: 1px solid transparent;
    cursor: pointer;
    font-size: 13px;
    padding: 5px 10px;
    color: #777;
    margin-left: 5px;
    font-weight: 500;
    transition: all 0.2s;
}

.lang-switcher button:hover {
    color: #000;
    border-color: #ddd;
}

.lang-switcher button.active {
    color: #000;
    border: 1px solid #999;
    background-color: #f0f0f0;
}

/* --- Map Container --- */
.map-container {
    position: relative;
    width: 100%;
    height: 75vh;
    /* Desktop height */
    background-color: #ddd;
    border-bottom: 4px solid var(--accent-dark);
}

#map {
    height: 100%;
    width: 100%;
    z-index: 1;
}

/* Redesigned Control Panel (Paper Card Style) */
.control-panel {
    position: absolute;
    top: 20px;
    right: 20px;
    width: 300px;
    background: #fff;
    padding: 20px;
    border: 1px solid #ccc;
    box-shadow: 2px 2px 0px rgba(0, 0, 0, 0.1);
    /* Hard shadow for retro feel */
    z-index: 1000;
    max-height: calc(75vh - 40px);
    overflow-y: auto;
}

.control-panel h2 {
    font-size: 16px;
    text-transform: uppercase;
    letter-spacing: 1px;
    border-bottom: 1px solid #eee;
    padding-bottom: 10px;
    margin-bottom: 15px;
    color: var(--accent-dark);
    font-weight: bold;
    font-family: var(--font-body);
}

.filter-group {
    margin-bottom: 20px;
}

.filter-group label {
    display: block;
    margin-bottom: 8px;
    font-size: 13px;
    font-weight: bold;
    color: #444;
    text-transform: uppercase;
}

/* Custom UI Elements */
input[type=range] {
    width: 100%;
    cursor: pointer;
}

.year-ticks {
    display: flex;
    justify-content: space-between;
    font-size: 11px;
    color: #777;
    margin-top: 4px;
    font-family: monospace;
}

select {
    width: 100%;
    padding: 8px;
    border-radius: 0;
    border: 1px solid #999;
    background: #f9f9f9;
    font-family: var(--font-body);
}

/* --- Toggle Switch (Refined) --- */
.toggle-wrapper {
    display: flex;
    align-items: center;
    gap: 10px;
}

.toggle-label {
    font-size: 13px;
    color: #666;
}

.switch {
    position: relative;
    display: inline-block;
    width: 40px;
    height: 20px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
    transition: .4s;
    border-radius: 20px;
}

.slider:before {
    position: absolute;
    content: "";
    height: 14px;
    width: 14px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: .4s;
    border-radius: 50%;
}

input:checked+.slider {
    background-color: var(--accent-dark);
}

input:checked+.slider:before {
    transform: translateX(20px);
}

/* --- Play Button (Refined) --- */
.btn-play {
    width: 100%;
    padding: 8px;
    background-color: var(--text-color);
    color: #fff;
    border: none;
    cursor: pointer;
    font-size: 13px;
    text-transform: uppercase;
    font-weight: bold;
    letter-spacing: 0.5px;
    transition: background 0.3s;
}

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

.btn-play.playing {
    background-color: var(--highlight);
}

/* Stats & Legend */
.stats {
    font-size: 13px;
    background: #f4f4f0;
    padding: 10px;
    border: 1px solid #e0e0e0;
    margin-bottom: 20px;
    font-family: monospace;
}

.legend-item {
    font-size: 12px;
    display: flex;
    align-items: center;
    margin-bottom: 4px;
}

.color-box {
    width: 12px;
    height: 12px;
    margin-right: 8px;
    border: 1px solid rgba(0, 0, 0, 0.1);
}

.meta {
    margin-top: 20px;
    border-top: 1px solid #eee;
    padding-top: 10px;
    color: #888;
    font-size: 11px;
    line-height: 1.4;
}

/* --- Content Sections --- */
.content-sections {
    max-width: 1000px;
    margin: 0 auto;
    padding: 60px 20px;
}

.info-section {
    margin-bottom: 60px;
}

.info-section h2 {
    font-size: 32px;
    border-bottom: 3px double #dcdcd9;
    padding-bottom: 15px;
    margin-bottom: 30px;
    color: var(--text-color);
}

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

.card {
    background: #fff;
    padding: 25px;
    border: 1px solid #dcdcd9;
    /* archival note aesthetic */
}

.card h3 {
    font-size: 22px;
    border-bottom: 1px solid var(--accent-color);
    padding-bottom: 10px;
    margin-bottom: 15px;
}

.card p {
    font-size: 15px;
    color: #444;
}

.note {
    font-size: 14px;
    color: #666;
    font-style: italic;
    background: #f9f9f9;
    padding: 10px;
    border-left: 2px solid #ccc;
    margin-top: 15px;
}

.warning {
    font-size: 14px;
    color: #8a4a4a;
    border-left: 2px solid #d47e48;
    padding-left: 10px;
    margin-top: 10px;
}

.text-content {
    font-size: 18px;
    max-width: 800px;
    color: #333;
}

.data-list li {
    font-size: 16px;
    margin-bottom: 12px;
    color: #444;
    list-style-type: square;
}

.sources-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 40px;
    background: #fff;
    padding: 30px;
    border: 1px solid #eee;
}

.sources-grid h4 {
    font-size: 16px;
    text-transform: uppercase;
    color: var(--accent-dark);
    margin-bottom: 15px;
}

.sources-grid ul {
    padding-left: 20px;
}

.sources-grid li {
    margin-bottom: 8px;
    font-size: 14px;
}

.sources-grid a {
    color: #2b2b2b;
    text-decoration: underline;
    text-decoration-color: var(--accent-color);
    text-underline-offset: 3px;
}

.sources-grid a:hover {
    color: var(--highlight);
}

/* --- Footer --- */
.site-footer {
    text-align: center;
    padding: 40px;
    background: #e6e6e3;
    color: #666;
    font-size: 14px;
    border-top: 1px solid #ccc;
    margin-top: 60px;
}

/* --- Mobile Responsiveness --- */
@media (max-width: 768px) {
    .site-header {
        padding: 15px 20px;
    }

    .header-inner {
        flex-direction: column;
        align-items: center;
        text-align: center;
    }

    .lang-switcher {
        margin-top: 10px;
    }

    .map-container {
        height: 60vh;
    }

    .control-panel {
        top: auto;
        bottom: 0;
        right: 0;
        left: 0;
        width: 100%;
        max-height: 40%;
        border-radius: 20px 20px 0 0;
        box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1);
        border: none;
        overflow-y: auto;
    }

    .control-panel h2 {
        text-align: center;
        position: sticky;
        top: 0;
        background: #fff;
        z-index: 10;
        padding-top: 10px;
    }

    .info-section h2 {
        font-size: 24px;
    }

    .card {
        padding: 20px;
    }
}

/* --- Gallery & New Section Styles --- */
.archive-gallery {
    display: flex;
    gap: 20px;
    margin-top: 30px;
    flex-wrap: wrap;
}

.gallery-item {
    margin: 0;
    flex: 1;
    min-width: 250px;
    background: #fff;
    padding: 10px;
    border: 1px solid #dcdcd9;
    box-shadow: 2px 2px 5px rgba(0, 0, 0, 0.05);
}

.gallery-item img {
    width: 100%;
    height: auto;
    display: block;
    filter: sepia(0.2) contrast(1.1);
    /* Slight archival feel */
}

.gallery-item figcaption {
    margin-top: 10px;
    font-size: 13px;
    color: #666;
    font-style: italic;
    border-top: 1px solid #eee;
    padding-top: 8px;
}

.content-wrapper {
    display: flex;
    gap: 40px;
    align-items: flex-start;
    flex-wrap: wrap;
}

.content-wrapper .text-content {
    flex: 2;
    min-width: 300px;
}

.sidebar-gallery {
    flex: 1;
    min-width: 300px;
    margin-top: 0;
}

.gallery-item.large {
    width: 100%;
}

.warning-caption {
    color: #8a4a4a;
    border-left: 2px solid #d47e48;
    padding-left: 10px;
}

@media (max-width: 768px) {
    .content-wrapper {
        flex-direction: column;
    }

    .col-2 {
        grid-template-columns: 1fr;
    }

    .sidebar-gallery {
        width: 100%;
        margin-top: 20px;
    }
}

/* --- Library / Recommended Reading --- */
.books-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 24px;
    margin-top: 20px;
}

.book-card {
    display: flex;
    flex-direction: column;
    background: #fff;
    border: 1px solid var(--border-color);
    padding: 20px;
    box-shadow: 2px 2px 0px rgba(0, 0, 0, 0.05);
}

.book-cover {
    width: 100%;
    height: 260px;
    object-fit: contain;
    background: #eee;
    border: 1px solid #ddd;
    margin-bottom: 15px;
}

.book-card h3 {
    font-size: 18px;
    margin-bottom: 5px;
    line-height: 1.3;
    color: var(--text-color);
    border-bottom: none;
    padding-bottom: 0;
}

.book-author {
    font-size: 14px;
    color: #666;
    margin-bottom: 10px;
    font-style: italic;
    font-weight: 500;
}

.book-description {
    font-size: 14px;
    color: #444;
    margin-bottom: 15px;
    flex-grow: 1;
    line-height: 1.4;
    max-height: 4.2em;
    /* Ensure it cuts cleanly up to 3 lines */
    overflow: hidden;
}

.amazon-link {
    display: inline-block;
    padding: 8px 16px;
    background-color: var(--text-color);
    color: #fff;
    text-decoration: none;
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: bold;
    align-self: flex-start;
    transition: background 0.2s;
    border: 1px solid var(--text-color);
}

.amazon-link:hover {
    background-color: var(--highlight);
    border-color: var(--highlight);
    color: #fff;
}

.amazon-disclaimer {
    margin-top: 30px;
    text-align: right;
    font-style: italic;
    color: #777;
    border-top: 1px dotted #ccc;
    padding-top: 10px;
}

@media (max-width: 1024px) {
    .books-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 640px) {
    .books-grid {
        grid-template-columns: 1fr;
    }
}