/* ============================================
   Articles Page Styles - Newspaper Layout

   Old-fashioned newspaper styling with:
   - Vintage paper texture
   - Multi-column article layout
   - Newspaper masthead
   - Accessible text sizing controls
   ============================================ */

/* ============================================
   CSS Variables - Colors, Fonts, Overrides
   ============================================ */

:root {
    /* Color Palette - Vintage Newspaper */
    --ink: #1d1b16;
    --paper: #f4efe2;
    --paper-edge: #ece4d2;
    --muted: rgba(29, 27, 22, 0.85);
    --rule: rgba(29, 27, 22, 0.18);

    /* Typography - newspaper style with Times New Roman */
    --font-head: "Times New Roman", Times, "Noto Serif", Georgia, serif;
    --font-body: "Times New Roman", Times, "Noto Serif", Georgia, serif;
    --font-ui: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;

    /* PicoCSS Overrides */
    --pico-background-color: var(--paper);
    --pico-color: var(--ink);
    --pico-font-family: var(--font-body);
    --pico-line-height: 1.75;
    --pico-border-radius: 0.2rem;

    /* Text size scaling for accessibility */
    --text-scale: 1;
}

body.text-size-large {
    --text-scale: 1.15;
}

body.text-size-xlarge {
    --text-scale: 1.3;
}

/* ============================================
   Global Styles
   ============================================ */

html,
body {
    height: 100%;
    margin: 0;
}

/* ============================================
   Accessibility Features
   ============================================ */

/* Focus indicators for accessibility */
a:focus-visible,
button:focus-visible {
    outline: 3px solid var(--ink);
    outline-offset: 2px;
    border-radius: 2px;
}

/* Skip link for keyboard navigation - Hidden until keyboard focus */
.skip-link {
    position: absolute;
    top: -100%;
    left: 0;
    background: var(--ink);
    color: var(--paper);
    padding: 0.5rem 1rem;
    text-decoration: none;
    font-family: var(--font-ui);
    font-size: 0.9rem;
    z-index: 10000;
    border-radius: 0 0 4px 0;
    opacity: 0;
    pointer-events: none;
    transform: translateY(-100%);
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.skip-link:focus {
    top: 0;
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0);
    outline: 3px solid var(--ink);
    outline-offset: 2px;
}

/* Editorial notes styling */
.editorial-note {
    font-style: italic;
    color: rgba(29, 27, 22, 0.65);
    font-size: 0.9em;
}

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

/* ============================================
   Page Layout - Paper & Masthead
   ============================================ */

/* Paper "fiber" + speckles */
.paper {
    position: relative;
    padding: 1.25rem;
    max-width: 1100px;
    margin: 1.25rem auto 4rem;
    background-color: var(--paper);
    background-image:
        repeating-linear-gradient(0deg,
            rgba(29, 27, 22, 0.02) 0px,
            rgba(29, 27, 22, 0.02) 1px,
            transparent 1px,
            transparent 6px),
        radial-gradient(circle at 30% 40%, rgba(29, 27, 22, 0.03) 0 1px, transparent 2px),
        radial-gradient(circle at 70% 60%, rgba(29, 27, 22, 0.025) 0 1px, transparent 2px),
        linear-gradient(180deg, rgba(255, 255, 255, 0.5), rgba(255, 255, 255, 0));
    box-shadow:
        0 20px 60px rgba(0, 0, 0, 0.12),
        0 2px 0 rgba(0, 0, 0, 0.05);
    border: 1px solid rgba(0, 0, 0, 0.08);
}

.paper::before {
    content: "";
    position: absolute;
    inset: 0;
    pointer-events: none;
    background:
        radial-gradient(circle at 10% 20%, rgba(0, 0, 0, 0.035), transparent 22%),
        radial-gradient(circle at 90% 15%, rgba(0, 0, 0, 0.03), transparent 25%),
        radial-gradient(circle at 85% 80%, rgba(0, 0, 0, 0.03), transparent 28%);
    mix-blend-mode: multiply;
    opacity: 0.35;
}

/* Masthead */
.masthead {
    text-align: center;
    padding: 1.25rem 0 0.75rem;
    border-bottom: 2px solid var(--ink);
    margin-bottom: 1rem;
    position: relative;
}

.masthead .kicker {
    font-family: var(--font-ui);
    text-transform: uppercase;
    letter-spacing: 0.18em;
    font-size: 0.78rem;
    color: var(--muted);
    margin-bottom: 0.25rem;
}

.masthead h1 {
    font-family: var(--font-head);
    font-weight: 600;
    letter-spacing: 0.04em;
    margin: 0.25rem 0 0.25rem;
    font-size: clamp(2rem, 5.5vw, 3.25rem);
    line-height: 1.05;
}

