/* Style for technical posts built from Markdown by build_technical.py.
   Always light, because the figures have light backgrounds. */

:root {
    color-scheme: light;
    --page: #fff;
    --ink: #193649;
    --muted: #657985;
    --toc: #6e7d86;
    --teal: #0c7f82;
    --line: #dce3df;
    --band: #f0f3ee;
    --mono: 'Geist Mono', ui-monospace, SFMono-Regular, Menlo, monospace;

    /* Read by the shared site header */
    --background: var(--page);
    --border-background-color: var(--line);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    background: var(--page);
    color: var(--ink);
    font-family: 'Helvetica Neue', Helvetica, 'Segoe UI', Arial, freesans, sans-serif;
    font-size: 16px;
    line-height: 1.65;
    letter-spacing: 0.003em;
    -webkit-font-smoothing: antialiased;
}

/* Layout: text centered on the page, contents in the left margin */
.post-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 644px) minmax(0, 1fr);
    padding: 0 28px;
}

.post-layout > article {
    grid-column: 2;
    grid-row: 1;
    min-width: 0;
    padding: 52px 0 90px;
}

.toc {
    grid-column: 1;
    grid-row: 1;
    justify-self: end;
    width: 190px;
    margin-right: 96px;
}

.toc nav {
    position: sticky;
    top: 110px;
    max-height: calc(100vh - 130px);
    overflow-y: auto;
    margin-top: 62px;
    margin-left: -14px;  /* room for the dot without moving the text */
    padding-left: 14px;
}

