/* Site stylesheet (home + articles) — Anthropic-style redesign, promoted
 * from exp_claude/ on 2026-09-26. The previous design is in archive/v1/;
 * lab/ and cv.html still use styling.css.
 *
 * Token names match the live site (styling.css) so the inline <style> blocks
 * carried over from /articles/ keep resolving: --background --surface
 * --surface-raised --border --text --ink-2 --muted --accent --accent-2
 * --paper-3, plus --accent-soft and --shadow.
 *
 * Rules here deliberately use low-specificity selectors (bare elements, or at
 * most a single class) wherever an article's inline <style> also targets the
 * same thing, so the article keeps the last word — same contract the live
 * stylesheet had.
 *
 * Defaults: palette terra, theme dark, font sf (sans reading face). The font
 * switch moves --font-body and, in sf mode, the heading face (--font-display)
 * too, so every text face follows it: sans makes the whole page sans, serif
 * makes it serif (the wordmark and nav included). Mono labels and code stay mono.
 */

/* ============================ tokens ============================ */

:root {
  /* terra dark is the default (and the showcase) */
  color-scheme: dark;
  --background: #141413;
  --surface: #1D1C1A;
  --surface-raised: #272624;
  --border: #33322E;
  --text: #ECEAE2;
  --ink-2: #CECCC2;
  --muted: #A6A49A;
  --accent: #C46A4A;
  --accent-2: #D6835F;
  --accent-soft: #30211A;
  --paper-3: #201F1D;
  --shadow: 0 1px 2px rgba(0, 0, 0, .45), 0 10px 30px rgba(0, 0, 0, .30);

  /* aliases the article inline CSS may reach for */
  --ink: var(--text);
  --card-bg: var(--surface);
  --card-hover: var(--surface-raised);
  --strong-color: var(--text);

  /* ---------------- type ---------------- */
  --font-display: "Anthropic Serif", "Tiempos Headline", "Source Serif 4", Georgia, serif;
  --font-sans: "Anthropic Sans", "Styrene B", "Instrument Sans", system-ui, sans-serif;
  --font-serif: "Anthropic Serif", "Tiempos Text", "Source Serif 4", Georgia, serif;
  --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Consolas, monospace;
  --font-body: var(--font-sans);

  /* 38rem ≈ 68 characters at the 17px sans / 18px serif body size. A literal
     `68ch` cannot be used here: ch is resolved against each element's own font
     size, so an h2 at 1.6rem would get a ~880px column while a 17px paragraph
     got ~585px and the headings drifted out of the text column. */
  --measure: 38rem;
  --gut: 16px;
  --shell: 1040px;
  --shell-article: 900px;
}

/* ---------------------------- palettes ---------------------------- */

/* terra light */
:root[data-palette="terra"][data-theme="light"] {
  color-scheme: light;
  --background: #FAF9F5;
  --surface: #F0EEE6;
  --surface-raised: #E8E6DC;
  --border: #DEDCD1;
  --text: #141413;
  --ink-2: #3D3D3A;
  --muted: #7A796F;
  --accent: #9C4A2C;
  --accent-2: #7C3A22;
  --accent-soft: #EFE0D5;
  --paper-3: #EDEBE3;
  --shadow: 0 1px 2px rgba(20, 20, 19, .05), 0 10px 26px rgba(20, 20, 19, .07);
}

/* mono dark */
:root[data-palette="mono"][data-theme="dark"] {
  color-scheme: dark;
  --background: #141413;
  --surface: #1B1B1A;
  --surface-raised: #242423;
  --border: #2E2E2C;
  --text: #E6E6E3;
  --ink-2: #C9C9C5;
  --muted: #9A9A95;
  --accent: #E6E6E3;
  --accent-2: #A8A8A3;
  --accent-soft: #262625;
  --paper-3: #1F1F1E;
  --shadow: 0 1px 2px rgba(0, 0, 0, .5), 0 10px 30px rgba(0, 0, 0, .34);
}

/* mono light */
:root[data-palette="mono"][data-theme="light"] {
  color-scheme: light;
  --background: #FAFAF9;
  --surface: #F2F2F0;
  --surface-raised: #E8E8E5;
  --border: #E0E0DC;
  --text: #141413;
  --ink-2: #3A3A38;
  --muted: #75756F;
  --accent: #141413;
  --accent-2: #55554F;
  --accent-soft: #EAEAE7;
  --paper-3: #EFEFEC;
  --shadow: 0 1px 2px rgba(20, 20, 19, .05), 0 10px 26px rgba(20, 20, 19, .07);
}