.masthead .subhead {
    font-family: var(--font-head);
    font-style: italic;
    color: var(--muted);
    margin: 0.25rem auto 0.75rem;
    max-width: 70ch;
}

.masthead .meta {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
    border-top: 1px solid var(--rule);
    padding-top: 0.65rem;
    font-family: var(--font-ui);
    font-size: 0.78rem;
    color: var(--muted);
}

.masthead .meta span {
    white-space: nowrap;
}

/* ============================================
   Navigation & Controls
   ============================================ */

/* Nav / buttons */
.top-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    margin: 0.25rem 0 1.25rem;
    flex-wrap: wrap;
    font-family: var(--font-ui);
}

.top-actions a[role="button"] {
    font-family: var(--font-ui);
    text-transform: uppercase;
    letter-spacing: 0.12em;
    font-size: 0.72rem;
    border-color: rgba(0, 0, 0, 0.35);
    color: var(--ink);
    background: transparent;
}

.top-actions a[role="button"]:hover {
    background: rgba(0, 0, 0, 0.06);
}

.text-size-control {
    position: fixed;
    bottom: calc(20px + env(safe-area-inset-bottom));
    right: calc(20px + env(safe-area-inset-right));
    z-index: 1000;
    font-family: var(--font-ui);
    text-transform: uppercase;
    letter-spacing: 0.12em;
    font-size: 0.85rem;
    font-weight: 500;
    background: var(--ink);
    color: var(--paper);
    padding: 0.85rem 1.15rem;
    cursor: pointer;
    border: none;
    border-radius: 50%;
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25), 0 2px 4px rgba(0, 0, 0, 0.15);
    transition: all 0.2s ease;
}

.text-size-control:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.3), 0 3px 6px rgba(0, 0, 0, 0.2);
}

.text-size-control:active {
    transform: scale(0.95);
}

/* Apply text scaling to all body text (excludes masthead h1) */
p,
li,
figcaption,
blockquote,
.deck,
.columns p,
.columns li,
.byline,
.editorial-note,
.meta span,
.footer span,
.toc a,
.toc li,
.top-actions a {
    font-size: calc(1rem * var(--text-scale));
}

/* Smaller text elements scale proportionally */
small,
.kicker,
.toc h2 {
    font-size: calc(0.78rem * var(--text-scale));
}

/* Subhead scales but stays smaller than headline */
.subhead {
    font-size: calc(1rem * var(--text-scale));
}

/* Article headlines scale (these are h2, not the main h1 masthead) */
.headline {
    font-size: calc(clamp(1.25rem, 3.6vw, 1.75rem) * var(--text-scale));
}

/* Section subheadings in articles */
.columns h3 {
    font-size: calc(1.1rem * var(--text-scale));
}

/* ============================================
   Table of Contents
   ============================================ */

.toc {
    border-top: 1px solid var(--rule);
    border-bottom: 1px solid var(--rule);
    padding: 0.5rem 0.75rem;
    margin: 0 0 1rem;
    display: flex;
    align-items: baseline;
    gap: 0.75rem;
    flex-wrap: wrap;
}

/* Mobile toggle button - hidden on desktop */
.toc-toggle {
    display: none;
}

/* Desktop heading */
.toc-heading-desktop {
    font-family: var(--font-ui);
    text-transform: uppercase;
    letter-spacing: 0.14em;
    font-size: calc(0.75rem * var(--text-scale));
    color: var(--muted);
    margin: 0;
    white-space: nowrap;
}

.toc-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem 0;
    padding: 0;
    margin: 0;
    list-style: none;
    font-size: 0.82rem;
    line-height: 1.3;
    flex: 1;
}

.toc li {
    display: inline;
}

.toc li:not(:last-child)::after {
    content: " · ";
    color: var(--muted);
    margin: 0 0.35rem;
}

.toc a {
    color: var(--ink);
    text-decoration: none;
    border-bottom: 1px dotted rgba(0, 0, 0, 0.3);
    white-space: nowrap;
}

.toc a:hover {
    border-bottom-style: solid;
}

/* ============================================
   Table of Contents - Mobile Collapsible
   ============================================ */

