/* ==========================================================
   Article styles — loaded after /styles.css on essay pages.
   Ported from the standalone draft; review-only styles removed.
   ========================================================== */

:root { --red: var(--accent); }

/* ---------- Layout: TOC sidebar + centred text ---------- */

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

.article { max-width: 720px; }

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

.ttl { margin: 56px 0 28px; }
.article h1 {
    font-family: var(--font-ui);
    font-size: clamp(32px, 7vw, 44px);
    font-weight: 800;
    letter-spacing: -.02em;
    line-height: 1.08;
    color: var(--ink);
    margin: 0 0 12px;
}
.article .dek {
    font: 600 clamp(19px, 4.4vw, 23px)/1.35 var(--font-ui);
    letter-spacing: -.01em;
    color: var(--sub);
    margin: 0;
}
.article .byline {
    font-family: var(--font-ui);
    font-size: 14px;
    color: var(--muted);
    margin-top: 16px;
}

/* ---------- Body ---------- */

.article p, .article li { font-size: 18px; line-height: 1.65; color: var(--text); }
.article > p { margin-bottom: 18px; }
.article ol:not(.refs) { margin: 0 0 18px 24px; }
.article h3 {
    font-family: var(--font-ui);
    font-size: 22px;
    font-weight: 700;
    letter-spacing: -.01em;
    color: var(--ink);
    margin: 48px 0 10px;
}

/* ---------- Chart cards ---------- */

.card {
    background: var(--surface);
    border-radius: 6px;
    padding: 24px 24px 16px;
    margin: 28px 0;
    box-shadow: 0 0 0 1px var(--rule);
    font-family: var(--font-ui);
}
.card h2 {
    font-family: var(--font-ui);
    font-weight: 800;
    font-size: 21px;
    margin: 0 0 6px;
    letter-spacing: -.01em;
    line-height: 1.2;
    color: var(--ink);
}
.card .sub { font-family: var(--font-ui); font-size: 15px; color: var(--sub); margin: 0 0 10px; }
.key { font-family: var(--font-ui); font-size: 13px; color: var(--sub); display: flex; flex-wrap: wrap; gap: 16px; margin: 4px 0 2px; }
.key i { display: inline-block; width: 12px; height: 12px; border-radius: 2px; margin-right: 6px; vertical-align: -1px; }
.src { font-size: 12px; color: var(--muted); margin-top: 6px; line-height: 1.5; }
.card svg { overflow: visible; }

/* ---------- Table ---------- */

.tbl { overflow-x: auto; margin: 14px 0 18px; }
.tbl table { border-collapse: collapse; width: 100%; font: 14.5px/1.4 var(--font-ui); background: var(--surface); border-radius: 6px; }
.tbl th, .tbl td { padding: 10px 12px; border-bottom: 1px solid var(--rule); text-align: left; vertical-align: top; }
.tbl th { font-weight: 700; }
.tbl td:first-child { color: var(--sub); }
.tbl .p { background: var(--tint); color: var(--red); }
.tbl th.p { color: var(--red); }

/* ---------- Citations + references ---------- */

sup { line-height: 0; vertical-align: baseline; position: relative; top: -0.45em; }
a.cite { text-decoration: none; }
a.cite sup { color: var(--link); font: 700 11px var(--font-ui); padding: 0 2px; border-radius: 3px; }
a.cite + a.cite sup { margin-left: 1px; }

.refs { list-style: none; padding-left: 0; }
.refs li {
    font-size: 15px !important;
    line-height: 1.5 !important;
    padding-left: 34px;
    text-indent: -34px;
    margin-bottom: 6px;
    border-radius: 4px;
    transition: background .4s;
}
.refs a { color: var(--link); word-break: break-all; text-decoration: none; }
.refs a:hover { text-decoration: underline; }
a.rnum { display: inline-block; width: 34px; text-indent: 0; color: var(--link); text-decoration: none; font: 600 14px var(--font-ui); }
li.flash { background: var(--highlight); }

/* ---------- Table of contents ---------- */

.article .toc .label, .toc .label { font-size: 12px; line-height: 1.4; }
.article .toc li { font-size: 14px; line-height: 1.35; }

.toc {
    font-family: var(--font-ui);
    max-width: 720px;
    width: 100%;
    margin: 0 auto;
    padding: 0 20px;
    order: 0;
}
.toc ol { list-style: none; }
.toc a {
    display: flex;
    gap: 10px;
    padding: 5px 0 5px 12px;
    border-left: 2px solid var(--rule);
    font-size: 14px;
    line-height: 1.35;
    color: var(--sub);
    text-decoration: none;
}
.toc a:hover { color: var(--ink); }
.toc a.active { color: var(--ink); font-weight: 600; border-left-color: var(--accent); }
.toc .toc-n { min-width: 22px; color: var(--muted); font-weight: 400; font-variant-numeric: tabular-nums; }

/* Narrow screens: TOC sits below the title as a compact box */
@media (max-width: 1179px) {
    .article-layout { display: flex; flex-direction: column; }
    .article-layout .article { order: 1; }
    .toc { display: none; }                     /* hidden until JS moves it under the title */
    .toc.inline { display: block; padding: 0; margin: 0 0 32px; }
    .toc.inline ol { columns: 2; column-gap: 24px; }
    .toc.inline li { break-inside: avoid; }
}

/* Wide screens: sticky left sidebar, article stays centred */
@media (min-width: 1180px) {
    .article-layout {
        grid-template-columns: 1fr minmax(0, 720px) 1fr;
        column-gap: 24px;
        max-width: 1400px;
        margin: 0 auto;
    }
    .toc {
        grid-column: 1;
        justify-self: end;
        width: 210px;
        padding: 0;
        position: sticky;
        top: 96px;
        align-self: start;
        margin: 190px 0 0 auto;
    }
    .article { grid-column: 2; width: 100%; }
}

@media (max-width: 640px) {
    .article p, .article li { font-size: 17px; }
    .ttl { margin-top: 36px; }
    .card { padding: 18px 16px 12px; margin: 22px -4px; }
    .toc.inline ol { columns: 1; }
}
.site-header .site-nav { max-width: 720px; }

/* Left sidebar variant: TOC goes to the right-hand column */
@media (min-width: 1180px) {
    [data-nav="left"] .article-layout { grid-template-columns: minmax(0, 720px) 230px; justify-content: center; column-gap: 40px; }
    [data-nav="left"] .article { grid-column: 1; grid-row: 1; }
    [data-nav="left"] .toc { grid-column: 2; grid-row: 1; justify-self: start; margin: 190px 0 0; top: 40px; }
}

/* Floating nav: article text starts at the same x as the home page text,
   so the nav never moves between pages. Contents list floats on the right. */
@media (min-width: 1024px) {
    [data-nav="float"] .article-layout { display: block; }
    [data-nav="float"] .article { max-width: 720px; margin-left: max(0px, calc(50% - (var(--measure) / 2))); margin-right: auto; }
}
@media (min-width: 1024px) and (max-width: 1279px) {
    [data-nav="float"] .toc:not(.inline) { display: none; }
    [data-nav="float"] .toc.inline { display: block; max-width: none; padding: 0; margin: 0 0 32px; }
    [data-nav="float"] .toc.inline ol { columns: 2; column-gap: 24px; }
    [data-nav="float"] .toc.inline li { break-inside: avoid; }
}
@media (min-width: 1280px) {
    [data-nav="float"] .toc {
        position: fixed;
        top: 64px;
        left: calc(50% - (var(--measure) / 2) + 740px);
        width: 210px;
        margin: 0;
        padding: 0;
    }
}
