/* Blog: the post index and long-form articles. Loaded after common.css only;
   support.css is left out, so `code`, `pre` and lists are styled here for
   reading rather than for the support cards.

   Posts are static English HTML rather than JSON rendered by a script: the
   text is in the first response, so the page paints at once, needs no
   opacity mask, and search engines read the article itself.

   The look is an editorial one: a white page, one charcoal for headings and
   prose alike, bold sans headings, plain list markers, and the brand rose kept
   for links and the one button in the header. Nothing is set in uppercase
   monospace, and nothing glows. The `blog` class on <html> scopes the palette
   below to these pages; the rest of the site keeps its own. */

/* ---------- Palette ---------- */

:root.blog {
    --bg: #ffffff;
    --bg-card: #ffffff;
    --bg-code: #f5f6f7;
    --bg-inset: #f5f6f7;
    --code-inline: #eceef0;

    /* One colour for headings and prose (10.6:1 on white); weight, not a
       darker shade, tells a heading from its text. */
    --text: #3b3f44;
    --text-muted: #3b3f44;
    --text-dim: #6a7179;
    --text-faint: #8b9198;

    --accent: #BA365C;
    --accent-hover: #9e2a4d;
    --accent-soft: #a82c53;
    --accent-soft-hover: #86203f;
    --link-underline: rgba(168, 44, 83, .35);

    --line: #e4e6e9;
    --line-strong: #cdd1d5;
    --hover-wash: rgba(59, 63, 68, .05);
    --selection: rgba(186, 54, 92, .18);

    --header-blur: rgba(255, 255, 255, .9);
    --surface-float: rgba(255, 255, 255, .97);

    /* SF Mono on Apple devices: a code face that reads as code and nothing
       more. The page-wide mono is a display face meant for labels. */
    --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas,
            "Liberation Mono", monospace;

    /* One reading column: about 70 characters of 18px prose, and room for a
       line of a profile listing. */
    --prose: 720px;
}

/* Neutral greys rather than the site's navy, so the dark page reads as the
   same design with the lights off. */
:root.blog.dark {
    --bg: #18191b;
    --bg-card: #18191b;
    --bg-code: #212225;
    --bg-inset: #212225;
    --code-inline: #2b2d30;

    --text: #dcdee1;
    --text-muted: #dcdee1;
    --text-dim: #9ba1a8;
    --text-faint: #767c83;

    --accent: #BA365C;
    --accent-hover: #cf4a70;
    --accent-soft: #ec93ad;
    --accent-soft-hover: #f6c4d3;
    --link-underline: rgba(236, 147, 173, .4);

    --line: rgba(255, 255, 255, .10);
    --line-strong: rgba(255, 255, 255, .18);
    --hover-wash: rgba(255, 255, 255, .05);
    --selection: rgba(236, 147, 173, .28);

    --header-blur: rgba(24, 25, 27, .88);
    --surface-float: rgba(33, 34, 37, .97);
}

.blog-shell {
    max-width: calc(var(--prose) + 2 * var(--gutter));
    margin: 0 auto;
    padding-left: var(--gutter);
    padding-right: var(--gutter);
}

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

code {
    font-family: var(--mono);
    font-size: .86em;
    color: var(--text);
    background: var(--code-inline);
    border-radius: 4px;
    padding: .1em .35em;
    /* A path can be longer than a line even on a desktop. break-word only
       splits a word that cannot fit on a line of its own and, unlike anywhere,
       leaves table columns their width. */
    overflow-wrap: break-word;
}

pre {
    background: var(--bg-code);
    border-radius: 6px;
    padding: 18px 20px;
    overflow-x: auto;
    max-width: 100%;
    font-family: var(--mono);
    font-size: 13.5px;
    line-height: 1.65;
    color: var(--text);
}

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

/* ---------- Index header ---------- */

.blog .page-head {
    padding: 56px 0 8px;
}

.blog .page-head::before {
    content: none;
}

.blog .page-head .shell {
    animation: none;
}

.blog .page-head h1 {
    font-size: 48px;
    font-weight: 700;
    letter-spacing: -0.01em;
    line-height: 1.15;
}

.blog .page-head p {
    margin-top: 12px;
    font-size: 18px;
    line-height: 1.5;
    color: var(--text-dim);
}

/* ---------- Post header ---------- */

.post-head {
    padding: 36px 0 0;
}

.breadcrumb {
    margin: 0 0 28px;
    font-size: 14px;
    color: var(--text-dim);
}

.breadcrumb ol {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px 8px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.breadcrumb li {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
}

.breadcrumb li + li::before {
    content: '›';
    color: var(--text-faint);
}

.breadcrumb a {
    color: var(--text-dim);
}

.breadcrumb a:hover {
    color: var(--text);
    text-decoration: underline;
    text-underline-offset: 3px;
}

.breadcrumb [aria-current] {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 46ch;
}

.post-head h1 {
    font-size: 44px;
    font-weight: 700;
    letter-spacing: -0.01em;
    line-height: 1.18;
    margin: 0;
    text-wrap: balance;
}

.post-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px 8px;
    margin: 18px 0 0;
    font-size: 14px;
    color: var(--text-dim);
}

