/* Reset and base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #2c3e50;
    --secondary-color: #34495e;
    --accent-color: #8b7355;
    --light-accent: #f4f2f0;
    --text-primary: #2c3e50;
    --text-secondary: #5d6d7e;
    --text-muted: #7f8c8d;
    --background: #fefcfa;
    --sidebar-bg: #f8f6f3;
    --border-color: #e8e6e3;
    --shadow: rgba(44, 62, 80, 0.1);
    
    --font-primary: 'Crimson Text', serif;
    --font-secondary: 'Inter', sans-serif;
    
    --sidebar-width: 320px;
    --content-max-width: 800px;
}

body {
    font-family: var(--font-primary);
    background-color: var(--background);
    color: var(--text-primary);
    line-height: 1.7;
    font-size: 18px;
}

.container {
    display: flex;
    min-height: 100vh;
}

/* Sidebar Navigation */
.sidebar {
    width: var(--sidebar-width);
    background-color: var(--sidebar-bg);
    border-right: 1px solid var(--border-color);
    padding: 2rem 0;
    position: fixed;
    height: 100vh;
    overflow-y: auto;
    z-index: 100;
}

.nav-header {
    padding: 0 2rem 2rem;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 2rem;
}

.book-title {
    font-family: var(--font-primary);
    font-size: 1.8rem;
    font-weight: 600;
    color: var(--primary-color);
    margin-bottom: 0.5rem;
    line-height: 1.3;
}

.book-subtitle {
    font-family: var(--font-secondary);
    font-size: 0.9rem;
    color: var(--text-secondary);
    font-style: italic;
    font-weight: 300;
}

.nav-content {
    padding: 0 1rem;
}

.nav-list {
    list-style: none;
}

.nav-item {
    margin-bottom: 0.5rem;
}

.nav-link {
    display: block;
    padding: 0.75rem 1rem;
    color: var(--text-secondary);
    text-decoration: none;
    border-radius: 8px;
    font-family: var(--font-secondary);
    font-weight: 400;
    font-size: 0.95rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.nav-item:hover .nav-link,
.nav-item.active .nav-link {
    background-color: var(--light-accent);
    color: var(--primary-color);
}

.nav-item.active .nav-link {
    font-weight: 500;
}

.nav-sublist {
    list-style: none;
    margin-top: 0.5rem;
    margin-left: 1rem;
    border-left: 2px solid var(--border-color);
}

.nav-subitem {
    padding: 0.4rem 0 0.4rem 1rem;
    font-size: 0.85rem;
    color: var(--text-muted);
    cursor: pointer;
    transition: color 0.2s ease;
    font-family: var(--font-secondary);
}

.nav-subitem:hover,
.nav-subitem.active {
    color: var(--accent-color);
}

/* Main Content */
.main-content {
    margin-left: var(--sidebar-width);
    flex: 1;
    padding: 3rem;
}

.content-wrapper {
    max-width: var(--content-max-width);
    margin: 0 auto;
}

#content-area {
    background-color: white;
    padding: 3rem;
    border-radius: 12px;
    box-shadow: 0 4px 6px var(--shadow);
    margin-bottom: 2rem;
    min-height: 500px;
}

/* Typography */
#content-area h1 {
    font-size: 2.5rem;
    color: var(--primary-color);
    margin-bottom: 1rem;
    line-height: 1.3;
    font-weight: 600;
}

#content-area h2 {
    font-size: 2rem;
    color: var(--secondary-color);
    margin: 2.5rem 0 1.5rem;
    line-height: 1.4;
    font-weight: 600;
}

#content-area h3 {
    font-size: 1.5rem;
    color: var(--secondary-color);
    margin: 2rem 0 1rem;
    font-weight: 600;
}

#content-area p {
    margin-bottom: 1.5rem;
    text-align: justify;
}

#content-area blockquote {
    background-color: var(--light-accent);
    border-left: 4px solid var(--accent-color);
    padding: 1.5rem;
    margin: 2rem 0;
    font-style: italic;
    border-radius: 0 8px 8px 0;
}

#content-area blockquote p {
    margin-bottom: 0.5rem;
}

#content-area blockquote p:last-child {
    margin-bottom: 0;
    font-size: 0.9rem;
    color: var(--text-secondary);
    text-align: right;
}

