/*
 * shwetalmehta.com — shared design tokens and components.
 *
 * One stylesheet for every page: the front door, the landing pages, the
 * project pages, the blog and the apps gallery. The build (sitekit.py) gives
 * every page the same top bar and footer; the classes here are the whole
 * visual vocabulary.
 *
 * 2026-09-27 redesign: a clean one-screen homepage, everything else on its
 * own linked page, and short visual project pages whose graphics are
 * hand-written SVG inlined at build time so they follow light and dark mode.
 * The .dg-* block at the end is the diagram component kit those SVGs use.
 */

:root {
  --paper: #ffffff;
  --paper-2: #f3f6fa;
  --card: #ffffff;
  --ink: #0f1a2b;
  --ink-2: #364357;
  --ink-3: #5f6d82;
  --rule: #dfe5ee;
  --rule-2: #c9d2de;
  --panel: #eef2f7;
  --brass: #1d5bd6;
  --brass-soft: #6f9bff;
  --brass-tint: #e4edff;
  --ok: #2f7d4a;
  --warn: #9b630d;
  --shadow: 0 1px 2px rgb(27 29 34 / 4%), 0 8px 24px -12px rgb(27 29 34 / 18%);
  --shadow-lift: 0 2px 4px rgb(27 29 34 / 5%), 0 18px 40px -16px rgb(27 29 34 / 28%);
  --radius: 14px;
  --band: #f3f6fa;
  --accent-deep: #143d99;
  --amber: #c9701a;
  --wrap: 1040px;
  --serif: "Instrument Serif", Georgia, "Times New Roman", serif;
  --sans: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", Helvetica, Arial, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --gutter: clamp(16px, 4vw, 40px);
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #0e131b;
    --paper-2: #141b25;
    --card: #172030;
    --ink: #e8edf5;
    --ink-2: #b7c2d2;
    --ink-3: #8593a8;
    --rule: #223046;
    --rule-2: #2f3f58;
    --panel: #1a2333;
    --brass: #7eaaff;
    --brass-soft: #3f6fd1;
    --brass-tint: #1a2a48;
    --ok: #6cc48b;
    --warn: #e0a83c;
    --band: #141b25;
    --accent-deep: #9dbcff;
    --amber: #e8a14a;
    --shadow: 0 1px 2px rgb(0 0 0 / 30%), 0 8px 24px -12px rgb(0 0 0 / 50%);
    --shadow-lift: 0 2px 4px rgb(0 0 0 / 35%), 0 18px 40px -16px rgb(0 0 0 / 65%);
  }
}

:root[data-theme="dark"] {
  --paper: #0e131b;
  --paper-2: #141b25;
  --card: #172030;
  --ink: #e8edf5;
  --ink-2: #b7c2d2;
  --ink-3: #8593a8;
  --rule: #223046;
  --rule-2: #2f3f58;
  --panel: #1a2333;
  --brass: #7eaaff;
  --brass-soft: #3f6fd1;
  --brass-tint: #1a2a48;
  --ok: #6cc48b;
  --warn: #e0a83c;
  --band: #141b25;
  --accent-deep: #9dbcff;
  --amber: #e8a14a;
  --shadow: 0 1px 2px rgb(0 0 0 / 30%), 0 8px 24px -12px rgb(0 0 0 / 50%);
  --shadow-lift: 0 2px 4px rgb(0 0 0 / 35%), 0 18px 40px -16px rgb(0 0 0 / 65%);
}

* { box-sizing: border-box; }
html { height: 100%; scroll-behavior: smooth; scroll-padding-top: 72px; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 17px;
  line-height: 1.6;
  padding-inline: var(--gutter);
  padding-block: 0 56px;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
}

a {
  color: inherit;
  text-decoration: none;
  border-bottom: 1px solid var(--brass-soft);
  transition: border-color .15s, color .15s;
}
a:hover { border-bottom-color: var(--brass); color: var(--brass); }
a:focus-visible { outline: 2px solid var(--brass); outline-offset: 3px; border-radius: 2px; }

img { max-width: 100%; }

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

