/* ==========================================================================
   Design tokens — every aesthetic decision on the site lives in this block.
   Changing the look means changing values here, not hunting the stylesheet.
   ========================================================================== */
:root {
  /* Typeface stacks. System fonts only: no third-party font requests, so the
     site renders identically behind firewalls that block Google Fonts. */
  --font-body: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto,
               "Helvetica Neue", Arial, sans-serif;
  /* Headings and the masthead: a Palatino-derived serif, self-hosted from
     static/fonts/ (see tools/sitetools/fonts.py). The fallbacks are the
     Palatinos most systems carry, so the page keeps its face while the
     28 KB file loads or if it cannot. */
  --font-head: "Site Serif", "Palatino Linotype", Palatino, "Book Antiqua",
               "URW Palladio L", Georgia, serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

  /* Scale */
  --measure: 44rem;          /* reading column width  */
  --wrap: 52rem;             /* page container width  */
  --step: 1.6;               /* body line height      */
  --size-body: 1.0625rem;
  --size-small: 0.875rem;
  --size-h1: 2.4rem;
  --size-h2: 1.55rem;
  --size-h3: 1.0625rem;
  --head-weight: 700;        /* the serif ships in one weight: bold  */
  --head-tracking: -0.01em;
  --sub-weight: 650;         /* h3 and record titles, in the body sans */

  /* Rhythm */
  --gap: 1.1rem;
  --block: 2.6rem;
  --radius: 5px;
  --portrait-width: 11.5rem; /* the About page photograph, floated right */
  --hero-height: 20rem;      /* cap on the Research lines illustrations  */
  --tile-ratio: 4 / 3;       /* gallery tiles: figures fit inside, uncropped */

  /* Palette */
  --bg: #ffffff;
  --bg-soft: #f7f7f6;
  --fg: #16181d;
  --fg-muted: #5c6270;
  --accent: #12507e;
  --accent-soft: #e8f0f7;
  --rule: #e3e4e8;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14161a;
    --bg-soft: #1c1f25;
    --fg: #e6e8ec;
    --fg-muted: #9aa1af;
    --accent: #7db3e0;
    --accent-soft: #1e2937;
    --rule: #2b2f37;
  }
}

/* ========================================================================== */

@font-face {
  font-family: "Site Serif";
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url("../fonts/site-serif-bold.woff2") format("woff2");
}

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

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font-body);
  font-size: var(--size-body);
  line-height: var(--step);
  text-rendering: optimizeLegibility;
}

.wrap {
  width: 100%;
  max-width: var(--wrap);
  margin-inline: auto;
  padding-inline: 1.25rem;
}

.skip {
  position: absolute;
  left: -9999px;
}
.skip:focus {
  left: 1rem; top: 1rem;
  z-index: 10;
  background: var(--bg);
  padding: 0.5rem 0.75rem;
  border: 2px solid var(--accent);
  border-radius: var(--radius);
}

/* --- Masthead ------------------------------------------------------------ */

.masthead {
  border-bottom: 1px solid var(--rule);
  background: var(--bg);
}
.masthead-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.4rem 1.5rem;
  padding-block: 1.1rem;
}
.brand {
  font-family: var(--font-head);
  font-weight: var(--head-weight);
  letter-spacing: var(--head-tracking);
  font-size: 1.25rem;
  color: var(--fg);
  text-decoration: none;
  white-space: nowrap;
}
.nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0 1.15rem;
  margin: 0;
  padding: 0;
  list-style: none;
  font-size: var(--size-small);
}
.nav a {
  color: var(--fg-muted);
  text-decoration: none;
  padding-block: 0.15rem;
  border-bottom: 1.5px solid transparent;
}
.nav a:hover { color: var(--fg); }
.nav a[aria-current="page"] {
  color: var(--fg);
  border-bottom-color: var(--accent);
}

/* --- Prose --------------------------------------------------------------- */

main { padding-block: var(--block) calc(var(--block) * 1.4); }

/* The reading column is narrower than the container the masthead and the
   gallery use; centring it splits the difference on both sides instead of
   leaving it all on the right. */
.prose { max-width: var(--measure); margin-inline: auto; }

