@font-face {
    font-family: 'Sztos-Thin';
    src: url('/fonts/Sztos-Thin.otf') format('opentype');
    font-weight: normal;
    font-style: normal;
}

:root {
    --max-content-width: 650px;
    --toc-width: 250px;
    --sidenote-width: 250px;
    --main-font: Georgia, 'Times New Roman', serif;
    --heading-font: Georgia, 'Times New Roman', serif;
    --brand-font: 'Sztos-Thin', Georgia, 'Times New Roman', serif;
    --text-color: #333;
    --link-color: #0066cc;
    --border-color: #e0e0e0;
    --bg-subtle: #f9f9f9;
    --sidenote-color: #666;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: var(--main-font);
    font-size: 17px;
    line-height: 1.6;
    color: var(--text-color);
    background: #fafafa;
}

hr {
    border: none;
    border-top: 1px solid var(--border-color);
    margin: 2rem 0;
}

/* Site Header */
.site-header {
    padding: 1rem 2rem;
    text-align: center;
}

.site-header a {
    color: var(--text-color);
    text-decoration: none;
    font-family: var(--brand-font);
    font-weight: bold;
    font-size: 0.9rem;
    text-transform: lowercase;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 2rem;
}

/* Table of Contents - Left Side */
.toc {
    position: fixed;
    left: 2rem;
    top: 2rem; /* Will be dynamically set by JS to align with content */
    width: var(--toc-width);
    max-height: calc(100vh - 4rem);
    overflow-y: auto;
    font-size: 0.85em;
    line-height: 1.5;
}

.toc h3 {
    font-family: var(--heading-font);
    font-size: 0.9em;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #888;
    margin-bottom: 1rem;
    font-weight: normal;
}

.toc ul {
    list-style: none;
}

.toc > ul > li {
    margin: 0.5rem 0;
}

.toc li li {
    margin: 0.3rem 0;
}

/* Indent nested levels */
.toc ul ul {
    padding-left: 1.2rem;
    margin-top: 0.2rem;
}

.toc a {
    color: var(--text-color);
    text-decoration: none;
    opacity: 0.7;
    transition: opacity 0.2s;
    display: block;
}

/* Style different heading levels */
.toc > ul > li > a {
    font-weight: 500;
    opacity: 0.85;
}

.toc ul ul a {
    font-size: 0.95em;
}

.toc ul ul ul a {
    font-size: 0.9em;
    opacity: 0.6;
}

.toc a:hover,
.toc a.active {
    opacity: 1;
}

/* Banner styling */
.banner-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    z-index: -1;
    overflow: hidden;
}

.banner-image {
    width: 100%;
    height: auto;
    display: block;
}

/* Show mobile banner on mobile, desktop banner on desktop */
.mobile-banner {
    display: none;
}

@media (max-width: 473px) {
    .desktop-banner {
        display: none;
    }
    
    .mobile-banner {
        display: block;
    }
}

/* Main Content */
article.content {
    max-width: var(--max-content-width);
    margin: 0 auto;
    position: relative;
}

article header {
    margin-bottom: 2rem;
}

/* Featured image - newspaper/LessWrong style */
.featured-image {
    margin: 2rem -3rem;
    margin-bottom: 2.5rem;
}

.featured-image img {
    width: 100%;
    height: auto;
    display: block;
}

/* Add caption support */
.featured-image figcaption {
    font-size: 0.85rem;
    color: #666;
    font-style: italic;
    text-align: center;
    margin-top: 0.75rem;
    padding: 0 3rem;
}

@media (max-width: 768px) {
    .featured-image {
        margin: 2rem -1rem;
        margin-bottom: 2rem;
    }

    .featured-image figcaption {
        padding: 0 1rem;
    }
}

article h1 {
    font-family: var(--heading-font);
    font-size: 2.2rem;
    line-height: 1.3;
    margin-bottom: 1rem;
}