::selection { background: var(--brass-tint); color: var(--ink); }

/* ---------------------------------------------------------------- utilities */

.eyebrow {
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--brass);
  margin: 0 0 10px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 10px 20px;
  border: 1px solid var(--rule-2);
  border-radius: 999px;
  background: var(--card);
  color: var(--ink);
  font-size: 15px;
  font-weight: 500;
  line-height: 1;
  box-shadow: var(--shadow);
  transition: transform .15s, box-shadow .15s, border-color .15s, background .15s, color .15s;
}
.btn:hover { transform: translateY(-1px); box-shadow: var(--shadow-lift); border-color: var(--brass); color: var(--brass); }
.btn.primary { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.btn.primary:hover { background: var(--brass); border-color: var(--brass); color: #fff; }

.dot { color: var(--rule-2); padding-inline: 2px; }

/* ------------------------------------------------------------------ top bar */

.sitenav {
  position: sticky;
  top: 0;
  z-index: 20;
  margin-inline: calc(-1 * var(--gutter));
  padding-inline: var(--gutter);
  background: color-mix(in srgb, var(--paper) 92%, transparent);
  backdrop-filter: saturate(160%) blur(12px);
  -webkit-backdrop-filter: saturate(160%) blur(12px);
  border-bottom: 1px solid var(--rule);
}

.navwrap {
  max-width: var(--wrap);
  margin-inline: auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  flex-wrap: wrap;
  padding-block: 11px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  border-bottom: 0;
  font-family: var(--serif);
  font-size: 19px;
  letter-spacing: -.005em;
  color: var(--ink);
}
.brand img { border-radius: 50%; display: block; width: 28px; height: 28px; object-fit: cover; }
.brand:hover { border-bottom: 0; color: var(--brass); }

.navlinks {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px 22px;
  font-size: 14.5px;
}
.navlinks a { border-bottom: 2px solid transparent; color: var(--ink-2); padding: 4px 0 2px; }
.navlinks a:hover { color: var(--ink); border-bottom-color: var(--brass); }
.navlinks a.here { color: var(--brass); font-weight: 500; border-bottom-color: var(--brass); }
.navlinks a.pill {
  border: 1px solid var(--ink);
  border-radius: 999px;
  padding: 7px 16px;
  color: var(--paper);
  font-weight: 500;
  background: var(--ink);
  margin-left: 4px;
}
.navlinks a.pill:hover, .navlinks a.pill.here { background: var(--brass); border-color: var(--brass); color: #fff; }

.menu-btn {
  display: none;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  padding: 6px 12px;
  border: 1px solid var(--rule-2);
  border-radius: 999px;
  background: var(--card);
  color: var(--ink);
  font: 500 14px var(--sans);
  cursor: pointer;
}
.menu-ic { display: inline-block; width: 16px; height: 2px; background: currentColor; box-shadow: 0 -5px 0 currentColor, 0 5px 0 currentColor; }
.menu-btn[aria-expanded="true"] .menu-ic { box-shadow: 0 -5px 0 currentColor; }

@media (max-width: 720px) {
  .menu-btn { display: inline-flex; }
  .navlinks {
    display: none;
    flex-direction: column;
    align-items: stretch;
    width: 100%;
    gap: 0;
    padding: 6px 0 12px;
    font-size: 16px;
  }
  .navlinks.open { display: flex; }
  .navlinks a { padding: 10px 4px; border-bottom: 1px solid var(--rule); }
  .navlinks a.here { border-bottom-color: var(--rule); }
  .navlinks a.pill { margin: 12px 0 0; text-align: center; padding: 10px 16px; border-radius: 999px; }
}

/* ----------------------------------------------------------------- homepage */

.home-hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(220px, 300px);
  gap: 28px clamp(28px, 6vw, 64px);
  align-items: center;
  padding-block: clamp(28px, 4.5vw, 48px) 4px;
}

.home-hero h1 {
  font-family: var(--serif);
  font-weight: 400;
  font-size: clamp(36px, 5.2vw, 56px);
  line-height: 1.06;
  letter-spacing: -.015em;
  margin: 0 0 18px;
  text-wrap: balance;
}
.home-hero h1 em { font-style: italic; color: var(--brass); }

.home-hero .lede {
  font-size: clamp(17px, 1.9vw, 18.5px);
  line-height: 1.6;
  color: var(--ink-2);
  max-width: 56ch;
  margin: 0;
  text-wrap: pretty;
}

.portrait {
  margin: 0;
  position: relative;
  justify-self: end;
  width: 100%;
  max-width: 300px;
}
.portrait img {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 4 / 5;
  object-fit: cover;
  border-radius: 22px;
  box-shadow: var(--shadow-lift);
  transform: rotate(1.5deg);
  transition: transform .4s cubic-bezier(.2,.7,.2,1);
}
.portrait:hover img { transform: rotate(0deg) scale(1.01); }
.portrait::before {
  content: "";
  position: absolute;
  inset: 10px -10px auto 10px;
  aspect-ratio: 4 / 5;
  border-radius: 22px;
  background: var(--brass-tint);
  transform: rotate(-2deg);
  z-index: -1;
}
.portrait figcaption {
  margin-top: 14px;
  font-family: var(--serif);
  font-style: italic;
  font-size: 17px;
  color: var(--ink-3);
  text-align: center;
}

.home-numbers {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px 24px;
  margin-top: 26px;
  padding: 24px 0 4px;
  border-top: 2px solid var(--rule-2);
}
.bignum b {
  display: block;
  font-family: var(--serif);
  font-weight: 400;
  font-size: clamp(34px, 4vw, 46px);
  line-height: 1;
  color: var(--amber);
  letter-spacing: -.01em;
}
.bignum span {
  display: block;
  margin-top: 8px;
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--ink-3);
  line-height: 1.45;
}

.home-cta { padding: 16px 0 36px; }
.looking { margin: 0 0 14px; font-size: 16px; color: var(--ink-2); max-width: 70ch; }
.looking::before { content: ""; display: inline-block; width: 10px; height: 10px; border-radius: 50%; background: var(--ok); margin-right: 10px; vertical-align: 1px; }
.cta { display: flex; flex-wrap: wrap; gap: 12px; }

.tiles {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 20px;
  padding: 36px 0 8px;
  border-top: 2px solid var(--rule-2);
}
.tile, .card {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--rule-2);
  border-bottom: 1px solid var(--rule-2);
  border-radius: var(--radius);
  background: var(--card);
  overflow: hidden;
  box-shadow: var(--shadow);
  color: inherit;
  transition: transform .2s, box-shadow .2s, border-color .2s;
}
.tile:hover, .card:hover { transform: translateY(-3px); box-shadow: var(--shadow-lift); border-color: var(--brass-soft); color: inherit; }
.tile:hover h2, .card:hover h2 { color: var(--brass); }
.tile-art, .card-art { background: var(--paper-2); border-bottom: 1px solid var(--rule); aspect-ratio: 1200 / 750; line-height: 0; }
.tile-art svg, .card-art svg { width: 100%; height: 100%; display: block; }
.tile h2 { font: 600 16.5px/1.3 var(--sans); margin: 14px 16px 0; letter-spacing: 0; transition: color .15s; }
.tile p { margin: 5px 16px 16px; font-size: 14.5px; line-height: 1.5; color: var(--ink-2); }

