/* Inter (text) and Source Serif 4 (name and headings), self-hosted; licences in static/fonts/. */
@font-face {
  font-display: swap;
  font-family: "Inter";
  font-style: normal;
  font-weight: 100 900;
  src: url("../fonts/inter-latin-opsz-normal.4b73e2ff3024.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
  font-display: swap;
  font-family: "Inter";
  font-style: normal;
  font-weight: 100 900;
  src: url("../fonts/inter-latin-ext-opsz-normal.084b211fc382.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

@font-face {
  font-display: swap;
  font-family: "Inter";
  font-style: italic;
  font-weight: 100 900;
  src: url("../fonts/inter-latin-opsz-italic.59036e902b79.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
  font-display: swap;
  font-family: "Inter";
  font-style: italic;
  font-weight: 100 900;
  src: url("../fonts/inter-latin-ext-opsz-italic.af57dae033bf.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

@font-face {
  font-display: swap;
  font-family: "Source Serif 4";
  font-style: normal;
  font-weight: 200 900;
  src: url("../fonts/source-serif-4-latin-opsz-normal.e9192c2fe0a3.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
  font-display: swap;
  font-family: "Source Serif 4";
  font-style: normal;
  font-weight: 200 900;
  src: url("../fonts/source-serif-4-latin-ext-opsz-normal.33ba75072ebc.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

:root {
  color-scheme: dark;
  --font-text: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Helvetica, Arial, sans-serif;
  --font-display: "Source Serif 4", Georgia, "Times New Roman", serif;
  --font-mono: ui-monospace, "SFMono-Regular", Menlo, Consolas, "Liberation Mono", monospace;
  --page-width: 54rem;
  --reading-width: 42rem;
  --gutter: 1.25rem;
  --bg: #1b1915;
  --text: #e8e2d6;
  --strong: #f5f0e6;
  --muted: #a69f92;
  --line: #332f28;
  --accent: #7dcdc6;
  --accent-2: #d9b27e;
  --panel: #23201b;
  --code-bg: #23201b;
}

html {
  scrollbar-gutter: stable;
}

html[data-theme="light"] {
  color-scheme: light;
  --bg: #f6f2e8;
  --text: #2a3033;
  --strong: #12171a;
  --muted: #5d686d;
  --line: #e3ddcf;
  --accent: #0e6169;
  --accent-2: #8a4b0f;
  --panel: #efeadd;
  --code-bg: #1b2226;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-text);
  font-size: 1.0625rem;
  font-kerning: normal;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

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

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

a {
  color: var(--accent);
  text-decoration-color: color-mix(in srgb, currentColor 35%, transparent);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.22em;
  transition: color 0.15s ease, text-decoration-color 0.15s ease;
}

a:hover {
  text-decoration-color: currentColor;
}

p,
li {
  text-wrap: pretty;
}

img {
  display: block;
  max-width: 100%;
  height: auto;
}

.skip-link {
  position: absolute;
  left: -999px;
  top: 0;
}

.skip-link:focus {
  left: 1rem;
  top: 1rem;
  z-index: 20;
}

/* Header and footer */

.site-header {
  border-bottom: 1px solid var(--line);
}

.site-footer {
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.875rem;
  padding: 2.25rem max(var(--gutter), calc((100% - var(--page-width)) / 2 + var(--gutter)));
}

.nav {
  align-items: center;
  display: flex;
  gap: 1.5rem;
  justify-content: space-between;
  margin: 0 auto;
  max-width: var(--page-width);
  padding: 1.15rem var(--gutter);
}

.brand {
  color: var(--strong);
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 600;
  letter-spacing: -0.005em;
  text-decoration: none;
}

.nav-links {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  font-size: 0.9375rem;
  gap: 1.35rem;
  justify-content: flex-end;
}

.nav-links > a {
  color: var(--muted);
  text-decoration: none;
}

.nav-links > a:hover,
.nav-links > a[aria-current="page"] {
  color: var(--strong);
}

.profile-icons {
  align-items: center;
  display: inline-flex;
  gap: 0.6rem;
}

.profile-icon {
  align-items: center;
  color: var(--muted);
  display: inline-flex;
  height: 1.55em;
  justify-content: center;
  line-height: 1;
  text-decoration: none;
  width: 1.55em;
}

.profile-icon:hover,
.profile-icon:focus {
  color: var(--text);
}

.profile-icon svg {
  fill: currentColor;
  height: 1.35em;
  width: 1.35em;
}

.theme-toggle {
  align-items: center;
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  display: inline-flex;
  font-size: 0.9rem;
  height: 1.85rem;
  justify-content: center;
  min-height: 1.85rem;
  padding: 0;
  width: 1.85rem;
}

.theme-toggle:hover,
.theme-toggle:focus {
  border-color: var(--accent);
  color: var(--text);
}

.profile-icon span {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.page {
  margin: 0 auto;
  max-width: var(--page-width);
  padding: 3.75rem var(--gutter) 5.5rem;
}

/* Type scale */

h1,
h2 {
  color: var(--strong);
  font-family: var(--font-display);
  font-optical-sizing: auto;
  font-weight: 600;
  letter-spacing: -0.012em;
  text-wrap: balance;
}

h1 {
  font-size: clamp(2.15rem, 1.6rem + 2.2vw, 2.95rem);
  line-height: 1.1;
  margin: 0 0 0.85rem;
}

h2 {
  font-size: 1.5rem;
  line-height: 1.25;
  margin: 3.75rem 0 1rem;
}

h3 {
  color: var(--strong);
  font-size: 1.0625rem;
  font-weight: 600;
  line-height: 1.4;
  margin: 0 0 0.3rem;
  text-wrap: balance;
}

.eyebrow,
.meta,
.authors,
figcaption {
  color: var(--muted);
}

.eyebrow {
  font-size: 0.8125rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  margin: 0 0 0.75rem;
  text-transform: uppercase;
}

.lede {
  color: var(--muted);
  font-size: 1.125rem;
  line-height: 1.5;
}

.authors strong,
.meta strong {
  color: var(--text);
  font-weight: 600;
}

.profile-image {
  aspect-ratio: 1;
  border-radius: 14px;
  object-fit: cover;
}

/* Buttons and links */

.action-row,
.link-row,
.compact-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
}

.action-row {
  gap: 0.5rem;
}

.compact-links {
  gap: 0.2rem 1rem;
  margin-top: 0.45rem;
}

.compact-links a,
.compact-links .link-button {
  font-size: 0.9375rem;
  font-weight: 500;
  text-decoration: none;
}

.compact-links a:hover,
.compact-links .link-button:hover {
  text-decoration: underline;
}

.button,
button {
  align-items: center;
  border-radius: 6px;
  cursor: pointer;
  display: inline-flex;
  font: inherit;
  text-decoration: none;
}

button {
  background: var(--accent);
  border: 1px solid var(--accent);
  color: white;
  min-height: 2.4rem;
  padding: 0.45rem 0.8rem;
}

.button {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--text);
  font-size: 0.9375rem;
  font-weight: 500;
  min-height: 2.25rem;
  padding: 0.3rem 0.95rem;
  transition: border-color 0.15s ease, color 0.15s ease;
}

.button:hover {
  border-color: var(--accent);
}

.button:not(.secondary) {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--bg);
}

.button:not(.secondary):hover {
  filter: brightness(1.08);
}

.link-button {
  background: none;
  border: 0;
  color: var(--accent);
  display: inline;
  min-height: 0;
  padding: 0;
  text-decoration: underline;
}

.copy-button {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.8125rem;
  min-height: 0;
  padding: 0.2rem 0.7rem;
}

.copy-button:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.copy-source {
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  height: 1px;
  overflow: hidden;
  position: absolute;
  white-space: pre;
  width: 1px;
}

/* Lists: interests, publications, posts, CV entries */

.item-list,
.publication-list,
.tag-grid {
  display: grid;
  gap: 0;
}

.item,
.publication-item,
.tag-grid article {
  padding: 1.15rem 0;
}

.publication-item p,
.item p {
  margin: 0.15rem 0 0;
}

.item > p:not(.meta) {
  margin-top: 0.3rem;
}

.item h2 a,
.item h3 a {
  color: var(--strong);
  text-decoration: none;
}

.item h2 a:hover,
.item h3 a:hover {
  color: var(--accent);
}

.authors,
.publication-item .meta {
  font-size: 0.96875rem;
}

/* Location and year stay together, so a long venue line breaks after the conference name. */
.publication-place {
  white-space: nowrap;
}

/* Blog index titles are h2 inside list items. */
.item-list .item h2 {
  font-size: 1.3rem;
  margin: 0 0 0.2rem;
}

/* CV entries with a date: the date gets its own column. */
.item:has(> h3 + p.meta) {
  column-gap: 1.75rem;
  display: grid;
  grid-template-columns: 7.25rem minmax(0, 1fr);
}

.item:has(> h3 + p.meta) > * {
  grid-column: 2;
}

.item:has(> h3 + p.meta) > p.meta {
  font-size: 0.9375rem;
  font-variant-numeric: tabular-nums;
  grid-column: 1;
  grid-row: 1 / span 3;
  margin: 0.05rem 0 0;
}

.timeline article {
  border-left: 2px solid var(--line);
  display: grid;
  gap: 0.8rem;
  grid-template-columns: 8rem 1fr;
  padding-left: 1rem;
}

.page-header {
  margin-bottom: 2rem;
}

.section-heading {
  align-items: baseline;
  display: flex;
  justify-content: space-between;
  margin: 3.75rem 0 1rem;
}

.section-heading h2 {
  margin: 0;
}

pre,
.code-listing {
  background: var(--code-bg);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: #f4f7f7;
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  line-height: 1.65;
  overflow-x: auto;
  padding: 1rem 1.2rem;
}

/* A code listing whose comment lines can hold rendered math: one div per line. */
.code-line {
  white-space: pre;
}

.code-math {
  color: #8fd694;
  margin-top: 0.35rem;
}

.code-math .katex {
  font-size: 1.08em;
}

/* Article pages: one centred reading column. */

.publication-detail,
.post {
  margin-inline: auto;
  max-width: var(--reading-width);
}

.publication-detail h1,
.post h1 {
  font-size: clamp(1.95rem, 1.5rem + 1.7vw, 2.55rem);
  line-height: 1.15;
}

.publication-detail p {
  overflow-wrap: anywhere;
}

.publication-detail .authors a,
.publication-item .authors a {
  text-decoration: none;
}

.publication-detail .page-header .authors,
.publication-detail .page-header .meta {
  font-size: 1.0625rem;
  margin: 0.2rem 0 0;
}

.publication-detail .action-row {
  margin-top: -0.5rem;
}

.publication-detail section > p {
  font-size: 1.125rem;
  line-height: 1.75;
}

.post .page-header .meta {
  font-size: 0.9375rem;
  margin: 0 0 0.75rem;
}

.post .lede {
  font-size: 1.1875rem;
  line-height: 1.6;
}

.post-body > * + * {
  margin-top: 1.15rem;
}

.post-body .markdown-body {
  font-size: 1.125rem;
  line-height: 1.75;
}

.post-body .markdown-body h2 {
  font-size: 1.5rem;
  margin: 3rem 0 0.75rem;
}

.post-body .markdown-body p {
  margin: 0 0 1.15rem;
}

.post-body .katex {
  font-size: 1.12em;
}

figure {
  margin: 2rem 0;
}

.post-body figure {
  margin-left: auto;
  margin-right: auto;
  max-width: 80%;
  text-align: center;
}

/* Blog figures are wider than the reading column, up to the page width. */
/* The paper a post presents, under the post's title. */
.post .paper-card {
  background: color-mix(in srgb, var(--accent) 5%, transparent);
  border: 1px solid var(--line);
  border-radius: 10px;
  margin-top: 1.5rem;
  padding: 1rem 1.25rem 1.1rem;
}

.post .paper-card .eyebrow {
  margin: 0 0 0.35rem;
}

.post .paper-card-title {
  color: var(--text);
  font-size: 1.0625rem;
  font-weight: 600;
  line-height: 1.4;
  margin: 0;
}

.post .paper-card .authors {
  font-size: 0.9375rem;
  margin: 0.2rem 0 0.8rem;
}

/* Figures span exactly the width of the text column. */
.post-body figure.blog-figure {
  margin: 2.5rem 0;
  max-width: 100%;
  width: 100%;
}

.post-body figure.blog-figure--narrow {
  margin-inline: auto;
  width: min(100%, 30rem);
}

.post-body figure.blog-figure img {
  display: block;
  width: 100%;
  height: auto;
}

/* Several images in one figure share the column width equally. */
.post-body .blog-figure-row {
  display: flex;
  gap: 0.75rem;
}

.post-body .blog-figure-row img {
  flex: 1 1 0;
  min-width: 0;
}

.post-body figure img {
  margin-left: auto;
  margin-right: auto;
  max-width: 100%;
}

.post-body figcaption {
  font-size: 0.9375rem;
  margin: 0.65rem auto 0;
  max-width: var(--reading-width);
}

/* A caption written in Markdown comes as one paragraph. */
.post-body figcaption > p {
  margin: 0;
}

/* A table never makes the page wider than the screen: if it cannot fit, it scrolls inside the column. */
.post-body table {
  border-collapse: collapse;
  display: block;
  font-size: 0.9375rem;
  margin: 1.5rem auto;
  max-width: 100%;
  overflow-x: auto;
  width: max-content;
}

.post-body th,
.post-body td {
  border: 1px solid var(--line);
  padding: 0.45rem 0.65rem;
  text-align: left;
  vertical-align: top;
}

.post-body th {
  background: var(--panel);
}

/* A table formula is never broken inside: on phones, only its right-hand side goes to its own line. */
.post-body td:has(.formula-rhs) {
  white-space: nowrap;
}

blockquote,
.callout {
  border-left: 2px solid var(--accent-2);
  color: var(--text);
  margin: 1.5rem 0;
  padding: 0.2rem 0 0.2rem 1rem;
}

.equation {
  overflow-x: auto;
}

@media (max-width: 720px) {
  :root {
    --gutter: 1rem;
  }

  /* Tighter tables, so that the post tables fit a phone screen. */
  .post-body table {
    font-size: 0.8125rem;
  }

  .post-body th,
  .post-body td {
    padding: 0.35rem 0.45rem;
  }

  /* On phones, a table formula puts its right-hand side on its own line. */
  .post-body .formula-rhs {
    display: block;
  }

  .post-body .formula-rhs + br {
    display: none;
  }

  /* Name, profile icons and theme switch on the first row; page links on the second. */
  .nav {
    column-gap: 1.15rem;
    flex-wrap: wrap;
    row-gap: 0.55rem;
  }

  .nav-links {
    display: contents;
  }

  .brand {
    flex: 1 1 auto;
    order: 0;
  }

  .profile-icons {
    order: 1;
  }

  .theme-toggle {
    margin-left: -0.4rem;
    order: 2;
  }

  .nav::after {
    content: "";
    flex-basis: 100%;
    order: 3;
  }

  .nav-links > a {
    order: 4;
  }

  .page {
    padding-top: 2.25rem;
  }

  h2 {
    margin-top: 3rem;
  }

  .item:has(> h3 + p.meta) {
    display: block;
  }

  .timeline article {
    grid-template-columns: 1fr;
  }

  .post-body figure {
    max-width: 100%;
  }

  .post-body .markdown-body {
    font-size: 1.0625rem;
  }
}

/* On the smallest phones, tables get smaller text and cells so that they still fit. */
@media (max-width: 380px) {
  .post-body table {
    font-size: 0.75rem;
  }

  .post-body th,
  .post-body td {
    padding: 0.3rem 0.35rem;
  }
}

@media print {
  .site-header,
  .site-footer,
  .action-row {
    display: none;
  }

  body {
    background: white;
  }
}