.post-meta .dot {
    color: var(--text-faint);
}

.post-lede {
    margin: 28px 0 0;
    font-size: 21px;
    line-height: 1.55;
    color: var(--text);
    text-wrap: pretty;
}

.lang-fallback {
    margin: 20px 0 0;
    font-size: 15px;
    color: var(--text-dim);
    border-inline-start: 4px solid var(--line-strong);
    padding: 2px 0 2px 16px;
}

/* The `hidden` attribute is only a UA `display: none`, which any author
   display would beat. */
.lang-fallback[hidden] {
    display: none;
}

/* ---------- Contents ---------- */

.post-toc {
    margin: 36px 0 0;
    padding: 24px 0;
    border-top: 1px solid var(--line);
    border-bottom: 1px solid var(--line);
}

.post-toc-title {
    font-size: 18px;
    font-weight: 700;
    color: var(--text);
    margin: 0 0 10px;
}

.post-toc ol {
    margin: 0;
    padding-inline-start: 1.6em;
    font-size: 16px;
    line-height: 1.5;
    color: var(--text-dim);
}

.post-toc li {
    padding: 3px 0;
}

.post-toc a {
    color: var(--text);
}

.post-toc a:hover {
    color: var(--accent-soft);
    text-decoration: underline;
    text-decoration-color: var(--link-underline);
    text-underline-offset: 3px;
}

/* ---------- Article body ---------- */

.post-body {
    padding: 36px 0 8px;
    font-size: 18px;
    line-height: 1.6;
    color: var(--text);
}

.post-body > * {
    margin-top: 0;
    margin-bottom: 24px;
}

.post-body p,
.post-body li {
    text-wrap: pretty;
}

.post-body h2 {
    font-size: 32px;
    font-weight: 700;
    letter-spacing: -0.01em;
    line-height: 1.25;
    margin: 56px 0 20px;
    /* The header is sticky, so an anchored heading must clear it. */
    scroll-margin-top: 92px;
    text-wrap: balance;
}

.post-body h3 {
    font-size: 24px;
    font-weight: 700;
    line-height: 1.3;
    margin: 40px 0 14px;
    scroll-margin-top: 92px;
}

.post-body h2 + h3 {
    margin-top: 28px;
}

.post-body strong {
    font-weight: 700;
}

/* Colour alone would not do: the rose sits too close to the charcoal for a
   reader who cannot tell the two apart, so links keep a quiet underline. */
.post-body a,
.callout a,
.related-list a {
    color: var(--accent-soft);
    text-decoration: underline;
    text-decoration-color: var(--link-underline);
    text-decoration-thickness: 1px;
    text-underline-offset: 3px;
    overflow-wrap: anywhere;
}

.post-body a:hover,
.callout a:hover,
.related-list a:hover {
    color: var(--accent-soft-hover);
    text-decoration-color: currentColor;
}

.post-body ul,
.post-body ol {
    padding-inline-start: 1.5em;
}

.post-body ul {
    list-style: disc;
}

.post-body ol {
    list-style: decimal;
}

.post-body li {
    margin-bottom: 8px;
    padding-inline-start: 4px;
}

.post-body li::marker {
    color: var(--text);
}

.post-body ol > li::marker {
    font-weight: 700;
}

/* Keeps a command-line flag with its argument: browsers break a line after a
   hyphen, which would split `tr -d` into `tr -` and `d`. */
.nowrap {
    white-space: nowrap;
}

.post-body hr {
    border: none;
    border-top: 1px solid var(--line);
    margin: 48px 0;
}

/* Names the listing below it, so it sits closer to that than to the text
   above. A positive gap: the pre is painted later, and any overlap hides the
   caption's lower half behind its background. Wins over `.post-body > *` by
   coming later at the same specificity. */
.code-caption {
    font-size: 15px;
    line-height: 1.5;
    color: var(--text-dim);
    margin: 0 0 8px;
}

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

.post-figure {
    margin: 36px 0;
}

.post-figure .figure-frame {
    /* A phone gets a diagram it can pan rather than one too small to read. */
    overflow-x: auto;
}

.post-figure svg {
    display: block;
    width: 100%;
    height: auto;
}

.post-figure figcaption {
    margin-top: 12px;
    font-size: 15px;
    line-height: 1.5;
    color: var(--text-dim);
    text-align: center;
    text-wrap: pretty;
}

/* Diagram parts take the page's colours, so they follow light and dark. The
   rose marks the push, the only path that is not your own connection. */
.dg-box {
    fill: var(--bg-inset);
    stroke: var(--line-strong);
    stroke-width: 1;
}

.dg-title {
    fill: var(--text);
    font-family: var(--font);
    font-size: 15px;
    font-weight: 700;
}

.dg-sub {
    fill: var(--text-dim);
    font-family: var(--font);
    font-size: 13px;
}