@media (max-width: 960px) { .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 720px) {
  .home-hero { grid-template-columns: 1fr; gap: 24px; padding-block: 24px 4px; }
  .portrait { justify-self: start; max-width: 190px; order: -1; }
  .portrait figcaption { text-align: left; }
  .home-numbers { grid-template-columns: 1fr; gap: 14px; }
}
@media (max-width: 440px) { .tiles { grid-template-columns: 1fr; } }

/* -------------------------------------------------------------- page heads */

.page-head { padding: 34px 0 22px; }
h1 {
  font-family: var(--serif);
  font-weight: 400;
  font-size: clamp(38px, 6vw, 56px);
  line-height: 1.04;
  margin: 0 0 14px;
  letter-spacing: -.01em;
  text-wrap: balance;
}
.lede {
  font-size: 18.5px;
  color: var(--ink-2);
  max-width: 62ch;
  margin: 0 0 8px;
  text-wrap: pretty;
}
.lede--long { max-width: 74ch; font-size: 17.5px; }

h2 {
  font-family: var(--serif);
  font-weight: 400;
  font-size: clamp(28px, 4vw, 34px);
  line-height: 1.1;
  margin: 0 0 8px;
  letter-spacing: -.01em;
  color: var(--ink);
}
h3 { font-family: var(--serif); font-weight: 400; font-size: 22px; margin: 0 0 4px; }

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

