/* The blog's stylesheet: the parts of a blog page that are not the chrome.
 *
 * **The top bar, the footer and the brand tokens are not here any more.** They
 * are `shared/web/chrome.css`, which this page links first and which the
 * marketing site links as `/chrome.css` — one source, two servers. What used
 * to stand in this comment was an apology for the duplication: the tokens were
 * "copied from client/site/styles.css… a real drift risk and the honest
 * mitigation is that they are brand constants which have not moved". They had
 * not moved yet.
 *
 * The other half of that comment still holds and is why the blog serves its
 * own copy rather than linking nginx's: a stylesheet that only resolves once a
 * load-balancer rule lands is one nobody can review before then. See
 * `site/chrome.py`.
 *
 * What remains below is the reading column, the headings, the article and the
 * listing — the things the marketing pages have no use for.
 */

:root {
  /* The brand tokens come from chrome.css, linked first. What is left is this
     stylesheet's own column width — meaningless to the marketing grid, which
     has `--max` for the same job and a different answer. */
  --measure: 68ch;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  padding-inline: var(--gutter);
  background: var(--bg);
  color: var(--ink);
  font-family: var(--body);
  font-size: 17px;
  line-height: 1.62;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); }
a:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 4px; }

.wrap { max-width: var(--measure); margin-inline: auto; }

/* --- crumbs ---------------------------------------------------------------
 * The one piece of chrome that is the blog's alone: the marketing pages are
 * three levels deep at most and say where you are with the nav. */

.crumbs { max-width: 1200px; margin: 18px auto 0; font-size: 13px; color: var(--muted); }
.crumbs ol { list-style: none; display: flex; flex-wrap: wrap; gap: 8px; margin: 0; padding: 0; }
.crumbs li + li::before { content: "/"; margin-right: 8px; color: var(--line); }
.crumbs a { color: var(--muted); text-decoration: none; }
.crumbs a:hover { color: var(--ink); }

/* --- headings ------------------------------------------------------------- */

h1 {
  font-family: var(--display);
  font-weight: 600;
  font-size: clamp(32px, 5vw, 46px);
  line-height: 1.06;
  letter-spacing: -0.03em;
  margin: 0;
  text-wrap: balance;
}

h2 {
  font-family: var(--display);
  font-weight: 600;
  font-size: clamp(22px, 2.6vw, 27px);
  line-height: 1.2;
  letter-spacing: -0.02em;
  text-wrap: balance;
}

h3 { font-family: var(--display); font-weight: 600; font-size: 19px; line-height: 1.3; }

.lede { padding-block: clamp(40px, 6vw, 72px) 8px; }
.lede h1 { margin: 0; }
.lede .standfirst { margin: 14px 0 0; }
.standfirst { font-size: clamp(17px, 2vw, 20px); color: var(--ink-2); text-wrap: pretty; }

/* --- listings ------------------------------------------------------------- */

/* --- the listing ----------------------------------------------------------
 * Wider than an article, because a list is scanned and prose is read. 68ch is
 * the right measure for a paragraph and the wrong one for a row of cards.
 *
 * The header keeps the reading measure even so: a headline and a standfirst
 * are still prose, and stretching them to the full width of the grid would
 * make the one thing on the page somebody actually reads the hardest to. */
.listing { max-width: 1320px; }
.listing .lede,
.listing .search { max-width: var(--measure); }

/* One, two, then three — and never more than three.
 *
 * `auto-fit` is the tempting one-liner and it is wrong here: it fits as many
 * columns as the container allows, which on a wide monitor means four or five
 * cards each too narrow to read a headline in. The count is capped instead,
 * and each step up happens only when there is room to take it.
 *
 * The breakpoints are derived rather than guessed. A card needs about 360px
 * before its summary starts breaking into slivers; three of those plus two
 * 34px gaps plus the page gutters is roughly 1260px, which is where the third
 * column arrives. The second arrives the same way at 820. */
.cards {
  display: grid;
  grid-template-columns: 1fr;
  gap: 4px 34px;
  margin-top: 28px;
}

@media (min-width: 820px) {
  .cards { grid-template-columns: repeat(2, 1fr); }
}

@media (min-width: 1260px) {
  .cards { grid-template-columns: repeat(3, 1fr); }
}

