/* CSS Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    /* Default Light mode colors - Sepia Paper */
    --bg-color: #f4f1ea;
    --text-color: #2c2416;
    --text-secondary: #6b635a;
    --link-color: #0e7490;
    --link-hover: #0a5a6e;
    --border-color: #e8e2d5;
    --header-border: #d8d2c5;
}

/* Light Theme Option 1: Warm Cream */
[data-light-theme="warm"] {
    --bg-color: #faf9f6;
    --text-color: #2d2d2d;
    --text-secondary: #6b6b6b;
    --link-color: #0052a3;
    --link-hover: #003d7a;
    --border-color: #ebe7e0;
    --header-border: #ddd9d0;
}

/* Light Theme Option 2: Cool Minimalist */
[data-light-theme="cool"] {
    --bg-color: #f8f9fa;
    --text-color: #0a0a0a;
    --text-secondary: #6c757d;
    --link-color: #0066ff;
    --link-hover: #0052cc;
    --border-color: #dee2e6;
    --header-border: #ced4da;
}

/* Light Theme Option 3: Sepia/Paper */
[data-light-theme="sepia"] {
    --bg-color: #f4f1ea;
    --text-color: #2c2416;
    --text-secondary: #6b635a;
    --link-color: #0e7490;
    --link-hover: #0a5a6e;
    --border-color: #e8e2d5;
    --header-border: #d8d2c5;
}

/* Light Theme Option 4: Soft Purple */
[data-light-theme="purple"] {
    --bg-color: #fafbff;
    --text-color: #1e1e2e;
    --text-secondary: #5c5c6b;
    --link-color: #6366f1;
    --link-hover: #4f46e5;
    --border-color: #e8e9f3;
    --header-border: #d8d9e8;
}

[data-theme="dark"] {
    /* Dark mode colors */
    --bg-color: #1a1a1a;
    --text-color: #e0e0e0;
    --text-secondary: #a0a0a0;
    --link-color: #6699ff;
    --link-hover: #99bbff;
    --border-color: #333333;
    --header-border: #404040;
}