.prose h1 {
  font-family: var(--font-head);
  font-size: var(--size-h1);
  font-weight: var(--head-weight);
  letter-spacing: var(--head-tracking);
  line-height: 1.15;
  margin: 0 0 1.2rem;
}
.prose h2 {
  font-family: var(--font-head);
  font-size: var(--size-h2);
  font-weight: var(--head-weight);
  letter-spacing: var(--head-tracking);
  line-height: 1.25;
  margin: var(--block) 0 0.6rem;
}
.prose h3 {                 /* stays in the body sans: the serif above it is
                                what marks the step down */
  font-size: var(--size-h3);
  font-weight: var(--sub-weight);
  line-height: 1.3;
  margin: 1.9rem 0 0.4rem;
}
.prose p { margin: 0 0 var(--gap); }
.prose ul, .prose ol { margin: 0 0 var(--gap); padding-left: 1.3rem; }
.prose li { margin-bottom: 0.3rem; }
.prose li::marker { color: var(--fg-muted); }

.prose a { color: var(--accent); text-underline-offset: 2px; }
.prose a:hover { text-decoration-thickness: 2px; }

.prose img {
  max-width: 100%;
  height: auto;
  border-radius: var(--radius);
}

.prose code {
  font-family: var(--font-mono);
  font-size: 0.9em;
  background: var(--bg-soft);
  padding: 0.1em 0.35em;
  border-radius: 3px;
}

/* The About page photograph: floated beside the introduction. The paragraph
   Markdown wraps it in would otherwise keep its own margin below the float. */
.prose .portrait {
  float: right;
  width: var(--portrait-width);
  margin: 0.3rem 0 1rem 1.6rem;
}
.prose p:has(> .portrait) { margin: 0; }

/* The illustration that opens each research line: scaled down, never
   cropped, so a tall picture does not push the text below the fold. */
.prose .hero {
  display: block;
  width: auto;
  max-width: 100%;
  max-height: var(--hero-height);
  margin: 0 auto var(--gap);
}

/* A row of links under a heading: the repository, the course page, a video.
   Written in Markdown as a paragraph carrying the "links" class. */
.prose .links {
  font-size: var(--size-small);
  color: var(--fg-muted);
  margin: -0.2rem 0 var(--gap);
}
.prose .links code { font-size: 0.95em; }

/* In-page figures on the hand-written pages: a screenshot with its caption,
   styled like the gallery figures. */
.prose figure {
  margin: 0 0 var(--block);
}
.prose figure img {
  display: block;
  width: 100%;
  background: var(--bg-soft);
  border: 1px solid var(--rule);
}
.prose figcaption {
  font-size: 0.8125rem;
  line-height: 1.4;
  color: var(--fg-muted);
  margin-top: 0.45rem;
}

/* A collapsed block, for material worth keeping but not worth the space:
   the native details element, so it needs no script. */
.prose details {
  margin: 0 0 var(--gap);
  padding: 0.4rem 0.9rem;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  background: var(--bg-soft);
}
.prose summary {
  cursor: pointer;
  font-size: var(--size-small);
  color: var(--fg-muted);
}
.prose summary:hover { color: var(--fg); }
.prose details[open] summary { margin-bottom: 0.6rem; }
.prose details > :last-child { margin-bottom: 0.4rem; }

.lede {
  color: var(--fg-muted);
  font-size: var(--size-small);
  margin-bottom: var(--block);
}

/* --- Publication and talk records ---------------------------------------- */

.year { margin-bottom: var(--block); }

.year h2 {                  /* a label, not a title: stays in the sans */
  font-family: var(--font-body);
  font-size: 0.8125rem;
  font-weight: 600;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--fg-muted);
  padding-bottom: 0.4rem;
  border-bottom: 1px solid var(--rule);
  margin: 0 0 1rem;
}

.prose .records {            /* the prose list padding would indent the
                                records past the year rule above them */
  list-style: none;
  margin: 0;
  padding: 0;
  counter-reset: none;
}

.record {
  display: grid;
  gap: 0.15rem;
  padding-block: 0.7rem;
  border-bottom: 1px solid var(--rule);
}
.record:last-child { border-bottom: none; }

/* Numbered lists (publications): the running number reads as part of the
   title line, "12) Title", rather than sitting in a column of its own. */
.record-number {
  font-variant-numeric: tabular-nums;
  color: var(--fg-muted);
  font-weight: 400;
}

.record-title { font-weight: var(--sub-weight); line-height: 1.35; }
.record-title a { color: var(--fg); text-decoration: none; }
.record-title a:hover { color: var(--accent); text-decoration: underline; }

