:root {
  color-scheme: dark;
  --color-background: #08130f;
  --color-text: #f3f7f4;
  --color-muted: #d0dcd4;
  --color-accent: #cde6c9;
  --color-accent-hover: #ecf7ea;
  --color-accent-soft: #a3c4a5;
  --color-edge: #6f8f7c;
  --color-node: #adc4b6;
  --color-rule: #32503f;
  --color-wash: #101f18;
  --content-width: 1056px;
  --sidebar-width: 252px;
  --font-body: -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
  --font-heading: Georgia, "Times New Roman", serif;
  /* Header heights; assets/tree-nav.js measures the real values. These hold until it runs, or without JavaScript. */
  --header-full: 150px;
  --header-h: 92px;
  /* Vertical gap from the name to the navigation tree's five leaves, unfolded and folded. */
  --tree-drop: 3.4rem;
  --tree-drop-compact: 2.1rem;
}

* { box-sizing: border-box; }

/* Base text size; every rem in this file scales with it. 125% is 20px at the browser default of 16px. */
html { font-size: 125%; scroll-padding-top: calc(var(--header-h) + 1.5rem); }

body {
  margin: 0;
  padding-top: var(--header-full);
  background: var(--color-background);
  color: var(--color-text);
  font-family: var(--font-body);
  font-size: 1rem;
  line-height: 1.75;
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--color-accent);
  text-decoration: underline;
  text-underline-offset: 0.2em;
}

a:hover {
  color: var(--color-accent-hover);
  text-decoration: underline;
}

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

p { margin: 0 0 1.1rem; }
strong { font-weight: 600; }

h1, h2, h3 {
  margin: 0;
  font-weight: 500;
  line-height: 1.3;
}

h1, h2 { font-family: var(--font-heading); }
/* Sized so the full name fits on one line in the desktop sidebar. */
h1 { font-size: 1.65rem; letter-spacing: -0.035em; }
h2 { margin-bottom: 1.3rem; font-size: 1.75rem; letter-spacing: -0.025em; }
h3 { font-size: 1.03rem; font-weight: 600; line-height: 1.5; }

.skip-link {
  position: absolute;
  top: 0.75rem;
  left: 1rem;
  z-index: 20;
  padding: 0.5rem 1rem;
  background: var(--color-background);
  border: 2px solid var(--color-accent);
  transform: translateY(-200%);
}
.skip-link:focus { transform: translateY(0); }

.monogram {
  display: grid;
  place-items: center;
  min-width: 1.9rem;
  height: 1.9rem;
  padding: 0 0.35rem;
  background: var(--color-accent);
  color: var(--color-background);
  font-family: var(--font-heading);
  font-size: 0.85rem;
  font-weight: 500;
  border-radius: 3px;
}

/* Navigation tree. The header is fixed so it can fold into a shorter tree while scrolling without shifting the page;
   a short background fade under it softens text passing beneath. assets/tree-nav.js draws the edges and nodes. */
.tree-header { position: fixed; top: 0; right: 0; left: 0; z-index: 10; background: var(--color-background); }
.tree-header::after { content: ""; position: absolute; top: 100%; right: 0; left: 0; height: 14px; background: linear-gradient(var(--color-background), transparent); pointer-events: none; }
.tree-nav {
  position: relative;
  max-width: var(--content-width);
  margin: 0 auto;
  padding: 1.5rem 0 0.8rem;
  border-bottom: 1px solid var(--color-rule);
}

.tree-root {
  position: relative;
  z-index: 1;
  display: block;
  width: max-content;
  margin: 0 auto;
  color: var(--color-text);
  font-family: var(--font-heading);
  font-size: 1.85rem;
  letter-spacing: -0.03em;
  line-height: 1.2;
  text-decoration: none;
}
.tree-root:hover { color: var(--color-accent); text-decoration: none; }
.tree-root .monogram { display: none; }
/* Equal outer columns put the middle initial at the center, directly above the root node. */
.tree-root-name { display: grid; grid-template-columns: 1fr auto 1fr; }
.name-first { text-align: right; }
.name-middle { white-space: pre; }

