/* ---------------------------------------------
   Tokens
--------------------------------------------- */
:root {
  --paper: #f7f7f3;
  --ink: #1c1c1a;
  --graphite: #5c5c56;
  --faint: #8a8a82;
  --rule: #dcdad0;
  --accent: #3e4c59;
  --accent-soft: #6c7a89;
  --serif: "Source Serif 4", Georgia, "Times New Roman", serif;
  --mono: "IBM Plex Mono", "Courier New", monospace;
}

* { box-sizing: border-box; }

html {
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--serif);
  font-size: 17px;
  line-height: 1.6;
}

a {
  color: var(--accent);
  text-decoration: none;
  border-bottom: 1px solid var(--rule);
}

a:hover, a:focus {
  border-bottom-color: var(--accent);
}

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

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

/* ---------------------------------------------
   Layout
--------------------------------------------- */
.wrap {
  max-width: 1040px;
  margin: 0 auto;
  padding: 56px 24px 96px;
  display: grid;
  grid-template-columns: 250px 1fr;
  gap: 64px;
}

@media (max-width: 760px) {
  .wrap {
    grid-template-columns: 1fr;
    gap: 40px;
    padding: 36px 20px 72px;
  }
}

/* ---------------------------------------------
   Sidebar
--------------------------------------------- */
.sidebar {
  position: sticky;
  top: 56px;
  align-self: start;
}

@media (max-width: 760px) {
  .sidebar { position: static; }
}

.avatar {
  width: 104px;
  height: 104px;
  border-radius: 50%;
  border: 1px solid var(--rule);
  margin-bottom: 20px;
  object-fit: cover;
  background: #eceae1;
}

.name {
  font-size: 21px;
  font-weight: 600;
  letter-spacing: -0.01em;
  margin: 0 0 4px;
}

.role {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--faint);
  text-transform: lowercase;
  letter-spacing: 0.02em;
  margin: 0 0 22px;
}

nav.primary {
  margin-bottom: 28px;
  border-top: 1px solid var(--rule);
  padding-top: 18px;
}

nav.primary ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

nav.primary li { margin-bottom: 9px; }

nav.primary a {
  border-bottom: none;
  color: var(--graphite);
  font-size: 15px;
}

nav.primary a:hover { color: var(--ink); }

nav.primary a.current {
  color: var(--ink);
  position: relative;
  padding-left: 13px;
}

nav.primary a.current::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.55em;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--accent);
}

.meta-block {
  border-top: 1px solid var(--rule);
  padding-top: 18px;
  font-family: var(--mono);
  font-size: 12.5px;
  color: var(--graphite);
}

.meta-block dl {
  margin: 0;
  display: grid;
  grid-template-columns: auto 1fr;
  row-gap: 8px;
  column-gap: 12px;
}

.meta-block dt {
  color: var(--faint);
}

.meta-block dd {
  margin: 0;
  word-break: break-word;
}

.meta-block a {
  color: var(--graphite);
  border-bottom: 1px solid var(--rule);
}

.meta-block a:hover { color: var(--ink); border-bottom-color: var(--ink); }

/* ---------------------------------------------
   Main content
--------------------------------------------- */
main { max-width: 660px; }

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

h1.page-title {
  font-size: 30px;
  font-weight: 600;
  letter-spacing: -0.01em;
  margin: 0 0 28px;
}

h2.section-title {
  font-size: 18px;
  font-weight: 600;
  margin: 44px 0 6px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--rule);
}

p { margin: 0 0 16px; }

.lede {
  font-size: 18px;
  color: var(--ink);
}

.dim { color: var(--graphite); }

/* Entry: shared pattern for education, roles, distinctions */
.entry {
  margin: 20px 0 28px;
}

.entry-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px 20px;
}

.entry-title {
  font-weight: 600;
  font-size: 16.5px;
}

.entry-when {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--faint);
  white-space: nowrap;
}

.entry-where {
  font-size: 14px;
  color: var(--graphite);
  margin: 2px 0 8px;
}

.entry-body {
  font-size: 15.5px;
  color: var(--ink);
}

/* Projects */
.project {
  border-top: 1px solid var(--rule);
  padding: 32px 0;
}

.project:first-of-type { border-top: none; padding-top: 8px; }

.project-figure {
  border: 1px solid var(--rule);
  background: #efeee7;
  padding: 18px;
  margin-bottom: 16px;
}

.project-figure svg { width: 100%; height: auto; display: block; }

.project-title {
  font-size: 19px;
  font-weight: 600;
  margin: 0 0 4px;
}

.project-tag {
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--faint);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin: 0 0 10px;
}

.project-links {
  margin-top: 10px;
  font-family: var(--mono);
  font-size: 12.5px;
}

.project-links a { margin-right: 16px; }

