/* 2read article page: rules shared by every style.
   style.css in a saved article is this file followed by one style file,
   which sets the variables below and adds its own touches.
   Everything is scoped to classes the page template owns. The sanitizer
   strips class attributes from article content, so nothing an article
   contains can pick up the page's own layout rules. */

:root {
    color-scheme: light dark;
    --paper: #fff;
    --ink: #20242b;
    --soft: #667080;
    --rule: #dcdfe4;
    --wash: #f1f2f3;
    --line: #b98f00;
    /* The 2read yellow. Used like a highlighter pen: link hover, selection, <mark>. */
    --mark: #ffe14a;
    --mark-ink: #1f2530;
    --picture: transparent;
    --body-font: serif;
    --head-font: var(--body-font);
    --mono-font: ui-monospace, "Cascadia Mono", "SF Mono", Menlo, Consolas, "DejaVu Sans Mono", monospace;
    --size: 1.0625rem;
    --leading: 1.6;
    --measure: 34em;
    --gap: 1.1em;
    --side: clamp(1.1rem, 5vw, 2.5rem);
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }

body {
    margin: 0;
    background: var(--paper);
    color: var(--ink);
    font: var(--size)/var(--leading) var(--body-font);
    overflow-wrap: break-word;
}

::selection { background: var(--mark); color: var(--mark-ink); }

.page, .foot {
    max-width: calc(var(--measure) + 2 * var(--side));
    margin: 0 auto;
    padding: 0 var(--side);
}
.page { padding-top: clamp(1.75rem, 7vw, 5rem); }

/* Title block */

.head { margin-bottom: 2.2em; }
.title {
    margin: 0;
    font-family: var(--head-font);
    font-size: 2.2em;
    line-height: 1.12;
    text-wrap: balance;
}
.lede { margin: .9em 0 0; color: var(--soft); font-size: 1.12em; line-height: 1.45; }
.source {
    display: flex;
    flex-wrap: wrap;
    gap: .1em 1.4em;
    margin: 1.5em 0 0;
    padding-bottom: .8em;
    border-bottom: 1px solid var(--rule);
    color: var(--soft);
    font-size: .86em;
    line-height: 1.5;
}
.source .byline { color: var(--ink); }
.source time { margin-inline-start: auto; }

/* Links */

a {
    color: inherit;
    text-decoration: underline;
    text-decoration-color: var(--line);
    text-decoration-thickness: .075em;
    text-underline-offset: .2em;
    transition: background-color .12s;
}
a:visited { text-decoration-color: var(--rule); }
a:hover, a:focus-visible {
    background: var(--mark);
    color: var(--mark-ink);
    text-decoration-color: transparent;
}
a:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }

/* Article body */

.content > :first-child,
.content > div:first-child > :first-child,
.content > div:first-child > div:first-child > :first-child { margin-top: 0; }

.content p, .content ul, .content ol, .content dl, .content blockquote,
.content pre, .content table { margin: 0 0 var(--gap); }

.content h1, .content h2, .content h3, .content h4, .content h5, .content h6 {
    margin: 1.9em 0 .55em;
    font-family: var(--head-font);
    line-height: 1.2;
    text-wrap: balance;
}
.content h1, .content h2 { font-size: 1.5em; }
.content h3 { font-size: 1.2em; }
.content h4 { font-size: 1em; }
.content h5, .content h6 { font-size: .88em; color: var(--soft); }

.content img { max-width: 100%; height: auto; background: var(--picture); }
.content figure { margin: 1.7em 0; }
.content figure img { display: block; margin: 0 auto; }
.content figcaption { margin-top: .6em; color: var(--soft); font-size: .84em; line-height: 1.45; }

.content blockquote {
    margin-inline: 0;
    padding-inline-start: 1.1em;
    border-inline-start: 3px solid var(--line);
}
.content blockquote > :last-child { margin-bottom: 0; }

.content ul, .content ol { padding-inline-start: 1.4em; }
.content li { margin: .3em 0; }
.content li > ul, .content li > ol { margin-bottom: 0; }
.content dt { font-weight: 600; }
.content dd { margin: 0 0 .6em; margin-inline-start: 1.4em; }

.content pre, .content code, .content kbd, .content samp { font-family: var(--mono-font); font-size: .86em; }
.content pre {
    overflow-x: auto;
    padding: .9em 1.1em;
    background: var(--wash);
    line-height: 1.5;
    border-radius: 4px;
}
.content pre code { font-size: 1em; }
.content :not(pre) > code, .content kbd { padding: .1em .35em; background: var(--wash); border-radius: 3px; }

/* Wide tables scroll inside themselves instead of stretching the page. */
.content table {
    display: block;
    width: max-content;
    max-width: 100%;
    overflow-x: auto;
    border-collapse: collapse;
    font-size: .88em;
    line-height: 1.4;
    font-variant-numeric: tabular-nums;
}
.content th, .content td {
    padding: .45em .8em;
    border-bottom: 1px solid var(--rule);
    text-align: start;
    vertical-align: top;
}
.content th { font-weight: 600; }
.content caption { padding-bottom: .5em; text-align: start; font-weight: 600; }

/* Formulas. The browser draws MathML itself, in the colour of the text. */
.content math { font-variant-numeric: normal; letter-spacing: normal; hyphens: none; }
/* The server puts every display formula into a .formula box, so that a
   formula wider than the screen scrolls there instead of widening the page. */
.content .formula { display: block; margin: 1.1em 0; padding: .25em 0; overflow-x: auto; overflow-y: hidden; }

.content hr { margin: 2.2em 0; border: 0; border-top: 1px solid var(--rule); }
.content sup, .content sub { font-size: .72em; line-height: 0; }
.content mark { background: var(--mark); color: var(--mark-ink); }
.content abbr[title] { text-decoration: underline dotted; }
.content summary { cursor: pointer; }

/* Footer */

.foot { margin-top: 3.5em; padding-bottom: 3em; }
.foot p { margin: 0; padding-top: .9em; border-top: 1px solid var(--rule); color: var(--soft); font-size: .8em; }
.foot .ours { background: var(--mark); color: var(--mark-ink); padding: .1em .35em; text-decoration: none; }

@media (prefers-reduced-motion: reduce) {
    a { transition: none; }
}

@media print {
    :root { --paper: #fff; --ink: #000; --soft: #444; --rule: #bbb; --wash: #f2f2f2; --picture: transparent; }
    .page { padding-top: 0; }
    .foot { display: none; }
}