.record-authors,
.record-venue {
  font-size: var(--size-small);
  color: var(--fg-muted);
  line-height: 1.45;
}
.record-venue { font-style: italic; }
.record-venue strong {      /* the journal reference stands out from the
                                author line by colour, not by a second bold */
  font-weight: 500;
  color: var(--fg);
}
.record-authors .me {       /* his own name in the author list */
  text-decoration: underline;
  text-underline-offset: 0.15em;
}

.tag {
  display: inline-block;
  font-style: normal;
  font-size: 0.6875rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--accent);
  background: var(--accent-soft);
  border-radius: 3px;
  padding: 0.1rem 0.35rem;
  margin-left: 0.35rem;
  text-decoration: none;
  vertical-align: 1px;
}
.tag-invited { color: var(--fg-muted); background: var(--bg-soft); }

/* A venue link that should not shout: styled as body text until hovered. */
a.plain { color: inherit; text-decoration: none; border-bottom: 1px dotted var(--rule); }
a.plain:hover { color: var(--accent); border-bottom-color: currentColor; }

/* --- Gallery -------------------------------------------------------------- */

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 1.6rem 1.2rem;
  align-items: start;
  margin-bottom: var(--gap);
}
.grid img { width: 100%; display: block; }

/* --- Footer --------------------------------------------------------------- */

.footer {
  border-top: 1px solid var(--rule);
  padding-block: 1.6rem 2.4rem;
  margin-top: var(--block);
}
.footer .links {
  display: flex;
  flex-wrap: wrap;
  gap: 0 1.1rem;
  list-style: none;
  margin: 0 0 0.5rem;
  padding: 0;
  font-size: var(--size-small);
}
.footer a { color: var(--accent); text-decoration: none; }
.footer a:hover { text-decoration: underline; }
.fine { font-size: 0.8125rem; color: var(--fg-muted); margin: 0; }

/* --- Narrow screens -------------------------------------------------------- */

@media (max-width: 34rem) {
  :root { --size-h1: 1.9rem; --size-h2: 1.35rem; --block: 2rem; --portrait-width: 42%; }
  .masthead-inner { flex-direction: column; align-items: flex-start; }
  .prose .portrait { margin-left: 1rem; }
}

@media print {
  .masthead, .footer, .skip { display: none; }
  .prose { max-width: none; }
  a { color: inherit; }
}

/* --- Tabs (CSS only; radio inputs, no JavaScript) -------------------------- */

.tabs > input { position: absolute; opacity: 0; pointer-events: none; }

.tab-labels {
  display: flex;
  flex-wrap: wrap;
  gap: 0.15rem;
  border-bottom: 1px solid var(--rule);
  margin-bottom: var(--block);
}
.tab-labels label {
  font-size: var(--size-small);
  color: var(--fg-muted);
  padding: 0.35rem 0.55rem;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  cursor: pointer;
  user-select: none;
}
.tab-labels label:hover { color: var(--fg); }

.tab-panel { display: none; }

.tab-note {
  font-size: var(--size-small);
  color: var(--fg-muted);
  margin: 0 0 var(--block);
}