/* Zero-width items space the node centers evenly across the full width; the outer labels sit flush with the edges
   of the page content, under the ends of the rule. */
.tree-nav ul {
  display: flex;
  justify-content: space-between;
  margin: var(--tree-drop) 0 0;
  padding: 0;
  list-style: none;
}
.tree-nav li { display: flex; justify-content: center; width: 0; }
.tree-nav li:first-child { justify-content: flex-start; }
.tree-nav li:last-child { justify-content: flex-end; }
.tree-nav ul a { display: inline-block; color: var(--color-muted); font-size: 0.9375rem; line-height: 1.5; text-decoration: none; white-space: nowrap; transition: color 0.2s; }
.tree-nav ul a:hover, .tree-nav ul a[aria-current] { color: var(--color-accent); }
.tree-nav ul a[aria-current] { font-weight: 600; }
.tree-nav .nav-cv { color: var(--color-accent); font-weight: 600; }

/* Folded state once the reader scrolls: the name gives way to the monogram and the branches shorten. */
.is-compact .tree-nav { padding-top: 0.6rem; }
.is-compact .tree-root-name { display: none; }
.is-compact .tree-root .monogram { display: grid; min-width: 1.6rem; height: 1.6rem; padding: 0 0.3rem; font-size: 0.75rem; }
.is-compact .tree-nav ul { margin-top: var(--tree-drop-compact); }

.tree-nav-edges { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; pointer-events: none; }
.nav-edge { fill: none; stroke: var(--color-edge); stroke-width: 1.2; transition: stroke 0.25s; }
.nav-edge.is-hover { stroke: var(--color-accent-soft); stroke-width: 1.8; }
.nav-edge.is-active { stroke: var(--color-accent); stroke-width: 2.2; }
.nav-node { fill: var(--color-background); stroke: var(--color-node); stroke-width: 1.4; transition: fill 0.25s, stroke 0.25s; }
.nav-node.is-hover { stroke: var(--color-accent); }
.nav-node.is-active { fill: var(--color-accent); stroke: var(--color-accent); }
.nav-node.is-terminal { fill: var(--color-wash); stroke: var(--color-accent); }
.nav-root { fill: var(--color-text); }

.page-layout {
  display: grid;
  grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
  align-items: start;
  gap: 5rem;
  max-width: var(--content-width);
  margin: 2.6rem auto 0;
}

/* The sidebar stays in view under the folded header; a 5:4 portrait crop and tight spacing keep it short enough to
   fit whole on tall windows. Shorter windows scroll its lower part inside it (see the screen query below). */
.profile {
  --profile-top: calc(var(--header-h) + 1.6rem);
  position: sticky;
  top: var(--profile-top);
  padding-bottom: 1rem;
}
.portrait {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 5 / 4;
  object-fit: cover;
  object-position: center 30%;
  border-radius: 4px;
  margin-bottom: 1.2rem;
}

.profile-role { margin: 0.4rem 0 0.2rem; font-size: 0.875rem; }
.profile-affiliation { margin-bottom: 0; color: var(--color-muted); font-size: 0.875rem; line-height: 1.65; }
.profile-links { margin-top: 1rem; }
.email-link { font-size: 0.875rem; overflow-wrap: anywhere; }
.social-links { display: flex; flex-wrap: wrap; gap: 1.1rem; margin-top: 0.4rem; font-size: 0.875rem; }
.sidebar-note { border-top: 1px solid var(--color-rule); margin-top: 1.25rem; padding-top: 1rem; }
.small-heading { margin-bottom: 0.5rem; font-size: 0.875rem; font-weight: 600; }
.sidebar-note .small-heading { margin-bottom: 0.3rem; }
.sidebar-note > p:last-of-type { margin-bottom: 0; color: var(--color-muted); font-size: 0.875rem; line-height: 1.75; }