@media (max-width: 768px) {
    .toc {
        flex-direction: column;
        align-items: stretch;
        padding: 0;
        gap: 0;
    }

    /* Hide desktop heading on mobile */
    .toc-heading-desktop {
        display: none;
    }

    /* Show toggle button on mobile */
    .toc-toggle {
        display: flex;
        align-items: center;
        justify-content: space-between;
        width: 100%;
        padding: 0.75rem;
        background: transparent;
        border: none;
        cursor: pointer;
        font-family: var(--font-ui);
        text-transform: uppercase;
        letter-spacing: 0.14em;
        font-size: calc(0.78rem * var(--text-scale));
        color: var(--muted);
        text-align: left;
    }

    .toc-toggle:hover {
        background: rgba(0, 0, 0, 0.03);
    }

    .toc-toggle:focus-visible {
        outline: 2px solid var(--ink);
        outline-offset: -2px;
    }

    /* Chevron icon */
    .toc-toggle-icon {
        width: 0;
        height: 0;
        border-left: 5px solid transparent;
        border-right: 5px solid transparent;
        border-top: 6px solid var(--muted);
        transition: transform 0.2s ease;
    }

    .toc-toggle[aria-expanded="true"] .toc-toggle-icon {
        transform: rotate(180deg);
    }

    /* Collapsible list */
    .toc-list {
        display: none;
        flex-direction: column;
        gap: 0;
        padding: 0 0.75rem 0.75rem;
        border-top: 1px solid var(--rule);
        background: rgba(0, 0, 0, 0.015);
    }

    .toc-list.is-open {
        display: flex;
    }

    .toc li {
        display: block;
        padding: 0.5rem 0;
        border-bottom: 1px solid rgba(0, 0, 0, 0.06);
    }

    .toc li:last-child {
        border-bottom: none;
    }

    .toc li:not(:last-child)::after {
        display: none;
    }

    .toc a {
        display: block;
        white-space: normal;
        line-height: 1.4;
        border-bottom: none;
        padding: 0.25rem 0;
    }

    .toc a:hover {
        color: var(--ink);
        background: rgba(0, 0, 0, 0.03);
        margin: -0.25rem -0.5rem;
        padding: 0.25rem 0.5rem;
        border-radius: 4px;
    }
}

/* ============================================
   Article Blocks & Typography
   ============================================ */

/* Article blocks */
.article {
    padding: 1.25rem 0 1.75rem;
    border-bottom: 1px solid var(--rule);
}

.article:last-of-type {
    border-bottom: none;
}

.headline {
    font-family: var(--font-head);
    font-weight: 600;
    letter-spacing: 0.02em;
    font-size: clamp(1.35rem, 3.6vw, 2.15rem);
    line-height: 1.1;
    margin: 0 0 0.35rem;
}

.deck {
    margin: 0 0 0.75rem;
    color: var(--muted);
    font-style: italic;
    max-width: 80ch;
}

.byline {
    font-family: var(--font-ui);
    font-size: 0.78rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--muted);
    margin-bottom: 0.75rem;
}

.byline .rule {
    height: 1px;
    flex: 1;
    background: var(--rule);
    min-width: 120px;
}

/* ============================================
   Column Layout - Newspaper Style
   ============================================ */

/* Column layout for readable newspaper feel */
.columns {
    column-width: 18rem;
    column-gap: 2.25rem;
    column-rule: 1px solid rgba(0, 0, 0, 0.08);
}

.columns p {
    margin: 0 0 0.85rem;
}

/* Drop cap */
.columns p.dropcap:first-letter {
    float: left;
    font-family: var(--font-head);
    font-size: 3.4rem;
    line-height: 0.9;
    padding: 0.15rem 0.5rem 0 0;
    font-weight: 600;
}

.column-break {
    break-before: column;
    -webkit-column-break-before: column;
}

/* ============================================
   Images, Figures & Scans
   ============================================ */

/* Figures that can sit inside columns without breaking awkwardly */
figure {
    position: relative;
    margin: 0.5rem 0 1.25rem;
    break-inside: avoid;
    -webkit-column-break-inside: avoid;
    background: linear-gradient(
        145deg,
        rgba(255, 255, 255, 0.5) 0%,
        rgba(244, 239, 226, 0.35) 100%
    );
    border: 1px solid rgba(0, 0, 0, 0.08);
    border-radius: 6px;
    padding: 10px;
    box-shadow:
        0 2px 6px rgba(0, 0, 0, 0.05),
        0 1px 2px rgba(0, 0, 0, 0.06),
        inset 0 1px 0 rgba(255, 255, 255, 0.4);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

figure:hover {
    transform: translateY(-2px);
    box-shadow:
        0 6px 16px rgba(0, 0, 0, 0.08),
        0 3px 6px rgba(0, 0, 0, 0.06),
        inset 0 1px 0 rgba(255, 255, 255, 0.4);
}

/* Decorative corner accents for inline figures */
figure::before,
figure::after {
    content: "";
    position: absolute;
    width: 14px;
    height: 14px;
    border: 1.5px solid rgba(0, 0, 0, 0.07);
    pointer-events: none;
    transition: border-color 0.2s ease;
}

figure::before {
    top: 5px;
    left: 5px;
    border-right: none;
    border-bottom: none;
    border-radius: 3px 0 0 0;
}

figure::after {
    bottom: 5px;
    right: 5px;
    border-left: none;
    border-top: none;
    border-radius: 0 0 3px 0;
}

figure:hover::before,
figure:hover::after {
    border-color: rgba(0, 0, 0, 0.12);
}

figure img {
    display: block;
    width: 100%;
    height: auto;
    border-radius: 3px;
    filter: grayscale(0.1) sepia(0.18) contrast(1.03);
    cursor: zoom-in;
    transition: filter 0.2s ease;
}

figure:hover img {
    filter: grayscale(0) sepia(0.1) contrast(1.05);
}

figcaption {
    font-family: var(--font-ui);
    font-size: calc(0.75rem * var(--text-scale));
    color: var(--muted);
    padding: 8px 4px 2px;
    margin-top: 8px;
    border-top: 1px solid rgba(0, 0, 0, 0.06);
    text-align: center;
    line-height: 1.4;
}

/* ============================================
   Scan Gallery - Full Page Image Grid
   ============================================ */

.scan-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1.5rem;
    margin-top: 1.5rem;
    padding: 0.5rem;
}

