/* Hallmark · shape: Long Document · genre: editorial · theme: brand · redesign: full · copy: verbatim · job: read · hero: Banner, a teal masthead with the cover over its edge · nav: kept · footer: kept · signature: the cover overlapping a teal masthead above one reading column
 * contrast: pass · fold: pass · v2.0.0 */
/* Hallmark · pre-emit critique: P4 H5 E4 S3 R5 V3 · weakest: S, the shell could hold any journal; it earns its place through the real covers and the guide list drawn from each post's own headings, with the banner and avatar cut */
/* Hallmark · waive 49b · a real phrase that cannot shorten, titles and headings stay as stored under contract rule 5 · guide entries and related post titles are the articles' own words, so they wrap like headlines */
/* Hallmark · waive 79 · the body text starts straight under the masthead when a post has no cover · five posts have no cover, and their reading column fills the space this gate calls empty */
/* Hallmark · dismissed 3 · the contract names the orange callout rule as one of the small marks allowed on this page, and the study note keeps the rule it already had */
/* Hallmark · dismissed 77 · an article page is one long read with a short close, not a landing strip */
/* Hallmark · answered F19 · body 400, titles 500, labels 600 and strong 700 are the four weights in the token set */
/* Hallmark · dismissed F25 · the rail's guide list is the same list phones get in the closed "In this guide" disclosure, one tap away */

/* Article page shell. Window 2 owns this file. Tokens only. Everything inside .article-prose
   belongs to article-prose.css. */

.page-article {
    /* ch is the width of a zero, wider than the average letter. In Hanken Grotesk at 18px, 68ch sets
       81 characters a line and 58ch sets 67, so the column takes whichever of the two is narrower. */
    --article-measure: min(var(--mg-measure), 58ch);
    --article-overlap: 0px;
}

/* The prose headings set scroll-margin-top, and scroll-padding-top would add to it. */
html:has(.page-article) {
    scroll-padding-top: 0;
}

@media (prefers-reduced-motion: reduce) {
    html {
        scroll-behavior: auto;
    }
}

/* ---------- Column widths: the measure is in ch, read from this font and size, so they stay on the wrapper ---------- */

.article-page {
    font-family: var(--mg-font-body);
    font-size: var(--mg-size-prose);
    color: var(--mg-body);
}

.article-measure,
.article-column {
    width: min(var(--article-measure), 100% - 2 * var(--mg-gutter));
    margin-inline: auto;
}

.article-wide {
    width: min(var(--mg-container), 100% - 2 * var(--mg-gutter));
    margin-inline: auto;
}

/* ---------- Masthead ---------- */

.article-masthead {
    padding-top: calc(var(--mg-header-h) + 8px);
}

.page-article .article-back {
    display: inline-flex;
    align-items: center;
    min-height: 44px;
    font-size: var(--mg-size-small);
    font-weight: var(--mg-weight-label);
    color: var(--mg-link);
    text-decoration: none;
}

.page-article .article-back:hover {
    text-decoration: underline;
}

.page-article .article-title {
    min-width: 0;
    margin: 4px 0 0;
    font-family: var(--mg-font-title);
    /* 44px at most: a 585px column at the full 52px runs long titles to four lines and pushes the cover off the first screen. */
    font-size: min(var(--mg-size-h1), 2.75rem);
    font-weight: var(--mg-weight-title);
    line-height: var(--mg-leading-tight);
    letter-spacing: var(--mg-tracking-title);
    color: var(--mg-teal);
    overflow-wrap: break-word;
    hyphens: auto;
    hyphenate-limit-chars: 14 7 5;
    text-wrap: balance;
}

.page-article .article-summary {
    margin: 12px 0 0;
    font-family: var(--mg-font-body);
    font-size: var(--mg-size-lead);
    line-height: 1.45;
    color: var(--mg-muted);
    text-wrap: pretty;
}

/* ---------- Byline ---------- */

.article-byline {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas:
        "who share"
        "meta share";
    align-items: center;
    gap: 4px 16px;
    margin-top: 16px;
    padding-top: 12px;
    border-top: 1px solid var(--mg-line);
    font-size: var(--mg-size-small);
}

.page-article .article-byline__who,
.page-article .article-byline__meta {
    display: flex;
    flex-wrap: wrap;
    margin: 0;
    font-family: var(--mg-font-body);
    font-size: var(--mg-size-small);
    line-height: var(--mg-leading-snug);
}

