/* Distill.pub-style blog article layout */
/* Designed to match the site's 700px container width */

html {
    scroll-behavior: smooth;
}

@media (prefers-reduced-motion: reduce) {
    html {
        scroll-behavior: auto;
    }
}

/* ===== ROOT LAYOUT ===== */
.distill-layout {
    /* Uses parent .container for width - no special sizing */
}

/* ===== LEFT SIDEBAR - TABLE OF CONTENTS ===== */
.distill-toc {
    position: fixed;
    top: 120px;
    left: max(1rem, calc((100vw - 700px) / 2 - 220px));
    width: 180px;
    max-height: calc(100vh - 140px);
    overflow-y: auto;
    font-size: 13px;
}

.distill-toc-title {
    font-family: var(--font-sans);
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-light);
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border-color);
}

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

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

.distill-toc-list a {
    color: var(--text-light);
    text-decoration: none;
    line-height: 1.4;
    display: block;
    transition: color 0.2s ease;
}

.distill-toc-list a:hover,
.distill-toc-list a.active {
    color: var(--accent-color);
}

.distill-toc-list .toc-h3 {
    padding-left: 12px;
    font-size: 12px;
}

.distill-toc-list .toc-h4 {
    padding-left: 24px;
    font-size: 11px;
}

/* Hide TOC when not enough space */
@media (max-width: 1100px) {
    .distill-toc {
        display: none;
    }
}

/* ===== ARTICLE CONTAINER ===== */
.distill-article {
    /* Inherits from .container - same 700px max-width */
}

/* ===== HEADER ===== */
.distill-header {
    margin-bottom: 1.5rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid var(--border-color);
}

/* ===== TITLE ===== */
.distill-title {
    font-family: 'Plus Jakarta Sans', var(--font-display);
    font-size: 2.75rem;
    font-weight: 700;
    line-height: 1.2;
    margin: 0 0 1rem 0;
    color: var(--text-color);
    letter-spacing: -0.02em;
}

/* ===== SUBTITLE ===== */
.distill-subtitle {
    font-family: var(--font-sans);
    font-size: 1.15rem;
    font-weight: 400;
    line-height: 1.5;
    color: var(--text-light);
    margin: 0;
}

/* ===== BYLINE ===== */
.distill-byline {
    margin: 0.5rem 0 1rem 0;
    font-family: var(--font-sans);
    color: var(--text-light);
}

.byline-authors {
    font-size: 16px;
}

.byline-date {
    font-size: 14px;
}

.byline-date {
    margin-top: 0.25rem;
}

.distill-byline a {
    color: var(--text-color);
    text-decoration: none;
}

.distill-byline a:hover {
    color: var(--accent-color);
    text-decoration: underline;
}


/* ===== CONTENT AREA ===== */
.distill-content {
    font-family: var(--font-sans);
    font-size: 17px;
    line-height: 1.75;
    color: var(--text-color);
}

.distill-content p {
    margin-bottom: 1.4rem;
}

.distill-content h1,
.distill-content h2,
.distill-content h3,
.distill-content h4,
.distill-content h5,
.distill-content h6 {
    font-family: 'Plus Jakarta Sans', var(--font-display);
    margin-top: 2.25rem;
    margin-bottom: 0.875rem;
    line-height: 1.3;
    scroll-margin-top: 80px;
}

.distill-content h2 {
    font-size: 1.6rem;
    font-weight: 600;
}

.distill-content h3 {
    font-size: 1.3rem;
    font-weight: 600;
}

.distill-content h4 {
    font-size: 1.1rem;
    font-weight: 600;
}

.distill-content h1:first-child,
.distill-content h2:first-child,
.distill-content h3:first-child {
    margin-top: 0;
}

/* Links in content */
.distill-content a {
    color: var(--accent-color);
    text-decoration: none;
}

.distill-content a:hover {
    text-decoration: underline;
}

/* ===== SIDENOTES (Tufte style) ===== */
.sidenote {
    float: right;
    clear: right;
    margin-right: -45%;
    width: 40%;
    margin-top: 0.3rem;
    margin-bottom: 1rem;
    font-size: 13px;
    line-height: 1.5;
    color: var(--text-light);
    padding-left: 15px;
    border-left: 2px solid var(--border-color);
}

.sidenote p {
    margin: 0 0 0.5rem 0;
}

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

.sidenote-number {
    font-size: 12px;
    font-weight: 600;
    color: var(--accent-color);
    margin-right: 4px;
}

/* Hide sidenotes on smaller screens */
@media (max-width: 1199px) {
    .sidenote {
        display: none;
    }
}

/* Footnote reference */
.distill-content .footnote-ref {
    font-size: 12px;
    font-weight: 600;
    color: var(--accent-color);
    text-decoration: none;
    position: relative;
    top: -0.3em;
}

.distill-content .footnote-ref:hover {
    text-decoration: underline;
}

/* ===== FOOTNOTES AT BOTTOM ===== */
@media (max-width: 1199px) {
    .distill-content .footnotes {
        display: block;
        margin-top: 2.5rem;
        padding-top: 1.5rem;
        border-top: 1px solid var(--border-color);
        font-size: 14px;
        color: var(--text-light);
    }
    
    .distill-content .footnotes ol {
        padding-left: 1.5rem;
    }
    
    .distill-content .footnotes li {
        margin-bottom: 0.75rem;
    }
}

/* ===== RESPONSIVE: TABLET ===== */

/* ===== RESPONSIVE: MOBILE ===== */
@media (max-width: 600px) {
    .distill-title {
        font-size: 2.25rem;
    }

    .distill-subtitle {
        font-size: 1rem;
    }

    .distill-content {
        font-size: 16px;
        line-height: 1.7;
    }

    .distill-content h2 {
        font-size: 1.4rem;
    }

    .distill-content h3 {
        font-size: 1.2rem;
    }
}

/* ===== RESPONSIVE: SMALL MOBILE ===== */
@media (max-width: 480px) {
    .distill-title {
        font-size: 2rem;
    }

    .distill-subtitle {
        font-size: 0.95rem;
    }

    .distill-content {
        font-size: 15px;
    }

    .distill-content h2 {
        font-size: 1.3rem;
    }

    .distill-content h3 {
        font-size: 1.1rem;
    }
}

/* ===== HIDE SIDENOTES SPACER ===== */
.distill-sidenotes-spacer {
    display: none;
}
