/* ============================================================
   Tokens
   ============================================================ */

:root {
  --bg: #fcfbf8;
  --text: #1d1c1a;
  --muted: #6d6a63;
  --faint: #98958d;
  --rule: #e8e5de;
  --accent: #00356b;
  --accent-soft: rgba(0, 53, 107, 0.08);
  --code-bg: #f3f1ec;

  --serif: "Newsreader", "Iowan Old Style", "Songti SC", "Noto Serif SC", Georgia, serif;
  --sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;

  --measure: 44rem;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #111315;
    --text: #e9e7e2;
    --muted: #a19e96;
    --faint: #76736c;
    --rule: #2a2d31;
    --accent: #9cc1ee;
    --accent-soft: rgba(156, 193, 238, 0.12);
    --code-bg: #1a1d20;
  }
}

:root[data-theme="dark"] {
  --bg: #111315;
  --text: #e9e7e2;
  --muted: #a19e96;
  --faint: #76736c;
  --rule: #2a2d31;
  --accent: #9cc1ee;
  --accent-soft: rgba(156, 193, 238, 0.12);
  --code-bg: #1a1d20;
}

/* ============================================================
   Base
   ============================================================ */

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

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

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 1.0625rem;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

::selection { background: var(--accent-soft); }

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

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

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

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

strong { font-weight: 600; }

.wrap {
  width: 100%;
  max-width: calc(var(--measure) + 3rem);
  margin: 0 auto;
  padding: 0 1.5rem;
}

main.wrap {
  flex: 1;
  padding-top: 4rem;
  padding-bottom: 5rem;
}

.skip-link {
  position: absolute;
  left: -999px;
  top: 0.5rem;
  background: var(--bg);
  padding: 0.4rem 0.8rem;
  z-index: 10;
}

.skip-link:focus { left: 0.5rem; }

[hidden] { display: none !important; }

/* ============================================================
   Header and footer
   ============================================================ */

.site-header__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding-top: 1.5rem;
  padding-bottom: 1.5rem;
}

.site-name {
  font-family: var(--serif);
  font-size: 1.25rem;
  font-weight: 500;
  color: var(--text);
  text-decoration: none;
  letter-spacing: -0.005em;
}

.site-nav {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  font-size: 0.9rem;
}

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

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

.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  margin-left: -0.4rem;
  margin-right: -0.5rem;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: none;
  color: var(--muted);
  cursor: pointer;
  transition: color 0.15s ease, background 0.15s ease;
}

.theme-toggle:hover {
  color: var(--text);
  background: var(--accent-soft);
}

.theme-toggle .icon-sun { display: none; }

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-toggle .icon-sun { display: block; }
  :root:not([data-theme="light"]) .theme-toggle .icon-moon { display: none; }
}

:root[data-theme="dark"] .theme-toggle .icon-sun { display: block; }
:root[data-theme="dark"] .theme-toggle .icon-moon { display: none; }

.site-footer {
  border-top: 1px solid var(--rule);
  color: var(--faint);
  font-size: 0.82rem;
}

.site-footer__inner {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0.25rem 1rem;
  padding-top: 1.5rem;
  padding-bottom: 2rem;
}

/* ============================================================
   Hero
   ============================================================ */

.hero {
  display: flex;
  align-items: center;
  gap: 2.25rem;
  margin-bottom: 3rem;
}

.hero__photo {
  flex-shrink: 0;
  width: 148px;
  height: 148px;
  border-radius: 50%;
  object-fit: cover;
  object-position: 55% 42%;
}

.hero__name {
  margin: 0;
  font-family: var(--serif);
  font-size: 2.75rem;
  font-weight: 400;
  line-height: 1.1;
  letter-spacing: -0.02em;
}

.hero__name-alt {
  margin-left: 0.35em;
  font-size: 0.5em;
  color: var(--faint);
  letter-spacing: 0.08em;
  white-space: nowrap;
}

.hero__role {
  margin: 0.6rem 0 0;
  color: var(--muted);
}

.hero__links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 1.25rem;
  margin: 1rem 0 0;
  padding: 0;
  list-style: none;
  font-size: 0.92rem;
}

/* ============================================================
   Sections
   ============================================================ */

.section { margin-top: 3.5rem; }

.section--intro { margin-top: 0; }

.section--intro p { margin: 0 0 1rem; }

.section--intro p:last-child { margin-bottom: 0; }

.section__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
}

.section__label {
  margin: 0 0 1.5rem;
  font-family: var(--sans);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--faint);
}

.section__more {
  font-size: 0.85rem;
  white-space: nowrap;
}

.statement {
  margin: 0 0 2rem;
  font-family: var(--serif);
  font-size: 1.6rem;
  font-weight: 400;
  line-height: 1.4;
  letter-spacing: -0.01em;
  text-wrap: balance;
}

.statement em { color: var(--accent); }

.facts {
  margin: 0;
  display: grid;
  grid-template-columns: minmax(0, 15rem) minmax(0, 1fr);
}

.facts dt,
.facts dd {
  margin: 0;
  padding: 0.85rem 0;
  border-top: 1px solid var(--rule);
}

.facts dt {
  padding-right: 1.5rem;
  font-weight: 500;
}

.facts dd { color: var(--muted); }

.closing {
  margin: 3.5rem 0 0;
  padding-top: 1.75rem;
  border-top: 1px solid var(--rule);
  color: var(--muted);
}