/* ---------------- font switch (body face, plus the heading face in sf mode) ---------------- */
:root[data-font="serif"] { --font-body: var(--font-serif); }
:root[data-font="sf"] { --font-display: var(--font-sans); }

/* ============================ base ============================ */

*, *::before, *::after { box-sizing: border-box; }

html {
  scroll-behavior: smooth;
  scroll-padding-top: 20px;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  overflow-x: hidden;
  color: var(--text);
  background: var(--background);
  font-family: var(--font-body);
  font-size: 17px;
  font-weight: 460;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  transition: background-color .35s ease, color .35s ease;
}

:root[data-font="serif"] body { font-size: 18px; font-weight: 450; }

::selection { background: color-mix(in srgb, var(--accent) 34%, transparent); color: var(--text); }

h1, h2, h3, h4, h5, h6 {
  color: var(--text);
  font-family: var(--font-display);
  font-weight: 500;
  line-height: 1.18;
  letter-spacing: -.015em;
}

p { margin: .9em 0; }
/* bold is emphasis, not shouting: text colour, one step heavier */
strong, b { color: var(--text); font-weight: 650; }
hr { border: 0; border-top: 1px solid var(--border); margin: 2.4rem 0; }

a {
  color: var(--accent);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
  text-decoration-color: color-mix(in srgb, var(--accent) 45%, transparent);
}
a:hover { color: var(--accent-2); text-decoration-color: currentColor; }
a:focus-visible { outline: 1px solid var(--accent); outline-offset: 3px; border-radius: 2px; }

img, svg, video, canvas { max-width: 100%; height: auto; }

code, kbd, samp { font-family: var(--font-mono); font-size: .86em; font-weight: 500; }

:not(pre) > code {
  padding: .1em .38em;
  color: var(--ink-2);
  background: var(--accent-soft);
  border: 1px solid color-mix(in srgb, var(--accent) 14%, transparent);
  border-radius: 5px;
}

pre {
  overflow-x: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: .8rem;
  line-height: 1.62;
}
/* size the pre itself so line boxes follow the mono size, not the body's */
pre code { display: block; font-size: inherit; line-height: inherit; tab-size: 2; }

::placeholder { color: var(--muted); }

/* ============================ chrome: top bar ============================ */

.topbar { border-bottom: 1px solid var(--border); }

.topbar-inner {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  max-width: var(--shell);
  margin: 0 auto;
  padding: 15px var(--gut);
}

/* the wordmark follows the typeface toggle like everything else */
.wordmark {
  font-family: var(--font-body);
  font-weight: 500;
  font-size: 1.16rem;
  letter-spacing: -.015em;
  color: var(--text);
  text-decoration: none;
}
.wordmark:hover { color: var(--accent); }

.topnav {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 16px;
  font-family: var(--font-body);
  font-size: .82rem;
  font-weight: 500;
}
.topnav a {
  color: var(--muted);
  text-decoration: none;
  transition: color .15s ease;
}
.topnav a:hover, .topnav a[aria-current="page"] { color: var(--text); }

/* ============================ home: hero ============================ */

/* home masthead strip — the artwork is a 3.4:1 abstract, left unfiltered in terra */
.home-banner {
  max-width: var(--shell);
  margin: 2.2rem auto 0;
  padding: 0 var(--gut);
}
.home-banner figure {
  margin: 0;
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
}
.home-banner img {
  display: block;
  width: 100%;
  aspect-ratio: 3.4 / 1;
  object-fit: cover;
}
:root[data-palette="mono"] .home-banner img { filter: grayscale(1) contrast(1.05); }

/* hero: single column until there is room for the aside */
.hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 2.6rem;
  align-items: start;
  max-width: var(--shell);
  margin: 0 auto;
  padding: 2.6rem var(--gut) 0;
}
.hero-main { min-width: 0; }

.hero-body { max-width: 34rem; color: var(--ink-2); }
.hero-body p { margin: 0 0 1.05em; }
.hero-body p:last-child { margin-bottom: 0; }
/* the first intro paragraph is the lead */
.hero-body p:first-child { color: var(--text); }