.card { padding-block: 26px; border-top: 1px solid var(--line); }

/* The picture, on the card.
 *
 * Above the headline rather than beside it: every one of these is a wide
 * diagram, and a square thumbnail would crop the middle out of exactly the
 * part that carries the meaning. Full width keeps it readable at a glance and
 * costs nothing, because a 3:1 image in this column is about 200px tall.
 *
 * `width` and `height` come from the file, so the card reserves its space
 * before the bytes arrive. Without that a list of cards re-flows as each one
 * loads, which is the same layout shift as an article and happens a dozen
 * times on one page. */
.card-image {
  display: block;
  margin-bottom: 18px;
  border-radius: 12px;
  overflow: hidden;
  background: var(--wash);
}

.card-image img {
  display: block;
  width: 100%;
  height: auto;
  /* A very tall picture would push the headline off the screen; a very wide
     one is left alone, which is the case that actually occurs. */
  max-height: 180px;
  object-fit: cover;
  object-position: center;
}
.card h2 { margin: 0 0 8px; font-size: clamp(20px, 2.4vw, 25px); }
.card h2 a { text-decoration: none; color: var(--ink); }
.card h2 a:hover { color: var(--accent); }
.card-summary { margin: 0 0 10px; color: var(--ink-2); text-wrap: pretty; }

.byline { margin: 0; font-size: 13.5px; color: var(--muted); }
.byline a { color: var(--muted); text-decoration: none; }
.byline a:hover { color: var(--ink); }

.tags { display: flex; flex-wrap: wrap; gap: 6px; list-style: none; margin: 12px 0 0; padding: 0; }
.tags a {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--wash);
  color: var(--ink-2);
  font-size: 12.5px;
  text-decoration: none;
}
.tags a:hover { background: var(--accent-soft); color: var(--accent); }

.pager {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 8px 14px;
  margin-top: 44px;
  padding-top: 22px;
  border-top: 1px solid var(--line);
  font-size: 14px;
  color: var(--muted);
}

/* Newer and Older keep their place when there is nowhere to go, as dimmed
   text rather than a missing control. A row whose buttons move depending on
   which page you are on is one you have to re-read every time. */
.pager .step {
  padding: 7px 14px;
  border-radius: 999px;
  text-decoration: none;
  color: var(--ink-2);
}

