@charset "UTF-8";

/* ── Layout (derived from Tufte CSS) ─────────────────────────────── */

body {
    width: 87.5%;
    margin-left: auto;
    margin-right: auto;
    padding-left: 12.5%;
    max-width: 1400px;
    counter-reset: sidenote-counter;
}

article {
    padding: 3rem 0;
}

section {
    padding-top: 1rem;
    padding-bottom: 1rem;
}

section > p,
section > footer,
section > table,
section > blockquote {
    width: 55%;
}

section > dl,
section > ol,
section > ul {
    width: 50%;
    -webkit-padding-start: 5%;
}

section > pre,
section > div > pre,
section > .sourceCode {
    width: 52.5%;
    box-sizing: border-box;
}

hr {
    display: block;
    height: 1px;
    width: 55%;
    border: 0;
    border-top: 1px solid #ccc;
    margin: 1em 0;
    padding: 0;
}

figure {
    padding: 0;
    border: 0;
    font: inherit;
    vertical-align: baseline;
    max-width: 55%;
    -webkit-margin-start: 0;
    -webkit-margin-end: 0;
    margin: 0 0 3em 0;
}

figcaption {
    float: right;
    clear: right;
    margin-top: 0;
    margin-bottom: 0;
    font-size: 0.85rem;
    line-height: 1.6;
    vertical-align: baseline;
    position: relative;
    max-width: 40%;
}

/* ── Typography ──────────────────────────────────────────────────── */

html {
    font-size: 16px;
}

body {
    font-family: "Literata", Georgia, "Times New Roman", serif;
    background-color: #fff;
    color: #1a1a1a;
    line-height: 1.7;
}

p, dl, ol, ul, blockquote {
    font-size: 1rem;
    line-height: 1.7;
}

h1, h2, h3, h4, h5, h6 {
    font-style: normal;
    font-weight: 600;
    letter-spacing: -0.01em;
    line-height: 1.2;
}

h1 {
    font-size: 2.4rem;
    margin-top: 3rem;
    margin-bottom: 1.5rem;
}

h2 {
    font-size: 1.6rem;
    margin-top: 2.4rem;
    margin-bottom: 1rem;
}

h3 {
    font-size: 1.3rem;
    margin-top: 2rem;
    margin-bottom: 0.8rem;
}

a {
    color: #1a6fb5;
    text-decoration: underline;
    text-decoration-thickness: 1px;
    text-underline-offset: 2px;
}

a:hover {
    color: #0d4f82;
}

dt:not(:first-child),
li:not(:first-child) {
    margin-top: 0.25rem;
}

/* ── Dark mode ───────────────────────────────────────────────────── */