/* ---- hero aside: ELSEWHERE / LATEST, card-free with hairline rules ---- */
.hero-aside { min-width: 0; }
.aside-block + .aside-block { margin-top: 2.4rem; }

.aside-label {
  margin: 0;
  padding-top: .72rem;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: .66rem;
  font-weight: 500;
  letter-spacing: .16em;
  text-transform: uppercase;
  border-top: 1px solid var(--border);
}

.aside-list { margin: 0; padding: 0; list-style: none; }
.aside-list a {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  padding: .66rem 0;
  color: var(--text);
  font-size: .92rem;
  font-weight: 500;
  text-decoration: none;
  border-bottom: 1px solid var(--border);
}
.aside-list a:hover { color: var(--accent); }
.aside-meta {
  flex: 0 0 auto;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: .68rem;
  font-weight: 500;
}

/* ============================ home: writing ============================ */

.writing {
  max-width: var(--shell);
  margin: 2.2rem auto 0;
  padding: 0 var(--gut);
}

.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  padding-top: 1.15rem;
  border-top: 1px solid var(--border);
}
.section-head h2 { margin: 0; font-size: 1.35rem; }
.section-head a {
  font-family: var(--font-body);
  font-size: .84rem;
  color: var(--muted);
  font-weight: 500;
  text-decoration: none;
}
.section-head a:hover { color: var(--accent); }

/* lead article: image + text side by side so it doesn't echo the masthead */
.lead-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 1.1rem;
  margin-top: 1.6rem;
  color: inherit;
  text-decoration: none;
}

.lead-card figure {
  margin: 0;
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
}
.lead-card img { display: block; width: 100%; aspect-ratio: 16 / 9; object-fit: cover; }
.lead-text { min-width: 0; }

.lead-kicker {
  margin: 0 0 .55rem;
  color: var(--accent);
  font-family: var(--font-mono);
  font-size: .66rem;
  font-weight: 500;
  letter-spacing: .16em;
  text-transform: uppercase;
}

.lead-card h3 {
  max-width: 22ch;
  margin: 0 0 .7rem;
  font-weight: 500;
  font-size: clamp(1.4rem, 2.6vw, 1.9rem);
  line-height: 1.16;
  text-wrap: balance;
}
.lead-card:hover h3, .lead-card:focus-visible h3 { color: var(--accent); }

.lead-dek { margin: 0 0 .9rem; color: var(--ink-2); font-size: .95rem; font-weight: 500; line-height: 1.55; max-width: 34rem; }

.date {
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: .71rem;
  font-weight: 500;
  letter-spacing: .02em;
}

.row-list { margin-top: 1.5rem; }

.row {
  display: flex;
  align-items: center;
  gap: 1.4rem;
  padding: 1.15rem 0;
  border-top: 1px solid var(--border);
  color: inherit;
  text-decoration: none;
}
.row:last-child { border-bottom: 1px solid var(--border); }
.row-main { flex: 1 1 auto; min-width: 0; }
.row h3 {
  margin: 0 0 .4rem;
  font-weight: 500;
  font-size: 1.14rem;
  line-height: 1.22;
}
.row img {
  flex: 0 0 auto;
  width: 118px;
  height: 76px;
  object-fit: cover;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
}
.row:hover h3, .row:focus-visible h3 { color: var(--accent); }

/* ============================ footer ============================ */

/* hairline aligned with the content edges, less dead space */
.site-footer {
  max-width: var(--shell);
  margin: 4.5rem auto 0;
  padding: 0 var(--gut) 5.5rem;
  border-top: 0;
}

.footer-cols {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 1.4rem 2rem;
  align-items: center;
  padding-top: 2rem;
  border-top: 1px solid var(--border);
}
.footer-brand .wordmark { font-size: 1.1rem; }

.footer-links {
  display: flex;
  flex-wrap: wrap;
  gap: .35rem 1.3rem;
  font-family: var(--font-body);
  font-size: .82rem;
  font-weight: 500;
}
.footer-links a { color: var(--muted); text-decoration: none; }
.footer-links a:hover { color: var(--text); }

.footer-meta { margin-top: 2.2rem; color: var(--muted); font-size: .85rem; }
.footer-meta p { margin: .3rem 0; }

.updated {
  margin: 1.4rem 0 0;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: .69rem;
  font-weight: 500;
  letter-spacing: .03em;
}

/* ============================ controls ============================ */

