/* =========================================
   1. Theme Variables (Native Dark Mode)
   ========================================= */
:root {
    /* Light Theme Tokens */
    --bg-base: #faf9f6;
    --bg-surface: #ffffff;
    --text-main: #1a1a1a;
    --text-muted: #666666;
    --accent: #b05a41;
    --accent-hover: #8e4833;
    
    --border-color: rgba(0, 0, 0, 0.08);
    --border-hover: rgba(0, 0, 0, 0.15);
    
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.04);
    --shadow-hover: 0 20px 40px -12px rgba(0, 0, 0, 0.1);
    
    /* Semantic Quiz Colors */
    --success-bg: #e6f4ea;
    --success-text: #137333;
    --error-bg: #fce8e6;
    --error-text: #c5221f;

    /* Typography & Spacing */
    --font-serif: 'Newsreader', serif;
    --font-sans: 'Outfit', -apple-system, sans-serif;
    --transition: 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg-base: #0a0a0a;
        --bg-surface: #141414;
        --text-main: #ededed;
        --text-muted: #888888;
        --accent: #d2775c;
        --accent-hover: #e08b73;
        
        --border-color: rgba(255, 255, 255, 0.08);
        --border-hover: rgba(255, 255, 255, 0.2);
        
        --shadow-sm: 0 4px 12px rgba(0, 0, 0, 0.4);
        --shadow-hover: 0 24px 48px -12px rgba(0, 0, 0, 0.6);
        
        --success-bg: rgba(19, 115, 51, 0.2);
        --success-text: #5bb974;
        --error-bg: rgba(197, 34, 31, 0.2);
        --error-text: #e25c59;
    }
}

/* =========================================
   2. Modern Reset & Base Typography
   ========================================= */
*, *::before, *::after { 
    margin: 0; 
    padding: 0; 
    box-sizing: border-box; 
}

body {
    font-family: var(--font-sans);
    background-color: var(--bg-base);
    color: var(--text-main);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3 {
    font-family: var(--font-serif);
    font-weight: 500;
    line-height: 1.1;
    letter-spacing: -0.02em;
}

a { 
    color: inherit; 
    text-decoration: none; 
    transition: var(--transition); 
}

.container {
    width: 100%;
    max-width: 1120px;
    margin: 0 auto;
    padding: 0 2rem;
}

/* =========================================
   3. Header & Navigation (Glassmorphism)
   ========================================= */
.site-header {
    position: sticky;
    top: 0;
    z-index: 100;
    background-color: rgba(var(--bg-base), 0.8);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border-color);
    padding: 1.25rem 0;
    margin-bottom: clamp(3rem, 6vw, 5rem);
}

.site-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo a {
    font-family: var(--font-serif);
    font-size: 1.5rem;
    font-weight: 600;
}

.nav-links { 
    display: flex; 
    gap: 2.5rem; 
    font-size: 0.95rem; 
    font-weight: 500; 
}
.nav-links a { color: var(--text-muted); }
.nav-links a:hover, .nav-links a.active { color: var(--text-main); }

@media (max-width: 768px) {
    .site-nav {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }
    .nav-links {
        width: 100%;
        overflow-x: auto;
        padding-bottom: 0.5rem;
        gap: 1rem !important;
        -webkit-overflow-scrolling: touch;
    }
}

.article-header {
    text-align: center;
    max-width: 760px;
    margin: 0 auto clamp(3rem, 6vw, 5rem);
}

.article-header h1 {
    font-size: clamp(2.5rem, 6vw, 4rem);
    margin-bottom: 1.25rem;
}

.article-header p.subtitle {
    font-size: clamp(1.1rem, 2vw, 1.3rem);
    color: var(--text-muted);
}

/* =========================================
   4. Premium Grid & Card Architecture
   ========================================= */
.hub-grid {
    display: grid;
    grid-template-columns: 1fr; /* Mobile: 1 column */
    gap: 1.5rem;
    margin-bottom: 6rem;
}

/* Tablet Layout */
@media (min-width: 768px) {
    .hub-grid {
        grid-template-columns: repeat(2, 1fr); 
    }
    .quiz-wrapper { 
        grid-column: 1 / -1; 
    }
}