.scan-item {
    position: relative;
    background: linear-gradient(
        145deg,
        rgba(255, 255, 255, 0.6) 0%,
        rgba(244, 239, 226, 0.4) 100%
    );
    border: 1px solid rgba(0, 0, 0, 0.08);
    border-radius: 8px;
    padding: 12px;
    box-shadow:
        0 2px 8px rgba(0, 0, 0, 0.06),
        0 1px 3px rgba(0, 0, 0, 0.08),
        inset 0 1px 0 rgba(255, 255, 255, 0.5);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.scan-item:hover {
    transform: translateY(-3px);
    box-shadow:
        0 8px 24px rgba(0, 0, 0, 0.1),
        0 4px 8px rgba(0, 0, 0, 0.08),
        inset 0 1px 0 rgba(255, 255, 255, 0.5);
}

.scan-item img {
    display: block;
    width: 100%;
    height: auto;
    border-radius: 4px;
    cursor: zoom-in;
    filter: grayscale(0.1) sepia(0.15) contrast(1.02);
    transition: filter 0.2s ease;
}

.scan-item:hover img {
    filter: grayscale(0) sepia(0.08) contrast(1.05);
}

.scan-item figcaption {
    margin-top: 10px;
    padding: 8px 4px 4px;
    border-top: 1px solid rgba(0, 0, 0, 0.06);
    font-family: var(--font-ui);
    font-size: calc(0.78rem * var(--text-scale));
    color: var(--muted);
    text-align: center;
    line-height: 1.4;
}

/* Decorative corner accents */
.scan-item::before,
.scan-item::after {
    content: "";
    position: absolute;
    width: 20px;
    height: 20px;
    border: 2px solid rgba(0, 0, 0, 0.08);
    pointer-events: none;
    transition: border-color 0.2s ease;
}

.scan-item::before {
    top: 6px;
    left: 6px;
    border-right: none;
    border-bottom: none;
    border-radius: 4px 0 0 0;
}

.scan-item::after {
    bottom: 6px;
    right: 6px;
    border-left: none;
    border-top: none;
    border-radius: 0 0 4px 0;
}

.scan-item:hover::before,
.scan-item:hover::after {
    border-color: rgba(0, 0, 0, 0.15);
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .scan-grid {
        grid-template-columns: 1fr;
        gap: 1.25rem;
        padding: 0;
    }

    .scan-item {
        padding: 10px;
        border-radius: 6px;
    }

    .scan-item::before,
    .scan-item::after {
        width: 16px;
        height: 16px;
    }
}

/* ============================================
   Footer & Lightbox
   ============================================ */

/* Footer */
.footer {
    border-top: 2px solid var(--ink);
    margin-top: 1.5rem;
    padding-top: 1rem;
    font-family: var(--font-ui);
    color: var(--muted);
    font-size: 0.82rem;
    display: flex;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.75rem;
}

/* Lightbox */
.lightbox {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.92);
    display: none !important;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    z-index: 9999;
}

.lightbox.active {
    display: flex !important;
}

.lightbox img {
    max-width: 96vw;
    max-height: 92vh;
    width: auto;
    height: auto;
    cursor: zoom-out;
    filter: none;
}

.lightbox button {
    position: absolute;
    top: 1rem;
    right: 1rem;
    font-family: var(--font-ui);
    text-transform: uppercase;
    letter-spacing: 0.12em;
    font-size: 0.72rem;
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.35);
    color: rgba(255, 255, 255, 0.9);
}

/* ============================================
   Responsive Design - Media Queries
   ============================================ */

/* Responsive styles for larger tablets - disable columns earlier */
@media (max-width: 1024px) {
    .columns {
        column-count: 1;
        column-width: auto;
    }

    .column-break {
        break-before: auto;
        -webkit-column-break-before: auto;
    }
}