.tabs > input:nth-of-type(1):checked ~ .tab-labels label:nth-of-type(1) { color: var(--fg); border-bottom-color: var(--accent); }
.tabs > input:nth-of-type(1):checked ~ .tab-panels > .tab-panel:nth-of-type(1) { display: block; }
.tabs > input:nth-of-type(2):checked ~ .tab-labels label:nth-of-type(2) { color: var(--fg); border-bottom-color: var(--accent); }
.tabs > input:nth-of-type(2):checked ~ .tab-panels > .tab-panel:nth-of-type(2) { display: block; }
.tabs > input:nth-of-type(3):checked ~ .tab-labels label:nth-of-type(3) { color: var(--fg); border-bottom-color: var(--accent); }
.tabs > input:nth-of-type(3):checked ~ .tab-panels > .tab-panel:nth-of-type(3) { display: block; }
.tabs > input:nth-of-type(4):checked ~ .tab-labels label:nth-of-type(4) { color: var(--fg); border-bottom-color: var(--accent); }
.tabs > input:nth-of-type(4):checked ~ .tab-panels > .tab-panel:nth-of-type(4) { display: block; }
.tabs > input:nth-of-type(5):checked ~ .tab-labels label:nth-of-type(5) { color: var(--fg); border-bottom-color: var(--accent); }
.tabs > input:nth-of-type(5):checked ~ .tab-panels > .tab-panel:nth-of-type(5) { display: block; }
.tabs > input:nth-of-type(6):checked ~ .tab-labels label:nth-of-type(6) { color: var(--fg); border-bottom-color: var(--accent); }
.tabs > input:nth-of-type(6):checked ~ .tab-panels > .tab-panel:nth-of-type(6) { display: block; }
.tabs > input:nth-of-type(7):checked ~ .tab-labels label:nth-of-type(7) { color: var(--fg); border-bottom-color: var(--accent); }
.tabs > input:nth-of-type(7):checked ~ .tab-panels > .tab-panel:nth-of-type(7) { display: block; }
.tabs > input:nth-of-type(8):checked ~ .tab-labels label:nth-of-type(8) { color: var(--fg); border-bottom-color: var(--accent); }
.tabs > input:nth-of-type(8):checked ~ .tab-panels > .tab-panel:nth-of-type(8) { display: block; }
.tabs > input:nth-of-type(9):checked ~ .tab-labels label:nth-of-type(9) { color: var(--fg); border-bottom-color: var(--accent); }
.tabs > input:nth-of-type(9):checked ~ .tab-panels > .tab-panel:nth-of-type(9) { display: block; }
.tabs > input:nth-of-type(10):checked ~ .tab-labels label:nth-of-type(10) { color: var(--fg); border-bottom-color: var(--accent); }
.tabs > input:nth-of-type(10):checked ~ .tab-panels > .tab-panel:nth-of-type(10) { display: block; }
.tabs > input:nth-of-type(11):checked ~ .tab-labels label:nth-of-type(11) { color: var(--fg); border-bottom-color: var(--accent); }
.tabs > input:nth-of-type(11):checked ~ .tab-panels > .tab-panel:nth-of-type(11) { display: block; }
.tabs > input:nth-of-type(12):checked ~ .tab-labels label:nth-of-type(12) { color: var(--fg); border-bottom-color: var(--accent); }
.tabs > input:nth-of-type(12):checked ~ .tab-panels > .tab-panel:nth-of-type(12) { display: block; }
.tabs > input:nth-of-type(13):checked ~ .tab-labels label:nth-of-type(13) { color: var(--fg); border-bottom-color: var(--accent); }
.tabs > input:nth-of-type(13):checked ~ .tab-panels > .tab-panel:nth-of-type(13) { display: block; }
.tabs > input:nth-of-type(14):checked ~ .tab-labels label:nth-of-type(14) { color: var(--fg); border-bottom-color: var(--accent); }
.tabs > input:nth-of-type(14):checked ~ .tab-panels > .tab-panel:nth-of-type(14) { display: block; }
.tabs > input:nth-of-type(15):checked ~ .tab-labels label:nth-of-type(15) { color: var(--fg); border-bottom-color: var(--accent); }
.tabs > input:nth-of-type(15):checked ~ .tab-panels > .tab-panel:nth-of-type(15) { display: block; }
.tabs > input:nth-of-type(16):checked ~ .tab-labels label:nth-of-type(16) { color: var(--fg); border-bottom-color: var(--accent); }
.tabs > input:nth-of-type(16):checked ~ .tab-panels > .tab-panel:nth-of-type(16) { display: block; }
.tabs > input:nth-of-type(17):checked ~ .tab-labels label:nth-of-type(17) { color: var(--fg); border-bottom-color: var(--accent); }
.tabs > input:nth-of-type(17):checked ~ .tab-panels > .tab-panel:nth-of-type(17) { display: block; }
.tabs > input:nth-of-type(18):checked ~ .tab-labels label:nth-of-type(18) { color: var(--fg); border-bottom-color: var(--accent); }
.tabs > input:nth-of-type(18):checked ~ .tab-panels > .tab-panel:nth-of-type(18) { display: block; }
.tabs > input:nth-of-type(19):checked ~ .tab-labels label:nth-of-type(19) { color: var(--fg); border-bottom-color: var(--accent); }
.tabs > input:nth-of-type(19):checked ~ .tab-panels > .tab-panel:nth-of-type(19) { display: block; }
.tabs > input:nth-of-type(20):checked ~ .tab-labels label:nth-of-type(20) { color: var(--fg); border-bottom-color: var(--accent); }
.tabs > input:nth-of-type(20):checked ~ .tab-panels > .tab-panel:nth-of-type(20) { display: block; }