/* Desktop Layout (3-3-Full Structure) */
@media (min-width: 1080px) {
    .hub-grid {
        grid-template-columns: repeat(3, 1fr); 
    }
    .quiz-wrapper { 
        grid-column: 1 / -1; 
        max-width: 800px; 
        margin: 0 auto;   
    }
}

.hub-card {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 2.5rem;
    box-shadow: var(--shadow-sm);
    transition: var(--transition);
}

a.hub-card:not(.inactive-card):hover {
    transform: translateY(-4px) scale(1.01);
    box-shadow: var(--shadow-hover);
    border-color: var(--border-hover);
}

.hub-card h2 { font-size: 1.75rem; margin-bottom: 1rem; }
.hub-card p { color: var(--text-muted); font-size: 1.05rem; }

.card-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 2rem;
    color: var(--accent);
}

.card-footer svg {
    transition: transform var(--transition);
}

a.hub-card:hover .card-footer svg {
    transform: translateX(4px);
}

/* Fallback for inactive modules */
.inactive-card {
    cursor: default;
    opacity: 0.85; 
}
.inactive-card:hover {
    transform: none !important; 
    box-shadow: var(--shadow-sm) !important;
    border-color: var(--border-color) !important;
}

/* =========================================
   5. Interactive Quiz Module
   ========================================= */
.quiz-wrapper { 
    grid-column: 1 / -1; 
    max-width: 800px; 
    margin: 0 auto; 
    width: 100%; 
}

.quiz-question {
    font-size: clamp(1.25rem, 3vw, 1.75rem);
    font-family: var(--font-serif);
    margin-bottom: 2.5rem;
}

.quiz-options { 
    list-style: none; 
    display: grid; 
    gap: 1rem; 
}