/* Responsive styles for tablets and below */
@media (max-width: 768px) {
    .paper {
        padding: 1rem;
        margin: 0.5rem;
        border-radius: 0;
    }

    .masthead h1 {
        font-size: clamp(1.75rem, 8vw, 2.5rem);
    }

    .masthead .subhead {
        font-size: 0.9rem;
    }

    .masthead .meta {
        justify-content: center;
        font-size: 0.7rem;
    }

    .top-actions {
        flex-direction: column;
        align-items: stretch;
    }

    .top-actions a[role="button"] {
        width: 100%;
        text-align: center;
    }

    .headline {
        font-size: clamp(1.25rem, 6vw, 1.75rem);
    }

    .byline {
        font-size: 0.7rem;
        flex-direction: column;
        gap: 0.25rem;
    }

    .byline .rule {
        display: none;
    }

    figure {
        margin: 0.25rem 0 1.25rem;
        padding: 8px;
        border-radius: 5px;
    }

    figure::before,
    figure::after {
        width: 12px;
        height: 12px;
    }

    figure::before {
        top: 4px;
        left: 4px;
    }

    figure::after {
        bottom: 4px;
        right: 4px;
    }

    figcaption {
        font-size: calc(0.7rem * var(--text-scale));
        padding: 6px 2px 0;
        margin-top: 6px;
    }

    .scan-grid {
        grid-template-columns: 1fr;
    }

    .footer {
        flex-direction: column;
        text-align: center;
        gap: 0.5rem;
    }
}

/* Responsive styles for mobile phones */
@media (max-width: 480px) {
    .paper {
        padding: 0.75rem;
        margin: 0;
        border-left: none;
        border-right: none;
        border-radius: 0;
    }

    .masthead {
        padding: 1rem 0 0.75rem;
    }

    .masthead h1 {
        font-size: 1.75rem;
    }

    .masthead .kicker {
        font-size: 0.65rem;
    }

    .toc ul {
        font-size: 0.78rem;
    }

    .toc li:not(:last-child)::after {
        margin: 0 0.25rem;
    }

    .text-size-control {
        bottom: calc(16px + env(safe-area-inset-bottom));
        right: calc(16px + env(safe-area-inset-right));
        width: 44px;
        height: 44px;
        font-size: 0.8rem;
    }
}

/* ============================================
   Utility Classes
   ============================================ */

/* Link styling for footer */
.footer-link {
    color: inherit;
    text-decoration: underline;
}

/* Screen reader only announcement (visually hidden) */
.sr-announcement {
    position: absolute;
    left: -10000px;
    width: 1px;
    height: 1px;
    overflow: hidden;
}

/* ============================================
   Reading Progress Bar
   ============================================ */

.reading-progress {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 3px;
    background: rgba(29, 27, 22, 0.1);
    z-index: 9999;
}

.reading-progress-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--ink) 0%, rgba(29, 27, 22, 0.7) 100%);
    width: 0%;
    transition: width 0.1s ease-out;
}

/* ============================================
   Back to Top Button
   ============================================ */

.back-to-top {
    position: fixed;
    bottom: calc(80px + env(safe-area-inset-bottom));
    right: calc(20px + env(safe-area-inset-right));
    width: 48px;
    height: 48px;
    background: var(--ink);
    color: var(--paper);
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
    opacity: 0;
    visibility: hidden;
    transform: translateY(10px);
    transition: opacity 0.3s ease, transform 0.3s ease, visibility 0.3s ease, background 0.2s ease;
    z-index: 999;
}

.back-to-top.visible {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.back-to-top:hover {
    background: rgba(29, 27, 22, 0.8);
    transform: translateY(-2px);
}

.back-to-top:focus-visible {
    outline: 3px solid var(--ink);
    outline-offset: 2px;
}

@media (max-width: 480px) {
    .back-to-top {
        bottom: calc(70px + env(safe-area-inset-bottom));
        right: calc(16px + env(safe-area-inset-right));
        width: 44px;
        height: 44px;
    }
}

/* ============================================
   Decorative Article Dividers
   ============================================ */

.article-divider {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    margin: 2.5rem 0;
    padding: 1rem 0;
}

.article-divider::before,
.article-divider::after {
    content: "";
    flex: 1;
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--rule), transparent);
    max-width: 100px;
}

.article-divider .ornament {
    font-family: var(--font-head);
    font-size: 1.5rem;
    color: var(--muted);
    opacity: 0.5;
    letter-spacing: 0.3em;
}

@media (max-width: 768px) {
    .article-divider {
        margin: 1.5rem 0;
    }

    .article-divider .ornament {
        font-size: 1.25rem;
    }
}

/* ============================================
   Active TOC Highlighting
   ============================================ */

.toc a {
    transition: color 0.2s ease, border-color 0.2s ease;
}

.toc a.active {
    color: var(--ink);
    font-weight: 500;
    border-bottom-style: solid;
    border-bottom-color: var(--ink);
}