main { min-width: 0; overflow-wrap: anywhere; }
.content-section { margin-bottom: 3.1rem; scroll-margin-top: 2rem; }

/* About: the heading and bio. */
.about-section { margin-bottom: 2.5rem; }
.about-main p { line-height: 1.85; text-wrap: pretty; }
.about-main p:last-child { margin-bottom: 0; }

/* Learning dynamics: replicator path on the strategy simplex, drawn by assets/learning-dynamics.js. It sits in the
   sidebar under the research interests and is hidden with them in print. */
.dynamics-figure { margin: 1rem 0 0; }
.figure-caption { margin: 0.35rem 0 0; color: var(--color-muted); font-size: 0.75rem; line-height: 1.5; }
.simplex { display: block; width: 100%; height: auto; overflow: visible; }
.simplex-edge { fill: none; stroke: var(--color-edge); stroke-width: 1; }
.simplex-vertex { fill: var(--color-muted); font: italic 10px var(--font-heading); }
.simplex-path {
  fill: none;
  stroke: var(--color-accent);
  stroke-width: 1.1;
  stroke-linejoin: round;
  opacity: 0.85;
  stroke-dasharray: 1;
  stroke-dashoffset: 1;
  animation: simplex-draw 3.2s cubic-bezier(0.3, 0.1, 0.2, 1) 0.2s forwards;
}
.simplex-start { fill: var(--color-background); stroke: var(--color-accent); stroke-width: 1; }
.simplex-eq { fill: var(--color-accent); opacity: 0; animation: simplex-fade 0.5s ease 3.1s forwards; }
@keyframes simplex-draw { to { stroke-dashoffset: 0; } }
@keyframes simplex-fade { to { opacity: 1; } }

.updates { list-style: none; margin: 0; padding: 0; }
.updates li { display: grid; grid-template-columns: 5.2rem minmax(0, 1fr); gap: 1.2rem; margin-bottom: 0.8rem; font-size: 0.925rem; }
.updates li:last-child { margin-bottom: 0; }
.updates time { color: var(--color-muted); font-size: 0.875rem; padding-top: 0.035rem; }

.research-group + .research-group { margin-top: 2.6rem; }
.research-group h3 { margin: 0 0 1rem; font-family: var(--font-heading); font-size: 1.35rem; font-weight: 400; letter-spacing: -0.015em; }
.work-list, .paper-list, .community-list { margin: 0; padding: 0; list-style: none; }
.work-list li { position: relative; padding-left: 1.2rem; }
.work-list li + li { margin-top: 0.55rem; }
.work-list li::before { content: ""; position: absolute; top: 0.72em; left: 0.1rem; width: 6px; height: 6px; border-radius: 50%; background: var(--color-accent); }
.work-title { font-weight: 600; }
.work-with { color: var(--color-muted); font-size: 0.9375rem; }
.paper-list li { padding: 0.1rem 0 0.1rem 1.1rem; border-left: 3px solid var(--color-accent); }
.paper-list li + li { margin-top: 1.4rem; }
.paper-list p { margin: 0; }
.paper-title { font-size: 1.0625rem; font-weight: 600; line-height: 1.45; }
.paper-authors { margin-top: 0.3rem; color: var(--color-muted); font-size: 0.9375rem; }
.paper-meta { margin-top: 0.2rem; font-size: 0.875rem; }
.paper-venue { color: var(--color-accent); }

.honors-list { margin: 0; padding: 0; list-style: none; }
.honors-list li { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; padding: 0.85rem 0; border-bottom: 1px solid var(--color-rule); font-size: 0.925rem; }
.honors-list li:first-child { padding-top: 0; }
.honors-list li:last-child { border-bottom: 0; }
.honor-year { flex: none; color: var(--color-muted); font-size: 0.875rem; white-space: nowrap; }

.community-list li + li { margin-top: 1.1rem; }
.community-list p { margin: 0; }
.community-name { font-weight: 600; }
.community-detail { color: var(--color-muted); font-size: 0.9375rem; }