#content-area ul, #content-area ol {
    margin-left: 2rem;
    margin-bottom: 1.5rem;
}

#content-area li {
    margin-bottom: 0.5rem;
}

#content-area em {
    font-style: italic;
    color: var(--accent-color);
}

#content-area strong {
    font-weight: 600;
    color: var(--primary-color);
}

#content-area hr {
    border: none;
    border-top: 1px solid var(--border-color);
    margin: 3rem 0;
}

#content-area a {
    color: var(--accent-color);
    text-decoration: none;
    border-bottom: 1px solid transparent;
    transition: border-color 0.2s ease;
}

#content-area a:hover {
    border-bottom-color: var(--accent-color);
}

/* Content Navigation */
.content-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
}

.nav-btn {
    background: var(--accent-color);
    color: white;
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: 8px;
    font-family: var(--font-secondary);
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.nav-btn:hover {
    background: var(--secondary-color);
    transform: translateY(-2px);
}

.nav-btn:disabled {
    background: var(--text-muted);
    cursor: not-allowed;
    transform: none;
}

/* Loading */
.loading {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(254, 252, 250, 0.9);
    display: flex;
    justify-content: center;
    align-items: center;
    flex-direction: column;
    z-index: 1000;
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--border-color);
    border-top: 3px solid var(--accent-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Responsive Design */
@media (max-width: 1024px) {
    :root {
        --sidebar-width: 280px;
    }
    
    .main-content {
        padding: 2rem;
    }
    
    #content-area {
        padding: 2rem;
    }
}

@media (max-width: 768px) {
    .container {
        flex-direction: column;
    }
    
    .sidebar {
        position: relative;
        width: 100%;
        height: auto;
        padding: 1rem 0;
    }
    
    .main-content {
        margin-left: 0;
        padding: 1rem;
    }
    
    #content-area {
        padding: 1.5rem;
    }
    
    .nav-header {
        text-align: center;
        padding: 1rem;
    }
    
    .book-title {
        font-size: 1.5rem;
    }
    
    #content-area h1 {
        font-size: 2rem;
    }
    
    #content-area h2 {
        font-size: 1.5rem;
    }
}

/* Special styling for scripture quotes */
.scripture {
    text-align: center;
    font-style: italic;
    color: var(--accent-color);
    margin: 2rem 0;
    padding: 1rem;
    border-top: 1px solid var(--border-color);
    border-bottom: 1px solid var(--border-color);
}

/* Chapter artwork styling */
.chapter-image {
    margin: 40px 0;
    text-align: center;
}

.chapter-image img {
    max-width: 100%;
    height: auto;
    border-radius: 8px;
    box-shadow: 0 4px 12px var(--shadow);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.chapter-image img:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px var(--shadow);
}

/* Table of contents styling */
.toc {
    background: var(--light-accent);
    padding: 2rem;
    border-radius: 8px;
    margin: 2rem 0;
}

.toc h2 {
    margin-top: 0;
    color: var(--primary-color);
}

.toc ul {
    margin-left: 1rem;
}

.toc a {
    color: var(--secondary-color);
    font-weight: 500;
}

/* Addendums Section */
.nav-divider {
    height: 1px;
    background: var(--border-color);
    margin: 1.5rem 1rem;
}

.addendums-section {
    padding: 0 1rem;
    margin-top: 1rem;
}

.addendums-title {
    font-family: var(--font-secondary);
    font-size: 0.85rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    margin-bottom: 1rem;
    padding-left: 1rem;
}

.addendum-link {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem;
    background: linear-gradient(135deg, rgba(139, 115, 85, 0.08), rgba(139, 115, 85, 0.15));
    border: 2px solid var(--accent-color);
    border-radius: 12px;
    text-decoration: none;
    transition: all 0.3s ease;
    cursor: pointer;
    margin-bottom: 0.75rem;
}

.addendum-link:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 12px rgba(139, 115, 85, 0.2);
    background: linear-gradient(135deg, rgba(139, 115, 85, 0.12), rgba(139, 115, 85, 0.2));
}

.addendum-icon {
    font-size: 2rem;
    flex-shrink: 0;
    line-height: 1;
}

.addendum-text {
    flex: 1;
}