.controls {
  position: fixed;
  z-index: 80;
  right: calc(var(--gut) + env(safe-area-inset-right, 0px));
  bottom: calc(16px + env(safe-area-inset-bottom, 0px));
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 4px;
  background: color-mix(in srgb, var(--surface) 90%, transparent);
  border: 1px solid var(--border);
  border-radius: 999px;
  box-shadow: var(--shadow);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
}

.controls button {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  padding: 0;
  color: var(--muted);
  background: none;
  border: 0;
  border-radius: 50%;
  cursor: pointer;
  transition: color .15s ease, background-color .15s ease;
}
.controls button:hover { color: var(--text); background: var(--surface-raised); }
.controls button[aria-pressed="true"] { color: var(--accent); }
.controls button:focus-visible { outline: 1px solid var(--accent); outline-offset: 2px; }

.controls svg {
  display: block;
  width: 17px;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.55;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.controls svg .fill { fill: currentColor; stroke: none; }
.controls .btn-font svg { fill: currentColor; stroke: none; width: 19px; height: 19px; }

.progress {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 90;
  width: 0;
  height: 2px;
  background: var(--accent);
  transition: width .1s linear;
}

.to-top {
  position: fixed;
  z-index: 79;
  right: calc(var(--gut) + env(safe-area-inset-right, 0px));
  bottom: calc(70px + env(safe-area-inset-bottom, 0px));
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  padding: 0;
  color: var(--text);
  background: color-mix(in srgb, var(--surface) 90%, transparent);
  border: 1px solid var(--border);
  border-radius: 50%;
  box-shadow: var(--shadow);
  cursor: pointer;
  opacity: 0;
  visibility: hidden;
  transform: translateY(6px);
  transition: opacity .25s ease, transform .25s ease, visibility .25s;
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
}
.to-top.is-shown { opacity: 1; visibility: visible; transform: none; }
.to-top:hover { border-color: var(--accent); }
.to-top svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }

/* ---------------------------- copy button ---------------------------- */

.code-block { position: relative; margin: 1.5rem 0; }

/* code sits on the measure with the prose; only figures bleed to the shell */
.reading > pre, .reading > .code-block { max-width: var(--measure); margin-inline: auto; }
.code-block pre { margin: 0; padding: 1.2rem 3.7rem 1.15rem 1.2rem; }

.code-copy {
  position: absolute;
  top: 10px;
  right: 10px;
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  padding: 0;
  color: var(--muted);
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  transition: color .15s ease, border-color .15s ease, background-color .15s ease;
}
.code-copy span {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}
.code-copy svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.code-copy:hover { color: var(--text); border-color: var(--accent); }
.code-copy:focus-visible { outline: 1px solid var(--accent); outline-offset: 3px; }
.code-copy.is-copied { color: var(--accent); border-color: var(--accent); }

/* ============================ reveal ============================ */

.reveal {
  opacity: 0;
  transform: translateY(10px);
  transition: opacity .55s ease var(--reveal-delay, 0ms), transform .55s ease var(--reveal-delay, 0ms);
}
.reveal.is-visible { opacity: 1; transform: none; }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .reveal { opacity: 1; transform: none; transition: none; }
  .to-top, .progress { transition: none; }
  body, .lead-card, .row { transition: none; }
}

/* ============================ article pages ============================ */

.page-article {
  max-width: var(--shell-article);
  margin: 0 auto;
  padding: 0 var(--gut) 2rem;
}

/* header shares the banner's left edge; body keeps its narrower measure */
.article-head { max-width: none; margin: 3.6rem 0 2.2rem; }
.article-head h1 {
  margin: 0 0 .9rem;
  font-weight: 500;
  font-size: clamp(2rem, 4.6vw, 3.15rem);
  line-height: 1.08;
  letter-spacing: -.02em;
  text-wrap: balance;
}
/* title, then the date */
.article-date {
  margin: 0;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: .76rem;
  font-weight: 500;
  letter-spacing: .03em;
}

/* reading column: text sits on the measure, figures/tables/code get the shell */
.reading > :where(p, ul, ol, blockquote, h2, h3, h4, h5, h6, dl, section.footnotes) {
  max-width: var(--measure);
  margin-inline: auto;
}
/* article text spans the full banner width, starting at the header's left edge;
   the second rule must stay after the first so wide blocks stay inside it */
