@charset "UTF-8";

/* ==========================================================================
   Tufte CSS — adapted for EB Garamond + JetBrains Mono
   Based on: https://github.com/edwardtufte/tufte-css (Dave Liepmann)
   ========================================================================== */

/* Tufte CSS styles */
html {
    font-size: 15px;
}

body {
    width: 87.5%;
    margin-left: auto;
    margin-right: auto;
    padding-left: 12.5%;
    font-family: "EB Garamond", Palatino, "Palatino Linotype",
        "Palatino LT STD", "Book Antiqua", Georgia, serif;
    background-color: #fffff8;
    color: #111;
    max-width: 1400px;
    counter-reset: sidenote-counter;
}

/* Dark mode */
@media (prefers-color-scheme: dark) {
    body {
        background-color: #151515;
        color: #ddd;
    }

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

    code {
        background-color: #303030 !important;
        color: #e0e0e0;
    }

    pre > code,
    .highlight pre.chroma code {
        background-color: transparent !important;
    }
}

/* ---------- Headings ---------- */

h1 {
    font-weight: 400;
    margin-top: 4rem;
    margin-bottom: 1.5rem;
    font-size: 3.2rem;
    line-height: 1;
}

h2 {
    font-style: italic;
    font-weight: 400;
    margin-top: 2.1rem;
    margin-bottom: 1.4rem;
    font-size: 2.2rem;
    line-height: 1;
}

h3 {
    font-style: italic;
    font-weight: 400;
    font-size: 1.7rem;
    margin-top: 2rem;
    margin-bottom: 1.4rem;
    line-height: 1;
}

/* ---------- Body text ---------- */

p,
dl,
ol,
ul {
    font-size: 1.4rem;
    line-height: 2rem;
}

p {
    margin-top: 1.4rem;
    margin-bottom: 1.4rem;
    padding-right: 0;
    vertical-align: baseline;
}

article {
    padding: 5rem 0;
}

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

/* ---------- Horizontal rule ---------- */

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

/* ---------- Subtitle ---------- */

p.subtitle {
    font-style: italic;
    margin-top: 1rem;
    margin-bottom: 1rem;
    font-size: 1.8rem;
    display: block;
    line-height: 1;
}

/* ---------- Epigraphs ---------- */

div.epigraph {
    margin: 5em 0;
}

div.epigraph > blockquote {
    margin-top: 3em;
    margin-bottom: 3em;
}

div.epigraph > blockquote,
div.epigraph > blockquote > p {
    font-style: italic;
}

div.epigraph > blockquote > footer {
    font-style: normal;
}

div.epigraph > blockquote > footer > cite {
    font-style: italic;
}

/* ---------- Blockquotes ---------- */

blockquote {
    font-size: 1.4rem;
}

blockquote p {
    width: 55%;
    margin-right: 40px;
}

blockquote footer {
    width: 55%;
    font-size: 1.1rem;
    text-align: right;
}

/* ---------- Width constraints ---------- */

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

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

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

/* ---------- Figures ---------- */

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

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

figure.fullwidth figcaption {
    margin-right: 24%;
}

/* ---------- Links ---------- */

a:link,
a:visited {
    color: inherit;
    text-underline-offset: 0.15em;
    text-decoration-thickness: 0.05em;
}

a:hover {
    text-decoration-thickness: 0.1em;
}

/* ---------- Images ---------- */

img {
    max-width: 100%;
}

/* ---------- Sidenotes & margin notes ---------- */

.sidenote,
.marginnote {
    float: right;
    clear: right;
    margin-right: -60%;
    width: 50%;
    margin-top: 0.3rem;
    margin-bottom: 0;
    font-size: 1.1rem;
    line-height: 1.3;
    vertical-align: baseline;
    position: relative;
}

.sidenote-number {
    counter-increment: sidenote-counter;
}

.sidenote-number::after,
.sidenote::before {
    position: relative;
    vertical-align: baseline;
}

.sidenote-number::after {
    content: counter(sidenote-counter);
    font-size: 1rem;
    top: -0.5rem;
    left: 0.1rem;
}

.sidenote::before {
    content: counter(sidenote-counter) " ";
    font-size: 1rem;
    top: -0.5rem;
}

blockquote .sidenote,
blockquote .marginnote {
    margin-right: -82%;
    min-width: 59%;
    text-align: left;
}

/* ---------- Full-width elements ---------- */

div.fullwidth,
table.fullwidth {
    width: 100%;
}

.fullwidth {
    max-width: 90%;
    clear: both;
}

