/* Appendix-specific styling for Journeys to the Planet Mars */

body {
    display: flex;
    min-height: 100vh;
}

.journeys-sidebar {
    width: 280px;
    background: var(--nav-bg);
    border-right: 1px solid var(--border-color);
    padding: 1.5rem;
    position: fixed;
    left: 0;
    top: 0;
    height: 100vh;
    overflow-y: auto;
    z-index: 100;
}

.journeys-sidebar h3 {
    margin: 0 0 1rem 0;
    font-size: 1.1rem;
    color: var(--text-secondary);
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 0.5rem;
}

.journeys-nav-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.journeys-nav-list li {
    margin-bottom: 0.3rem;
}

.journeys-nav-list a {
    display: block;
    padding: 0.4rem 0.6rem;
    color: var(--text-color);
    text-decoration: none;
    font-size: 0.85rem;
    border-radius: 3px;
    transition: all 0.2s ease;
    text-underline-offset: 3px;
}

.journeys-nav-list a:hover {
    color: var(--accent-nav);
    text-decoration: underline;
    text-decoration-color: #999;
}

.journeys-nav-list a.current {
    background: var(--bg-color);
    color: var(--accent-nav);
    font-weight: 600;
    border-left: 3px solid var(--accent-nav);
    padding-left: calc(0.6rem - 3px);
}

.appendix-next-chapter {
    margin-top: 3rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border-color);
    font-size: 0.95rem;
}

.appendix-next-chapter a {
    color: var(--accent-nav);
    text-decoration: none;
}

.appendix-next-chapter a:hover {
    text-decoration: underline;
    text-decoration-color: #999;
}

.journeys-back-link {
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border-color);
}

.journeys-back-link a {
    color: var(--accent-nav);
    text-decoration: none;
    font-size: 0.9rem;
    transition: all 0.2s ease;
}

.journeys-back-link a:hover {
    text-decoration: underline;
    text-decoration-color: #999;
}

.appendix-content {
    margin-left: 280px;
    max-width: 45rem;
    padding: 2rem 2rem;
    font-family: 'OFL Goudy';
    line-height: 1.6;
    flex: 1;
}

.appendix-nav {
    display: none; /* Hide old nav since we have sidebar */
}

.book-intro {
    background: var(--nav-bg);
    padding: 1.5rem;
    border-radius: 4px;
    margin-bottom: 2rem;
    font-style: italic;
}

.table-of-contents {
    margin: 2rem 0;
}

.table-of-contents h2 {
    text-align: center;
    font-family: 'OFL Goudy';
    font-size: 1.5rem;
    margin-bottom: 2rem;
    color: var(--text-secondary);
}

.chapter-list {
    list-style: none;
    padding: 0;
    max-width: 40rem;
    margin: 0 auto;
}

.chapter-list li {
    display: flex;
    align-items: baseline;
    margin-bottom: 0.8rem;
    padding: 0.5rem 0;
}

.chapter-list a {
    color: var(--text-color);
    text-decoration: none;
    flex: 1;
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    border: none;
    padding: 0.2rem 0;
    transition: all 0.2s ease;
}

.chapter-list a:hover {
    color: var(--accent-nav);
    text-decoration: underline;
    text-decoration-color: #999;
    background-color: transparent;
}

.chapter-list a::after {
    content: "";
    flex: 1;
    margin: 0 0.5rem;
    min-width: 1rem;
}

.chapter-number {
    font-weight: bold;
    color: var(--text-secondary);
    margin-right: 0.5rem;
    min-width: 2rem;
}

.chapter-content {
    font-size: 1.1rem;
    line-height: 1.7;
}

.chapter-content blockquote {
    margin: 1.5rem 0;
    padding: 1rem;
    border-left: 4px solid var(--accent-decorative);
    background: var(--nav-bg);
    font-style: italic;
}

/* Different typography for historical text */
.appendix-content h1 {
    font-family: 'OFL Goudy';
    color: var(--text-secondary);
    text-align: center;
    font-weight: normal;
    font-size: 1.5rem;
    letter-spacing: 0.05em;
    line-height: 1.3;
    margin-top: 1rem;
    margin-bottom: 2.5rem;
    padding-bottom: 0;
    border-bottom: none;
}