/* Publications */
.pub {
  padding: 18px 0;
  border-top: 1px solid var(--rule);
}

.pub:first-of-type { border-top: none; padding-top: 0; }

.pub-title { font-weight: 600; font-size: 15.5px; margin: 0 0 4px; }
.pub-meta { font-family: var(--mono); font-size: 12px; color: var(--faint); margin: 0 0 6px; }
.post-meta { font-family: var(--mono); font-size: 12px; color: var(--faint); margin: 0 0 24px; }
.pub-status { color: var(--graphite); font-size: 14.5px; }

/* List (smaller code projects, distinctions) */
.plain-list {
  margin: 0 0 8px;
  padding-left: 0;
  list-style: none;
}

.plain-list li {
  padding: 10px 0;
  border-top: 1px solid var(--rule);
  font-size: 15px;
}

.plain-list li:first-child { border-top: none; }

.plain-list .label { font-weight: 600; }
.plain-list .sub { color: var(--graphite); font-size: 14px; display: block; margin-top: 2px; }

/* Blog */
.post-item {
  padding: 18px 0;
  border-top: 1px solid var(--rule);
}

.post-item:first-of-type { border-top: none; padding-top: 0; }

.post-item-title {
  font-weight: 600;
  font-size: 16.5px;
  margin: 0 0 4px;
}

.post-item-title a {
  border-bottom: none;
  color: var(--ink);
}

.post-item-title a:hover { color: var(--accent); }

.post-summary {
  color: var(--graphite);
  font-size: 14.5px;
  margin: 0;
}

footer.page-foot {
  margin-top: 56px;
  padding-top: 18px;
  border-top: 1px solid var(--rule);
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--faint);
}

/* ---------------------------------------------
   Markdown blog content (post.html, #post-body)
--------------------------------------------- */
.md-content h1,
.md-content h2,
.md-content h3,
.md-content h4 {
  font-weight: 600;
  letter-spacing: -0.01em;
  margin: 32px 0 12px;
}

.md-content h1 { font-size: 24px; }
.md-content h2 { font-size: 20px; padding-bottom: 6px; border-bottom: 1px solid var(--rule); }
.md-content h3 { font-size: 17px; }
.md-content h4 { font-size: 15.5px; color: var(--graphite); }

.md-content > *:first-child { margin-top: 0; }

.md-content p { margin: 0 0 16px; }

.md-content ul,
.md-content ol {
  margin: 0 0 16px;
  padding-left: 22px;
}

.md-content li { margin-bottom: 6px; }

.md-content blockquote {
  margin: 0 0 16px;
  padding: 2px 0 2px 16px;
  border-left: 2px solid var(--accent-soft);
  color: var(--graphite);
}

.md-content hr {
  border: none;
  border-top: 1px solid var(--rule);
  margin: 32px 0;
}

.md-content a {
  color: var(--accent);
}

.md-content code {
  font-family: var(--mono);
  font-size: 0.88em;
  background: #eceae1;
  padding: 1px 5px;
  border-radius: 3px;
}

.md-content pre {
  background: #24292e;
  padding: 16px;
  border-radius: 4px;
  overflow-x: auto;
  margin: 0 0 20px;
}

.md-content pre code {
  background: none;
  padding: 0;
  color: #e6e6e6;
  font-size: 13px;
  line-height: 1.5;
}

.md-content table {
  width: 100%;
  border-collapse: collapse;
  margin: 0 0 20px;
  font-size: 14.5px;
}

.md-content th,
.md-content td {
  border: 1px solid var(--rule);
  padding: 8px 10px;
  text-align: left;
}

.md-content th {
  background: #efeee7;
  font-weight: 600;
}

.md-content img {
  border: 1px solid var(--rule);
  margin: 8px 0 20px;
}

/* Mermaid diagrams, rendered into a div.mermaid-diagram in place of the
   ```mermaid code fence */
.mermaid-diagram {
  margin: 8px 0 24px;
  padding: 24px 16px;
  background: #efeee7;
  border: 1px solid var(--rule);
  overflow-x: auto;
  display: flex;
  justify-content: center;
}

.mermaid-diagram svg {
  max-width: 100%;
  height: auto !important;
  display: block;
}

/* Plotly charts, rendered into a div.plot-container in place of the
   ```plot code fence. min-height matches the default height set in
   renderPlotsIn so the container never collapses to zero before Plotly
   has measured it. */
.plot-container {
  margin: 8px 0 24px;
  border: 1px solid var(--rule);
  padding: 8px;
  min-height: 420px;
}

.plot-container .js-plotly-plot,
.plot-container .plot-container.plotly {
  width: 100%;
}

/* KaTeX display math can overflow narrow viewports, scroll instead of
   breaking layout */
.katex-display {
  overflow-x: auto;
  overflow-y: hidden;
}