/* Keyboard focus still has to be visible even though the radio itself is not. */
.tabs > input:focus-visible ~ .tab-labels label { outline: none; }
.tabs > input:nth-of-type(1):focus-visible ~ .tab-labels label:nth-of-type(1),
.tabs > input:nth-of-type(2):focus-visible ~ .tab-labels label:nth-of-type(2),
.tabs > input:nth-of-type(3):focus-visible ~ .tab-labels label:nth-of-type(3),
.tabs > input:nth-of-type(4):focus-visible ~ .tab-labels label:nth-of-type(4),
.tabs > input:nth-of-type(5):focus-visible ~ .tab-labels label:nth-of-type(5) {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

@media print {                 /* paper has no tabs: show every panel */
  .tab-panel { display: block !important; }
}

/* --- Gallery figures ------------------------------------------------------- */

.gallery-page { max-width: var(--wrap); }

.shot {
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}
.shot > a {                  /* the image link only: the caption link must keep
                                its line box, or it overlaps the text above it.
                                Every tile has the same shape, so the rows line
                                up; the figure is fitted inside it uncropped. */
  display: block;
  line-height: 0;
  aspect-ratio: var(--tile-ratio);
  background: var(--bg-soft);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  overflow: hidden;
}
.shot img {
  width: 100%;               /* overrides the width/height attributes, which
                                would otherwise win over object-fit */
  height: 100%;
  object-fit: contain;       /* figures and portrait covers must not be cropped */
}
.shot > a:hover { border-color: var(--accent); }
.shot figcaption {
  font-size: 0.8125rem;
  line-height: 1.4;
  color: var(--fg-muted);
}
.shot figcaption p { margin: 0; }
.shot figcaption a { color: var(--accent); }

/* --- News ------------------------------------------------------------------ */
/* A dated timeline of the announcements from the Bluesky feed: text and its
   links, no images -- the date sits in a column beside the text on a wide
   screen and above it on a narrow one. */

.news-page { max-width: var(--wrap); }

.news-list {
  list-style: none;
  margin: 0;
  padding: 0;
}
.news-item {
  display: grid;
  grid-template-columns: 6.5rem 1fr;
  gap: var(--gap);
  padding: calc(var(--gap) * 0.9) 0;
  border-top: 1px solid var(--rule);
  align-items: baseline;
}
.news-item:first-child { border-top: 0; padding-top: 0; }

.news-item time {
  font-size: var(--size-small);
  color: var(--fg-muted);
  font-variant-numeric: tabular-nums;
}
.news-text p { margin: 0; }
.news-text a { color: var(--accent); }

@media (max-width: 34rem) {
  .news-item { grid-template-columns: 1fr; gap: 0.3rem; }
}

/* --- Charts --------------------------------------------------------------- */
/* Drawn as inline SVG at build time, so they carry no script and take their
   colours from the tokens above, following the light and dark themes. */
.charts {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr));
  gap: var(--block) var(--gap);
  margin-block: var(--block);
}
.chart { margin: 0; }
.chart-wide { grid-column: 1 / -1; }
.chart-svg {
  display: block;
  width: 100%;
  height: auto;
  overflow: visible;
}
.chart figcaption {          /* only ever a footnote now: the title is in the SVG,
                                 where it scales and prints with the chart */
  margin-top: 0.35rem;
  font-size: var(--size-small);
  color: var(--fg-muted);
}
.chart-title {
  fill: var(--fg);
  font-family: var(--font-head);
  font-size: 16px;
  font-weight: 650;
  letter-spacing: var(--head-tracking);
}
.chart-bar { fill: var(--accent); }
.chart-area { fill: var(--accent); opacity: 0.14; }
.chart-line {
  fill: none;
  stroke: var(--accent);
  stroke-width: 1.8;
  stroke-linejoin: round;
}
.chart-dot { fill: var(--accent); }
.chart-grid { stroke: var(--rule); stroke-width: 1; }
.chart-tick {                /* sized to read like the page around it, not like a
                                figure in a paper: the SVG is ~320 units wide and is
                                displayed at roughly that many pixels */
  fill: var(--fg-muted);
  font-family: var(--font-body);
  font-size: 13px;
}
.chart-value {
  fill: var(--fg-muted);
  font-family: var(--font-body);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}
.chart-axis {
  fill: var(--fg-muted);
  font-family: var(--font-body);
  font-size: 13px;
}