.cards {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 26px;
  margin: 10px 0 8px;
}
.card h2 { font: 600 20px/1.3 var(--sans); margin: 16px 20px 0; letter-spacing: 0; transition: color .15s; }
.card p { margin: 6px 20px 0; font-size: 15.5px; line-height: 1.5; color: var(--ink-2); }
.card > :last-child { margin-bottom: 20px; }

.chips { list-style: none; display: flex; flex-wrap: wrap; gap: 8px; margin: 14px 20px 0; padding: 0; }
.chips li {
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: .02em;
  padding: 5px 10px;
  border-radius: 999px;
  background: var(--brass-tint);
  color: var(--accent-deep);
  line-height: 1.4;
}
.chips-cap { margin: 22px 0 34px; gap: 10px; }
.chips-cap li { font-family: var(--sans); font-size: 14.5px; font-weight: 500; padding: 8px 14px; letter-spacing: 0; }

@media (max-width: 640px) { .cards { grid-template-columns: 1fr; } }

/* ---------------------------------------------------------- hero graphics */

.hero-art { margin: 10px 0 26px; }
.hero-art .dg-wrap {
  border: 1px solid var(--rule-2);
  border-radius: var(--radius);
  background: var(--paper);
  padding: 10px;
  overflow: hidden;
}
.hero-art figcaption { font-size: 14px; color: var(--ink-3); margin-top: 10px; max-width: 76ch; }
.hero-art--wide { margin-top: 18px; }

.dg-wrap svg { width: 100%; height: auto; display: block; }
.dg-mobile { display: none; }
@media (max-width: 640px) {
  .dg-desktop { display: none; }
  .dg-mobile { display: block; }
}

/* --------------------------------------------------------------------- apps */

.apps { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 34px 28px; margin: 14px 0 8px; }
.app { display: flex; flex-direction: column; }
.shot-frame {
  display: block;
  position: relative;
  border: 1px solid var(--rule-2);
  border-radius: 12px;
  overflow: hidden;
  background: var(--panel);
  box-shadow: var(--shadow);
  padding-top: 26px;
  line-height: 0;
  transition: transform .25s cubic-bezier(.2,.7,.2,1), box-shadow .25s, border-color .2s;
}
.shot-frame:hover { transform: translateY(-3px); box-shadow: var(--shadow-lift); border-color: var(--brass-soft); }
.shot-frame::before {
  content: "";
  position: absolute; top: 0; left: 0; right: 0; height: 26px;
  background: var(--paper-2);
  border-bottom: 1px solid var(--rule);
}
.shot-frame::after {
  content: "";
  position: absolute; top: 9px; left: 12px; width: 34px; height: 8px;
  background:
    radial-gradient(circle at 4px 4px, var(--rule-2) 3.5px, transparent 4px),
    radial-gradient(circle at 17px 4px, var(--rule-2) 3.5px, transparent 4px),
    radial-gradient(circle at 30px 4px, var(--rule-2) 3.5px, transparent 4px);
}
.shot-frame img { display: block; width: 100%; height: auto; }
.app h2 { font: 600 20px/1.3 var(--sans); margin: 16px 0 0; letter-spacing: 0; }
.app p { margin: 6px 0 0; color: var(--ink-2); font-size: 15.5px; }
.app .app-links { display: flex; gap: 10px; margin-top: 14px; }
.app .app-links .btn { min-height: 40px; padding: 8px 18px; font-size: 14px; }