.page-article .article-byline__who {
    grid-area: who;
    gap: 2px 12px;
}

.page-article .article-byline__meta {
    grid-area: meta;
    gap: 2px 16px;
    color: var(--mg-muted);
    font-variant-numeric: tabular-nums;
}

.article-byline__name {
    font-weight: var(--mg-weight-label);
    color: var(--mg-teal);
}

.article-byline__role {
    color: var(--mg-muted);
}

.article-share {
    position: relative;
    grid-area: share;
}

.article-share__button {
    display: inline-flex;
    align-items: center;
    min-height: 44px;
    padding: 0 16px;
    border: 1px solid var(--mg-line);
    border-radius: var(--mg-radius-pill);
    background: transparent;
    color: var(--mg-link);
    font-family: inherit;
    font-size: var(--mg-size-small);
    font-weight: var(--mg-weight-label);
    cursor: pointer;
    transition: transform var(--mg-duration) var(--mg-ease);
}

.article-share__button:hover {
    border-color: var(--mg-link);
}

.article-share__button:active {
    transform: translateY(1px);
}

.article-share__status {
    position: absolute;
    right: 0;
    bottom: calc(100% + 6px);
    padding: 4px 12px;
    border-radius: var(--mg-radius-pill);
    background: var(--mg-teal);
    color: var(--mg-on-teal);
    font-size: var(--mg-size-small);
    white-space: nowrap;
    pointer-events: none;
    opacity: 0;
    transition: opacity var(--mg-duration) var(--mg-ease);
}

.article-share__status.is-visible {
    opacity: 1;
}

/* Sharing needs a script, so the button stays out of a no-script page. */
@media (scripting: none) {
    .article-share {
        display: none;
    }
}

/* ---------- Cover ---------- */

.article-cover {
    margin-block: 20px 0;
}

.article-cover img {
    display: block;
    width: 100%;
    height: auto;
    aspect-ratio: 16 / 9;
    object-fit: cover;
    border-radius: var(--mg-radius-md);
    background: var(--mg-wash);
    outline: 1px solid color-mix(in srgb, var(--mg-ink) 10%, transparent);
    outline-offset: -1px;
}

/* ---------- Guide list, phones and tablets ---------- */

.article-guide {
    margin-bottom: 24px;
    border-block: 1px solid var(--mg-line);
}

.article-guide__summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    min-height: 48px;
    color: var(--mg-teal);
    font-size: var(--mg-size-body);
    font-weight: var(--mg-weight-label);
    list-style: none;
    cursor: pointer;
}

.article-guide__summary::-webkit-details-marker {
    display: none;
}

.article-guide__chevron {
    flex: none;
    transition: transform var(--mg-duration) var(--mg-ease);
}

details[open] > .article-guide__summary .article-guide__chevron {
    transform: rotate(180deg);
}

.article-guide__list,
.article-guidebar__panel ol {
    margin: 0;
    padding: 0 0 8px;
    list-style: none;
}

.page-article .article-guide__list a,
.page-article .article-guidebar__panel a,
.page-article .article-rail__list a {
    display: grid;
    grid-template-columns: 2ch minmax(0, 1fr);
    column-gap: 8px;
    text-decoration: none;
}

/* A heading with no number starts at the number column. */
.article-toc-text:only-child {
    grid-column: 1 / -1;
}

.article-toc-num {
    color: var(--mg-muted);
    font-variant-numeric: tabular-nums;
}

.page-article .article-guide__list a,
.page-article .article-guidebar__panel a {
    padding-block: 12px;
    color: var(--mg-link);
    font-size: var(--mg-size-body);
    line-height: var(--mg-leading-snug);
}

.article-guide__list a:hover .article-toc-text,
.article-guidebar__panel a:hover .article-toc-text,
.article-guidebar__panel a[aria-current] .article-toc-text {
    text-decoration: underline;
}

/* ---------- Reading column ---------- */

.article-body {
    margin-top: 24px;
}

.article-page--no-cover .article-body {
    margin-top: 20px;
}

.article-column {
    min-width: 0;
    overflow-wrap: break-word;
}

.article-rail {
    display: none;
}

.article-page .article-note {
    margin: 0 0 24px;
    padding: 12px 16px;
    border-left: 3px solid var(--mg-callout-rule);
    border-radius: 0 var(--mg-radius-md) var(--mg-radius-md) 0;
    background: var(--mg-callout-bg);
    font-family: var(--mg-font-body);
    font-size: var(--mg-size-body);
    line-height: var(--mg-leading-body);
    color: var(--mg-body);
}

