:root {
    --primary-green: #1b3d2b;
    --accent-orange: #d97736;
    --bg-cream: #f4f3ef;
    --dark-text: #1a1a1a;
    --card-bg: #eae7df;
    --white: #ffffff;
    --border-tan: #e2dfd7;
}

body {
    margin: 0;
    padding: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background-color: var(--bg-cream);
    color: var(--dark-text);
}

.hidden {
    display: none !important;
}

/* ========================================== */
/* HEADER & NAVIGATION BUTTON GROUP           */
/* ========================================== */

header {
    background-color: var(--white);
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 5%;
    border-bottom: 1px solid var(--border-tan);
}

.logo {
    font-size: 22px;
    font-weight: 800;
    letter-spacing: 1px;
    color: var(--dark-text);
}

/* Container Box for Header Buttons */
.nav-button-group {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    gap: 8px;
    background: var(--bg-cream);
    padding: 6px 8px;
    border-radius: 10px;
    border: 1px solid var(--border-tan);
}

/* Base Nav Button Rules */
.nav-btn-secondary,
.nav-btn-primary {
    text-decoration: none;
    font-size: 13px;
    font-weight: 600;
    padding: 8px 14px;
    border-radius: 6px;
    transition: all 0.2s ease-in-out;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.nav-btn-secondary {
    background-color: var(--white);
    color: var(--dark-text);
    border: 1px solid var(--border-tan);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

.nav-btn-secondary:hover {
    background-color: var(--card-bg);
    border-color: #d1cdc4;
}

.nav-btn-secondary:active {
    transform: translateY(1px);
}

.nav-btn-primary {
    background-color: var(--dark-text);
    color: var(--white);
    border: 1px solid var(--dark-text);
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.1);
}

.nav-btn-primary:hover {
    background-color: var(--primary-green);
    border-color: var(--primary-green);
}

.nav-btn-primary:active {
    transform: translateY(1px);
}

nav a:not(.nav-btn-secondary):not(.nav-btn-primary) {
    margin-left: 24px;
    text-decoration: none;
    font-weight: 500;
    color: var(--dark-text);
    font-size: 14px;
}

/* ========================================== */
/* HERO SECTION                               */
/* ========================================== */

.hero {
    background-color: var(--primary-green);
    color: var(--white);
    padding: 60px 5%;
    text-align: center;
}

.hero h1 {
    font-size: 32px;
    margin-bottom: 12px;
    font-weight: 700;
}

.hero p {
    font-size: 16px;
    opacity: 0.9;
    max-width: 600px;
    margin: 0 auto;
}

/* Search Bar in Hero */
.hero-search-box {
    margin-top: 20px;
    display: flex;
    justify-content: center;
}

.hero-search-box input {
    width: 100%;
    max-width: 450px;
    padding: 12px 18px;
    border-radius: 25px;
    border: none;
    font-size: 14px;
    outline: none;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

/* ========================================== */
/* CATEGORY & SUB-THEME FILTER SECTION        */
/* ========================================== */

.category-filter-container {
    background-color: var(--white);
    border-bottom: 1px solid var(--border-tan);
    padding: 16px 5%;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.02);
}

.category-pills-row,
.subthemes-pills-row {
    display: flex;
    align-items: center;
    gap: 10px;
    overflow-x: auto;
    white-space: nowrap;
    padding-bottom: 4px;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
}

.category-pills-row::-webkit-scrollbar,
.subthemes-pills-row::-webkit-scrollbar {
    height: 4px;
}

.category-pills-row::-webkit-scrollbar-thumb,
.subthemes-pills-row::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 2px;
}

.filter-label {
    font-size: 13px;
    font-weight: 700;
    color: var(--dark-text);
    margin-right: 5px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.sub-label {
    font-size: 12px;
    font-weight: 700;
    color: var(--primary-green);
    margin-right: 5px;
}

.cat-pill {
    background: var(--bg-cream);
    border: 1px solid var(--border-tan);
    color: var(--dark-text);
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease-in-out;
    outline: none;
}

.cat-pill:hover {
    background: var(--card-bg);
    border-color: var(--primary-green);
}

.cat-pill.active {
    background: var(--primary-green);
    color: var(--white);
    border-color: var(--primary-green);
    box-shadow: 0 2px 6px rgba(27, 61, 43, 0.25);
}

.subthemes-pills-row {
    margin-top: 12px;
    padding-top: 10px;
    border-top: 1px dashed var(--border-tan);
}

.sub-pill {
    background: var(--white);
    border: 1px solid #27ae60;
    color: #27ae60;
    padding: 5px 12px;
    border-radius: 15px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease-in-out;
    outline: none;
}

.sub-pill:hover {
    background: #e8f8f5;
}

.sub-pill.active {
    background: #27ae60;
    color: var(--white);
    border-color: #27ae60;
}

/* ========================================== */
/* CONTENT LAYOUT & BOOK CARDS GRID           */
/* ========================================== */

.content-wrapper {
    padding: 40px 5%;
}

.content-wrapper h2 {
    font-size: 20px;
    font-weight: 700;
    margin-bottom: 25px;
}

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

.book-card {
    background-color: var(--card-bg);
    padding: 16px;
    border-radius: 6px;
    display: flex;
    flex-direction: column;
    box-shadow: 0 2px 6px rgba(0,0,0,0.04);
}

.book-cover-placeholder {
    height: 240px;
    background-color: #d1cdc4;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 32px;
    margin-bottom: 14px;
    border: 1px solid var(--border-tan);
}

.book-card img {
    width: 100%;
    height: 280px;
    object-fit: contain;
    background-color: #e0dcd3;
    border-radius: 4px;
    margin-bottom: 14px;
    border: 1px solid var(--border-tan);
    box-sizing: border-box;
}

.book-card h3 {
    margin: 0 0 6px 0;
    font-size: 16px;
    font-weight: 600;
}

.author-tag {
    margin: 0 0 16px 0;
    font-size: 13px;
    opacity: 0.7;
}

.price-tag {
    font-weight: 700;
    color: var(--accent-orange);
    margin: 0 0 14px 0;
}

.buy-btn {
    background-color: var(--primary-green);
    color: var(--white);
    border: none;
    padding: 10px;
    border-radius: 4px;
    font-weight: 600;
    cursor: pointer;
    margin-top: auto;
    transition: background 0.2s;
}

.buy-btn:hover {
    background-color: #24523a;
}

/* ========================================== */
/* MODALS (PREVIEW & TOP AUTHORS)             */
/* ========================================== */

.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.6);
    display: none; /* Managed dynamically by JS using 'flex' */
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 20px;
    box-sizing: border-box;
}