.description {
    font-size: 1.1rem;
    color: #666;
    margin: 0.5rem 0 1rem 0;
    line-height: 1.5;
    font-style: italic;
}

.meta {
    font-size: 0.9rem;
    color: #888;
}

.meta .author {
    margin-right: 1rem;
}

/* Article Typography */
.article-content h2 {
    font-family: var(--heading-font);
    font-size: 1.6rem;
    margin: 2rem 0 1rem;
    line-height: 1.3;
}

.article-content h3 {
    font-family: var(--heading-font);
    font-size: 1.3rem;
    margin: 1.5rem 0 0.75rem;
    line-height: 1.3;
}

.article-content p {
    margin-bottom: 1.2rem;
}

.article-content a {
    color: var(--link-color);
    text-decoration: none;
    border-bottom: 1px solid transparent;
    transition: border-color 0.2s;
}

.article-content a:hover {
    border-bottom-color: var(--link-color);
}

.article-content blockquote {
    border-left: 3px solid var(--border-color);
    padding-left: 1.5rem;
    margin: 1.5rem 0;
    font-style: italic;
    color: #666;
}

.article-content code {
    font-size: 0.85em;
    padding: 0.2em 0.4em;
    background: var(--bg-subtle);
    border-radius: 3px;
    font-family: 'Courier New', monospace;
}

.article-content pre {
    background: var(--bg-subtle);
    padding: 1rem;
    border-radius: 4px;
    overflow-x: auto;
    margin: 1.5rem 0;
}

.article-content pre code {
    padding: 0;
    background: none;
}

/* Regular images in content - newspaper/LessWrong style */
.article-content p img {
    max-width: 100%;
    height: auto;
    display: block;
    margin: 2rem auto;
}

/* Style for image captions - Hugo renders as <em> immediately after images */
.article-content p img + em {
    display: block;
    text-align: center;
    font-size: 0.85rem;
    color: #666;
    margin-top: -1.5rem;
    margin-bottom: 2rem;
    line-height: 1.4;
    font-style: italic;
}

/* If Hugo uses figure tags */
.article-content figure {
    margin: 2rem 0;
    text-align: center;
}

.article-content figure img {
    margin: 0 auto;
    max-width: 100%;
    height: auto;
}

.article-content figcaption {
    font-size: 0.85rem;
    color: #666;
    font-style: italic;
    margin-top: 0.75rem;
    line-height: 1.4;
}

/* Sidenotes */
.sidenote {
    font-size: 0.85rem;
    line-height: 1.5;
    color: var(--sidenote-color);
    transition: background-color 0.2s;
    padding: 0.5rem;
    border-radius: 3px;
}

.sidenote:hover,
.sidenote.highlight {
    background-color: rgba(0, 0, 0, 0.05);
}

.sidenote-ref {
    font-size: 0.8em;
    vertical-align: super;
    color: var(--link-color);
    cursor: pointer;
    margin-left: -0.2em;
    margin-right: 0.1em;
    transition: background-color 0.2s;
    padding: 0.1em 0.3em;
    border-radius: 2px;
}

.sidenote-ref:hover,
.sidenote-ref.highlight {
    background-color: rgba(0, 102, 204, 0.15);
}

/* Desktop: Sidenotes in right margin */
@media (min-width: 1200px) {
    .sidenote {
        position: absolute;
        right: calc(-1 * var(--sidenote-width) - 2rem);
        width: var(--sidenote-width);
        margin-top: -0.5rem;
    }
}