.article-page .article-note a {
    color: var(--mg-link);
    text-decoration: underline;
}

/* ---------- After the article ---------- */

.article-page .closing-cta {
    margin-top: var(--mg-space-section);
    padding-inline: max(var(--mg-gutter), (100% - var(--article-measure)) / 2);
}

.article-related {
    padding-block: var(--mg-space-section);
}

.article-guides {
    padding-bottom: var(--mg-space-section);
}

.closing-cta + .article-guides {
    padding-top: var(--mg-space-section);
}

.page-article .article-section-title {
    margin: 0 0 20px;
    font-family: var(--mg-font-title);
    font-size: var(--mg-size-h2);
    font-weight: var(--mg-weight-title);
    line-height: var(--mg-leading-tight);
    letter-spacing: var(--mg-tracking-title);
    color: var(--mg-teal);
    overflow-wrap: break-word;
}

.article-related__grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 32px;
}

.article-guides__list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.page-article .article-guides__link {
    display: inline-flex;
    align-items: center;
    min-height: 44px;
    padding: 0 16px;
    border: 1px solid var(--mg-line);
    border-radius: var(--mg-radius-pill);
    color: var(--mg-teal);
    font-size: var(--mg-size-small);
    font-weight: var(--mg-weight-label);
    text-decoration: none;
    transition: transform var(--mg-duration) var(--mg-ease);
}

.page-article .article-guides__link:hover {
    border-color: var(--mg-line-strong);
    text-decoration: underline;
}

.page-article .article-guides__link:active {
    transform: translateY(1px);
}

/* ---------- Phone guide bar: built by article.js, one of the three liquid glass spots ---------- */

.article-guidebar {
    position: fixed;
    right: var(--mg-gutter);
    bottom: calc(var(--mg-dock-h) + 12px);
    left: var(--mg-gutter);
    z-index: 990;
    display: flex;
    flex-direction: column-reverse;
    align-items: flex-start;
    gap: 8px;
    pointer-events: none;
    transition: opacity var(--mg-duration) var(--mg-ease), transform var(--mg-duration) var(--mg-ease);
}

.article-guidebar.is-hidden {
    visibility: hidden;
    opacity: 0;
    transform: translateY(8px);
    transition: opacity var(--mg-duration) var(--mg-ease), transform var(--mg-duration) var(--mg-ease), visibility 0s linear var(--mg-duration);
}

.article-guidebar__toggle {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: 44px;
    padding: 0 16px;
    border: 1px solid var(--mg-line);
    border-radius: var(--mg-radius-pill);
    color: var(--mg-teal);
    font-family: inherit;
    font-size: var(--mg-size-small);
    font-weight: var(--mg-weight-label);
    cursor: pointer;
    pointer-events: auto;
}

/* The panel opens upward, so the closed bar points up. */
.article-guidebar__toggle .article-guide__chevron {
    transform: rotate(180deg);
}

.article-guidebar__toggle[aria-expanded="true"] .article-guide__chevron {
    transform: none;
}

.article-guidebar__panel {
    width: 100%;
    max-height: min(60vh, 420px);
    padding: 8px 16px 0;
    overflow-y: auto;
    border-radius: var(--mg-radius-md);
    background: var(--mg-paper);
    box-shadow: 0 8px 28px color-mix(in srgb, var(--mg-ink) 22%, transparent);
    pointer-events: auto;
}

/* ---------- Focus: instant, on every control in the shell ---------- */

.page-article .article-back:focus-visible,
.page-article .article-guide__list a:focus-visible,
.page-article .article-guidebar__panel a:focus-visible,
.page-article .article-rail a:focus-visible,
.page-article .article-note a:focus-visible,
.page-article .article-guides__link:focus-visible,
.article-share__button:focus-visible,
.article-guide__summary:focus-visible,
.article-guidebar__toggle:focus-visible {
    outline: 2px solid var(--mg-focus);
    outline-offset: 2px;
}

/* ---------- Small tablets up ---------- */