@media (max-width: 768px) {
    body {
        display: block;
    }
    
    .journeys-sidebar {
        position: relative;
        width: 100%;
        height: auto;
        border-right: none;
        border-bottom: 1px solid var(--border-color);
        padding: 1rem;
    }
    
    .appendix-content {
        margin-left: 0;
        padding: 1rem;
        max-width: none;
    }
    
    .chapter-list {
        max-width: none;
    }
    
    .chapter-list a::after {
        display: none;
    }
}

/* Speaker dialogue formatting */
.speaker {
    margin: 1.5rem 0;
    line-height: 1.8;
}

.speaker strong {
    color: var(--text-secondary);
    font-weight: 700;
}

/* Date markers */
.date-marker {
    text-align: left;
    font-style: normal;
    color: var(--text-secondary);
    margin: 2rem 0 1rem 0;
    font-size: 1.1rem;
    font-weight: bold;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 0.5rem;
}

/* Better paragraph spacing */
.chapter-content p {
    margin-bottom: 1.2rem;
}

.chapter-content p:last-child {
    margin-bottom: 0;
}

/* Song and poetry formatting */
.song {
    margin: 2rem 0;
    padding: 1.5rem;
    background: var(--nav-bg);
    border-left: 4px solid var(--accent-decorative);
    border-radius: 4px;
}

.verse, .refrain {
    margin: 1rem 0;
    line-height: 1.8;
    font-style: italic;
}

.refrain {
    margin-left: 1rem;
    color: var(--text-secondary);
}

.refrain-label {
    font-weight: bold;
    margin: 1rem 0 0.5rem 0;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.verse em, .refrain em {
    font-style: italic;
}

/* Botanical illustration plates */
.chapter-content figure {
    margin: 3rem auto;
    padding: 2.5rem 2rem 2rem;
    max-width: 22rem;
    text-align: center;
    background:
        linear-gradient(
            to bottom,
            var(--sepia-lighter, #f9f6f2),
            oklch(from var(--sepia, #a89986) calc(l + (1 - l) * 0.92) calc(c * 0.15) h)
        );
    border-top: 1px solid var(--sepia, #a89986);
    border-bottom: 1px solid var(--sepia, #a89986);
    position: relative;
}

/* Thin decorative rule above and below the plate area */
.chapter-content figure::before,
.chapter-content figure::after {
    content: '';
    display: block;
    width: 40%;
    height: 0;
    border-top: 1px solid var(--border-color, #D5CEC4);
    margin: 0 auto;
}

.chapter-content figure::before {
    margin-bottom: 1.5rem;
}

.chapter-content figure::after {
    margin-top: 1.5rem;
}

.chapter-content figure img {
    display: block;
    max-width: 100%;
    height: auto;
    margin: 0 auto;
    mix-blend-mode: multiply;
    filter: contrast(1.1) saturate(0.3);
}

/* Visually hidden but accessible to screen readers */
.chapter-content figcaption {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Dark mode adjustments */
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) .chapter-content figure {
        background:
            linear-gradient(
                to bottom,
                var(--gray-950, #2B2520),
                var(--gray-975, #1F1C18)
            );
        border-color: var(--gray-850, #483F37);
    }

    :root:not([data-theme="light"]) .chapter-content figure::before,
    :root:not([data-theme="light"]) .chapter-content figure::after {
        border-color: var(--gray-850, #483F37);
    }

    :root:not([data-theme="light"]) .chapter-content figure img {
        mix-blend-mode: normal;
        filter: contrast(1.05) saturate(0.2) brightness(0.85);
        opacity: 0.88;
    }
}

[data-theme="dark"] .chapter-content figure {
    background:
        linear-gradient(
            to bottom,
            var(--gray-950, #2B2520),
            var(--gray-975, #1F1C18)
        );
    border-color: var(--gray-850, #483F37);
}

[data-theme="dark"] .chapter-content figure::before,
[data-theme="dark"] .chapter-content figure::after {
    border-color: var(--gray-850, #483F37);
}

[data-theme="dark"] .chapter-content figure img {
    mix-blend-mode: normal;
    filter: contrast(1.05) saturate(0.2) brightness(0.85);
    opacity: 0.88;
}

@media (max-width: 768px) {
    .chapter-content figure {
        margin: 2rem auto;
        padding: 2rem 1.25rem 1.5rem;
        max-width: 85%;
    }
}