/* Mobile/Tablet: Sidenotes inline */
@media (max-width: 1199px) {
    .toc {
        display: none;
    }

    .sidenote {
        display: block;
        margin: 2rem 0;
        padding: 0.75rem 0 0.75rem 1rem;
        border-left: 3px solid var(--border-color);
        background: var(--bg-subtle);
    }

    /* For sidenotes in tables on mobile: hide them */
    table .sidenote-wrapper .sidenote {
        display: none !important;
    }

    /* Style for table footnotes container */
    .table-footnotes {
        margin: 1rem 0 2rem 0;
        padding: 0.75rem 0 0.75rem 1rem;
        border-left: 3px solid var(--border-color);
        background: var(--bg-subtle);
        font-size: 0.85rem;
        line-height: 1.5;
        color: var(--sidenote-color);
    }

    .table-footnotes p {
        margin: 0.5rem 0;
    }

    .table-footnotes p:first-child {
        margin-top: 0;
    }

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

/* List/Home Pages */
.list-container,
.home {
    max-width: var(--max-content-width);
    margin: 0 auto;
}

.home header {
    margin-bottom: 3rem;
    text-align: center;
}

.home h1 {
    font-family: var(--heading-font);
}

.site-description {
    font-size: 1.2rem;
    color: #666;
    margin-top: 1rem;
}

.post-item {
    margin: 2rem 0;
    padding-bottom: 2rem;
    border-bottom: 1px solid var(--border-color);
}

.post-item:last-child {
    border-bottom: none;
}

.post-item h2,
.post-item h3 {
    font-family: var(--heading-font);
    margin-bottom: 0.5rem;
}

.post-item h2 a,
.post-item h3 a {
    color: var(--text-color);
    text-decoration: none;
}

.post-item h2 a:hover,
.post-item h3 a:hover {
    color: var(--link-color);
}

.post-item time {
    font-size: 0.9rem;
    color: #888;
}

.summary {
    margin-top: 0.75rem;
    color: #666;
}

/* Lists - prevent jutting out */
.article-content ul,
.article-content ol {
    margin: 1rem 0;
    padding-left: 1.5rem;
}

.article-content li {
    margin: 0.4rem 0;
}

/* Nested lists */
.article-content li ul,
.article-content li ol {
    margin-top: 0.4rem;
    margin-bottom: 0.4rem;
}

/* Table wrapper for scroll */
.table-scroll {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin: 1.5rem 0;
    max-width: 100%;
}

/* Tables */
.article-content table {
    border-collapse: separate;
    border-spacing: 0;
    font-size: 0.95em;
    border: 1px solid var(--border-color);
    width: max-content;
    min-width: 100%;
    display: table;
}

/* Direct tables without wrapper - wrap them automatically */
.article-content > table {
    display: inline-block;
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    vertical-align: top;
    margin: 1.5rem 0;
}

/* Prevent tables from expanding page width */
.article-content {
    max-width: 100%;
    overflow-x: clip;
}

@media (max-width: 768px) {
    .article-content table {
        white-space: nowrap;
    }

    .article-content th,
    .article-content td {
        white-space: nowrap;
        min-width: 120px;
    }
}

.article-content thead {
    background: var(--bg-subtle);
}

.article-content th {
    padding: 0.5rem 0.75rem;
    text-align: left;
    font-weight: 600;
    border-right: 1px solid var(--border-color);
    border-bottom: 2px solid var(--border-color);
}

.article-content th:last-child {
    border-right: none;
}

.article-content td {
    padding: 0.4rem 0.75rem;
    border-bottom: 1px solid var(--border-color);
    border-right: 1px solid var(--border-color);
}

.article-content td:last-child {
    border-right: none;
}

/* Zebra striping - using td for Safari compatibility */
.article-content tbody tr:nth-child(even) td {
    background: rgba(0, 0, 0, 0.015);
}

.article-content tbody tr:hover td {
    background: rgba(0, 0, 0, 0.04);
}

.article-content tbody tr:last-child td {
    border-bottom: none;
}

/* Hide TOC on medium screens */
@media (max-width: 1400px) {
    .toc {
        left: 1rem;
        font-size: 0.8em;
    }
}

@media (max-width: 1200px) {
    .container {
        padding: 1rem;
    }
}