/* Article pages: long reads built from markdown by tools/build_article.py.
   On a wide screen there are three columns: on the left the logo, three links to the
   rest of the site and the article's sections, all staying put while the page scrolls; the text in the
   middle; and a right-hand margin where a source's citation appears while the reader points at the words
   that cite it. On a narrower screen the logo and the links sit above the title and the section list goes.
   On a phone those give way to the site's usual top bar, logo and menu button, which here is not pinned:
   it scrolls away with the page. Where there is no margin (or no mouse) a tap on the cited words opens the citation in place. */

.article-page .wrap { max-width:1180px; }
.article-page [id] { scroll-margin-top:28px; }
.article-page #top { scroll-margin-top:40px; }
.article-page main { padding-top:0; }
.article-page .top { display:none; }
@media (max-width:700px) {
  .article-page .top { display:flex; position:relative; }
  .article-page .top.stuck:not(.open) { border-bottom-color:transparent; }
  .article-page main { padding-top:44px; }
  .article-page .article .side { display:none; }
}

.article { --text:600px; --gap:56px; --note:250px; }
.article .text { max-width:var(--text); margin:0 auto; }

/* ---------- the logo, the links to the rest of the site, and the list of sections ---------- */
.article .side { display:flex; align-items:flex-end; gap:22px; max-width:var(--text); margin:0 auto 40px; }
.article .brand { display:block; flex:none; }
.article .brand img { display:block; width:84px; height:auto; }
.article .sitenav { display:flex; flex-wrap:wrap; align-items:baseline; font-family:var(--sans); font-size:12.5px; line-height:1.4; color:var(--muted); }
.article .sitenav a { padding:4px 0; text-decoration:none; white-space:nowrap; }
.article .sitenav a:hover { color:var(--ink); }
.article .sitenav i { font-style:normal; margin:0 7px; color:#b7b7b7; }
.article .sitenav .arrow { width:20px; height:9px; margin-right:7px; vertical-align:-1px; fill:currentColor; }   /* a drawn arrow, solid head and shaft, in place of a typed one */
.article .rail { display:none; }

/* ---------- the text ---------- */
.article h1 { font-size:clamp(34px,5vw,46px); line-height:1.1; }
.article h1 .deck { display:block; margin-top:14px; font-size:clamp(21px,2.8vw,25px); font-weight:300; line-height:1.32; letter-spacing:-.005em; color:var(--soft); }
.article .text > p { font-size:18px; line-height:1.72; color:var(--soft); margin-top:22px; }
.article .text > p strong { font-weight:500; color:var(--ink); }
.article .text > p.byline { font-family:var(--sans); font-size:13px; line-height:1.5; color:var(--muted); margin-top:26px; }   /* the line under the title */
.article .text > p.byline + p { margin-top:28px; }
.article .text > p a, .article .refs a { text-underline-offset:3px; text-decoration-thickness:1px; text-decoration-color:#b7b7b7; }
.article .text > p a:hover, .article .refs a:hover, .article .mn a:hover { text-decoration-color:currentColor; }
.article h2 { font-size:27px; line-height:1.22; margin-top:60px; }
.article .text > h2 + p { margin-top:18px; }
/* A quoted passage ("> " in the markdown): a thin red rule down the left and small grey sans-serif text. */
.article blockquote { margin:28px 0 0; padding:2px 0 2px 16px; border-left:2px solid var(--red); }
.article blockquote p { font-family:var(--sans); font-size:13px; line-height:1.55; color:var(--mid); }
.article .text > blockquote + p { margin-top:28px; }
.article mark.todo { background:#fff1b8; color:inherit; padding:1px 3px; }

/* ---------- sources ----------
   The words that cite a source are a link to it (class "cite"), and the citation (class "mn") follows them
   in the page. Here, with no margin, the citation is hidden until article.js opens it on a tap; the
   wide-screen rules further down move it into the margin and show it while the words are pointed at. */
.article .mn { display:none; font-family:var(--sans); font-size:12.5px; font-weight:400; font-style:normal; line-height:1.5; letter-spacing:0; color:var(--muted); }
.article .mn a { color:var(--mid); text-underline-offset:3px; text-decoration-thickness:1px; text-decoration-color:#b7b7b7; }
.article .mn.open { display:block; margin:8px 0 10px; padding-left:14px; border-left:1px solid var(--rule); }
.article span.cite { text-decoration:underline; text-underline-offset:3px; text-decoration-thickness:1px; text-decoration-color:#b7b7b7; }

/* ---------- tables ---------- */
.article .tbl { margin:30px 0 34px; }
.article .tbl table { width:100%; border-collapse:collapse; font-family:var(--sans); font-size:14px; line-height:1.4; font-variant-numeric:tabular-nums; }
.article .tbl th, .article .tbl td { padding:10px 0 10px 18px; text-align:right; vertical-align:bottom; border-bottom:1px solid var(--rule); font-weight:400; color:var(--soft); }
.article .tbl th:first-child { padding-left:0; text-align:left; }
.article .tbl thead th { font-size:12.5px; color:var(--muted); border-bottom-color:var(--line); text-wrap:balance; }
.article .tbl tbody th { font-weight:500; color:var(--ink); white-space:nowrap; }
.article .tbl td { white-space:nowrap; }

/* ---------- charts ---------- */
.article .chart { margin:32px 0 34px; }
.article .chart img { display:block; width:100%; height:auto; }
.article .chart iframe { display:block; }
.article .chart .still { display:none; }             /* the phone's picture of a chart; see the phone rules below */
.article .chart figcaption { margin-top:8px; font-family:var(--sans); font-size:12px; color:var(--muted); }

/* ---------- the list of references that closes the article ---------- */
.article .refs { list-style:none; margin:20px 0 0; padding:0; }
.article .refs li { font-family:var(--sans); font-size:14px; line-height:1.6; color:var(--soft); padding-left:18px; text-indent:-18px; overflow-wrap:anywhere; }
.article .refs li + li { margin-top:12px; }

/* ---------- a phone: tables with three or more columns become one block per row ---------- */
@media (max-width:640px) {
  .article .side { margin-bottom:32px; }
  .article .text > p { font-size:17px; line-height:1.68; }
  .article h2 { font-size:24px; margin-top:52px; }
  .article .chart.phone-picture iframe { display:none; }
  .article .chart.phone-picture .still { display:block; }
  .article .tbl table { font-size:13.5px; }
  .article .tbl th, .article .tbl td { padding-left:12px; }
  .article .tbl:not(.stack) td, .article .tbl tbody th { white-space:normal; }
  .article .tbl.stack table, .article .tbl.stack thead, .article .tbl.stack tbody, .article .tbl.stack tr, .article .tbl.stack tbody th { display:block; }
  .article .tbl.stack thead tr { padding:0; border:0; }
  .article .tbl.stack thead th { display:none; }                       /* each value carries its own column name instead */
  .article .tbl.stack thead th:first-child:not(:empty) { display:block; border:0; padding:0 0 9px; }
  .article .tbl.stack tbody { border-top:1px solid var(--line); }
  .article .tbl.stack tr { padding:12px 0 10px; border-bottom:1px solid var(--rule); }
  .article .tbl.stack tbody th { border:0; padding:0 0 4px; font-size:15px; }
  .article .tbl.stack td { display:flex; justify-content:space-between; align-items:baseline; gap:20px; border:0; padding:3px 0; white-space:normal; }
  .article .tbl.stack td::before { content:attr(data-label); text-align:left; color:var(--muted); }
}

/* ---------- room for a margin: a citation appears beside the text, level with the words that cite it ---------- */
@media (min-width:980px) {
  .article { max-width:calc(var(--text) + var(--gap) + var(--note)); margin:0 auto; }
  .article .text, .article .side { margin-left:0; margin-right:0; }
  .article .text > p { position:relative; }
  /* Taken out of the line and placed in the margin. With no "top" set, it keeps the height of the line it sits in. */
  .article .mn, .article .mn.open { display:inline; position:absolute; left:calc(100% + var(--gap)); width:var(--note); margin:7px 0 0; padding:0; border:0;
    visibility:hidden; opacity:0; transition:opacity .15s ease; }
  .article .cite:hover + .mn, .article .cite:focus-visible + .mn, .article .mn.open { visibility:visible; opacity:1; }
}
/* With a mouse, the cited words are the link, so the citation in the margin is plain text. */
@media (min-width:980px) and (hover:hover) {
  .article .mn a { color:inherit; text-decoration:none; }
}

/* ---------- a wide screen: the logo, the site links and the sections down the left, staying put ---------- */
@media (min-width:1200px) {
  .article { max-width:none; display:grid; grid-template-columns:170px minmax(0,var(--text)); column-gap:56px; }
  .article .side { display:block; position:sticky; top:40px; align-self:start; max-width:none; margin:0; }   /* 40px is where it starts, so it never moves */
  .article .brand img { width:112px; }
  .article .sitenav { margin-top:20px; }
  .article .rail { display:block; margin-top:22px; }
  .article .rail a { display:block; padding:6px 0; font-family:var(--sans); font-size:13px; line-height:1.4; color:var(--muted); text-decoration:none; }
  .article .rail a:hover, .article .rail a.on { color:var(--ink); }
}
@media (prefers-reduced-motion:reduce) {
  .article .mn { transition:none; }
}

@media print {
  .article .sitenav, .article .rail, .article .mn, .article-page .top { display:none; }
}
