/* Paper pages: long-form reading on screen, and the layout of the PDF
   that the browser's print function produces from the same page. */

@font-face {
    font-family: "IBM Plex Mono";
    src: url("../fonts/ibm-plex-mono-latin-400-normal.woff2") format("woff2");
    font-weight: 400;
    font-style: normal;
    font-display: swap;
}

:root {
    --mono: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}

html { scroll-padding-top: 1.5rem; }

@media (prefers-reduced-motion: no-preference) {
    html { scroll-behavior: smooth; }
}

/* ---------- Title block ---------- */

.article-head { padding-block: clamp(1.5rem, 5vw, 3.5rem) clamp(2rem, 5vw, 3.5rem); }

.article-head h1 {
    max-width: 19em;
    font-size: clamp(2.1rem, 5.2vw, 3.6rem);
    font-weight: 800;
    line-height: 1.03;
    letter-spacing: -0.035em;
}

.article-head .author {
    margin-top: 1.6rem;
    font-size: 1.25rem;
    font-weight: 700;
}

.article-head .affil,
.article-head .date { color: var(--muted); }

.article-head .links { margin-top: 1.4rem; }

.print-only { display: none; }

/* ---------- Contents beside the text ---------- */

.article-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    row-gap: 2rem;
}

.toc h2 {
    margin-bottom: 0.6rem;
    font-size: 1.0625rem;
    font-weight: 800;
}

.toc ol {
    columns: 2 9rem;
    column-gap: 2rem;
    font-size: 0.9375rem;
    line-height: 1.35;
}

.toc li { padding-block: 0.22rem; break-inside: avoid; }

.toc a { color: var(--ink); text-decoration: none; }
.toc a:hover { color: var(--link); text-decoration: underline; }

@media (min-width: 68rem) {
    .article-layout {
        grid-template-columns: var(--label) minmax(0, 43rem);
        column-gap: clamp(2rem, 5vw, 4.5rem);
    }

    .toc {
        position: sticky;
        top: 1.5rem;
        align-self: start;
        max-height: calc(100vh - 3rem);
        overflow-y: auto;
    }

    .toc ol { columns: auto; }
}

/* ---------- Text ---------- */

.prose {
    max-width: 43rem;
    font-family: var(--serif);
    font-size: 1.1875rem;
    line-height: 1.6;
    overflow-wrap: break-word;
}

.prose p { margin: 0 0 1.05em; }

.prose h2,
.prose h3 {
    font-family: var(--sans);
    line-height: 1.2;
}

.prose h2 {
    margin: 2.5em 0 0.7em;
    font-size: 1.625rem;
    font-weight: 800;
    letter-spacing: -0.025em;
}

.prose h3 {
    margin: 2em 0 0.55em;
    font-size: 1.1875rem;
    font-weight: 700;
    letter-spacing: -0.01em;
}

.prose strong { font-weight: 700; }

.prose ul,
.prose ol {
    margin: 0 0 1.05em;
    padding-left: 1.5em;
}

.prose ul { list-style: disc; }
.prose ol { list-style: decimal; }
.prose li + li { margin-top: 0.4em; }
.prose li > p { margin: 0; }

.prose code {
    padding: 0.1em 0.3em;
    background: var(--panel);
    font-family: var(--mono);
    font-size: 0.82em;
}

.prose pre {
    margin: 1.4em 0;
    padding: 1rem 1.2rem;
    overflow-x: auto;
    background: var(--panel);
    font-size: 0.875rem;
    line-height: 1.55;
}

.prose pre code {
    padding: 0;
    background: none;
    font-size: inherit;
}

.abstract { margin-bottom: 0.5rem; }

.prose .abstract h2 {
    margin: 0 0 0.6rem;
    font-size: 1.0625rem;
    letter-spacing: 0;
}

/* Tables: rules above and below, none between columns. */

.table-wrap {
    margin: 1.5em 0 1.7em;
    overflow-x: auto;
}

.prose table {
    width: 100%;
    border-collapse: collapse;
    border-top: 2px solid var(--ink);
    border-bottom: 2px solid var(--ink);
    font-family: var(--sans);
    font-size: 0.9375rem;
    line-height: 1.45;
}

.prose table.wide { min-width: 34rem; }

.prose th,
.prose td {
    padding: 0.55rem 1.1rem 0.55rem 0;
    text-align: left;
    vertical-align: top;
}

.prose th:last-child,
.prose td:last-child { padding-right: 0; }

.prose th {
    border-bottom: 1px solid var(--ink);
    font-weight: 700;
    vertical-align: bottom;
}