/* Mobile TOC active state */
@media (max-width: 768px) {
    .toc-list a.active {
        background: rgba(29, 27, 22, 0.05);
        margin: -0.25rem -0.5rem;
        padding: 0.25rem 0.5rem;
        border-radius: 4px;
        border-bottom: none;
    }
}

/* ============================================
   Scroll-Triggered Article Animations
   ============================================ */

.article {
    opacity: 0;
    transform: translateY(30px);
    transition: opacity 0.6s ease, transform 0.6s ease;
}

.article.is-visible {
    opacity: 1;
    transform: translateY(0);
}

/* Staggered animation for child elements */
.article.is-visible .headline {
    animation: fadeSlideIn 0.5s ease 0.1s both;
}

.article.is-visible .deck {
    animation: fadeSlideIn 0.5s ease 0.2s both;
}

.article.is-visible .byline {
    animation: fadeSlideIn 0.5s ease 0.3s both;
}

.article.is-visible .columns {
    animation: fadeSlideIn 0.5s ease 0.4s both;
}

@keyframes fadeSlideIn {
    from {
        opacity: 0;
        transform: translateY(15px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    .article {
        opacity: 1;
        transform: none;
        transition: none;
    }

    .article.is-visible .headline,
    .article.is-visible .deck,
    .article.is-visible .byline,
    .article.is-visible .columns {
        animation: none;
    }

    .reading-progress-bar {
        transition: none;
    }
}

/* ============================================
   Current Article Indicator (optional pill)
   ============================================ */

.article-indicator {
    position: fixed;
    top: 12px;
    left: 50%;
    transform: translateX(-50%) translateY(-50px);
    background: var(--ink);
    color: var(--paper);
    font-family: var(--font-ui);
    font-size: 0.75rem;
    padding: 0.4rem 0.8rem;
    border-radius: 20px;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, transform 0.3s ease, visibility 0.3s ease;
    z-index: 9998;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    pointer-events: none;
}

.article-indicator.visible {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(0);
}

@media (max-width: 480px) {
    .article-indicator {
        font-size: 0.7rem;
        padding: 0.35rem 0.7rem;
    }
}

/* ============================================
   SIDEBAR MAP - Journey Location Tracker
   ============================================ */

/* Memorial palette for map elements */
:root {
    --color-gold: #c9a962;
    --color-gold-light: #dcc584;
    --color-sage: #a8b5a0;
    --color-sage-dark: #6b7865;
}

/* Layout wrapper for sidebar + content */
.articles-layout {
    display: flex;
    min-height: 100vh;
}

/* ========== Sidebar Map (Desktop) ========== */
.map-sidebar {
    position: sticky;
    top: 0;
    left: 0;
    width: 280px;
    height: 100vh;
    flex-shrink: 0;
    background: var(--paper-edge);
    border-right: 1px solid var(--rule);
    display: flex;
    flex-direction: column;
    z-index: 100;
}

.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem;
    border-bottom: 1px solid var(--rule);
    background: var(--paper);
}

.sidebar-title {
    font-family: var(--font-head);
    font-size: 1.1rem;
    font-weight: 500;
    color: var(--ink);
    margin: 0;
}

.sidebar-link {
    font-family: var(--font-ui);
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--color-sage-dark);
    text-decoration: none;
    transition: color 0.2s ease;
}

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

/* Map container */
.sidebar-map-container {
    position: relative;
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

.sidebar-map {
    position: absolute;
    inset: 0;
    /* Vintage filter */
    filter: sepia(0.15) contrast(1.02) saturate(0.9);
}

.sidebar-map-vignette {
    position: absolute;
    inset: 0;
    pointer-events: none;
    background: radial-gradient(
        ellipse at center,
        transparent 30%,
        rgba(236, 228, 210, 0.4) 100%
    );
}

/* Location indicator at bottom of sidebar */
.sidebar-location {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    background: var(--paper);
    border-top: 1px solid var(--rule);
    font-family: var(--font-ui);
    font-size: 0.8rem;
}

.location-dot {
    width: 8px;
    height: 8px;
    background: var(--color-gold);
    border-radius: 50%;
    flex-shrink: 0;
    animation: pulse-dot 2s ease-in-out infinite;
}

@keyframes pulse-dot {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.2); opacity: 0.7; }
}