/* Text still to be supplied before publishing; scripts/check_site.py lists every element with this class. */
.fill-in { padding: 0 0.3rem; border: 1px dashed var(--color-accent-soft); border-radius: 3px; color: var(--color-accent); }

.site-footer { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 1rem; padding: 1.4rem 0 2.5rem; border-top: 1px solid var(--color-rule); color: var(--color-muted); font-size: 0.8125rem; }

@media (prefers-reduced-motion: reduce) {
  .simplex-path { animation: none; stroke-dashoffset: 0; }
  .simplex-eq { animation: none; opacity: 1; }
}

@media (max-width: 1152px) {
  .tree-nav, .page-layout { margin-left: 2rem; margin-right: 2rem; }
  .page-layout { gap: 3.5rem; }
}

/* Below 860px the sidebar narrows to give the main column room. */
@media (max-width: 860px) {
  .page-layout { grid-template-columns: 200px minmax(0, 1fr); gap: 2.5rem; }
}

/* Desktop windows too short for the whole stuck sidebar (its bottom edge sits near 1255px) scroll the rest of it,
   down to the learning-dynamics figure, inside the sidebar. The inline padding, cancelled by an equal negative margin,
   leaves room for link focus rings (2px outline at a 5px offset) that the scroll container would otherwise clip. */
@media screen and (min-width: 661px) {
  .profile {
    --focus-ring-room: 8px;
    max-height: calc(100vh - var(--profile-top));
    overflow-y: auto;
    scrollbar-width: thin;
    padding-inline: var(--focus-ring-room);
    margin-inline: calc(-1 * var(--focus-ring-room));
  }
}

/* Phones: the header scrolls away with the page, so nothing passes under it and it needs no fade. */
@media (max-width: 660px) {
  body { padding-top: 0; }
  .tree-header { position: static; }
  .tree-header::after { display: none; }
  .tree-nav { margin: 0 1.4rem; padding-top: 1.1rem; }
  .tree-root { font-size: 1.5rem; }
  .tree-nav ul { margin-top: calc(var(--tree-drop) * 0.8); }
  /* Phones fit five labels in one row by spacing them with equal gaps (not equal centers), shrinking them from 15px
     to 13px on the narrowest screens, and shortening "Honors & Awards" to "Honors". */
  .tree-nav li { width: auto; }
  .tree-nav ul a { font-size: clamp(0.65rem, 3.9vw, 0.75rem); }
  .nav-extra { display: none; }
  .page-layout { display: block; margin-left: 1.4rem; margin-right: 1.4rem; }
  .profile { position: static; margin-bottom: 2rem; border-bottom: 1px solid var(--color-rule); }
  .portrait { width: 168px; aspect-ratio: 1; }
  /* Keep the figure at its desktop sidebar size instead of stretching across the screen. */
  .dynamics-figure { max-width: var(--sidebar-width); }
  .content-section { margin-bottom: 2.6rem; }
  h2 { font-size: 1.65rem; }
  .updates li { grid-template-columns: minmax(0, 1fr); gap: 0.15rem; margin-bottom: 1.1rem; }
  .site-footer { padding-bottom: 2rem; }
}

@media print {
  :root {
    color-scheme: light;
    --color-background: #fff;
    --color-text: #292d32;
    --color-muted: #626871;
    --color-accent: #31573c;
    --color-rule: #dbe3dd;
    --color-wash: #f1f5f2;
  }
  body { padding-top: 0; font-size: 10pt; }
  .tree-header, .skip-link, .site-footer { display: none; }
  .page-layout { display: block; margin: 0; }
  .profile { position: static; padding: 0; margin-bottom: 1.5rem; }
  .portrait { float: right; width: 100px; margin: 0 0 1rem 1rem; }
  .sidebar-note { display: none; }
  .profile-links { margin-top: 0.5rem; }
  .content-section { margin-bottom: 1.5rem; }
  .paper-list li, .honors-list li { break-inside: avoid; }
  a { color: inherit; }
}
