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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    line-height: 1.7;
    color: #333;
    background: #f8f9fa;
}

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

/* Header */
header {
    background: #2c3e50;
    color: white;
    padding: 2rem 0;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

header h1 {
    font-size: 2rem;
    margin-bottom: 0.5rem;
}

.subtitle {
    font-size: 1.1rem;
    opacity: 0.9;
}

.back-link {
    display: inline-block;
    color: #3498db;
    text-decoration: none;
    margin-bottom: 1rem;
    font-weight: 500;
}

.back-link:hover {
    color: #2980b9;
}

/* Main Content */
main {
    padding: 2rem 0;
}

/* Book Promo (Homepage) */
.book-promo {
    background: white;
    border-radius: 8px;
    padding: 2rem;
    margin-bottom: 2rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.promo-content {
    display: flex;
    gap: 2rem;
    align-items: center;
}

.book-cover {
    width: 180px;
    height: auto;
    border-radius: 4px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.promo-text h2 {
    color: #2c3e50;
    margin-bottom: 1rem;
}

.cta-button {
    display: inline-block;
    background: #ff9900;
    color: white;
    padding: 0.75rem 1.5rem;
    text-decoration: none;
    border-radius: 4px;
    font-weight: 600;
    margin-top: 1rem;
    transition: background 0.3s;
}

.cta-button:hover {
    background: #e88b00;
}

/* Introduction Section */
.intro {
    background: white;
    border-radius: 8px;
    padding: 2rem;
    margin-bottom: 2rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.intro h2 {
    color: #2c3e50;
    margin-bottom: 1rem;
}

.intro ul {
    margin-left: 2rem;
    margin-top: 1rem;
}

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

/* Chapter Navigation */
.chapters {
    background: white;
    border-radius: 8px;
    padding: 2rem;
    margin-bottom: 2rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.chapters h2 {
    color: #2c3e50;
    margin-bottom: 1.5rem;
}

.chapter-nav {
    display: grid;
    gap: 1rem;
}

.chapter-link {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem;
    background: #f8f9fa;
    border-radius: 6px;
    text-decoration: none;
    color: #2c3e50;
    transition: all 0.3s;
    border-left: 4px solid #3498db;
}

.chapter-link:hover {
    background: #e9ecef;
    transform: translateX(5px);
}

.chapter-number {
    background: #3498db;
    color: white;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    flex-shrink: 0;
}

.chapter-title {
    font-size: 1.1rem;
    font-weight: 500;
}

/* Chapter Content Layout */
.content-wrapper {
    display: grid;
    grid-template-columns: 1fr 300px;
    gap: 2rem;
}

.chapter-content {
    background: white;
    border-radius: 8px;
    padding: 2.5rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

/* Markdown Content Styling */
.chapter-content h2 {
    color: #2c3e50;
    margin-top: 2rem;
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid #3498db;
}

.chapter-content h3 {
    color: #34495e;
    margin-top: 1.5rem;
    margin-bottom: 0.75rem;
}

.chapter-content p {
    margin-bottom: 1rem;
}

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

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

.chapter-content strong {
    color: #2c3e50;
    font-weight: 600;
}

.chapter-content em {
    font-style: italic;
}

.chapter-content code {
    background: #f4f4f4;
    padding: 2px 6px;
    border-radius: 3px;
    font-family: 'Courier New', monospace;
    font-size: 0.9em;
}

.chapter-content pre {
    background: #f4f4f4;
    padding: 1rem;
    border-radius: 4px;
    overflow-x: auto;
    margin-bottom: 1rem;
}

.chapter-content blockquote {
    border-left: 4px solid #3498db;
    padding-left: 1rem;
    margin-left: 0;
    margin-bottom: 1rem;
    color: #555;
    font-style: italic;
}

.chapter-content table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 1rem;
}

.chapter-content th,
.chapter-content td {
    border: 1px solid #ddd;
    padding: 0.75rem;
    text-align: left;
}

.chapter-content th {
    background: #f8f9fa;
    font-weight: 600;
    color: #2c3e50;
}

.chapter-content tr:nth-child(even) {
    background: #f8f9fa;
}

/* Sidebar */
.sidebar {
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

.sidebar-promo {
    background: white;
    border-radius: 8px;
    padding: 1.5rem;
    text-align: center;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    position: sticky;
    top: 20px;
}

.sidebar-book-cover {
    width: 100%;
    max-width: 200px;
    height: auto;
    margin-bottom: 1rem;
    border-radius: 4px;
}

.sidebar-promo h3 {
    color: #2c3e50;
    margin-bottom: 0.5rem;
    font-size: 1.2rem;
}

.sidebar-promo p {
    font-size: 0.9rem;
    color: #666;
    margin-bottom: 1rem;
}

.sidebar-button {
    display: block;
    background: #ff9900;
    color: white;
    padding: 0.75rem 1rem;
    text-decoration: none;
    border-radius: 4px;
    font-weight: 600;
    transition: background 0.3s;
}

.sidebar-button:hover {
    background: #e88b00;
}

/* Ad Spaces */
.ad-space {
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 2rem 0;
}

.ad-horizontal {
    min-height: 120px;
    background: #f0f0f0;
    border-radius: 8px;
}

.ad-sidebar {
    min-height: 250px;
    background: #f0f0f0;
    border-radius: 8px;
    position: sticky;
    top: 500px;
}

.ad-placeholder {
    color: #999;
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 1px;
}

/* Chapter Pagination */
.chapter-pagination {
    display: flex;
    justify-content: space-between;
    margin-top: 3rem;
    padding-top: 2rem;
    border-top: 2px solid #e9ecef;
}

.nav-button {
    background: #3498db;
    color: white;
    padding: 0.75rem 1.5rem;
    text-decoration: none;
    border-radius: 4px;
    font-weight: 500;
    transition: background 0.3s;
}

.nav-button:hover {
    background: #2980b9;
}

/* Footer */
footer {
    background: #2c3e50;
    color: white;
    padding: 2rem 0;
    margin-top: 3rem;
    text-align: center;
}

footer p {
    font-size: 0.9rem;
    opacity: 0.9;
    margin-bottom: 0.5rem;
}

footer a {
    color: #3498db;
    text-decoration: none;
}

footer a:hover {
    text-decoration: underline;
}

/* Responsive Design */
@media (max-width: 968px) {
    .content-wrapper {
        grid-template-columns: 1fr;
    }

    .sidebar {
        order: -1;
    }

    .sidebar-promo {
        position: static;
    }

    .ad-sidebar {
        position: static;
    }

    .promo-content {
        flex-direction: column;
        text-align: center;
    }
}

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

    .subtitle {
        font-size: 1rem;
    }

    .chapter-content {
        padding: 1.5rem;
    }

    .book-promo {
        padding: 1.5rem;
    }

    .chapter-link {
        padding: 0.75rem;
    }

    .chapter-number {
        width: 35px;
        height: 35px;
        font-size: 0.9rem;
    }

    .chapter-title {
        font-size: 1rem;
    }
}

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

    .chapter-pagination {
        flex-direction: column;
        gap: 1rem;
    }

    .nav-button {
        text-align: center;
    }
}