.location-text {
    color: var(--ink);
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ========== Mobile Location Indicator ========== */
.mobile-location-indicator {
    display: none;
    position: fixed;
    top: 8px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 9999;
    background: var(--paper);
    border: 1px solid var(--rule);
    border-radius: 20px;
    padding: 0.4rem 0.75rem;
    box-shadow: 0 2px 12px rgba(29, 27, 22, 0.15);
    font-family: var(--font-ui);
    font-size: 0.75rem;
    align-items: center;
    gap: 0.5rem;
}

.mobile-location-dot {
    width: 6px;
    height: 6px;
    background: var(--color-gold);
    border-radius: 50%;
    flex-shrink: 0;
}

.mobile-location-text {
    color: var(--ink);
    font-weight: 500;
    max-width: 150px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.mobile-map-link {
    font-weight: 500;
    color: var(--color-sage-dark);
    text-decoration: none;
    padding-left: 0.5rem;
    border-left: 1px solid var(--rule);
    margin-left: 0.25rem;
}

.mobile-map-link:hover {
    color: var(--color-gold);
}

/* ========== Mapbox Customizations ========== */
.map-sidebar .mapboxgl-ctrl-group {
    background: var(--paper) !important;
    border: 1px solid var(--rule) !important;
    box-shadow: none !important;
}

.map-sidebar .mapboxgl-ctrl-group button {
    background-color: var(--paper) !important;
}

.map-sidebar .mapboxgl-ctrl-group button:hover {
    background-color: var(--paper-edge) !important;
}

/* Hide attribution in sidebar (too small) */
.map-sidebar .mapboxgl-ctrl-attrib {
    display: none;
}

/* Custom markers */
.sidebar-marker {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    border: 2px solid;
    cursor: pointer;
    transition: transform 0.2s ease;
}

.sidebar-marker:hover {
    transform: scale(1.3);
}

.sidebar-marker.active {
    transform: scale(1.4);
    box-shadow: 0 0 0 3px rgba(201, 169, 98, 0.3);
}

.sidebar-marker-origin {
    background: var(--color-gold);
    border-color: var(--color-gold);
}

.sidebar-marker-peacecorps {
    background: var(--color-sage);
    border-color: var(--color-sage-dark);
}

.sidebar-marker-journey {
    background: var(--paper);
    border-color: var(--color-sage-dark);
}

.sidebar-marker-destination {
    background: var(--color-gold);
    border-color: var(--color-gold);
}

/* ========== Responsive - Hide sidebar on mobile ========== */
@media (max-width: 1024px) {
    .map-sidebar {
        width: 240px;
    }
}

@media (max-width: 768px) {
    .articles-layout {
        display: block;
    }

    .map-sidebar {
        display: none;
    }

    .mobile-location-indicator {
        display: flex;
    }

    /* Adjust paper width when no sidebar */
    .paper {
        margin-left: auto;
        margin-right: auto;
    }
}

/* ========== Reduced Motion ========== */
@media (prefers-reduced-motion: reduce) {
    .location-dot,
    .mobile-location-dot {
        animation: none;
    }

    .sidebar-marker {
        transition: none;
    }
}

/* ============================================
   Article 8 - Living Memories
   ============================================ */

/* Living Article Styling */
.article-living {
    position: relative;
    background: linear-gradient(135deg, rgba(168, 181, 160, 0.08) 0%, transparent 50%);
    border: 1px solid rgba(168, 181, 160, 0.3);
    border-radius: 4px;
    padding: 2.5rem 1.25rem 1.5rem;
    margin-top: 1rem;
}

@media (min-width: 600px) {
    .article-living {
        padding: 2.5rem 1.75rem 1.75rem;
    }
}

.living-badge {
    position: absolute;
    top: -0.6rem;
    left: 50%;
    transform: translateX(-50%);
    font-family: var(--font-ui);
    font-size: 0.6rem;
    text-transform: uppercase;
    letter-spacing: 0.15em;
    color: var(--paper);
    background: #6b7865;
    padding: 0.25rem 0.75rem;
    white-space: nowrap;
}

/* TOC badge for living article */
.toc-living {
    position: relative;
}

.toc-badge {
    font-family: var(--font-ui);
    font-size: 0.6rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #6b7865;
    background: rgba(168, 181, 160, 0.25);
    padding: 0.1rem 0.35rem;
    border-radius: 2px;
    margin-left: 0.5rem;
    vertical-align: middle;
}

/* Article continuation paragraph */
.article-continuation {
    font-size: calc(1rem * var(--text-scale));
    line-height: 1.75;
    margin-top: 1rem;
    text-indent: 1.5em;
}

/* Memories Section Header */
.memories-section-header {
    font-family: var(--font-ui);
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.2em;
    color: var(--muted);
    text-align: center;
    margin: 2rem 0 0.5rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--rule);
    font-weight: 500;
}

/* Memories Container - Card Grid */
.memories-article-container {
    margin-top: 0.5rem;
    display: grid;
    grid-template-columns: 1fr;
    gap: 0;
}

@media (min-width: 640px) {
    .memories-article-container {
        grid-template-columns: 1fr 1fr;
        gap: 0 1rem;
    }
}

.loading-memories {
    font-style: italic;
    color: var(--muted);
    text-align: center;
    padding: 2rem;
    grid-column: 1 / -1;
}

.no-memories,
.memories-error {
    font-style: italic;
    color: var(--muted);
    text-align: center;
    padding: 1.5rem;
    grid-column: 1 / -1;
}

.memories-error a,
.no-memories a {
    color: var(--ink);
}

/* Individual Memory Entry - Card Style */
.memory-entry {
    padding: 1rem 1.25rem;
    margin-bottom: 0.75rem;
    background: rgba(255, 255, 255, 0.5);
    border-radius: 8px;
    border: 1px solid rgba(0, 0, 0, 0.06);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.03);
    transition: box-shadow 0.2s ease, border-color 0.2s ease, background 0.2s ease;
    break-inside: avoid;
}