/* Slides down and fades out while scrolling down; back on scroll up */
.toc nav {
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.toc nav.toc-away {
    opacity: 0;
    transform: translateY(24px);
    pointer-events: none;
}

/* Small dot beside the current section; it glides between sections */
.toc ul {
    position: relative;
}

.toc-dot {
    position: absolute;
    top: 0;
    left: -12px;
    width: 5px;
    height: 5px;
    background: #111;
    border-radius: 50%;
    transition: transform 0.3s cubic-bezier(0.22, 1, 0.36, 1);
}

.toc-title {
    margin-bottom: 12px;
    color: var(--toc);
    font: 500 11px/1.4 var(--mono);
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

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

.toc a,
.toc-inline a {
    display: block;
    padding: 3px 0;
    color: var(--toc);
    font-size: 12.5px;
    line-height: 1.4;
    text-decoration: none;
    transition: color 0.2s;
}

.toc a.toc-sub,
.toc-inline a.toc-sub {
    padding-left: 12px;
    font-size: 12px;
}

.toc a:hover,
.toc a.active,
.toc-inline a:hover {
    color: var(--ink);
}

/* Collapsible contents under the title, shown when there's no room for the sidebar */
.toc-inline {
    display: none;
    margin: 0 0 32px;
    padding: 10px 14px;
    border: 1px solid var(--line);
    border-radius: 6px;
}

.toc-inline summary {
    color: var(--toc);
    font: 500 11px/1.6 var(--mono);
    letter-spacing: 0.08em;
    text-transform: uppercase;
    list-style: none;
    cursor: pointer;
}

.toc-inline summary::-webkit-details-marker {
    display: none;
}

.toc-inline summary::after {
    content: '+';
    float: right;
    font-size: 14px;
    line-height: 1.2;
}

.toc-inline[open] summary::after {
    content: '−';
}

.toc-inline ul {
    margin: 8px 0 2px;
    padding: 0;
    list-style: none;
}

.toc-inline li {
    margin: 0;
    padding: 0;
}

/* Header */
.post-header h1 {
    margin: 10px 0 18px;
    font-size: 38px;
    font-weight: 500;
    line-height: 1.1;
    letter-spacing: -0.01em;
}

.post-subtitle {
    margin: 0 0 14px;
    color: var(--muted);
    font-style: italic;
}

.post-meta {
    margin-bottom: 28px;
    color: var(--muted);
    font: 12px/1.5 var(--mono);
}

/* Text */
article a {
    color: var(--teal);
    text-underline-offset: 4px;
}

article a:hover {
    color: #095b5d;
}

article h2,
article h3 {
    font-weight: 500;
    line-height: 1.25;
    letter-spacing: -0.017em;
    scroll-margin-top: 100px;
}

article h2 {
    margin: 48px 0 14px;
    font-size: 23px;
}

article h3 {
    margin: 28px 0 8px;
    font-size: 17px;
}

article p {
    margin: 0 0 16px;
}

article strong {
    font-weight: 500;
}

article ul,
article ol {
    padding-left: 26px;
}

article li {
    margin-bottom: 6px;
    padding-left: 3px;
}

article li::marker {
    color: var(--muted);
}

article hr {
    margin: 44px 0;
    border: 0;
    border-top: 1px solid var(--line);
}

/* Figures. .card images get extra padding. */
.figure {
    margin: 32px 0;
}

.figure img {
    display: block;
    width: 100%;
    height: auto;
    margin: 0 auto;
    border-radius: 5px;
}

.figure.card img {
    padding: 14px;
    background: #fff;
}

.figure.small img {
    max-width: 440px;
}

.figure.medium img {
    max-width: 560px;
}

.figure figcaption {
    margin-top: 10px;
    color: var(--muted);
    font-size: 13.5px;
    font-style: italic;
    line-height: 1.55;
}

/* Plots are wider than the text when there is room */
@media (min-width: 1280px) {
    .figure:not(.card) {
        margin-right: -70px;
        margin-left: -70px;
    }

    .figure:not(.card) figcaption {
        padding: 0 70px;
    }
}

/* Math */
article .katex {
    font-size: 1.05em;
}

.math-display {
    margin: 20px 0;
    overflow-x: auto;
    overflow-y: hidden;
}

.math-display .katex-display {
    margin: 0;
}

/* Code */
code {
    font-family: var(--mono);
    font-size: 0.84em;
}

:not(pre) > code {
    padding: 0.12em 0.35em;
    background: var(--band);
    border-radius: 4px;
}

pre {
    padding: 22px;
    overflow-x: auto;
    background: var(--ink);
    color: #eef4ee;
    border-radius: 5px;
    font-size: 13.5px;
    line-height: 1.6;
    tab-size: 4;
}

pre code {
    font-size: inherit;
}

/* Syntax highlighting on the dark code background */
.token.comment,
.token.prolog {
    color: #8ea5ae;
    font-style: italic;
}

.token.keyword,
.token.operator.keyword {
    color: #f3a68f;
}

.token.string,
.token.char {
    color: #b8dba0;
}

.token.number,
.token.boolean,
.token.constant {
    color: #f2cb7e;
}

.token.function {
    color: #8fd6d2;
}

.token.builtin,
.token.class-name {
    color: #aebcf2;
}

.token.decorator,
.token.annotation {
    color: #d3aef2;
}

.token.operator,
.token.punctuation {
    color: #c9d6cf;
}

/* Tables */
.table-wrap {
    margin: 30px 0;
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13.5px;
    line-height: 1.6;
    font-variant-numeric: tabular-nums;
}

th {
    color: var(--muted);
    font: 500 12px var(--mono);
    text-align: left;
}

th,
td {
    padding: 11px 12px;
    border-bottom: 1px solid var(--line);
}

th:first-child,
td:first-child {
    padding-left: 0;
}

/* Callout box, e.g. the link to the interactive demo */
.cta {
    margin: 32px 0;
    padding: 18px 22px;
    background: #eff5ef;
    border: 1px solid #b9d8d1;
    border-radius: 5px;
}

.cta a {
    font-weight: 500;
}

.post-footer {
    display: flex;
    gap: 22px;
    margin-top: 65px;
    padding-top: 22px;
    border-top: 1px solid var(--line);
    font-size: 13px;
}

/* Medium screens: tighter margin for the contents */
@media (max-width: 1279px) {
    .toc {
        width: 170px;
        margin-right: 36px;
    }
}

/* Small screens: one column, no contents sidebar */
@media (max-width: 1099px) {
    .post-layout {
        display: block;
        max-width: 700px;
        margin: 0 auto;
    }

    .toc {
        display: none;
    }

    .toc-inline {
        display: block;
    }
}

@media (max-width: 600px) {
    body {
        font-size: 15px;
    }

    .post-layout {
        padding: 0 20px;
    }

    .post-layout > article {
        padding-top: 34px;
    }

    .post-header h1 {
        font-size: 30px;
    }

    article h2 {
        margin-top: 40px;
        font-size: 21px;
    }

    th,
    td {
        padding: 12px 8px;
        font-size: 12px;
    }
}