.page-article .reading > * { margin-left: 0; margin-right: auto; max-width: none; }
.page-article .reading > :is(table, pre, .code-block, figure) { max-width: 100%; }

.reading h2 {
  margin: 3rem auto 1rem;
  font-weight: 600;
  font-size: 1.6rem;
  line-height: 1.22;
}
/* sub-heads: serif at a size that holds its own against the body */
.reading h3 { margin: 2.5rem auto .7rem; font-weight: 600; font-size: 1.38rem; letter-spacing: -.012em; }
.reading h4 { margin: 2.2rem auto .6rem; font-family: var(--font-display); font-weight: 600; font-size: 1.2rem; letter-spacing: -.01em; }
.reading p, .reading li { color: var(--ink-2); }
.reading p { margin: .9em auto; }
.reading ul, .reading ol { padding-left: 1.35em; }
.reading li { margin: .45em 0; }
.reading li::marker { color: var(--muted); }
.reading li > p { margin: .3em 0; }

.reading blockquote {
  margin: 1.7rem auto;
  padding: .15rem 0 .15rem 1.2rem;
  color: var(--ink-2);
  border-left: 2px solid var(--accent);
}
.reading blockquote p { margin: .55em 0; }

.reading figure { margin: 2rem 0; }
.reading figure img {
  display: block;
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
}
figcaption {
  margin-top: .7rem;
  color: var(--muted);
  font-size: .78rem;
  font-weight: 500;
  line-height: 1.5;
  text-align: center;
}
/* multi-line benchmark captions read badly centred; the article's own inline
   sheet already left-aligns them, this just makes sure of it */
.benchmark-chart figcaption { text-align: left; }
/* the article sheet squares its plot corners and drops the border; the redesign
   rounds figures and hairline-rings them so the dark profiler captures read as
   a figure rather than a smudge in dark modes */
.reading figure.benchmark-chart img {
  border-radius: 10px;
  box-shadow: 0 0 0 1px var(--border);
}

/* tables: hairline rows, header in mono small caps on --paper-3.
   Kept as bare element selectors so the article's inline `thead th` wins. */
table {
  display: block;
  width: max-content;
  max-width: 100%;
  overflow-x: auto;
  border-collapse: collapse;
  margin: 1.7rem auto 2rem;
  font-size: .87rem;
  line-height: 1.55;
}
th, td {
  padding: .58rem .9rem;
  text-align: left;
  vertical-align: top;
  border-bottom: 1px solid var(--border);
}
thead th {
  color: var(--muted);
  background: var(--paper-3);
  font-family: var(--font-mono);
  font-size: .68rem;
  font-weight: 500;
  letter-spacing: .08em;
  text-transform: uppercase;
  white-space: nowrap;
}
tbody tr:last-child td { border-bottom: 0; }
tbody td:first-child { white-space: nowrap; }

/* footnotes */
.footnote-ref { color: var(--accent); text-decoration: none; }
.footnote-ref sup { font-size: .72em; line-height: 0; padding: 0 .12em; }
section.footnotes {
  margin-top: 3rem;
  padding-top: 1.4rem;
  color: var(--ink-2);
  font-size: .88rem;
  line-height: 1.62;
  border-top: 1px solid var(--border);
}
section.footnotes > hr { display: none; }
section.footnotes ol { padding-left: 1.6em; }
section.footnotes li { margin: .6em 0; }
.footnote-back { margin-left: .35em; color: var(--muted); text-decoration: none; }
.footnote-ref, li[id^="fn"] { scroll-margin-top: 24px; }

/* banner */
.article-banner {
  position: relative;
  margin: 0 0 2.4rem;
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
}
.article-banner img {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 2.4 / 1;
  object-fit: cover;
  border: 0;
  border-radius: 0;
}

/* ---------------------------- image tuning ----------------------------
   The banner artworks are warm sepia abstracts; the benchmark plots are
   white-ground PNGs; the profiler captures are dark-ground PNGs. */