.quiz-options li {
    background: var(--bg-base);
    border: 1px solid var(--border-color);
    padding: 1.25rem 1.5rem;
    border-radius: 12px;
    cursor: pointer;
    font-size: 1.05rem;
    transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

/* Micro-interactions */
.quiz-options li:active:not(.locked) { transform: scale(0.98); }
.quiz-options li:hover:not(.locked) { border-color: var(--text-main); }
.quiz-options li.selected {
    background: var(--text-main);
    color: var(--bg-surface);
    border-color: var(--text-main);
}

/* Validation States */
.quiz-options li.locked { cursor: default; pointer-events: none; }
.quiz-options li.correct { background: var(--success-bg); color: var(--success-text); border-color: var(--success-text); }
.quiz-options li.incorrect { background: var(--error-bg); color: var(--error-text); border-color: var(--error-text); }

.btn {
    margin-top: 2rem;
    background: var(--accent);
    color: #fff;
    border: none;
    padding: 1rem 2rem;
    border-radius: 8px;
    font-weight: 500;
    font-size: 1rem;
    cursor: pointer;
    transition: transform 0.2s, background-color 0.2s;
    width: 100%;
}

.btn:hover { background: var(--accent-hover); }
.btn:active { transform: scale(0.98); }

.result-container {
    margin-top: 2.5rem;
    padding: 1.5rem;
    border-radius: 12px;
    background: var(--bg-base);
    animation: slideUp 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

.result-title { margin-bottom: 0.5rem; font-family: var(--font-sans); }
.result-title.success { color: var(--success-text); }
.result-title.error { color: var(--error-text); }

/* =========================================
   6. Loaders, Animations & Footer
   ========================================= */
.skeleton-loader { display: flex; flex-direction: column; gap: 1rem; }
.skeleton-line {
    background: linear-gradient(90deg, var(--border-color) 25%, var(--bg-base) 50%, var(--border-color) 75%);
    background-size: 200% 100%;
    animation: loading 1.5s infinite;
    border-radius: 8px;
}
.skeleton-line.title { height: 2rem; width: 80%; margin-bottom: 1.5rem; }
.skeleton-line.option { height: 3.5rem; width: 100%; }

@keyframes loading {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

@keyframes slideUp {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.site-footer {
    border-top: 1px solid var(--border-color);
    padding: 4rem 0;
    text-align: center;
}
.footer-links { 
    display: flex; 
    justify-content: center; 
    gap: 2rem; 
    margin-bottom: 1.5rem; 
}
.footer-links a { color: var(--text-muted); font-size: 0.95rem; }
.footer-links a:hover { color: var(--text-main); }
.copyright { color: var(--text-muted); font-size: 0.85rem; }

/* =========================================
   7. Documentation Layout (Syllabus/Topic Pages)
   ========================================= */

/* Main Docs Container */
.docs-container {
    display: flex;
    flex-direction: column;
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 1.5rem;
}

@media (min-width: 1024px) {
    .docs-container {
        display: grid;
        grid-template-columns: 260px minmax(0, 1fr) 220px;
        gap: 3rem;
        align-items: flex-start;
    }
}

/* Left Sidebar (Syllabus) */
.docs-sidebar {
    display: none;
    position: sticky;
    top: 100px; /* Account for header */
    height: calc(100vh - 100px);
    overflow-y: auto;
    padding-bottom: 2rem;
    border-right: 1px solid var(--border-color);
    padding-right: 1.5rem;
}

@media (min-width: 1024px) {
    .docs-sidebar { display: block; }
}

.docs-sidebar h4 {
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    margin: 1.5rem 0 0.75rem 0;
}
.docs-sidebar h4:first-child { margin-top: 0; }

.docs-sidebar ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.docs-sidebar li {
    margin-bottom: 0.35rem;
}

.docs-sidebar a {
    display: block;
    padding: 0.4rem 0.5rem;
    color: var(--text-muted);
    border-radius: 6px;
    font-size: 0.95rem;
    transition: var(--transition);
}

.docs-sidebar a:hover {
    color: var(--text-main);
    background: var(--border-color);
}

.docs-sidebar a.active {
    color: var(--accent);
    background: rgba(176, 90, 65, 0.1);
    font-weight: 500;
}
@media (prefers-color-scheme: dark) {
    .docs-sidebar a.active { background: rgba(210, 119, 92, 0.15); }
}


/* Main Content Area */
.docs-main {
    min-width: 0;
    padding-bottom: 4rem;
}

/* Breadcrumbs */
.breadcrumbs {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.9rem;
    color: var(--text-muted);
    margin-bottom: 2rem;
}
.breadcrumbs a { transition: color 0.2s; }
.breadcrumbs a:hover { color: var(--text-main); }
.breadcrumbs svg { opacity: 0.5; width: 14px; height: 14px; }


/* Right TOC */
.docs-toc {
    display: none;
    position: sticky;
    top: 100px;
    height: calc(100vh - 100px);
    overflow-y: auto;
    padding-bottom: 2rem;
    padding-left: 1rem;
    border-left: 1px solid var(--border-color);
}
@media (min-width: 1280px) {
    .docs-toc { display: block; }
}
.docs-toc h5 {
    font-size: 0.85rem;
    text-transform: uppercase;
    color: var(--text-main);
    margin-bottom: 1rem;
    font-family: var(--font-sans);
}
.docs-toc ul { list-style: none; padding: 0; margin: 0; }
.docs-toc li { margin-bottom: 0.5rem; }
.docs-toc a {
    color: var(--text-muted);
    font-size: 0.85rem;
    transition: color 0.2s;
    display: block;
    line-height: 1.4;
}
.docs-toc a:hover { color: var(--text-main); }


/* Pagination (Next / Prev) */
.docs-pagination {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1rem;
    margin-top: 4rem;
    padding-top: 2rem;
    border-top: 1px solid var(--border-color);
}

@media (min-width: 640px) {
    .docs-pagination { grid-template-columns: 1fr 1fr; }
}

.docs-pagination a {
    display: flex;
    flex-direction: column;
    padding: 1.5rem;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    transition: var(--transition);
    background: var(--bg-surface);
}

.docs-pagination a:hover {
    border-color: var(--text-main);
    transform: translateY(-2px);
    box-shadow: var(--shadow-sm);
}

.docs-pagination a .label {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.docs-pagination a .title {
    font-size: 1.1rem;
    color: var(--accent);
    font-weight: 500;
}

.docs-pagination a.next { text-align: right; }

/* =========================================
   8. Constitution Explorer UI
   ========================================= */

.explorer-container {
    display: flex;
    flex-direction: column;
    height: auto;
    border-top: 1px solid var(--border-color);
}

@media (min-width: 768px) {
    .explorer-container {
        flex-direction: row;
        height: calc(100vh - 80px);
        overflow: hidden;
    }
}

.explorer-sidebar {
    width: 100%;
    max-height: 40vh;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    background: var(--bg-surface);
}

@media (min-width: 768px) {
    .explorer-sidebar {
        width: 350px;
        max-height: none;
        flex-shrink: 0;
        border-bottom: none;
        border-right: 1px solid var(--border-color);
        height: 100%;
    }
}

.explorer-search {
    padding: 1.5rem;
    border-bottom: 1px solid var(--border-color);
    position: relative;
}
.explorer-search svg {
    position: absolute;
    left: 2rem;
    top: 50%;
    transform: translateY(-50%);
    width: 18px;
    height: 18px;
    color: var(--text-muted);
}
.explorer-search input {
    width: 100%;
    padding: 0.75rem 1rem 0.75rem 2.5rem;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: var(--bg-base);
    color: var(--text-main);
    font-size: 0.95rem;
}
.explorer-search input:focus {
    outline: none;
    border-color: var(--accent);
}

.explorer-filters {
    display: flex;
    gap: 0.5rem;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border-color);
}
.filter-btn {
    background: transparent;
    border: 1px solid var(--border-color);
    padding: 0.25rem 0.75rem;
    border-radius: 16px;
    font-size: 0.8rem;
    color: var(--text-muted);
    cursor: pointer;
    transition: var(--transition);
}
.filter-btn.active, .filter-btn:hover {
    background: var(--text-main);
    color: var(--bg-base);
    border-color: var(--text-main);
}

.explorer-results {
    flex: 1;
    overflow-y: auto;
}

.explorer-item {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--border-color);
    cursor: pointer;
    transition: background 0.2s;
}
.explorer-item:hover {
    background: var(--bg-base);
}
.explorer-item.active {
    background: rgba(176, 90, 65, 0.05);
    border-left: 3px solid var(--accent);
}
@media (prefers-color-scheme: dark) {
    .explorer-item.active { background: rgba(210, 119, 92, 0.1); }
}

.type-badge {
    display: inline-block;
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    font-size: 0.7rem;
    text-transform: uppercase;
    font-weight: 600;
    margin-bottom: 0.5rem;
}
.type-badge.article { background: rgba(176, 90, 65, 0.15); color: var(--accent); }
.type-badge.act { background: rgba(46, 204, 113, 0.15); color: #2ecc71; }
@media (prefers-color-scheme: dark) {
    .type-badge.article { background: rgba(210, 119, 92, 0.2); color: #d2775c; }
}

.item-title {
    font-size: 1rem;
    font-weight: 500;
    margin-bottom: 0.25rem;
    color: var(--text-main);
}
.item-cat {
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* Main Content Pane */
.explorer-main {
    flex: 1;
    overflow-y: auto;
    padding: 2rem;
    background: var(--bg-base);
}
@media (min-width: 768px) {
    .explorer-main { padding: 4rem; }
}

.explorer-empty-state {
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    color: var(--text-muted);
}
.explorer-empty-state svg {
    width: 64px;
    height: 64px;
    margin-bottom: 1.5rem;
    opacity: 0.5;
}

.explorer-article {
    max-width: 800px;
    margin: 0 auto;
}
.explorer-article h1 {
    font-size: 2.5rem;
    margin: 1rem 0 2rem 0;
}
.type-tag, .cat-tag {
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-right: 1rem;
}
.type-tag { color: var(--accent); font-weight: 600; }
.cat-tag { color: var(--text-muted); }

.content-section {
    margin-bottom: 2.5rem;
}
.content-section h3 {
    font-family: var(--font-sans);
    font-size: 1.1rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 0.5rem;
    margin-bottom: 1rem;
}
.content-section p, .content-section ul {
    font-size: 1.1rem;
    line-height: 1.8;
    color: var(--text-main);
}
.content-section ul {
    padding-left: 1.5rem;
}
.content-section li {
    margin-bottom: 0.5rem;
}

.content-section.bare-text p {
    font-family: 'Newsreader', serif;
    font-style: italic;
    color: var(--text-muted);
    border-left: 4px solid var(--border-color);
    padding-left: 1.5rem;
    font-size: 1.2rem;
}

.content-section.example {
    background: var(--bg-surface);
    padding: 1.5rem;
    border-radius: 8px;
    border-left: 4px solid #2ecc71;
}
.content-section.example h3 { border-bottom: none; color: #2ecc71; margin-bottom: 0.5rem; }