@media (max-width: 640px) { .apps { grid-template-columns: 1fr; } }

/* --------------------------------------------------------------------- blog */

.posts { list-style: none; margin: 10px 0 0; padding: 0; }
.posts li { border-top: 1px solid var(--rule-2); }
.posts li:last-child { border-bottom: 1px solid var(--rule-2); }
.post-row {
  display: grid;
  grid-template-columns: 11em minmax(0, 1fr) auto;
  gap: 6px 24px;
  align-items: baseline;
  padding: 24px 8px;
  margin-inline: -8px;
  border-bottom: 0;
  border-radius: 10px;
  color: inherit;
  transition: background .15s;
}
.post-row:hover { background: var(--brass-tint); color: inherit; }
.post-date, .post-read { font-family: var(--mono); font-size: 12.5px; color: var(--ink-3); white-space: nowrap; }
.post-row h2 { font-size: 27px; line-height: 1.15; margin: 0 0 6px; text-wrap: balance; transition: color .15s; }
.post-row:hover h2 { color: var(--brass); }
.post-row p { margin: 0; color: var(--ink-2); font-size: 15.5px; }
@media (max-width: 640px) {
  .post-row { grid-template-columns: minmax(0, 1fr); }
  .post-read { grid-row: 1; }
}

/* -------------------------------------------------------------------- about */

.about-block { padding: 26px 0 8px; }
.about-block h2 { margin-bottom: 16px; }
.tenets { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.tenet { padding: 20px 22px; border: 1px solid var(--rule-2); border-left: 4px solid var(--brass); border-radius: 0 var(--radius) var(--radius) 0; background: var(--card); }
.tenet h3 { font-size: 24px; line-height: 1.2; margin: 0 0 8px; }
.tenet p { margin: 0; color: var(--ink-2); font-size: 15.5px; }
.dotted { margin: 0; color: var(--ink-2); max-width: 80ch; }
@media (max-width: 720px) { .tenets { grid-template-columns: 1fr; } }

/* ------------------------------------------------------------------ contact */

.contact-block { padding: 8px 0 20px; }
.big-mail { margin: 8px 0 18px; }
.big-mail a {
  font-family: var(--serif);
  font-size: clamp(28px, 5.4vw, 52px);
  line-height: 1.1;
  border-bottom: 2px solid var(--brass-soft);
  word-break: break-all;
}
.contact-lines { margin: 0; color: var(--ink-2); font-size: 17px; }

/* ------------------------------------------------------------- project page */

.crumb { padding: 22px 0 0; font-family: var(--mono); font-size: 13px; }
.crumb a { border-bottom-color: transparent; color: var(--brass); }
.crumb a:hover { border-bottom-color: var(--brass); }

.proj h1 { margin: 16px 0 20px; font-size: clamp(34px, 5.4vw, 50px); max-width: 24em; }
.results {
  list-style: none;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px 20px;
  margin: 0 0 8px;
  padding: 22px 0;
  border-top: 2px solid var(--rule-2);
  border-bottom: 2px solid var(--rule-2);
}
.results b { display: block; font-family: var(--serif); font-weight: 400; font-size: clamp(30px, 3.6vw, 42px); line-height: 1; color: var(--amber); white-space: nowrap; }
.results span { display: block; margin-top: 6px; font-size: 14.5px; color: var(--ink-2); line-height: 1.4; }
.proj section { max-width: 40em; }
.proj section h2 { font-size: 28px; margin: 30px 0 8px; }
.proj section p { margin: 0 0 14px; color: var(--ink-2); }
.proj section ul { margin: 0 0 14px; padding-left: 20px; color: var(--ink-2); }
.proj section li { margin-bottom: 8px; }
.recognition { margin: 24px 0 0; font-family: var(--mono); font-size: 13px; color: var(--ink-3); }
.related { display: flex; flex-wrap: wrap; gap: 8px 24px; margin-top: 36px; padding-top: 18px; border-top: 1px solid var(--rule-2); font-size: 15px; }
.related a { border-bottom-color: transparent; color: var(--ink-2); }
.related a:hover { color: var(--brass); border-bottom-color: var(--brass); }
@media (max-width: 520px) { .results { grid-template-columns: 1fr 1fr; } }

/* ----------------------------------------------------- articles (interim) */

article { padding-block: 12px 20px; }
article h1 { font-size: clamp(34px, 5.5vw, 52px); line-height: 1.08; margin: 16px 0 18px; text-wrap: balance; }
article h2 { font-size: 30px; margin: 44px 0 12px; padding-top: 18px; border-top: 2px solid var(--rule-2); }
article h3 { font-size: 22px; margin: 30px 0 6px; }
article p { margin: 0 0 16px; color: var(--ink-2); }
article > p:first-of-type strong { color: var(--ink); font-weight: 500; font-size: 1.06em; }
strong { color: var(--ink); font-weight: 600; }
article ul, article ol { color: var(--ink-2); padding-left: 22px; margin: 0 0 16px; }
article li { margin-bottom: 6px; }
hr { border: 0; border-top: 1px solid var(--rule); margin: 36px 0; }
blockquote { margin: 0 0 16px; padding-left: 16px; border-left: 2px solid var(--brass-soft); color: var(--ink-2); }

code { font-family: var(--mono); font-size: .88em; background: var(--panel); padding: 1px 5px; border-radius: 4px; }
pre { background: var(--panel); border: 1px solid var(--rule); border-radius: 10px; padding: 14px 16px; overflow-x: auto; margin: 0 0 18px; }
pre code { background: none; padding: 0; font-size: 13px; line-height: 1.5; }

.table-scroll { overflow-x: auto; margin: 0 0 20px; border: 1px solid var(--rule); border-radius: 10px; }
table { border-collapse: collapse; width: 100%; font-size: 14.5px; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--rule); vertical-align: top; }
th { font-family: var(--mono); font-size: 12px; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-3); font-weight: 500; white-space: nowrap; background: var(--paper-2); }
tbody tr:last-child td { border-bottom: 0; }
thead tr:not(:has(th:not(:empty))) { display: none; }