/* ---------- Tables ---------- */

div.table-wrapper {
    overflow-x: auto;
}

/* ---------- Code ---------- */

code,
pre > code {
    font-family: "JetBrains Mono", Consolas, "Liberation Mono", Menlo, Courier,
        monospace;
    font-size: 1rem;
    line-height: 1.42;
    text-size-adjust: 100%;
}

code {
    background-color: #e8e8e0;
    padding: 0.1em 0.3em;
    border-radius: 3px;
}

pre > code {
    font-size: 0.9rem;
    width: 52.5%;
    margin-left: 2.5%;
    overflow-x: auto;
    display: block;
    background-color: transparent;
    padding: 1em;
    border-radius: 0;
}

/* Chroma syntax highlighting wrapper */
.highlight pre.chroma {
    width: 52.5%;
    margin-left: 2.5%;
    padding: 1em;
    overflow-x: auto;
}

.highlight pre.chroma code {
    background-color: transparent;
    padding: 0;
    border-radius: 0;
}

pre.fullwidth > code {
    width: 90%;
}

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

.marginnote > code,
.sidenote > code {
    font-size: 1rem;
}

/* ---------- New thought (small-caps opener) ---------- */

span.newthought {
    font-variant: small-caps;
    font-size: 1.2em;
}

/* ---------- Sidenote toggle (mobile) ---------- */

input.margin-toggle {
    display: none;
}

label.sidenote-number {
    display: inline-block;
    max-height: 2rem;
}

label.margin-toggle:not(.sidenote-number) {
    display: none;
}

/* ---------- Iframe wrapper ---------- */

.iframe-wrapper {
    position: relative;
    padding-bottom: 56.25%;
    padding-top: 25px;
    height: 0;
}

.iframe-wrapper iframe {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

/* ---------- Site header / nav ---------- */

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

header.site-header nav {
    display: flex;
    align-items: baseline;
    gap: 1.5rem;
    flex-wrap: wrap;
}

header.site-header .site-name {
    font-size: 1.6rem;
    font-variant: small-caps;
    text-decoration: none;
    letter-spacing: 0.05em;
}

header.site-header .nav-links {
    display: flex;
    gap: 1.2rem;
    font-size: 1.1rem;
}

header.site-header .nav-links a {
    text-decoration: none;
    opacity: 0.7;
}

header.site-header .nav-links a:hover {
    opacity: 1;
    text-decoration: underline;
    text-decoration-thickness: 0.05em;
    text-underline-offset: 0.15em;
}

/* ---------- Post list ---------- */

.post-list {
    list-style: none;
    padding: 0;
}

.post-list li {
    margin-bottom: 1.2rem;
}

.post-list .post-date {
    font-size: 1rem;
    opacity: 0.6;
    font-variant-numeric: tabular-nums;
    margin-right: 0.8rem;
}

.post-list .post-title {
    font-size: 1.3rem;
}

/* ---------- Home header with avatar ---------- */

.home-header {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.home-header h1 {
    margin-top: 0;
}

.home-avatar {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    opacity: 0.85;
    flex-shrink: 0;
}

/* ---------- Post metadata ---------- */

.post-meta {
    font-size: 1.1rem;
    opacity: 0.6;
    margin-top: -1rem;
    margin-bottom: 2rem;
}

/* ---------- KaTeX display math ---------- */

.katex-display {
    text-align: center;
    width: 55%;
    margin: 1.4rem 0;
}

/* ---------- Footer ---------- */

footer.site-footer {
    margin-top: 4rem;
    padding: 2rem 0;
    border-top: 1px solid #ccc;
    font-size: 1rem;
    opacity: 0.6;
}

@media (prefers-color-scheme: dark) {
    footer.site-footer {
        border-top-color: #444;
    }
}

/* ---------- Responsive ---------- */

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

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

    pre > code {
        width: 97%;
    }

    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: 0;
    }

    blockquote p,
    blockquote footer {
        width: 100%;
    }

    label.margin-toggle:not(.sidenote-number) {
        display: inline;
    }

    .sidenote,
    .marginnote {
        display: none;
    }

    .margin-toggle:checked + .sidenote,
    .margin-toggle:checked + .marginnote {
        display: block;
        float: left;
        left: 1rem;
        clear: both;
        width: 95%;
        margin: 1rem 2.5%;
        vertical-align: baseline;
        position: relative;
    }

    label {
        cursor: pointer;
    }

    div.table-wrapper,
    table {
        width: 85%;
    }

    img {
        width: 100%;
    }
}