.dg-line {
    fill: none;
    stroke: var(--text-faint);
    stroke-width: 1.4;
}

.dg-line--accent {
    stroke: var(--accent);
}

.dg-head {
    fill: var(--text-faint);
}

.dg-head--accent {
    fill: var(--accent);
}

.dg-label {
    fill: var(--text);
    font-family: var(--font);
    font-size: 13px;
}

.dg-num {
    fill: var(--text);
    font-family: var(--font);
    font-size: 13px;
    font-weight: 700;
}

/* ---------- Callouts ---------- */

/* A quotation bar, not a box: the text stays on the page ground. */
.callout {
    padding: 2px 0 2px 24px;
    border-inline-start: 4px solid var(--line-strong);
    font-size: 17px;
    line-height: 1.6;
}

.callout > :last-child {
    margin-bottom: 0;
}

.callout p {
    margin: 0 0 8px;
}

.callout-title {
    font-weight: 700;
}

.callout--caution {
    border-inline-start-color: var(--accent);
}

.callout--tip {
    border-inline-start-color: var(--text);
}

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

.table-wrap {
    overflow-x: auto;
}

.post-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 16px;
    line-height: 1.5;
}

.post-table th,
.post-table td {
    text-align: start;
    vertical-align: top;
    padding: 12px 16px 12px 0;
    border-bottom: 1px solid var(--line);
}

.post-table th {
    font-weight: 700;
    border-bottom: 2px solid var(--line-strong);
    white-space: nowrap;
}

.post-table th:last-child,
.post-table td:last-child {
    padding-inline-end: 0;
}

/* ---------- Post footer ---------- */

.post-foot {
    margin: 40px 0 0;
    padding: 24px 0 0;
    border-top: 1px solid var(--line);
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    font-size: 15px;
    color: var(--text-dim);
}

.post-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.tag {
    display: inline-block;
    font-size: 14px;
    line-height: 1.4;
    color: var(--text-dim);
    background: var(--bg-inset);
    border-radius: 4px;
    padding: 3px 9px;
}

.back-link {
    color: var(--text);
}

.back-link:hover {
    color: var(--accent-soft);
}

/* ---------- Related reading ---------- */

.related {
    margin: 48px auto 32px;
}

.related-title {
    font-size: 24px;
    font-weight: 700;
    line-height: 1.3;
    margin: 0 0 14px;
}

.related-list {
    margin: 0;
    padding-inline-start: 1.5em;
    font-size: 17px;
    line-height: 1.6;
}

.related-list li {
    margin-bottom: 8px;
}

.related-list li::marker {
    color: var(--text);
}

/* ---------- Blog index ---------- */

.post-list {
    padding: 24px 0 32px;
}

.post-card {
    padding: 32px 0;
    border-top: 1px solid var(--line);
}

.post-card:last-child {
    border-bottom: 1px solid var(--line);
}

.post-card .post-meta {
    margin: 0 0 10px;
}

.post-card h2 {
    font-size: 28px;
    font-weight: 700;
    letter-spacing: -0.01em;
    line-height: 1.25;
    margin: 0 0 12px;
    text-wrap: balance;
}

.post-card h2 a {
    color: var(--text);
}

.post-card h2 a:hover {
    color: var(--accent-soft);
}

.post-card p {
    margin: 0 0 16px;
    font-size: 18px;
    line-height: 1.6;
    text-wrap: pretty;
}

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

@media (max-width: 880px) {
    .blog .page-head h1 {
        font-size: 38px;
    }

    .post-head {
        padding-top: 24px;
    }

    .post-head h1 {
        font-size: 34px;
    }

    .post-lede {
        font-size: 19px;
    }

    .post-body h2 {
        font-size: 27px;
        margin-top: 48px;
    }

    .post-body h3 {
        font-size: 21px;
    }
}

@media (max-width: 560px) {
    .blog .page-head {
        padding-top: 32px;
    }

    .blog .page-head h1 {
        font-size: 32px;
    }

    .blog .page-head p {
        font-size: 17px;
    }

    .post-head h1 {
        font-size: 29px;
    }

    .post-lede {
        font-size: 18px;
    }

    .post-body {
        font-size: 17px;
    }

    .post-body h2 {
        font-size: 24px;
    }

    .post-body h3 {
        font-size: 20px;
    }

    pre {
        font-size: 12.5px;
        padding: 14px 16px;
    }

    .post-figure svg {
        min-width: 600px;
    }

    .post-table {
        font-size: 15px;
    }

    /* Without a frame a table that scrolls sideways looks cut off, so on a
       phone let a long payload type break instead of widening its column.
       `anywhere`, unlike the page's break-word, also lowers the column's
       minimum width. */
    .post-table code {
        overflow-wrap: anywhere;
    }

    .post-table th,
    .post-table td {
        padding-inline-end: 12px;
    }

    .post-card h2 {
        font-size: 23px;
    }

    .post-card p {
        font-size: 17px;
    }

    .breadcrumb [aria-current] {
        max-width: 24ch;
    }
}