/* terra dark: settle the artwork into the page */
:root[data-palette="terra"][data-theme="dark"] .article-banner img,
:root[data-palette="terra"][data-theme="dark"] .lead-card img {
  filter: brightness(.9) saturate(.94);
}
/* terra light: warm the artwork into the ivory paper */
:root[data-palette="terra"][data-theme="light"] .article-banner img,
:root[data-palette="terra"][data-theme="light"] .lead-card img {
  filter: sepia(.16) saturate(1.06) brightness(1.01);
}
/* mono: no hue at all */
:root[data-palette="mono"] .article-banner img,
:root[data-palette="mono"] .lead-card img,
:root[data-palette="mono"] .row img {
  filter: grayscale(1) contrast(1.04);
}
:root[data-palette="mono"][data-theme="dark"] .article-banner img,
:root[data-palette="mono"][data-theme="dark"] .lead-card img,
:root[data-palette="mono"][data-theme="dark"] .row img {
  filter: grayscale(1) brightness(.9) contrast(1.06);
}

/* drawn artwork ships as a light and a dark variant; show the one for the theme */
:root[data-theme="dark"] img.art-light,
:root:not([data-theme="dark"]) img.art-dark { display: none !important; }
img.art-light, img.art-dark { filter: none !important; }
:root[data-palette="mono"] img.art-light,
:root[data-palette="mono"] img.art-dark { filter: grayscale(1) !important; }

/* ==================== shira: css-grid pipeline diagrams ==================== */
/* Ported from the live styling.css; the markup is <figure class="diagram">
   plus .dg-* nodes, no images. */

figure.diagram {
  margin: 2rem 0;
  padding: 1.15rem;
  overflow-x: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
}

.dg { display: grid; gap: .7rem 1rem; align-items: center; }

.dg-node {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: .55rem .8rem;
  text-align: center;
  color: var(--text);
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: 7px;
  font-family: var(--font-body);
  font-size: .88rem;
  line-height: 1.4;
}
.dg-node .dg-sub { display: block; color: var(--muted); font-size: .72rem; line-height: 1.35; }
.dg-node.is-hot {
  background: color-mix(in srgb, var(--accent) 12%, var(--surface-raised));
  border-color: color-mix(in srgb, var(--accent) 55%, var(--border));
}

.dg-arrow, .dg-down { justify-self: center; color: var(--muted); font-size: 1.05rem; line-height: 1; }
.dg-arrow { white-space: nowrap; }
.dg-arrow::before { content: attr(data-h); }

.dg-or { align-self: center; color: var(--accent); font-size: .72rem; letter-spacing: .16em; text-transform: uppercase; }

.dg-pipeline {
  grid-template-columns: minmax(8.5rem, 1.15fr) auto minmax(7.5rem, 1fr) auto minmax(8.5rem, 1.1fr);
  grid-template-areas:
    "q a1 clap a2 emb"
    ". .  .    .  d1"
    "d a3 enc  a4 s"
    ". .  .    .  d2"
    ". .  .    .  o";
}
.dg-pipeline .gp-q { display: flex; flex-direction: column; gap: .5rem; }
.dg-pipeline .gp-o { justify-self: center; }
:where(.dg-pipeline) .ga-q { grid-area: q; }
:where(.dg-pipeline) .ga-a1 { grid-area: a1; }
:where(.dg-pipeline) .ga-clap { grid-area: clap; }
:where(.dg-pipeline) .ga-a2 { grid-area: a2; }
:where(.dg-pipeline) .ga-emb { grid-area: emb; }
:where(.dg-pipeline) .ga-d1 { grid-area: d1; }
:where(.dg-pipeline) .ga-d { grid-area: d; }
:where(.dg-pipeline) .ga-a3 { grid-area: a3; }
:where(.dg-pipeline) .ga-enc { grid-area: enc; }
:where(.dg-pipeline) .ga-a4 { grid-area: a4; }
:where(.dg-pipeline) .ga-s { grid-area: s; }
:where(.dg-pipeline) .ga-d2 { grid-area: d2; }
:where(.dg-pipeline) .ga-o { grid-area: o; }

.dg-clap { grid-template-columns: 1fr 1fr; }
.dg-col { display: flex; flex-direction: column; gap: .55rem; }
.dg-col > .dg-node { width: 100%; }
.dg-split { display: grid; grid-template-columns: 1fr 1fr; gap: .55rem; }
.dg-split .dg-node { font-size: .78rem; }
.dg-varrow { align-self: center; color: var(--muted); font-size: .95rem; line-height: 1; }
.dg-joint {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 1.4rem;
  padding-top: 1.1rem;
  border-top: 1px dashed var(--border);
}
.dg-joint-title { color: var(--muted); font-size: .72rem; letter-spacing: .16em; text-transform: uppercase; }
.dg-mx { display: grid; grid-template-columns: auto repeat(5, 1fr); gap: 3px; width: min(250px, 100%); }
.dg-mx b { align-self: center; color: var(--text); font-size: .66rem; font-weight: 650; text-align: center; }
.dg-mx i { aspect-ratio: 1; display: block; background: var(--surface-raised); border: 1px solid var(--border); border-radius: 3px; }
.dg-mx i.hot { background: color-mix(in srgb, var(--accent) 42%, transparent); border-color: var(--accent); }