@media (prefers-color-scheme: dark) {
    body {
        background-color: #1a1a1a;
        color: #e0e0e0;
    }

    a { color: #6cb4ee; }
    a:hover { color: #9ccdf5; }

    pre, code {
        background-color: #252525;
        border-color: #333;
    }

    hr { border-top-color: #333; }

    blockquote {
        border-left-color: #444;
        color: #aaa;
    }

    .post-date, nav a { color: #999; }
    nav a:hover { color: #e0e0e0; }
    .post-preview { border-bottom-color: #333; }
    .archive-group h3 { color: #bbb; }
    .sidenote, .marginnote { color: #999; }
    footer { border-top-color: #333; color: #888; }

    /* Dark mode syntax highlighting */
    code span.al { color: #ff6b6b; }
    code span.an { color: #87ceeb; }
    code span.at { color: #b5cea8; }
    code span.bn { color: #b5cea8; }
    code span.bu { color: #dcdcaa; }
    code span.cf { color: #c586c0; }
    code span.ch { color: #ce9178; }
    code span.cn { color: #d4d4d4; }
    code span.co { color: #6a9955; }
    code span.cv { color: #6a9955; }
    code span.do { color: #ce9178; }
    code span.dt { color: #4ec9b0; }
    code span.dv { color: #b5cea8; }
    code span.er { color: #ff6b6b; }
    code span.fl { color: #b5cea8; }
    code span.fu { color: #dcdcaa; }
    code span.im { color: #c586c0; }
    code span.in { color: #6a9955; }
    code span.kw { color: #569cd6; }
    code span.op { color: #d4d4d4; }
    code span.ot { color: #569cd6; }
    code span.pp { color: #c586c0; }
    code span.sc { color: #d7ba7d; }
    code span.ss { color: #ce9178; }
    code span.st { color: #ce9178; }
    code span.va { color: #9cdcfe; }
    code span.vs { color: #ce9178; }
    code span.wa { color: #d7ba7d; }
}

/* ── Site header & nav ───────────────────────────────────────────── */

.site-header {
    margin-bottom: 2rem;
}

.site-header h1 {
    margin-bottom: 0.3rem;
}

.site-header h1 a {
    color: inherit;
    text-decoration: none;
}

.site-header h1 a:hover {
    text-decoration: underline;
}

nav {
    display: flex;
    gap: 1.5rem;
    font-size: 0.9rem;
}

nav a {
    color: #666;
    text-decoration: none;
}

nav a:hover {
    color: #1a1a1a;
    text-decoration: underline;
}

/* ── Post page ───────────────────────────────────────────────────── */

.post-title {
    margin-bottom: 0.2rem;
}

.post-date {
    display: block;
    color: #666;
    font-size: 0.9rem;
    margin-bottom: 1.5rem;
}

/* ── Code blocks ─────────────────────────────────────────────────── */

pre, code {
    font-family: "JetBrains Mono", "Fira Code", "SF Mono", "Cascadia Code",
                 Menlo, Consolas, "Liberation Mono", monospace;
    font-size: 0.85em;
}

code {
    background: #f4f4f8;
    padding: 0.15em 0.35em;
    border-radius: 3px;
}

pre {
    background: #f4f4f8;
    padding: 1em 1.2em;
    border-radius: 4px;
    overflow-x: auto;
    line-height: 1.5;
    border: 1px solid #e0e0e5;
}

pre code {
    background: none;
    padding: 0;
    border-radius: 0;
    font-size: inherit;
}

h1 > code, h2 > code, h3 > code {
    font-size: 0.8em;
}

/* Pandoc sourceCode wrapper */
div.sourceCode {
    margin: 1em 0;
}

pre.sourceCode {
    margin: 0;
}

pre > code.sourceCode {
    white-space: pre;
    position: relative;
}

pre > code.sourceCode > span {
    line-height: 1.25;
}

pre > code.sourceCode > span:empty {
    height: 1.2em;
}

code.sourceCode > span {
    color: inherit;
    text-decoration: inherit;
}

/* Syntax highlighting — pygments theme */
code span.al { color: #ff0000; font-weight: bold; } /* Alert */
code span.an { color: #60a0b0; font-weight: bold; font-style: italic; } /* Annotation */
code span.at { color: #7d9029; } /* Attribute */
code span.bn { color: #40a070; } /* BaseN */
code span.bu { color: #008000; } /* BuiltIn */
code span.cf { color: #007020; font-weight: bold; } /* ControlFlow */
code span.ch { color: #4070a0; } /* Char */
code span.cn { color: #880000; } /* Constant */
code span.co { color: #60a0b0; font-style: italic; } /* Comment */
code span.cv { color: #60a0b0; font-weight: bold; font-style: italic; } /* CommentVar */
code span.do { color: #ba2121; font-style: italic; } /* Documentation */
code span.dt { color: #902000; } /* DataType */
code span.dv { color: #40a070; } /* DecVal */
code span.er { color: #ff0000; font-weight: bold; } /* Error */
code span.fl { color: #40a070; } /* Float */
code span.fu { color: #06287e; } /* Function */
code span.im { color: #008000; font-weight: bold; } /* Import */
code span.in { color: #60a0b0; font-weight: bold; font-style: italic; } /* Information */
code span.kw { color: #007020; font-weight: bold; } /* Keyword */
code span.op { color: #666666; } /* Operator */
code span.ot { color: #007020; } /* Other */
code span.pp { color: #bc7a00; } /* Preprocessor */
code span.sc { color: #4070a0; } /* SpecialChar */
code span.ss { color: #bb6688; } /* SpecialString */
code span.st { color: #4070a0; } /* String */
code span.va { color: #19177c; } /* Variable */
code span.vs { color: #4070a0; } /* VerbatimString */
code span.wa { color: #60a0b0; font-weight: bold; font-style: italic; } /* Warning */

/* ── Blockquotes ─────────────────────────────────────────────────── */

blockquote {
    border-left: 3px solid #ddd;
    padding-left: 1em;
    margin-left: 0;
    color: #444;
}

blockquote p {
    width: 100%;
}

/* ── Sidenotes ───────────────────────────────────────────────────── */

/* Inline superscript number in body text */
.sidenote-number {
    counter-increment: sidenote-counter;
}

.sidenote-number:after {
    content: counter(sidenote-counter);
    font-size: 0.75rem;
    position: relative;
    top: -0.4rem;
    left: 0.1rem;
}

input.margin-toggle {
    display: none;
}

label.sidenote-number {
    display: inline-block;
}

/* Sidenote block in the margin */
aside.sidenote {
    float: right;
    clear: right;
    width: 35%;
    margin-right: 5%;
    margin-top: 0;
    margin-bottom: 1rem;
    font-size: 0.8rem;
    line-height: 1.4;
    position: relative;
    color: #555;
}

aside.sidenote p {
    margin: 0.4em 0;
}

aside.sidenote p:first-of-type {
    display: inline;
}

.sidenote-number-label {
    font-size: 0.7rem;
    vertical-align: super;
    margin-right: 0.2em;
}

/* Mobile: hide sidenotes, show on toggle */
label.margin-toggle:not(.sidenote-number) {
    display: none;
}

/* ── Index post previews ─────────────────────────────────────────── */

.post-preview {
    margin-bottom: 3rem;
    padding-bottom: 2rem;
    border-bottom: 1px solid #e0e0e5;
}

.post-preview h2 {
    margin-bottom: 0.2rem;
}

.archive-link {
    font-size: 0.95rem;
}

/* ── Archive ─────────────────────────────────────────────────────── */

.archive-group {
    margin-bottom: 0.8rem;
}

.archive-group h3 {
    margin-top: 0.8rem;
    margin-bottom: 0.2rem;
    font-size: 1.1rem;
    color: #444;
    font-weight: 600;
}

.post-archive {
    list-style: none;
    padding: 0;
    margin-top: 0.3rem;
}

.post-archive li {
    margin-bottom: 0.35rem;
    font-size: 0.95rem;
}

/* ── Comments section ────────────────────────────────────────────── */

#the-post hr {
    margin-top: 3rem;
}

/* ── Footer ──────────────────────────────────────────────────────── */

footer {
    margin-top: 3rem;
    padding-top: 1rem;
    border-top: 1px solid #e0e0e5;
    color: #888;
    font-size: 0.8rem;
}

/* ── Images ──────────────────────────────────────────────────────── */

img {
    display: block;
    max-width: 100%;
    height: auto;
    border-radius: 3px;
    margin-left: auto;
    margin-right: auto;
}

/* ── Responsive ──────────────────────────────────────────────────── */

@media (max-width: 760px) {
    body {
        width: 84%;
        padding-left: 8%;
        padding-right: 8%;
    }

    hr,
    section > p,
    section > footer,
    section > table,
    section > blockquote,
    section > pre {
        width: 100%;
    }

    section > dl,
    section > ol,
    section > ul {
        width: 90%;
    }

    figure {
        max-width: 90%;
    }

    figcaption,
    figure.fullwidth figcaption {
        margin-right: 0%;
        max-width: none;
    }

    blockquote {
        margin-left: 1.5em;
        margin-right: 0em;
        width: auto;
    }

    aside.sidenote {
        display: none;
        float: none;
        margin-right: 0;
        width: 95%;
        margin: 1rem 2.5%;
    }

    label {
        cursor: pointer;
    }

    img {
        width: 100%;
    }
}
