/* Reset and base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --bg-primary: #fefefe;
    --bg-secondary: #f8f9fa;
    --bg-sidebar: #2d3748;
    --text-primary: #2d3748;
    --text-secondary: #4a5568;
    --text-light: #e2e8f0;
    --accent: #6366f1;
    --accent-hover: #4f46e5;
    --border: #e2e8f0;
    --code-bg: #f7fafc;
    --code-border: #cbd5e0;
    --shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
    --transition: all 0.2s ease;
}

body {
    font-family: 'Merriweather', Georgia, serif;
    font-size: 18px;
    line-height: 1.8;
    color: var(--text-primary);
    background: var(--bg-primary);
}

/* Book container layout */
.book-container {
    display: grid;
    grid-template-columns: 300px 1fr;
    min-height: 100vh;
}

@media (max-width: 1024px) {
    .book-container {
        grid-template-columns: 1fr;
    }

    .sidebar {
        position: static;
        height: auto !important;
    }
}

/* Sidebar navigation */
.sidebar {
    background: var(--bg-sidebar);
    color: var(--text-light);
    padding: 2rem 1.5rem;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
    box-shadow: 2px 0 8px rgba(0, 0, 0, 0.1);
}

.sidebar-header {
    margin-bottom: 2rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.book-title a {
    font-family: 'Inter', sans-serif;
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--text-light);
    text-decoration: none;
    line-height: 1.3;
    display: block;
}

.book-subtitle {
    font-family: 'Source Code Pro', monospace;
    font-size: 0.85rem;
    color: var(--accent);
    margin-top: 0.5rem;
    font-weight: 400;
}

.chapter-nav h3 {
    font-family: 'Inter', sans-serif;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: rgba(255, 255, 255, 0.5);
    margin-bottom: 1rem;
    font-weight: 600;
}

.chapter-list {
    list-style: none;
    counter-reset: chapter-counter;
}

.chapter-list li {
    counter-increment: chapter-counter;
    margin-bottom: 0.5rem;
}

.chapter-list li a {
    display: block;
    padding: 0.6rem 1rem;
    color: rgba(255, 255, 255, 0.8);
    text-decoration: none;
    border-radius: 6px;
    font-size: 0.9rem;
    transition: var(--transition);
    position: relative;
}

.chapter-list li a::before {
    content: counter(chapter-counter) ". ";
    font-weight: 600;
    color: var(--accent);
    margin-right: 0.5rem;
}

.chapter-list li a:hover {
    background: rgba(255, 255, 255, 0.1);
    color: white;
    transform: translateX(4px);
}

.chapter-list li a.active {
    background: var(--accent);
    color: white;
    font-weight: 600;
}

.sidebar-footer {
    margin-top: 3rem;
    padding-top: 1.5rem;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.lisp-quote {
    font-family: 'Source Code Pro', monospace;
    font-size: 0.85rem;
    color: rgba(255, 255, 255, 0.4);
    text-align: center;
    font-style: italic;
}

/* Main content area */
.content {
    max-width: 800px;
    margin: 0 auto;
    padding: 3rem 2rem;
}

@media (max-width: 768px) {
    .content {
        padding: 2rem 1.5rem;
    }
}

.chapter h1 {
    font-family: 'Inter', sans-serif;
    font-size: 2.5rem;
    font-weight: 700;
    line-height: 1.2;
    margin-bottom: 1.5rem;
    color: var(--text-primary);
}

.chapter h2 {
    font-family: 'Inter', sans-serif;
    font-size: 1.8rem;
    font-weight: 600;
    margin-top: 3rem;
    margin-bottom: 1rem;
    color: var(--text-primary);
}

.chapter h3 {
    font-family: 'Inter', sans-serif;
    font-size: 1.4rem;
    font-weight: 600;
    margin-top: 2rem;
    margin-bottom: 0.8rem;
    color: var(--text-secondary);
}

.chapter h4 {
    font-family: 'Inter', sans-serif;
    font-size: 1.1rem;
    font-weight: 600;
    margin-top: 1.5rem;
    margin-bottom: 0.6rem;
    color: var(--text-secondary);
}

.chapter p {
    margin-bottom: 1.5rem;
}

.chapter ul, .chapter ol {
    margin-bottom: 1.5rem;
    margin-left: 2rem;
}

.chapter li {
    margin-bottom: 0.5rem;
}

.chapter a {
    color: var(--accent);
    text-decoration: none;
    border-bottom: 1px solid transparent;
    transition: var(--transition);
}

.chapter a:hover {
    color: var(--accent-hover);
    border-bottom-color: var(--accent-hover);
}

/* Code blocks */
.chapter code {
    font-family: 'Source Code Pro', monospace;
    font-size: 0.9em;
    background: var(--code-bg);
    padding: 0.2em 0.4em;
    border-radius: 3px;
    border: 1px solid var(--code-border);
}

.chapter pre {
    background: var(--code-bg);
    border: 1px solid var(--code-border);
    border-radius: 8px;
    padding: 1.5rem;
    overflow-x: auto;
    margin-bottom: 1.5rem;
    box-shadow: var(--shadow);
}

.chapter pre code {
    background: none;
    border: none;
    padding: 0;
    font-size: 0.9rem;
    line-height: 1.6;
}

/* Blockquotes */
.chapter blockquote {
    border-left: 4px solid var(--accent);
    padding-left: 1.5rem;
    margin: 2rem 0;
    font-style: italic;
    color: var(--text-secondary);
}

/* Page navigation */
.page-navigation {
    margin-top: 4rem;
    padding-top: 2rem;
    border-top: 2px solid var(--border);
}

.nav-links {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
}

@media (max-width: 600px) {
    .nav-links {
        grid-template-columns: 1fr;
    }
}

.nav-link {
    display: flex;
    flex-direction: column;
    padding: 1.5rem;
    background: var(--bg-secondary);
    border-radius: 8px;
    text-decoration: none;
    transition: var(--transition);
    border: 1px solid var(--border);
}

.nav-link:hover {
    background: white;
    box-shadow: var(--shadow);
    transform: translateY(-2px);
}

.nav-link.prev {
    text-align: left;
}

.nav-link.next {
    text-align: right;
}

.nav-label {
    font-family: 'Inter', sans-serif;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--accent);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.5rem;
}