/* ============================ articles index ============================ */

.art-index { max-width: var(--shell); margin: 0 auto; padding: 4.4rem var(--gut) 2rem; }
.art-index h1 {
  margin: 0 0 2.6rem;
  font-weight: 400;
  font-size: clamp(2rem, 5vw, 2.9rem);
  letter-spacing: -.02em;
}

.art-row {
  display: grid;
  grid-template-columns: 11rem minmax(0, 1fr);
  gap: 1.6rem;
  align-items: baseline;
  padding: 1.5rem 0;
  border-top: 1px solid var(--border);
  color: inherit;
  text-decoration: none;
}
.art-row:last-of-type { border-bottom: 1px solid var(--border); }
.art-row h2 {
  margin: 0;
  font-weight: 500;
  font-size: clamp(1.15rem, 2.2vw, 1.42rem);
  line-height: 1.22;
}
.art-row:hover h2, .art-row:focus-visible h2 { color: var(--accent); }

/* ============================ font toggle: headings ============================ */
/* In sf mode the headings follow the body's sans face and step one weight
   heavier; kept after the section headings above so the tie-goes-to-later
   cascade keeps them at 600 in sf mode. */

:root[data-font="sf"] :is(h1, h2, h3, h4) { font-weight: 600; letter-spacing: -.02em; }

/* article title and section heads follow the toggle too */
:root[data-font="sf"] .article-head h1,
:root[data-font="sf"] .reading :is(h2, h3, h4) {
  font-family: var(--font-sans);
  letter-spacing: -.02em;
}
:root[data-font="sf"] .article-head h1 { font-weight: 600; line-height: 1.06; }

/* ============================ responsive ============================ */

@media (max-width: 620px) {
  :root { --gut: 16px; }
  body { font-size: 16px; }
  :root[data-font="serif"] body { font-size: 17px; }

  .home-banner { margin-top: 1.2rem; }
  .home-banner figure { border-radius: 12px; }
  .home-banner img { aspect-ratio: 2 / 1; }
  .hero { padding-top: 1.9rem; }
  .hero h1 { font-size: clamp(2.1rem, 9vw, 2.6rem); }

  .row { gap: 1rem; }
  .row img { width: 82px; height: 58px; }

  .footer-cols { grid-template-columns: 1fr; gap: 1.5rem; }

  .article-head { margin: 2.2rem 0 1.6rem; }
  .article-banner { margin-bottom: 1.9rem; border-radius: 12px; }
  .article-banner img { aspect-ratio: 16 / 9; object-position: center; }
  .reading figure.benchmark-chart { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .reading figure.benchmark-chart img { min-width: 0; }

  .art-index { padding-top: 3.2rem; }
  .art-row { grid-template-columns: 1fr; gap: .4rem; }

  /* give code a header strip so the copy button never sits on the first line */
  .code-block pre { padding: 2.5rem 1rem 1rem; }
  .code-copy { top: .45rem; right: .45rem; }

  :not(pre) > code, a { overflow-wrap: anywhere; }
}

@media (max-width: 760px) {
  .dg-pipeline, .dg-clap { grid-template-columns: minmax(0, 1fr); }
  .dg-pipeline { grid-template-areas: none; }
  .dg-pipeline > * { grid-area: auto; }
  .dg-clap > * { grid-column: auto; }
  .dg-arrow { font-size: .95rem; }
  .dg-arrow::before { content: attr(data-v); }
  .dg-pipeline .ga-d1, .dg-pipeline .ga-d2 { display: none; }
}

@media (min-width: 760px) {
  .lead-card { grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 2.4rem; align-items: center; }
}

/* on narrow screens the aside only repeats the links in the last intro line */
@media (max-width: 899px) { .hero-aside { display: none; } }

@media (min-width: 900px) {
  .hero { grid-template-columns: minmax(0, 1fr) 15rem; gap: 5rem; }
  .hero-aside { padding-top: .45rem; }
}