.addendum-text strong {
    display: block;
    color: var(--primary-color);
    font-family: var(--font-secondary);
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.addendum-text p {
    color: var(--text-secondary);
    font-family: var(--font-secondary);
    font-size: 0.8rem;
    line-height: 1.4;
    margin: 0;
}

/* Fade-in animation for content loading */
.fade-in {
    animation: fadeIn 0.5s ease-in;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* Wilson's Shout Out Banner */
.wilson-banner {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    background: linear-gradient(135deg, #3b82f6 0%, #1e3a8a 100%);
    color: white;
    z-index: 1001;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    animation: slideDown 0.4s ease-out;
}

.wilson-banner-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 2rem;
    max-width: 1200px;
    margin: 0 auto;
}

.wilson-banner-text {
    font-family: var(--font-secondary);
    font-size: 1rem;
    font-weight: 500;
    flex: 1;
    text-align: center;
    padding: 0 1rem;
}

.wilson-banner-close {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    font-size: 1.5rem;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    flex-shrink: 0;
    line-height: 1;
    padding: 0;
}

.wilson-banner-close:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(1.1);
}

@keyframes slideDown {
    from {
        transform: translateY(-100%);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

/* Adjust body padding when banner is shown */
body.wilson-banner-active {
    padding-top: 60px;
}

@media (max-width: 768px) {
    .wilson-banner-content {
        padding: 0.75rem 1rem;
    }

    .wilson-banner-text {
        font-size: 0.9rem;
        padding: 0 0.5rem;
    }

    .wilson-banner-close {
        width: 28px;
        height: 28px;
        font-size: 1.25rem;
    }
} 


/* v2 dark-mode palette overrides
 * Applied via :root[data-theme="dark"] (explicit toggle) OR via
 * prefers-color-scheme: dark when no explicit override is set. */
:root[data-theme="dark"],
:root:not([data-theme="light"]) {
    /* default light values; overridden below if dark applies */
}
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --primary-color: #e6e9ef;
        --secondary-color: #cbd5e1;
        --accent-color: #d4a574;
        --light-accent: #1e293b;
        --text-primary: #e6e9ef;
        --text-secondary: #94a3b8;
        --text-muted: #64748b;
        --background: #0f172a;
        --sidebar-bg: #1a1f2e;
        --border-color: #334155;
        --shadow: rgba(0, 0, 0, 0.4);
    }
}
:root[data-theme="dark"] {
    --primary-color: #e6e9ef !important;
    --secondary-color: #cbd5e1 !important;
    --accent-color: #d4a574 !important;
    --light-accent: #1e293b !important;
    --text-primary: #e6e9ef !important;
    --text-secondary: #94a3b8 !important;
    --text-muted: #64748b !important;
    --background: #0f172a !important;
    --sidebar-bg: #1a1f2e !important;
    --border-color: #334155 !important;
    --shadow: rgba(0, 0, 0, 0.4) !important;
}

/* Difficulty selector — segmented control at top of chapter */
.difficulty-selector {
    display: flex;
    gap: 0;
    margin: 0 0 1.8em;
    padding: 4px;
    background: var(--light-accent);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    align-items: center;
    justify-content: center;
    max-width: 460px;
    margin-left: auto;
    margin-right: auto;
    font-family: var(--font-secondary);
}
.difficulty-selector .diff-label {
    font-size: 11px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin-right: 10px;
    padding-left: 6px;
}
.diff-btn {
    flex: 1;
    background: transparent;
    border: 0;
    padding: 7px 14px;
    border-radius: 6px;
    cursor: pointer;
    font-family: var(--font-secondary);
    font-size: 12.5px;
    font-weight: 500;
    color: var(--text-secondary);
    transition: background 0.15s, color 0.15s;
}
.diff-btn:hover { color: var(--text-primary); background: rgba(139, 115, 85, 0.08); }
.diff-btn.active {
    background: var(--accent-color);
    color: white;
}
.diff-btn:focus-visible { outline: 2px solid var(--accent-color); outline-offset: 2px; }

/* Show only the active difficulty container */
.diff-pane { display: none; }
:root[data-difficulty="college"] .diff-pane.diff-college { display: block; }
:root[data-difficulty="layman"]  .diff-pane.diff-layman  { display: block; }
:root[data-difficulty="eli5"]    .diff-pane.diff-eli5    { display: block; }

/* Theme toggle button (top-right) */
.theme-toggle {
    position: fixed;
    top: 14px;
    right: 18px;
    z-index: 1000;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    border: 1px solid var(--border-color);
    background: var(--sidebar-bg);
    color: var(--text-primary);
    cursor: pointer;
    font-size: 18px;
    line-height: 1;
    box-shadow: 0 2px 6px var(--shadow);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.15s, background 0.15s;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    padding: 0;
}
.theme-toggle:hover {
    transform: scale(1.08);
    background: var(--light-accent);
}
.theme-toggle:focus { outline: 2px solid var(--accent-color); outline-offset: 2px; }

/* v2 chapter additions */
.book-subtitle-large {
    font-family: var(--font-primary);
    font-style: italic;
    color: var(--text-secondary);
    font-size: 1.4em;
    margin-top: 0.6em;
}
.chapter-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 16px;
    margin: 2em 0;
}
.chapter-card {
    display: flex;
    flex-direction: column;
    padding: 18px 20px;
    background: var(--light-accent);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    text-decoration: none;
    color: var(--text-primary);
    transition: transform 0.12s, box-shadow 0.12s, border-color 0.12s;
}
.chapter-card:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 14px var(--shadow);
    border-color: var(--accent-color);
}
.chapter-card-number {
    font-family: var(--font-secondary);
    font-size: 0.78em;
    color: var(--accent-color);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-weight: 500;
    margin-bottom: 6px;
}
.chapter-card-title {
    font-family: var(--font-primary);
    font-size: 1.1em;
    line-height: 1.35;
    color: var(--text-primary);
}
.chapter-nav {
    margin-top: 4em;
    padding-top: 2em;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
}
.chapter-nav-link {
    font-family: var(--font-secondary);
    font-size: 0.92em;
    color: var(--accent-color);
    text-decoration: none;
    max-width: 48%;
}
.chapter-nav-link.next { text-align: right; margin-left: auto; }
.chapter-nav-link:hover { text-decoration: underline; }
.chapter-body blockquote {
    margin: 1.4em 0 1.6em;
    padding: 0.6em 1.2em;
    border-left: 3px solid var(--accent-color);
    font-style: italic;
    color: var(--text-secondary);
    background: var(--sidebar-bg);
}
.chapter-body h2 {
    font-family: var(--font-secondary);
    font-size: 1.4em;
    margin: 2em 0 0.6em;
    color: var(--primary-color);
    font-weight: 500;
}
.chapter-body h3 {
    font-family: var(--font-secondary);
    font-size: 1.1em;
    margin: 1.6em 0 0.4em;
    color: var(--secondary-color);
    font-weight: 500;
}
.chapter-body p { margin: 0.9em 0; line-height: 1.75; }
.chapter-body strong { color: var(--primary-color); }
.chapter-body em { color: var(--text-secondary); }
.chapter-body table {
    border-collapse: collapse;
    margin: 1.5em 0;
    width: 100%;
    font-family: var(--font-secondary);
    font-size: 0.95em;
}
.chapter-body th, .chapter-body td {
    padding: 8px 12px;
    border: 1px solid var(--border-color);
    text-align: left;
}
.chapter-body th { background: var(--light-accent); color: var(--primary-color); }
.chapter-body code {
    font-family: 'SF Mono', Menlo, monospace;
    font-size: 0.9em;
    background: var(--light-accent);
    padding: 1px 5px;
    border-radius: 3px;
}
.chapter-hero {
    margin: -28px -28px 2em;
    overflow: hidden;
    border-radius: 0;
    box-shadow: 0 6px 18px var(--shadow);
}
.chapter-hero img {
    display: block;
    width: 100%;
    height: auto;
    max-height: 360px;
    object-fit: cover;
}
@media (max-width: 768px) {
    .chapter-hero { margin: -16px -16px 1.4em; }
    .chapter-hero img { max-height: 220px; }
}
.chapter-header {
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 1.6em;
    margin-bottom: 2.4em;
}
.chapter-number {
    font-family: var(--font-secondary);
    color: var(--accent-color);
    text-transform: uppercase;
    letter-spacing: 0.12em;
    font-size: 0.85em;
    margin-bottom: 0.3em;
}
.chapter-title {
    font-family: var(--font-primary);
    font-size: 2.4em;
    line-height: 1.18;
    color: var(--primary-color);
    font-weight: 600;
}