/* ============================================================
   Publications
   ============================================================ */

.pub-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.pub {
  padding: 1.25rem 0;
  border-top: 1px solid var(--rule);
}

.pub__title {
  margin: 0;
  font-family: var(--sans);
  font-size: 1.02rem;
  font-weight: 500;
  line-height: 1.45;
}

.pub__title a {
  color: var(--text);
  text-decoration: none;
}

.pub__title a:hover { color: var(--accent); }

.pub__authors {
  margin: 0.35rem 0 0;
  font-size: 0.88rem;
  line-height: 1.55;
  color: var(--muted);
}

.me {
  color: var(--text);
  font-weight: 600;
}

.pub__meta {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.15rem 1rem;
  margin: 0.45rem 0 0;
  font-size: 0.88rem;
}

.pub__venue {
  font-family: var(--serif);
  font-style: italic;
  font-size: 1rem;
  color: var(--text);
}

.pub__link { white-space: nowrap; }

.pub__link::after {
  content: " ↗";
  font-size: 0.85em;
}

.pub__note {
  margin: 0.4rem 0 0;
  font-size: 0.78rem;
  color: var(--faint);
}

.pub-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 1.5rem;
  margin-bottom: 2.75rem;
}

.pub-tab {
  padding: 0.2rem 0;
  border: 0;
  border-bottom: 1.5px solid transparent;
  background: none;
  color: var(--muted);
  font: inherit;
  font-size: 0.9rem;
  cursor: pointer;
  transition: color 0.15s ease, border-color 0.15s ease;
}

.pub-tab:hover { color: var(--text); }

.pub-tab[aria-pressed="true"] {
  color: var(--text);
  border-bottom-color: var(--text);
}

.pub-year + .pub-year { margin-top: 2.75rem; }

.pub-year .section__label { margin-bottom: 1rem; }

/* ============================================================
   Inner pages
   ============================================================ */

.page-head { margin-bottom: 2.5rem; }

.page-title {
  margin: 0;
  font-family: var(--serif);
  font-size: 2.5rem;
  font-weight: 400;
  line-height: 1.15;
  letter-spacing: -0.02em;
  text-wrap: balance;
}

.page-title--paper {
  font-size: 1.9rem;
  line-height: 1.25;
  letter-spacing: -0.012em;
}

.page-head .pub__authors {
  margin-top: 1rem;
  font-size: 0.95rem;
}

.page-head .pub__meta {
  margin-top: 0.7rem;
  font-size: 0.92rem;
}

.page-meta {
  margin: 0.75rem 0 0;
  color: var(--muted);
}

.back-link {
  display: inline-block;
  margin-bottom: 1.5rem;
  font-size: 0.85rem;
  color: var(--muted);
  text-decoration: none;
}

.back-link:hover { color: var(--text); }

.prose > :first-child { margin-top: 0; }

.prose h2,
.prose h3,
.prose h4 {
  margin: 2.5rem 0 0.9rem;
  font-family: var(--sans);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--faint);
}

.prose p { margin: 0 0 1rem; }

.prose ul,
.prose ol {
  margin: 0 0 1rem;
  padding-left: 1.2rem;
}

.prose li { margin-bottom: 0.5rem; }

.prose li::marker { color: var(--faint); }

.prose hr {
  margin: 2.5rem 0;
  border: 0;
  border-top: 1px solid var(--rule);
}

.prose blockquote {
  margin: 1.5rem 0;
  padding-left: 1.1rem;
  border-left: 2px solid var(--rule);
  color: var(--muted);
}

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

.prose pre {
  margin: 0 0 1rem;
  padding: 1rem 1.1rem;
  border: 1px solid var(--rule);
  border-radius: 8px;
  background: var(--code-bg);
  font-size: 0.82rem;
  line-height: 1.6;
  overflow-x: auto;
}

.prose pre code {
  padding: 0;
  background: none;
  font-size: inherit;
}

.prose table {
  width: 100%;
  margin: 0 0 1rem;
  border-collapse: collapse;
  font-size: 0.92rem;
}

.prose th,
.prose td {
  padding: 0.55rem 0.75rem 0.55rem 0;
  border-bottom: 1px solid var(--rule);
  text-align: left;
}

/* ============================================================
   Small screens
   ============================================================ */

@media (max-width: 40rem) {
  body { font-size: 1rem; }

  .wrap { padding: 0 1.25rem; }

  main.wrap {
    padding-top: 2.25rem;
    padding-bottom: 3.5rem;
  }

  .site-header__inner {
    padding-top: 1.1rem;
    padding-bottom: 1.1rem;
  }

  .site-nav { gap: 1.1rem; }

  .hero {
    flex-direction: column;
    align-items: flex-start;
    gap: 1.5rem;
    margin-bottom: 2.25rem;
  }

  .hero__photo {
    width: 112px;
    height: 112px;
  }

  .hero__name { font-size: 2.2rem; }

  .section { margin-top: 2.75rem; }

  .statement { font-size: 1.35rem; }

  .facts { grid-template-columns: 1fr; }

  .facts dt {
    padding-bottom: 0;
    padding-right: 0;
  }

  .facts dd {
    padding-top: 0.2rem;
    border-top: 0;
  }

  .page-title { font-size: 2rem; }

  .page-title--paper { font-size: 1.5rem; }
}

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

@media print {
  .site-nav, .skip-link { display: none; }
  body { background: #fff; color: #000; }
}