pre.mermaid {
  background: var(--panel); border: 1px solid var(--rule); border-radius: 10px;
  padding: 18px; overflow-x: auto; line-height: 1.3; margin: 0 0 22px;
}
pre.mermaid svg { max-width: 100%; height: auto; display: block; margin-inline: auto; }

details.fold { border-top: 1px solid var(--rule); margin-top: 30px; padding-top: 16px; }
details.fold > summary { cursor: pointer; font-family: var(--mono); font-size: 12.5px; letter-spacing: .05em; text-transform: uppercase; color: var(--ink-3); list-style: none; }
details.fold > summary::-webkit-details-marker { display: none; }
details.fold > summary::before { content: "+ "; color: var(--brass); }
details.fold[open] > summary::before { content: "\2013  "; color: var(--brass); }
details.fold > summary:hover { color: var(--ink); }
details.fold[open] > summary { margin-bottom: 14px; }

article > h1, article > h2, article > h3, article > h4, article > p, article > ul, article > ol,
article > blockquote, article > details, article > hr, article > .table-scroll { max-width: 36em; }
article > pre.mermaid, article > .hero-art, article > .results, article > .related { max-width: none; }

/* ------------------------------------------------------------------- résumé */

.rgrid { display: grid; gap: 20px; grid-template-columns: repeat(2, minmax(0, 1fr)); margin: 22px 0 8px; }
.rcard { border: 1px solid var(--rule-2); border-radius: var(--radius); padding: 24px 24px 22px; background: var(--card); box-shadow: var(--shadow); display: flex; flex-direction: column; }
.rcard h2 { font-size: 27px; margin: 0 0 6px; }
.rcard .for { color: var(--ink-2); margin: 0 0 18px; font-size: 15.5px; flex: 1; }
.rcard .dl { margin: 0; }
@media (max-width: 640px) { .rgrid { grid-template-columns: 1fr; } }

/* --------------------------------------------------------------- blog post */

