/* ---------- Tokens ---------- */
:root {
  --paper: #f5f4ef;        /* warm paper ground, as on pi.website */
  --paper-hover: #ebeae5;
  --card: #ffffff;
  --ink: #141413;
  --ink-soft: #3d3c38;
  --muted: #686763;
  --divider: #e5e4dc;
  --rail: #c9c8bf;
  --link: #595955;
  --shadow: #141413;
  --vox-top: #8f8d84; --vox-left: #141413; --vox-right: #3d3c38;

  --serif: "Newsreader", "Iowan Old Style", Georgia, "Times New Roman", serif;
  --sans: "Source Sans 3", "Helvetica Neue", Arial, system-ui, sans-serif;
  --measure: 52rem;   /* 832px column; paragraphs stay capped below */
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #151513; --paper-hover: #1f1e1b; --card: #1b1b18;
    --ink: #ebe9e1; --ink-soft: #cfcdc4; --muted: #9a988f;
    --divider: #2b2a26; --rail: #3a3934; --link: #b3b1a8; --shadow: #ebe9e1;
    --vox-top: #8f8d84; --vox-left: #ebe9e1; --vox-right: #bab8af;
  }
}
:root[data-theme="dark"] {
  --paper: #151513; --paper-hover: #1f1e1b; --card: #1b1b18;
  --ink: #ebe9e1; --ink-soft: #cfcdc4; --muted: #9a988f;
  --divider: #2b2a26; --rail: #3a3934; --link: #b3b1a8; --shadow: #ebe9e1;
  --vox-top: #8f8d84; --vox-left: #ebe9e1; --vox-right: #bab8af;
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
a:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
img { max-width: 100%; display: block; }
h1, h2 { font-family: var(--serif); font-weight: 500; margin: 0; text-wrap: balance; }
.link { color: var(--link); text-decoration: underline; text-underline-offset: 3px; }
.link:hover { color: var(--ink); }

.page { max-width: var(--measure); margin: 0 auto; padding: 1.5rem 1.25rem 3rem; }
html, body { overflow-x: hidden; }   /* nothing should scroll the page sideways */

/* ---------- Top bar ---------- */
.topbar {
  display: flex; align-items: baseline; justify-content: space-between; gap: 1rem;
  padding-bottom: 1.25rem; margin-bottom: 2.25rem;
}
.wordmark { font-family: var(--serif); font-size: 1.2rem; display: inline-flex; align-items: center; gap: 0.55rem; }
.mark { height: 1.4em; width: auto; }
.mark polygon { stroke: var(--paper); stroke-width: 0.6; stroke-linejoin: round; }
.mark .f-top { fill: var(--vox-top); } .mark .f-left { fill: var(--vox-left); } .mark .f-right { fill: var(--vox-right); }
.topbar nav { display: flex; gap: 1.1rem; font-size: 0.85rem; }
.topbar nav a { color: var(--muted); }
.topbar nav a:hover { color: var(--ink); text-decoration: underline; text-underline-offset: 5px; }

/* ---------- Intro ---------- */
.intro { display: grid; grid-template-columns: 5rem minmax(0, 1fr); gap: 1.5rem; align-items: start; margin-bottom: 2.5rem; }
.avatar { width: 5rem; aspect-ratio: 1; border-radius: 999px; object-fit: cover; }
.intro p { margin: 0 0 0.7rem; color: var(--ink-soft); }
.intro p:last-child { margin-bottom: 0; }

/* ---------- Sections ---------- */
.section { margin-top: 2.5rem; }
.section h2 { font-size: 1.25rem; margin-bottom: 1.1rem; }

/* ---------- Timeline (pi.website feed) ---------- */
.timeline { position: relative; margin: 0; padding: 0 0 0 1.5rem; list-style: none; display: flex; flex-direction: column; gap: 0.35rem; }
.timeline::after {
  content: ""; position: absolute; left: 0; top: 0.5rem; bottom: 0; width: 1px;
  background: linear-gradient(to bottom, var(--rail) 0, var(--rail) calc(100% - 5rem), transparent 100%);
}
.entry { position: relative; display: flex; flex-direction: column; gap: 0.25rem; padding: 0.55rem 0.75rem; transition: background 150ms ease; }
.entry:hover { background: var(--paper-hover); }
.entry::before {
  content: ""; position: absolute; left: calc(-1.5rem - 3px); top: 0.95rem;
  width: 7px; height: 7px; border-radius: 2px; background: var(--ink); outline: 2px solid var(--paper); z-index: 1;
}
.entry .row { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; }
.entry .title { font-weight: 600; font-size: 0.86rem; line-height: 1.35; }
.entry a.title:hover { text-decoration: underline; text-underline-offset: 3px; }
.entry .when { font-size: 0.78rem; color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
.entry .desc { margin: 0; font-size: 0.82rem; line-height: 1.5; color: var(--muted); }
.entry .meta { display: flex; flex-wrap: wrap; gap: 0.25rem 0.9rem; font-size: 0.76rem; color: var(--muted); }
.entry .meta a { color: var(--link); text-decoration: underline; text-underline-offset: 3px; }
.entry .meta a:hover { color: var(--ink); }
.entry .meta .meta-links { flex-basis: 100%; }   /* links drop to their own line, under the affiliation */

.entry.is-featured {
  background: var(--card); border: 1px solid var(--shadow); box-shadow: 3px 3px 0 var(--shadow);
  transition: box-shadow 150ms ease;
}
.entry.is-featured:hover { box-shadow: 5px 5px 0 var(--shadow); }
.entry.is-featured .desc { color: var(--ink-soft); }

/* ---------- Card thumbnail ---------- */
.entry-main { display: grid; grid-template-columns: 11rem minmax(0, 1fr); gap: 0.95rem; align-items: start; }
.entry-text { display: flex; flex-direction: column; gap: 0.25rem; min-width: 0; }
.thumb { display: block; overflow: hidden; border: 1px solid var(--divider); border-radius: 5px; background: var(--paper); }
.thumb video, .thumb img { display: block; width: 100%; height: auto; border-radius: 4px; }   /* Safari clips video by its own radius, not the parent's */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .thumb video,
  :root:not([data-theme="light"]) .thumb img { filter: brightness(0.82); }
}
:root[data-theme="dark"] .thumb video,
:root[data-theme="dark"] .thumb img { filter: brightness(0.82); }
@media (max-width: 600px) {
  .entry-main { grid-template-columns: 1fr; gap: 0.6rem; }
  .thumb { max-width: 100%; }   /* fill the column on a phone, no arbitrary inset */
}

/* ---------- Publications ---------- */
.pubs { margin: 0; padding: 0; list-style: none; }
.pub { padding: 0.65rem 0; border-top: 1px solid var(--divider); font-size: 0.84rem; line-height: 1.5; }

.pub:last-child { border-bottom: 1px solid var(--divider); }
.pub .ptitle { display: block; font-family: var(--serif); font-size: 1rem; }
.pub .authors { color: var(--ink-soft); }
.pub .authors .me { font-weight: 600; color: var(--ink); }
.pub .venue { color: var(--muted); font-size: 0.78rem; }
.pub .venue a { color: var(--link); text-decoration: underline; text-underline-offset: 3px; }
.pub .venue a:hover { color: var(--ink); }

/* ---------- Research experience ---------- */
.orgs { margin: 0; padding: 0; list-style: none; }
.org { display: grid; grid-template-columns: 4.25rem minmax(0, 1fr); gap: 1.1rem; align-items: start; padding: 0.85rem 0; border-top: 1px solid var(--divider); }
.org:last-child { border-bottom: 1px solid var(--divider); }
.org-logo { display: flex; align-items: center; justify-content: center; width: 4.25rem; height: 3.25rem; }
.org-logo img { max-width: 100%; max-height: 100%; width: auto; height: auto; object-fit: contain; }
.org-body { display: flex; flex-direction: column; gap: 0.2rem; min-width: 0; }
.org .row { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; }
.org-name { font-weight: 600; font-size: 0.86rem; line-height: 1.35; }
.org .when { font-size: 0.78rem; color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
.org .desc { margin: 0; font-size: 0.82rem; line-height: 1.5; color: var(--muted); }
.org .desc a { color: var(--link); text-decoration: underline; text-underline-offset: 3px; }
.org .desc a:hover { color: var(--ink); }

/* ---------- Footer ---------- */
.footer { margin-top: 3.5rem; padding-top: 1.25rem; border-top: 1px solid var(--divider); font-size: 0.84rem; color: var(--muted); }
.footer p { margin: 0 0 0.5rem; }
.footer .wordmark { color: var(--ink); margin-top: 1.5rem; }

/* ---------- Responsive ---------- */
@media (max-width: 600px) {
  /* the four nav links do not fit beside the wordmark on a phone: let both wrap */
  .topbar { flex-wrap: wrap; gap: 0.5rem 1rem; align-items: baseline; }
  .topbar nav { flex-wrap: wrap; gap: 0.75rem 0.9rem; }
  .intro { grid-template-columns: 1fr; gap: 1rem; }
  .entry .row { flex-direction: column; gap: 0.1rem; }
  .org { grid-template-columns: 3.25rem minmax(0, 1fr); gap: 0.75rem; }
  .org-logo { width: 3.25rem; height: 2.75rem; }
  .org .row { flex-direction: column; gap: 0.1rem; }
}
@media (prefers-reduced-motion: reduce) { .entry { transition: none; } }
