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

html {
    font-size: 18px;
    scroll-behavior: smooth;
}

body {
    font-family: 'Source Serif 4', Georgia, 'Times New Roman', serif;
    color: #0a0a0a;
    background-color: #fff;
    line-height: 1.7;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Navigation */
nav {
    position: sticky;
    top: 0;
    background: #fff;
    border-bottom: 1px solid #ddd;
    padding: 1rem 2rem;
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.5rem 2rem;
    z-index: 100;
}

nav a {
    color: #0a0a0a;
    text-decoration: none;
    font-size: 0.95rem;
    padding: 0.25rem 0;
    border-bottom: 2px solid transparent;
    transition: border-color 0.2s ease;
}

nav a:hover {
    border-bottom-color: #0a0a0a;
}

nav a.active {
    border-bottom-color: #0a0a0a;
}

/* Layout with sidebar */
.page-container {
    display: flex;
    max-width: 1200px;
    margin: 0 auto;
    position: relative;
    overflow: visible;
}

/* Table of Contents Sidebar */
.toc-sidebar {
    width: 250px;
    flex-shrink: 0;
    padding: 2rem 1rem 2rem 1.5rem;
    position: sticky;
    top: 60px;
    height: calc(100vh - 60px);
    overflow-y: auto;
    border-right: 1px solid #eee;
}

.toc-sidebar h4 {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: #888;
    margin-bottom: 1rem;
    font-weight: 600;
}

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

.toc-sidebar li {
    margin-bottom: 0.5rem;
}

.toc-sidebar a {
    color: #555;
    text-decoration: none;
    font-size: 0.85rem;
    line-height: 1.4;
    display: block;
    padding: 0.25rem 0;
    border-left: 2px solid transparent;
    padding-left: 0.75rem;
    margin-left: -0.75rem;
    transition: all 0.2s ease;
}

.toc-sidebar a:hover {
    color: #0a0a0a;
}

.toc-sidebar a.active {
    color: #0a0a0a;
    border-left-color: #0a0a0a;
    font-weight: 500;
}

.toc-sidebar li.toc-h3 {
    margin-left: 0;
}

.toc-sidebar li.toc-h4 {
    margin-left: 0.75rem;
}

.toc-sidebar li.toc-h4 a {
    font-size: 0.8rem;
    color: #777;
}

/* Main content */
main {
    max-width: 720px;
    margin: 0 auto;
    padding: 3rem 1.5rem 4rem;
    flex-grow: 1;
    min-width: 0;
}

/* Header */
header {
    text-align: center;
    margin-bottom: 3rem;
    padding-bottom: 2rem;
    border-bottom: 1px solid #ddd;
}

header h1 {
    font-size: 2.2rem;
    font-weight: 600;
    line-height: 1.3;
    margin-bottom: 1rem;
}

header .author {
    font-size: 1.1rem;
    margin-bottom: 0.25rem;
}

header .affiliation {
    font-size: 0.95rem;
    color: #555;
}

/* Sections */
section {
    margin-bottom: 2.5rem;
}

section h2 {
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 1rem;
    margin-top: 2rem;
}

section h3 {
    font-size: 1.15rem;
    font-weight: 600;
    margin-bottom: 0.75rem;
    margin-top: 1.5rem;
}

section p {
    margin-bottom: 1rem;
    text-align: justify;
    hyphens: auto;
}

section ul, section ol {
    margin-left: 1.5rem;
    margin-bottom: 1rem;
}

section li {
    margin-bottom: 0.5rem;
}

/* Abstract */
.abstract {
    background: #f9f9f9;
    padding: 1.5rem 2rem;
    border-left: 4px solid #0a0a0a;
    margin-bottom: 2rem;
}

.abstract h2 {
    font-size: 1.1rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-top: 0;
    margin-bottom: 1rem;
}

.abstract p {
    margin-bottom: 0;
}

/* Definition box */
.definition-box {
    background: #f5f5f5;
    border: 1px solid #ddd;
    padding: 1.5rem 2rem;
    margin: 2rem 0;
}

.definition-box h3 {
    font-size: 1rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    margin-top: 0;
    margin-bottom: 1rem;
    color: #333;
}

/* Chapter cards */
.toc {
    margin-top: 3rem;
}

.chapter-card {
    padding: 1.5rem 0;
    border-bottom: 1px solid #eee;
}

.chapter-card:last-child {
    border-bottom: none;
}

.chapter-card h3 {
    margin-top: 0;
    margin-bottom: 0.75rem;
}

.chapter-card h3 a {
    color: #0a0a0a;
    text-decoration: none;
    border-bottom: 1px solid transparent;
    transition: border-color 0.2s ease;
}

.chapter-card h3 a:hover {
    border-bottom-color: #0a0a0a;
}

.chapter-card p {
    color: #333;
    font-size: 0.95rem;
    margin-bottom: 0;
}

/* Consequences section */
.consequences h3 {
    color: #0a0a0a;
    font-size: 1.05rem;
}

/* Causes section */
.causes h3 {
    color: #0a0a0a;
    font-size: 1.05rem;
}

/* Vision section */
.vision {
    background: #f9f9f9;
    padding: 2rem;
    margin-top: 3rem;
}

.vision h2 {
    margin-top: 0;
}

/* Chapter page styles */
.chapter-header {
    margin-bottom: 2rem;
}

.chapter-header .chapter-number {
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: #666;
    margin-bottom: 0.5rem;
}

.chapter-header h1 {
    font-size: 2rem;
    text-align: left;
}

.chapter-nav {
    display: flex;
    justify-content: space-between;
    padding: 2rem 0;
    border-top: 1px solid #ddd;
    margin-top: 3rem;
}

.chapter-nav a {
    color: #0a0a0a;
    text-decoration: none;
    font-size: 0.95rem;
}

.chapter-nav a:hover {
    text-decoration: underline;
}

.chapter-nav .prev::before {
    content: "\2190 ";
}

.chapter-nav .next::after {
    content: " \2192";
}

/* Figures */
figure {
    margin: 2rem 0;
}

figure.full-width {
    margin: 2.5rem -1rem;
}

figure img {
    width: 100%;
    height: auto;
    display: block;
}

figcaption {
    font-size: 0.9rem;
    color: #555;
    text-align: center;
    padding: 0.75rem 1rem;
    line-height: 1.5;
    font-style: italic;
}

/* Blockquote */
blockquote {
    border-left: 3px solid #ddd;
    padding-left: 1.5rem;
    margin: 1.5rem 0;
    color: #444;
    font-style: italic;
}

/* Callout box */
.callout {
    background: #fff;
    border: 1px solid #ddd;
    padding: 1.5rem;
    margin: 1.5rem 0;
}

.callout-title {
    font-weight: 600;
    margin-bottom: 0.75rem;
    font-size: 1rem;
}

/* Footer */
footer {
    text-align: center;
    padding: 2rem;
    border-top: 1px solid #ddd;
    color: #666;
    font-size: 0.9rem;
}

/* Links */
a {
    color: #0a0a0a;
}

/* Strong and emphasis */
strong {
    font-weight: 600;
}

em {
    font-style: italic;
}

/* Responsive */
@media (max-width: 1024px) {
    .toc-sidebar {
        width: 200px;
        padding: 1.5rem 0.75rem 1.5rem 1rem;
    }

    .toc-sidebar a {
        font-size: 0.8rem;
    }
}

@media (max-width: 768px) {
    html {
        font-size: 16px;
    }

    nav {
        padding: 0.75rem 1rem;
        gap: 0.25rem 1rem;
    }

    nav a {
        font-size: 0.85rem;
    }

    .page-container {
        display: block;
    }

    .toc-sidebar {
        display: none;
    }

    main {
        padding: 2rem 1rem 3rem;
    }

    header h1 {
        font-size: 1.75rem;
    }

    .abstract {
        padding: 1rem 1.25rem;
    }

    .definition-box {
        padding: 1rem 1.25rem;
    }

    .vision {
        padding: 1.5rem;
    }

    figure.full-width {
        margin: 2rem -1rem;
    }
}

/* ASCII Art Decorations - Margin Style */

/* Container for margin art - position relative to enable absolute children */
main {
    position: relative;
    overflow: visible;
}

/* Margin ASCII art - scrolls with content, positioned in right margin */
.ascii-art {
    position: absolute;
    left: calc(100% + 30px);
    width: 140px;
    font-family: 'Courier New', Consolas, monospace;
    font-size: 8px;
    line-height: 1.15;
    color: #a0b0c0;
    white-space: pre;
    text-align: left;
    opacity: 0.5;
    transition: all 0.4s ease;
    pointer-events: none;
    z-index: 10;
}

.ascii-art:hover {
    color: #5a7a8a;
    opacity: 1;
}

.ascii-art .caption {
    display: block;
    margin-top: 0.5rem;
    font-size: 9px;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: #9ab;
    font-family: 'Source Serif 4', Georgia, serif;
}

/* Floating animation */
.ascii-art.float {
    animation: float 6s ease-in-out infinite;
}

@keyframes float {
    0%, 100% { transform: translateY(0px); }
    50% { transform: translateY(-8px); }
}

/* Pulse animation */
.ascii-art.pulse {
    animation: pulse 4s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 0.6; }
    50% { opacity: 0.9; }
}