.prose tbody tr + tr td { border-top: 1px solid var(--rule); }

/* Figures */

.prose figure { margin: 1.9em 0; }

.fig-scroll { overflow-x: auto; }

/* Blocks that scroll sideways on a narrow screen can take the focus. */
.fig-scroll:focus-visible,
.table-wrap:focus-visible,
.prose pre:focus-visible {
    outline: 3px solid var(--ink);
    outline-offset: 2px;
}

.fig {
    display: block;
    width: 100%;
    min-width: 36rem;
    height: auto;
    font-family: var(--sans);
}

.prose figure img { width: 100%; }

/* Several plots in one figure sit side by side, and stack on a phone. */
.fig-grid {
    display: grid;
    grid-template-columns: repeat(var(--cols, 2), minmax(0, 1fr));
    gap: 1rem;
}

.fig-grid-3 { --cols: 3; }
.fig-grid figcaption { grid-column: 1 / -1; }

@media (max-width: 40rem) {
    .fig-grid { grid-template-columns: minmax(0, 1fr); }
}

.prose figcaption {
    margin-top: 0.7rem;
    color: var(--muted);
    font-family: var(--sans);
    font-size: 0.9375rem;
    line-height: 1.45;
}

.prose figcaption em { font-style: normal; font-weight: 700; color: var(--ink); }

.f-ink { fill: var(--ink); }
.f-quiet { fill: var(--muted); }
.f-band { fill: var(--panel); }
.f-box { fill: var(--paper); stroke: var(--ink); stroke-width: 1.25; }
.f-main { stroke-width: 2.25; }
.f-ctl { fill: none; stroke: var(--ink); stroke-width: 1.25; stroke-dasharray: 5 4; }
.f-data { fill: none; stroke: var(--ink); stroke-width: 1.75; }
.f-life { stroke: var(--rule); stroke-width: 1.25; }
.f-msg { fill: none; stroke: var(--ink); stroke-width: 1.25; }
.f-msg-main { stroke-width: 2.25; }
.f-tip { fill: var(--ink); }
.f-tip-main { fill: var(--ink); }
.f-lbl { paint-order: stroke; stroke: var(--paper); stroke-width: 4; stroke-linejoin: round; }

/* References */

.refs { font-size: 1.0625rem; line-height: 1.5; }
.refs li + li { margin-top: 0.55em; }

/* ---------- Print: this is what the PDF is made from ---------- */

@page {
    size: A4;
    margin: 22mm 25mm 24mm;

    @bottom-center {
        content: counter(page);
        font-family: "Schibsted Grotesk", Helvetica, Arial, sans-serif;
        font-size: 9pt;
        color: #5c5c5c;
    }
}

@media print {
    html { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
    body { font-size: 10.5pt; }
    .wrap { max-width: none; padding: 0; }
    .bar, .toc, .article-head .links, .foot { display: none; }
    .print-only { display: block; }

    .article-head { padding-block: 0 1.4rem; }
    .article-head h1 { max-width: none; font-size: 25pt; }
    .article-head .author { margin-top: 1rem; font-size: 12pt; }

    .article-layout { display: block; }

    .prose {
        max-width: none;
        font-size: 10.8pt;
        line-height: 1.46;
    }

    /* Text keeps a readable measure; tables, figures and listings use
       the full width of the page. */
    .prose > p,
    .prose > ul,
    .prose > ol,
    .prose > h2,
    .prose > h3,
    .abstract { max-width: 134mm; }

    .prose > .refs { max-width: none; }

    .prose h2 { margin-top: 1.9em; font-size: 14.5pt; break-after: avoid; }
    .prose h3 { margin-top: 1.6em; font-size: 11.5pt; break-after: avoid; }
    .prose p { orphans: 3; widows: 3; }
    .prose pre { font-size: 8.6pt; break-inside: avoid; }
    .prose table { font-size: 8.8pt; }
    .prose figure, .prose tr, .abstract { break-inside: avoid; }
    .prose thead { display: table-header-group; }
    .table-wrap, .fig-scroll { overflow: visible; }
    .fig, .prose table.wide { min-width: 0; }
    .prose figcaption { font-size: 8.8pt; }
    .refs { font-size: 9.6pt; }

    .prose a { color: inherit; text-decoration: none; }

    /* A printed reference needs its address. */
    .refs a::after {
        content: " (" attr(href) ")";
        font-family: var(--sans);
        font-size: 8pt;
        color: var(--muted);
        overflow-wrap: anywhere;
    }
}