.memory-entry:hover {
    background: rgba(255, 255, 255, 0.75);
    border-color: rgba(0, 0, 0, 0.1);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

/* Memory with photo - inline layout */
.memory-entry.has-photo {
    display: grid;
    grid-template-columns: 72px 1fr;
    gap: 1rem;
    align-items: start;
}

/* Memory Figure - Thumbnail Style */
.memory-figure {
    margin: 0;
    padding: 0;
    grid-row: 1 / 3;
}

.memory-photo-link {
    display: block;
    position: relative;
    width: 72px;
    height: 72px;
    overflow: hidden;
    border-radius: 6px;
    background: var(--rule);
    box-shadow:
        0 1px 3px rgba(0, 0, 0, 0.08),
        0 2px 8px rgba(0, 0, 0, 0.04);
    transition: box-shadow 0.2s ease, transform 0.2s ease;
}

.memory-entry:hover .memory-photo-link {
    box-shadow:
        0 2px 6px rgba(0, 0, 0, 0.12),
        0 4px 12px rgba(0, 0, 0, 0.06);
    transform: translateY(-1px);
}

.memory-figure img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 6px;
    transition: opacity 0.2s ease;
}

.photo-count-badge {
    position: absolute;
    bottom: 4px;
    right: 4px;
    min-width: 18px;
    height: 18px;
    padding: 0 4px;
    background: rgba(0, 0, 0, 0.65);
    backdrop-filter: blur(4px);
    border-radius: 9px;
    font-family: var(--font-ui);
    font-size: 0.6rem;
    font-weight: 500;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

/* Memory Content */
.memory-content {
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

/* Memory Header */
.memory-header {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 0.5rem;
}

.memory-author {
    font-family: var(--font-head);
    font-weight: 600;
    font-size: calc(0.95rem * var(--text-scale));
    color: var(--ink);
    font-style: normal;
    line-height: 1.3;
}

.memory-meta {
    display: inline;
}

.memory-relationship {
    font-family: var(--font-ui);
    font-size: calc(0.65rem * var(--text-scale));
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-style: normal;
    opacity: 0.8;
}

.memory-relationship::before {
    content: "·";
    margin-right: 0.5rem;
    opacity: 0.5;
}

/* Pull Quote Style */
.memory-quote {
    margin: 0;
    padding: 0;
    border: none;
    background: none;
}

.memory-quote p {
    font-family: var(--font-head);
    font-size: calc(0.875rem * var(--text-scale));
    line-height: 1.55;
    color: var(--ink);
    font-style: italic;
    margin: 0;
    quotes: none;
    opacity: 0.9;
}

/* Continue Reading Link */
.memory-continue {
    display: inline-flex;
    align-items: center;
    align-self: flex-start;
    margin-top: 0.25rem;
    padding: 0.3rem 0.6rem;
    font-family: var(--font-ui);
    font-size: calc(0.6rem * var(--text-scale));
    color: var(--muted);
    text-decoration: none;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    background: rgba(0, 0, 0, 0.04);
    border-radius: 4px;
    transition: background 0.15s ease, color 0.15s ease;
}

.memory-continue:hover {
    background: rgba(0, 0, 0, 0.08);
    color: var(--ink);
}

/* Call to action section */
.memories-cta {
    margin-top: 2rem;
    padding: 1.5rem;
    border: 2px solid var(--ink);
    text-align: center;
    background: linear-gradient(135deg, rgba(168, 181, 160, 0.1) 0%, transparent 100%);
}

.memories-cta p {
    font-family: var(--font-head);
    font-size: calc(0.9rem * var(--text-scale));
    color: var(--ink);
    margin-bottom: 0.5rem;
    font-style: italic;
}

.cta-link {
    font-family: var(--font-ui);
    font-size: calc(0.8rem * var(--text-scale));
    color: var(--ink);
    text-decoration: none;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    padding: 0.5rem 1rem;
    border: 1px solid var(--ink);
    display: inline-block;
    margin-top: 0.5rem;
    transition: all 0.2s ease;
}

.cta-link:hover {
    background: var(--ink);
    color: var(--paper);
}

/* Columns adjustment for living article */
.columns-living {
    column-count: 1 !important;
}

@media (min-width: 600px) {
    .columns-living {
        column-count: 1 !important;
    }
}