/* Gentle breathing for diagrams */
.ascii-art.breathe {
    animation: breathe 5s ease-in-out infinite;
}

@keyframes breathe {
    0%, 100% { transform: scale(1); opacity: 0.65; }
    50% { transform: scale(1.02); opacity: 0.9; }
}

/* Left margin variant */
.ascii-art.left {
    right: auto;
    left: -280px;
    text-align: right;
}

/* Hide old fixed margin art */
.ascii-margin {
    display: none;
}

/* ASCII art in sidebar below TOC */
.toc-sidebar .ascii-decoration {
    margin-top: 2rem;
    padding-top: 1rem;
    border-top: 1px solid #ddd;
    font-family: 'Courier New', monospace;
    font-size: 10px;
    line-height: 1.2;
    color: #8a9fb0;
    white-space: pre;
    text-align: center;
    animation: pulse 5s ease-in-out infinite;
}

/* Responsive - hide margin art on smaller screens */
@media (max-width: 1600px) {
    .ascii-art {
        left: calc(100% + 15px);
        width: 120px;
        font-size: 7px;
    }
}

@media (max-width: 1200px) {
    .ascii-art {
        display: none;
    }
}

@media (max-width: 768px) {
    .toc-sidebar .ascii-decoration {
        display: none;
    }
}

/* References/Citations section */
.references {
    margin-top: 3rem;
    padding-top: 2rem;
    border-top: 1px solid #ddd;
}

.references h2 {
    font-size: 1.3rem;
    margin-bottom: 1.5rem;
    margin-top: 0;
}

.references ol {
    list-style-type: decimal;
    padding-left: 2rem;
    margin: 0;
}

.references li {
    font-size: 0.9rem;
    line-height: 1.6;
    margin-bottom: 0.75rem;
    color: #333;
    text-align: left;
}

.references li .authors {
    font-weight: 500;
}

.references li .title {
    font-style: italic;
}

.references li .venue {
    color: #555;
}

.references li .year {
    color: #666;
}

.references li a {
    color: #0066cc;
    text-decoration: none;
    word-break: break-word;
}

.references li a:hover {
    text-decoration: underline;
}

/* Print styles */
@media print {
    nav {
        display: none;
    }

    main {
        max-width: 100%;
    }

    .chapter-nav {
        display: none;
    }
}