.modal-content {
    background: var(--white);
    border-radius: 8px;
    max-width: 600px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    padding: 25px;
    position: relative;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
}

.modal-close-btn {
    position: absolute;
    top: 15px;
    right: 15px;
    background: transparent;
    border: none;
    font-size: 20px;
    font-weight: bold;
    cursor: pointer;
    color: #666;
}

/* ========================================== */
/* AD PLACEMENT & PROMO BANNER SYSTEM          */
/* ========================================== */

.ad-container {
    width: 100%;
    max-width: 1100px;
    margin: 20px auto;
    padding: 0 5%;
    box-sizing: border-box;
}

.ad-content {
    background: var(--white);
    border: 1px solid var(--border-tan);
    border-radius: 6px;
    padding: 14px 20px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 55px;
    text-align: center;
}

.house-ad {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
    flex-wrap: wrap;
    width: 100%;
}

.house-ad p {
    margin: 0;
    font-size: 14px;
    color: var(--dark-text);
}

.ad-badge {
    background: var(--accent-orange);
    color: var(--white);
    font-size: 10px;
    font-weight: 800;
    padding: 3px 8px;
    border-radius: 3px;
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

.ad-cta-btn {
    background: var(--primary-green);
    color: var(--white);
    text-decoration: none;
    font-size: 13px;
    font-weight: 600;
    padding: 8px 16px;
    border-radius: 4px;
    transition: opacity 0.2s;
    white-space: nowrap;
}

.ad-cta-btn:hover {
    opacity: 0.9;
}

.ad-footer-slot {
    margin-top: 40px;
    margin-bottom: 20px;
}

/* ========================================== */
/* MOBILE RESPONSIVE MEDIA QUERIES            */
/* ========================================== */

@media (max-width: 650px) {
    header {
        flex-direction: column;
        gap: 12px;
        padding: 15px 5%;
        text-align: center;
    }

    .nav-button-group {
        width: 100%;
        gap: 6px;
        padding: 6px;
    }

    .nav-btn-secondary,
    .nav-btn-primary {
        flex: 1 1 auto;
        font-size: 12px;
        padding: 7px 10px;
        white-space: nowrap;
    }

    .house-ad {
        flex-direction: column;
        gap: 10px;
    }
    
    .ad-content {
        padding: 12px;
    }

    .hero h1 {
        font-size: 24px;
    }

    .hero p {
        font-size: 14px;
    }

    .category-filter-container {
        padding: 12px 15px;
    }

    .cat-pill {
        padding: 6px 12px;
        font-size: 12px;
    }
}

/* ========================================== */
/* FOOTER & COPYRIGHT SECTION                 */
/* ========================================== */

.site-footer {
    background-color: var(--white);
    border-top: 1px solid var(--border-tan);
    padding: 24px 5%;
    margin-top: 40px;
    text-align: center;
}

.footer-content {
    max-width: 800px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}

.copyright-text {
    margin: 0;
    font-size: 13px;
    color: var(--dark-text);
    opacity: 0.85;
    line-height: 1.5;
}

.footer-links {
    margin-top: 4px;
}

.footer-link {
    color: var(--primary-green);
    font-size: 13px;
    font-weight: 600;
    text-decoration: underline;
    text-underline-offset: 3px;
    transition: opacity 0.2s ease, color 0.2s ease;
}

.footer-link:hover {
    color: var(--accent-orange);
    opacity: 0.9;
}

.footer-link:active {
    color: var(--primary-green);
}

.main-site-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background-color: rgba(255, 255, 255, 0.15);
    color: var(--white, #ffffff);
    border: 1px solid rgba(255, 255, 255, 0.3);
    padding: 6px 12px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 600;
    text-decoration: none;
    transition: all 0.2s ease-in-out;
    white-space: nowrap;
}

.main-site-btn:hover {
    background-color: var(--white, #ffffff);
    color: var(--primary-green, #1b3d2b);
    border-color: var(--white, #ffffff);
}

.main-site-btn:active {
    transform: translateY(1px);
}