body {
    font-family: var(--font-family);
    line-height: 1.6;
    color: var(--text-color);
    background-color: var(--bg-color);
    transition: background-color 0.3s ease, color 0.3s ease;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Font Options */
:root {
    --font-family: 'Charter', 'Palatino Linotype', Palatino, 'Iowan Old Style', 'Book Antiqua', serif;
}

/* Font 1: System Default (San Francisco / Segoe UI) */
[data-font="system"] {
    --font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Helvetica Neue', Arial, sans-serif;
}

/* Font 2: Serif Classic (Georgia) */
[data-font="serif"] {
    --font-family: Georgia, 'Times New Roman', Times, serif;
}

[data-font="serif"] h1,
[data-font="serif"] h2,
[data-font="serif"] h3 {
    font-family: Georgia, 'Times New Roman', Times, serif;
}

/* Font 3: Modern Geometric (System UI based) */
[data-font="geometric"] {
    --font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

/* Font 4: Literary Serif (Charter / Palatino) */
[data-font="literary"] {
    --font-family: 'Charter', 'Palatino Linotype', Palatino, 'Iowan Old Style', 'Book Antiqua', serif;
}

[data-font="literary"] h1,
[data-font="literary"] h2,
[data-font="literary"] h3 {
    font-family: 'Charter', 'Palatino Linotype', Palatino, 'Iowan Old Style', 'Book Antiqua', serif;
    letter-spacing: -0.02em;
}

/* Font 5: Technical Mono (Monospace) */
[data-font="mono"] {
    --font-family: 'SF Mono', 'Monaco', 'Inconsolata', 'Fira Mono', 'Droid Sans Mono', 'Source Code Pro', monospace;
}

[data-font="mono"] h1,
[data-font="mono"] h2,
[data-font="mono"] h3 {
    font-family: 'SF Mono', 'Monaco', 'Inconsolata', 'Fira Mono', monospace;
    letter-spacing: -0.03em;
}

.container {
    max-width: 800px;
    margin: 0 auto;
    padding: 40px 20px;
}

/* Header Styles */
header {
    margin-bottom: 60px;
    border-bottom: 1px solid var(--header-border);
    padding-bottom: 20px;
}

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

h1 {
    font-size: 2rem;
    font-weight: 600;
    color: var(--text-color);
}

.theme-toggle {
    background: none;
    border: 1px solid var(--border-color);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    color: var(--text-color);
    font-size: 1.2rem;
}

.theme-toggle:hover {
    background-color: var(--border-color);
    transform: rotate(180deg);
}

/* Theme and Font Pickers */
.light-theme-picker,
.font-picker {
    position: fixed;
    background: var(--bg-color);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 16px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    z-index: 1000;
    transition: opacity 0.3s ease;
}

.light-theme-picker {
    bottom: 30px;
    right: 30px;
}

.font-picker {
    bottom: 30px;
    left: 30px;
}

[data-theme="dark"] .light-theme-picker {
    display: none;
}

.light-theme-picker h4,
.font-picker h4 {
    font-size: 0.85rem;
    font-weight: 600;
    margin-bottom: 12px;
    color: var(--text-color);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.theme-options,
.font-options {
    display: flex;
    gap: 8px;
    flex-direction: column;
}

.theme-option,
.font-option {
    padding: 8px 12px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    background: var(--bg-color);
    color: var(--text-color);
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: left;
}

.theme-option:hover,
.font-option:hover {
    background: var(--border-color);
}

.theme-option.active,
.font-option.active {
    background: var(--link-color);
    color: white;
    border-color: var(--link-color);
}

@media (max-width: 768px) {
    .light-theme-picker,
    .font-picker {
        bottom: 20px;
        padding: 12px;
    }

    .light-theme-picker {
        right: 20px;
    }

    .font-picker {
        left: 20px;
    }

    .light-theme-picker h4,
    .font-picker h4 {
        font-size: 0.75rem;
        margin-bottom: 8px;
    }

    .theme-option,
    .font-option {
        padding: 6px 10px;
        font-size: 0.85rem;
    }
}

/* Main Content */
main {
    margin-bottom: 60px;
}

.intro {
    margin-bottom: 50px;
    font-size: 1.1rem;
    line-height: 1.8;
}

.intro p {
    margin-bottom: 1rem;
}

/* Content Sections */
.content-section {
    margin-bottom: 40px;
}

h2 {
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 15px;
    color: var(--text-color);
}

.content-list {
    list-style: none;
    padding-left: 0;
}

.content-list li {
    margin-bottom: 12px;
    line-height: 1.6;
}

.content-link {
    color: var(--link-color);
    text-decoration: none;
    transition: color 0.2s ease;
}

.content-link:hover {
    color: var(--link-hover);
    text-decoration: underline;
}

.content-meta {
    color: var(--text-secondary);
    font-size: 0.95rem;
}

/* Footer */
footer {
    padding-top: 30px;
    border-top: 1px solid var(--border-color);
    text-align: center;
}

footer p {
    color: var(--text-secondary);
}

footer a {
    color: var(--link-color);
    text-decoration: none;
    margin: 0 8px;
    transition: color 0.2s ease;
}

footer a:hover {
    color: var(--link-hover);
    text-decoration: underline;
}

/* Home link in header */
.home-link {
    color: var(--text-color);
    text-decoration: none;
    transition: color 0.2s ease;
}

.home-link:hover {
    color: var(--link-color);
}

/* Essay Layout with Table of Contents */
.essay-layout {
    display: grid;
    grid-template-columns: 260px 1fr;
    gap: 80px;
    max-width: 1200px;
    margin: 0 auto;
    align-items: start;
}

/* Table of Contents */
.table-of-contents {
    position: relative;
}

.toc-nav {
    position: sticky;
    top: 40px;
}

.toc-title {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 1.2rem;
    color: var(--text-color);
    letter-spacing: 0.02em;
}

.toc-list {
    list-style: none;
    padding-left: 0;
}

.toc-list li {
    margin-bottom: 0.65rem;
}

.toc-link {
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.9rem;
    line-height: 1.5;
    display: block;
    transition: color 0.2s ease;
}

.toc-link:hover {
    color: var(--link-color);
}

.toc-link.active {
    color: var(--link-color);
    font-weight: 500;
}

/* Essay/Article Styles */
.essay {
    max-width: 700px;
    margin: 0;
}

.essay-header {
    margin-bottom: 50px;
    text-align: left;
}

.essay-title {
    font-size: 2.5rem;
    font-weight: 700;
    line-height: 1.2;
    margin-bottom: 20px;
    color: var(--text-color);
}

.essay-meta {
    color: var(--text-secondary);
    font-size: 0.95rem;
}

.meta-separator {
    margin: 0 8px;
}

.reading-time {
    font-style: italic;
}

.essay-content {
    font-size: 1.1rem;
    line-height: 1.8;
}

.essay-content p {
    margin-bottom: 1.5rem;
}

.essay-content .lead {
    font-size: 1.25rem;
    line-height: 1.7;
    margin-bottom: 2rem;
    color: var(--text-color);
}

.essay-content h3 {
    font-size: 1.75rem;
    font-weight: 600;
    margin-top: 3rem;
    margin-bottom: 1rem;
    color: var(--text-color);
}

.essay-content ul,
.essay-content ol {
    margin-bottom: 1.5rem;
    padding-left: 1.5rem;
}

.essay-content li {
    margin-bottom: 0.5rem;
    line-height: 1.7;
}

.essay-content blockquote {
    margin: 2rem 0;
    padding-left: 1.5rem;
    border-left: 4px solid var(--link-color);
    font-style: italic;
    color: var(--text-secondary);
    font-size: 1.1rem;
}

.essay-content hr {
    border: none;
    border-top: 1px solid var(--border-color);
    margin: 3rem 0;
}

.essay-content code {
    background-color: var(--border-color);
    padding: 2px 6px;
    border-radius: 3px;
    font-family: 'Courier New', monospace;
    font-size: 0.95em;
}

.essay-footnote {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-top: 3rem;
}

.essay-navigation {
    margin-top: 4rem;
    padding-top: 2rem;
    border-top: 1px solid var(--border-color);
}

.back-link {
    color: var(--link-color);
    text-decoration: none;
    font-size: 1rem;
    transition: color 0.2s ease;
}

.back-link:hover {
    color: var(--link-hover);
    text-decoration: underline;
}

/* Responsive Design */
@media (max-width: 1280px) {
    .essay-layout {
        max-width: 1000px;
        grid-template-columns: 220px 1fr;
        gap: 60px;
    }
}

@media (max-width: 1024px) {
    .essay-layout {
        grid-template-columns: 200px 1fr;
        gap: 40px;
    }
}

@media (max-width: 768px) {
    .container {
        padding: 30px 15px;
    }

    h1 {
        font-size: 1.75rem;
    }

    h2 {
        font-size: 1.3rem;
    }

    .intro {
        font-size: 1rem;
    }

    header {
        margin-bottom: 40px;
    }

    /* Hide table of contents on tablet and mobile */
    .essay-layout {
        display: block;
    }

    .table-of-contents {
        display: none;
    }

    .essay {
        max-width: 700px;
        margin: 0 auto;
    }

    .essay-title {
        font-size: 2rem;
    }

    .essay-content {
        font-size: 1.05rem;
    }

    .essay-content .lead {
        font-size: 1.15rem;
    }

    .essay-content h3 {
        font-size: 1.5rem;
        margin-top: 2rem;
    }

    .essay-content blockquote {
        padding-left: 1rem;
        margin: 1.5rem 0;
    }
}

@media (max-width: 480px) {
    h1 {
        font-size: 1.5rem;
    }

    .theme-toggle {
        width: 35px;
        height: 35px;
        font-size: 1rem;
    }

    footer a {
        display: inline-block;
        margin: 5px;
    }

    .essay-title {
        font-size: 1.75rem;
    }

    .essay-content {
        font-size: 1rem;
    }

    .essay-content .lead {
        font-size: 1.1rem;
    }

    .essay-content h3 {
        font-size: 1.3rem;
    }
}