.nav-title {
    font-family: 'Inter', sans-serif;
    font-size: 1rem;
    color: var(--text-primary);
    font-weight: 500;
}

/* Home page */
.home-page {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
}

.hero {
    min-height: 80vh;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 2rem;
}

.hero-content {
    max-width: 800px;
}

.hero-title {
    font-family: 'Inter', sans-serif;
    font-size: 3.5rem;
    font-weight: 700;
    color: white;
    margin-bottom: 1rem;
    line-height: 1.2;
}

@media (max-width: 768px) {
    .hero-title {
        font-size: 2.5rem;
    }
}

.hero-subtitle {
    font-family: 'Source Code Pro', monospace;
    font-size: 1.5rem;
    color: rgba(255, 255, 255, 0.9);
    margin-bottom: 1.5rem;
}

.hero-description {
    font-size: 1.3rem;
    color: rgba(255, 255, 255, 0.85);
    margin-bottom: 2.5rem;
    line-height: 1.6;
}

.cta-button {
    display: inline-block;
    padding: 1rem 2.5rem;
    margin: 0.5rem;
    font-family: 'Inter', sans-serif;
    font-size: 1.1rem;
    font-weight: 600;
    color: white;
    background: var(--accent);
    border-radius: 8px;
    text-decoration: none;
    transition: var(--transition);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.cta-button:hover {
    background: var(--accent-hover);
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.2);
}

.cta-button.secondary {
    background: rgba(255, 255, 255, 0.2);
    backdrop-filter: blur(10px);
}

.cta-button.secondary:hover {
    background: rgba(255, 255, 255, 0.3);
}

.home-content {
    background: white;
    padding: 4rem 2rem;
}

.home-footer {
    background: var(--bg-sidebar);
    color: var(--text-light);
    text-align: center;
    padding: 3rem 2rem;
}

.lisp-wisdom {
    font-style: italic;
    font-size: 1.2rem;
    margin-bottom: 1rem;
    color: rgba(255, 255, 255, 0.9);
}

.copyright {
    font-family: 'Source Code Pro', monospace;
    font-size: 0.9rem;
    color: rgba(255, 255, 255, 0.5);
}

/* Tables */
.chapter table {
    width: 100%;
    border-collapse: collapse;
    margin: 2rem 0;
    font-size: 0.95rem;
}

.chapter table th,
.chapter table td {
    padding: 0.75rem;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

.chapter table th {
    font-family: 'Inter', sans-serif;
    font-weight: 600;
    background: var(--bg-secondary);
    color: var(--text-primary);
}

.chapter table tr:hover {
    background: var(--bg-secondary);
}

/* Copy button for code blocks */
.copy-button {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    padding: 0.4rem 0.8rem;
    font-family: 'Inter', sans-serif;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-secondary);
    background: white;
    border: 1px solid var(--border);
    border-radius: 4px;
    cursor: pointer;
    transition: var(--transition);
    opacity: 0;
}

pre:hover .copy-button {
    opacity: 1;
}

.copy-button:hover {
    color: var(--accent);
    border-color: var(--accent);
}

.copy-button:active {
    transform: scale(0.95);
}

/* Syntax highlighting enhancements */
.highlight {
    background: var(--code-bg);
}

.highlight .c { color: #999988; font-style: italic; } /* Comment */
.highlight .k { color: #6366f1; font-weight: bold; } /* Keyword */
.highlight .s { color: #d14; } /* String */
.highlight .m { color: #009999; } /* Number */
.highlight .n { color: #2d3748; } /* Name */
.highlight .nf { color: #990000; font-weight: bold; } /* Function */