.pager .step:hover { background: var(--wash); color: var(--ink); }
.pager .step.is-off { color: var(--line-strong, #cfc7d6); }

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

.pages a,
.pages .here {
  display: grid;
  place-items: center;
  min-width: 34px;
  height: 34px;
  padding-inline: 8px;
  border-radius: 9px;
  text-decoration: none;
  font-variant-numeric: tabular-nums;
  color: var(--ink-2);
}

.pages a:hover { background: var(--wash); color: var(--ink); }

.pages .here {
  background: var(--ink);
  color: #fff;
  font-weight: 500;
}

.pages .gap { padding-inline: 2px; color: var(--muted); }

.search { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 28px; }
.search label {
  flex-basis: 100%;
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}
.search input {
  flex: 1 1 220px;
  font: inherit;
  font-size: 15px;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--bg);
  color: var(--ink);
}
.search input:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.search button {
  font: inherit;
  font-size: 15px;
  font-weight: 500;
  padding: 10px 20px;
  border: 0;
  border-radius: 999px;
  background: var(--ink);
  color: #fff;
  cursor: pointer;
}
.search button:hover { background: #2a2336; }

.empty { margin-top: 32px; color: var(--muted); }
.browse { margin-top: 56px; padding-top: 24px; border-top: 1px solid var(--line); }
.browse h2 { font-size: 15px; margin: 0; }

.profile { margin-top: 18px; color: var(--ink-2); }
.profile .role { margin: 0 0 6px; font-size: 14px; color: var(--muted); }

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

.post { padding-block: clamp(40px, 6vw, 72px) 0; }

/* **Both of these are `<header>` elements, and the shared chrome styles that
 * element by name.** `chrome.css` sets `header { display: flex }` for the top
 * bar, which is right for the top bar and catches every other header on the
 * page — so the title, the standfirst, the byline and the categories were
 * laid out as four columns of one row rather than four rows.
 *
 * Reset here rather than by narrowing the rule in `chrome.css`: that file is
 * shared with the marketing pages, and a selector change there is a change to
 * a site this stylesheet does not own. A page defending its own layout against
 * an element-level rule is the cheaper and more local fix. */
.post-head,
.lede {
  display: block;
}

/* The hero, stacked and spaced on purpose: the headline, then what it is
   about, then who wrote it and how long it takes, then where it is filed.
   Each step is a smaller commitment than the one above it, so each gets
   slightly less room. */
.post-head h1 { margin: 0; }
.post-head .standfirst { margin: 14px 0 0; max-width: 46ch; }
.post-head .byline { margin: 22px 0 0; }
.post-head .tags { margin: 14px 0 0; }

.summary {
  margin: 28px 0 0;
  font-size: 18.5px;
  line-height: 1.55;
  color: var(--ink-2);
  padding-left: 18px;
  border-left: 3px solid var(--accent);
  text-wrap: pretty;
}

.takeaways {
  margin: 32px 0 0;
  padding: 20px 24px;
  background: var(--wash);
  border-radius: 14px;
}
.takeaways h2 { margin: 0 0 10px; font-size: 15px; }
.takeaways ul { margin: 0; padding-left: 20px; }
.takeaways li { margin-bottom: 6px; }

.body { margin-top: 36px; }
.body > :first-child { margin-top: 0; }
.body h2 { margin: 44px 0 12px; }
.body h3 { margin: 32px 0 10px; }
.body p { margin: 0 0 18px; text-wrap: pretty; }
.body ul, .body ol { margin: 0 0 18px; padding-left: 24px; }
.body li { margin-bottom: 7px; }
.body li::marker { color: var(--muted); }
.body blockquote {
  margin: 28px 0;
  padding-left: 20px;
  border-left: 3px solid var(--line);
  color: var(--ink-2);
}
.body code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.87em;
  background: var(--wash);
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 0.1em 0.38em;
}
.body pre {
  overflow-x: auto;
  padding: 16px 18px;
  border-radius: 12px;
  background: var(--wash);
  border: 1px solid var(--line);
}
.body pre code { background: none; border: 0; padding: 0; }

/* Media never overflows its column, and never pushes the text when it loads:
   the `#WxH` fragment in the Markdown becomes width/height attributes, and
   `height: auto` beside them is what turns those into an aspect ratio the
   browser can reserve before the bytes arrive. */
.body figure { margin: 32px 0; }
.body img, .body video { display: block; max-width: 100%; height: auto; border-radius: 12px; }
.body figcaption { margin-top: 10px; font-size: 13.5px; color: var(--muted); text-wrap: pretty; }

.body table { width: 100%; border-collapse: collapse; font-size: 15px; margin: 24px 0; }
.body th, .body td { text-align: left; padding: 10px 14px; border-bottom: 1px solid var(--line); }
.body thead th { font-size: 12.5px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); }

.faq { margin-top: 56px; padding-top: 28px; border-top: 1px solid var(--line); }
.faq dt { font-weight: 600; margin-top: 20px; }
.faq dd { margin: 6px 0 0; color: var(--ink-2); }

.author-card {
  margin-top: 56px;
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 14px;
}
.author-card h2 { margin: 0; font-size: 18px; }
.author-card .role { margin: 4px 0 10px; font-size: 14px; color: var(--muted); }
.author-card .bio { margin: 0 0 12px; color: var(--ink-2); }

.related { margin-top: 72px; }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

/* --- 404 -------------------------------------------------------------------
 * A dead end is a page too, and the useful thing to put on one is a way out:
 * a search box and the most recent writing. "Not found" and nothing else makes
 * the reader press Back, which is the one action that cannot recover them. */

.notfound { padding-block: clamp(48px, 8vw, 96px) 0; }

.notfound .code {
  font-family: var(--display);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.22em;
  color: var(--accent);
  margin: 0 0 14px;
}

.notfound h1 { max-width: 16ch; }
.notfound .standfirst { margin-top: 16px; max-width: 46ch; }
.notfound .recent { margin-top: 56px; }
.notfound .recent h2 { font-size: 15px; margin: 0; }
.notfound .back { margin-top: 48px; font-size: 14px; color: var(--muted); }
.notfound .back a { color: var(--muted); text-decoration: none; }
.notfound .back a:hover { color: var(--ink); }