@media (min-width: 768px) {
    .article-related__grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

/* ---------- Desktop masthead: full-width teal, cover over its bottom edge ---------- */

@media (min-width: 992px) {
    .page-article {
        --article-overlap: clamp(104px, 11vw, 160px);
    }

    .article-masthead {
        padding-top: calc(var(--mg-header-h) + 24px);
        padding-bottom: calc(var(--article-overlap) + 32px);
        background: var(--mg-teal);
    }

    .article-page--no-cover .article-masthead {
        padding-bottom: 48px;
    }

    .page-article .article-back {
        color: var(--mg-on-teal-muted);
    }

    .page-article .article-title {
        color: var(--mg-on-teal);
    }

    .page-article .article-summary {
        margin-top: 16px;
        color: var(--mg-on-teal-muted);
    }

    .article-byline {
        margin-top: 20px;
        padding-top: 16px;
        border-top-color: color-mix(in srgb, var(--mg-on-teal) 22%, transparent);
    }

    .article-byline__name {
        color: var(--mg-on-teal);
    }

    .article-byline__role,
    .page-article .article-byline__meta {
        color: var(--mg-on-teal-muted);
    }

    .article-share__button {
        border-color: var(--mg-on-teal-muted);
        color: var(--mg-on-teal);
    }

    .article-share__button:hover {
        border-color: var(--mg-on-teal);
    }

    .article-share__status {
        background: var(--mg-paper);
        color: var(--mg-teal);
    }

    .page-article .article-back:focus-visible,
    .article-share__button:focus-visible {
        outline-color: var(--mg-focus-on-dark);
    }

    .article-cover {
        position: relative;
        margin-top: calc(-1 * var(--article-overlap));
    }

    .article-cover img {
        border-radius: var(--mg-radius-lg);
    }

    .article-body {
        margin-top: 40px;
    }
}

/* ---------- Wide: the guide list sits in the left margin, reading column stays centred ---------- */

@media (min-width: 1200px) {
    .article-body {
        display: grid;
        grid-template-columns: minmax(0, 1fr) min(var(--article-measure), 100%) minmax(0, 1fr);
        width: min(var(--mg-container), 100% - 2 * var(--mg-gutter));
        margin-inline: auto;
    }

    .article-column {
        grid-row: 1;
        grid-column: 2;
        width: auto;
        margin-inline: 0;
    }

    .article-guide {
        display: none;
    }

    .article-rail {
        display: block;
        position: sticky;
        top: calc(var(--mg-header-h) + 24px);
        grid-row: 1;
        grid-column: 1;
        align-self: start;
        max-height: calc(100vh - var(--mg-header-h) - 48px);
        margin-right: 32px;
        overflow-y: auto;
        scrollbar-width: thin;
    }

    .page-article .article-rail a:focus-visible {
        outline-offset: -2px;
    }

    .page-article .article-rail__title {
        margin: 0 0 12px;
        font-family: var(--mg-font-title);
        font-size: var(--mg-size-h4);
        font-weight: var(--mg-weight-title);
        line-height: var(--mg-leading-snug);
        color: var(--mg-teal);
    }

    /* The left border is the track, and the current section's mark sits on it. */
    .article-rail__list {
        display: grid;
        gap: 4px;
        margin: 0;
        padding: 0;
        border-left: 1px solid var(--mg-line);
        list-style: none;
    }

    .page-article .article-rail__list a {
        position: relative;
        padding: 4px 0 4px 16px;
        color: var(--mg-muted);
        font-size: var(--mg-size-small);
        line-height: var(--mg-leading-snug);
    }

    .page-article .article-rail__list a::before {
        content: "";
        position: absolute;
        top: 0;
        bottom: 0;
        left: -1px;
        width: 2px;
        background: var(--mg-orange);
        opacity: 0;
        transition: opacity var(--mg-duration) var(--mg-ease);
    }

    .page-article .article-rail__list a:hover {
        color: var(--mg-teal);
    }

    .article-rail__list a:hover .article-toc-text {
        text-decoration: underline;
    }

    /* Colour only: a bolder weight would re-wrap the line and make the list jump. */
    .page-article .article-rail__list a[aria-current] {
        color: var(--mg-teal);
    }

    .article-rail__list a[aria-current] .article-toc-num {
        color: var(--mg-orange-strong);
    }

    .page-article .article-rail__list a[aria-current]::before {
        opacity: 1;
    }

    .article-guidebar {
        display: none;
    }
}

@media (prefers-reduced-motion: reduce) {
    .article-share__button,
    .article-share__status,
    .article-guide__chevron,
    .article-guidebar,
    .article-guidebar.is-hidden,
    .page-article .article-guides__link,
    .page-article .article-rail__list a::before {
        transition: none;
    }

    .article-guidebar.is-hidden {
        transform: none;
    }
}