.post-head { max-width: 40em; padding-top: 18px; margin-bottom: 26px; }
.post-head h1 { font-size: clamp(36px, 5.6vw, 54px); line-height: 1.06; margin: 10px 0 16px; text-wrap: balance; }
.post-head .standfirst { font-size: 19px; color: var(--ink-2); margin: 0 0 22px; text-wrap: pretty; }
.byline { display: flex; align-items: center; gap: 12px; font-size: 14px; color: var(--ink-3); }
.byline img { width: 42px; height: 42px; border-radius: 50%; object-fit: cover; }
.byline b { color: var(--ink); font-weight: 500; display: block; }

.keynums { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(200px, 100%), 1fr)); gap: 14px; margin: 0 0 34px; }
.keynums div { padding: 18px 20px; border: 1px solid var(--rule-2); border-radius: var(--radius); background: var(--card); }
.keynums b { display: block; font-family: var(--serif); font-weight: 400; font-size: 34px; line-height: 1; margin-bottom: 8px; color: var(--ink); }
.keynums span { font-size: 14px; color: var(--ink-2); line-height: 1.45; display: block; }

figure.chart { margin: 30px 0 36px; }
figure.chart a { display: block; border: 1px solid var(--rule-2); border-radius: var(--radius); overflow: hidden; background: #fff; box-shadow: var(--shadow); line-height: 0; transition: box-shadow .2s, border-color .2s; }
figure.chart a:hover { box-shadow: var(--shadow-lift); border-color: var(--brass-soft); }
figure.chart img { width: 100%; height: auto; display: block; }
figure.chart figcaption { font-size: 14px; color: var(--ink-3); margin-top: 10px; max-width: 76ch; }
figure.chart figcaption b { color: var(--ink-2); font-weight: 500; }

.saiddid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(min(320px, 100%), 1fr)); gap: 14px;
  margin: 24px 0 36px;
}
.saiddid > div { padding: 18px 20px; border: 1px solid var(--rule); border-radius: var(--radius); background: var(--paper-2); font-size: 14.5px; }
.saiddid h3 { font-family: var(--sans); font-weight: 600; font-size: 16px; margin: 0 0 6px; }
.saiddid dl { margin: 0; }
.saiddid dt { font-family: var(--mono); font-size: 11.5px; letter-spacing: .08em; text-transform: uppercase; color: var(--brass); margin-top: 12px; }
.saiddid dd { margin: 4px 0 0; color: var(--ink-2); line-height: 1.5; }
.saiddid dd q { font-style: italic; }

.callout { border: 1px solid var(--rule); border-left: 3px solid var(--brass-soft); border-radius: 0 var(--radius) var(--radius) 0; padding: 16px 20px; background: var(--paper-2); margin: 0 0 18px; max-width: 36em; }
.callout p { margin: 0; }
.callout p + p { margin-top: 10px; }

.post-foot { margin-top: 44px; padding-top: 22px; border-top: 1px solid var(--rule); font-size: 14.5px; color: var(--ink-3); max-width: 40em; }
.post-foot .dl { display: flex; flex-wrap: wrap; gap: 10px; margin: 14px 0 6px; }
.post-foot .dl a { border: 1px solid var(--rule-2); border-radius: 999px; padding: 9px 15px; font-size: 14px; background: var(--paper); }
.post-foot .dl a:hover { border-color: var(--brass); color: var(--brass); }
.post-foot .dl a span { font-family: var(--mono); font-size: 12px; color: var(--ink-3); margin-left: 4px; }
.sources { font-size: 14px; color: var(--ink-2); padding-left: 20px; margin: 0; columns: 2; column-gap: 32px; }
.sources li { margin-bottom: 6px; break-inside: avoid; }
.sources a { word-break: break-word; }
@media (max-width: 640px) { .sources { columns: 1; } }

/* ------------------------------------------------------------------- footer */

.sitefoot {
  margin-top: 56px;
  border-top: 2px solid var(--rule-2);
  padding-top: 24px;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 8px 24px;
  font-size: 14.5px;
  color: var(--ink-3);
}
.sitefoot p { margin: 0; }
.foot-links a { border-bottom-color: transparent; color: var(--ink-2); }
.foot-links a:hover { color: var(--brass); border-bottom-color: var(--brass); }
.foot-copy { font-family: var(--mono); font-size: 12.5px; }

/* ------------------------------------------------------------------- motion */

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  * { transition: none !important; animation: none !important; }
}

/* ==========================================================================
   Diagram component kit (.dg-*)

   Used only inside the inlined SVG graphics under assets/diagrams/. Colours
   come from the tokens above, so the same file renders correctly in light and
   dark mode. Text sizes are in viewBox units; mobile variants carry the .dg-m
   class on their root and get the larger sizes.
   ========================================================================== */

.dg-node { fill: var(--card); stroke: var(--rule-2); stroke-width: 1.5; }
.dg-node--accent { fill: var(--brass-tint); stroke: var(--brass); stroke-width: 2; }
.dg-node--before { fill: var(--paper); stroke: var(--amber); stroke-width: 1.5; stroke-dasharray: 6 5; }
.dg-node--after { fill: var(--card); stroke: var(--ok); stroke-width: 2; }
.dg-panel { fill: var(--paper-2); stroke: none; }
.dg-screen { fill: var(--panel); stroke: var(--rule-2); stroke-width: 1.5; }

.dg-arrow { stroke: var(--ink-3); stroke-width: 2; fill: none; }
.dg-arrow--accent { stroke: var(--brass); stroke-width: 3; fill: none; }
.dg-arrow--amber { stroke: var(--amber); stroke-width: 2; fill: none; }
.dg-arrow--flow { stroke: var(--brass); stroke-width: 3; fill: none; }
.dg-hair { stroke: var(--rule-2); stroke-width: 1.5; fill: none; }
.dg-ah { fill: var(--ink-3); }
.dg-ah--accent { fill: var(--brass); }
.dg-ah--amber { fill: var(--amber); }

@media (prefers-reduced-motion: no-preference) {
  .dg-arrow--flow { stroke-dasharray: 14 10; animation: dg-flow 8s linear infinite; }
  @keyframes dg-flow { to { stroke-dashoffset: -240; } }
}

.dg-title { font: 400 34px var(--serif); fill: var(--ink); }
.dg-label { font: 500 22px var(--sans); fill: var(--ink); }
.dg-sub { font: 400 18px var(--sans); fill: var(--ink-2); }
.dg-tag { font: 500 18px var(--mono); fill: var(--ink-3); text-transform: uppercase; letter-spacing: .06em; }
.dg-tag--strong { fill: var(--ink-2); }
.dg-num { font: 400 48px var(--serif); fill: var(--ink); }

.dg-badge { fill: var(--brass-tint); }
.dg-badge-t { font: 600 20px var(--sans); fill: var(--accent-deep); }
.dg-badge--ok { fill: color-mix(in srgb, var(--ok) 14%, transparent); }
.dg-badge-t--ok { fill: var(--ok); }
.dg-badge--amber { fill: color-mix(in srgb, var(--amber) 12%, transparent); stroke: var(--amber); stroke-width: 1.5; }
.dg-badge-t--amber { fill: var(--ink); }

.dg-person { fill: var(--ink-2); }
.dg-icon { fill: none; stroke: var(--ink-2); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.dg-icon--amber { stroke: var(--amber); }
.dg-icon--fill { fill: var(--amber); stroke: none; }
.dg-bar { fill: var(--rule-2); }
.dg-dot { fill: var(--brass-soft); }
.dg-red { fill: var(--amber); }
.dg-milestone { fill: var(--card); stroke: var(--ink-3); stroke-width: 3; }
.dg-milestone--accent { fill: var(--brass-tint); stroke: var(--brass); stroke-width: 3; }

.dg-m .dg-title { font-size: 44px; }
.dg-m .dg-label { font-size: 32px; }
.dg-m .dg-sub { font-size: 28px; }
.dg-m .dg-tag { font-size: 28px; }
.dg-m .dg-badge-t { font-size: 28px; }
.dg-m .dg-num { font-size: 60px; }
