/* Tokens */
:root {
  /* Palette: white paper, ink, one deep teal-green accent */
  --bg:           #ffffff;
  --bg-2:         #f4f6f5;
  --rule:         #e1e7e4;
  --rule-2:       #cbd4d0;
  --text:         #17201d;
  --text-2:       #4b5651;
  --text-3:       #5f6964;
  --accent:       #0b6e5f;
  --accent-hover: #085246;

  --ff-display: Georgia, serif;
  --ff-body:    system-ui, sans-serif;

  --max:     1120px;
  --side:    240px;
  --measure: 68ch;
  --tap:     44px;
}

/* Base */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
@media (prefers-reduced-motion: no-preference) { html { scroll-behavior: smooth; } }
body { background: var(--bg); color: var(--text); font: 1rem/1.7 var(--ff-body); }
a { color: var(--accent); text-underline-offset: 2px; }
a:hover { color: var(--accent-hover); }
img { display: block; max-width: 100%; height: auto; }
ul { list-style: none; }
h1, h2, h3 { font-family: var(--ff-display); line-height: 1.25; }
h1 { font-size: clamp(1.9rem, 3.4vw, 2.5rem); font-weight: 600; letter-spacing: -.01em; }
h2 { font-size: 1.45rem; font-weight: 600; }
h3 { font-size: 1.1rem; font-weight: 700; }
cite { font-style: italic; }

.skip-link { position: absolute; left: 1rem; top: -4rem; z-index: 300; padding: .6rem 1rem; background: var(--accent); color: var(--bg); }
.skip-link:focus { top: 1rem; }

.container { width: min(var(--max), 100% - 2.5rem); margin-inline: auto; }
.section { padding-top: 3rem; }
.section-head { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; margin-bottom: 1rem; }
.section > h2 { margin-bottom: 1rem; }
.section-head a { font-size: .95rem; font-weight: 600; display: inline-flex; align-items: center; min-height: var(--tap); }
.lead { font-size: 1.12rem; color: var(--text-2); max-width: var(--measure); }

/* Header and footer */
.nav { border-bottom: 1px solid var(--rule); background: var(--bg); }
.nav-inner { display: flex; align-items: center; justify-content: space-between; min-height: 64px; }
.nav-logo { font: 700 1.15rem var(--ff-display); color: var(--text); text-decoration: none; display: inline-flex; align-items: center; min-height: var(--tap); }
.nav-links { display: flex; gap: 1.8rem; }
.nav-links a { display: block; padding: .6rem 0; color: var(--text-2); text-decoration: none; border-bottom: 2px solid transparent; }
.nav-links a:hover { color: var(--accent); }
.nav-links a.active { color: var(--text); border-bottom-color: var(--accent); }

.hamburger {
  display: none; flex-direction: column; justify-content: center; gap: 5px;
  background: none; border: none; cursor: pointer;
  width: var(--tap); height: var(--tap); padding: 0 11px; margin-right: -11px;
}
.hamburger span { width: 22px; height: 1.5px; background: var(--text); display: block; }
@media (max-width: 720px) {
  .nav { position: relative; }
  .nav-links { display: none; flex-direction: column; gap: 0; position: absolute; top: 100%; left: 0; right: 0; z-index: 10; background: var(--bg); padding: .5rem 1.25rem 1rem; border-bottom: 1px solid var(--rule); }
  .nav-links a.active { border-bottom-color: transparent; }
  .hamburger[aria-expanded="true"] + .nav-links { display: flex; }
  .hamburger { display: flex; }
}

.footer { border-top: 1px solid var(--rule); margin-top: 4rem; }
.footer-inner { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: .5rem 1.5rem; min-height: 72px; font-size: .9rem; color: var(--text-3); }

/* Layout: profile sidebar beside the page */
.layout { display: grid; grid-template-columns: var(--side) minmax(0, 1fr); gap: 4rem; align-items: start; padding-top: 3rem; }
/* the sidebar stays in view while scrolling only on screens tall enough to show all of it */
@media (min-width: 861px) and (min-height: 580px) { .profile { position: sticky; top: 1.5rem; } }
.avatar { width: 120px; height: 120px; border-radius: 50%; object-fit: cover; border: 1px solid var(--rule); }
.profile-name { font: 700 1.25rem/1.3 var(--ff-display); margin-top: 1rem; }
.profile-bio { font-size: .95rem; color: var(--text-2); margin: .2rem 0 .8rem; }
.profile-facts, .profile-links { font-size: .92rem; }
.profile-facts { margin-top: .7rem; padding-top: .7rem; border-top: 1px solid var(--rule); }
.profile-facts li { display: flex; gap: .6rem; align-items: flex-start; color: var(--text-2); padding: .2rem 0; }
.profile-links a { display: flex; gap: .6rem; align-items: center; min-height: 36px; color: var(--text); text-decoration: none; }
.profile-links a:hover { color: var(--accent); }
.profile-links a:hover span { text-decoration: underline; }
.icon { width: 18px; height: 18px; flex: none; margin-top: .2rem; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; color: var(--text-3); }
.profile-links .icon { margin-top: 0; color: var(--accent); }

@media (max-width: 860px) {
  .layout { grid-template-columns: 1fr; gap: 2rem; padding-top: 1.6rem; }
  .profile { position: static; display: grid; grid-template-columns: 72px 1fr; column-gap: 1rem; align-items: center; padding-bottom: 1.2rem; border-bottom: 1px solid var(--rule); }
  .avatar { width: 72px; height: 72px; grid-row: span 2; }
  .profile-name { margin: 0; align-self: end; }
  .profile-bio { margin: 0; align-self: start; font-size: .9rem; }
  .profile-facts { display: none; }
  .profile-links { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 0 1.2rem; margin-top: .8rem; padding-top: 0; border-top: 0; }
  .profile-links a { min-height: var(--tap); }
  /* inner pages: the page content comes first on a phone, the profile after it */
  .inner .profile { order: 2; border-bottom: 0; border-top: 1px solid var(--rule); padding: 1.2rem 0 0; }
}

/* Page top */
.page-top h1 { margin-bottom: .7rem; }
.home-head h1 { font-size: clamp(1.7rem, 3vw, 2.2rem); max-width: 24ch; margin-bottom: .8rem; }
.home-head p { color: var(--text-2); max-width: var(--measure); }

/* Work rows: thumbnail beside a short description */
.work-rows > li { display: grid; grid-template-columns: 184px 1fr; gap: 1.4rem; padding: 1.2rem 0; border-top: 1px solid var(--rule); }
.work-rows > li:last-child { border-bottom: 1px solid var(--rule); }
.work-rows img { width: 184px; height: 123px; object-fit: cover; object-position: top; border: 1px solid var(--rule); }
.work-rows h3 a { color: var(--text); text-decoration: none; }
.work-rows h3 a:hover { color: var(--accent); text-decoration: underline; }
.work-rows .meta { font-size: .875rem; color: var(--text-3); margin: .15rem 0 .35rem; }
.work-rows p { font-size: .95rem; color: var(--text-2); max-width: var(--measure); }
.links-row { display: flex; flex-wrap: wrap; gap: 0 1.4rem; font-weight: 600; font-size: .95rem; }
.links-row a { display: inline-flex; align-items: center; min-height: var(--tap); }
@media (max-width: 560px) {
  .work-rows > li { grid-template-columns: 1fr; gap: .8rem; }
  .work-rows img { width: 100%; height: 180px; }
}

/* Plain list: title and detail on the left, status on the right */
.plain-list > li { display: grid; grid-template-columns: 1fr auto; gap: .1rem 1.5rem; padding: 1rem 0; border-top: 1px solid var(--rule); }
.plain-list > li:last-child { border-bottom: 1px solid var(--rule); }
.plain-list h3 { font-size: 1.05rem; }
.plain-list p { grid-column: 1; font-size: .95rem; color: var(--text-2); max-width: var(--measure); }
.plain-list .status { grid-column: 2; grid-row: 1; font-size: .875rem; color: var(--text-3); text-align: right; }
@media (max-width: 640px) {
  .plain-list > li { grid-template-columns: 1fr; }
  .plain-list .status { grid-column: 1; grid-row: auto; text-align: left; }
}

/* Entries: publications, experience, education */
.entries > li { padding: 1.2rem 0; border-top: 1px solid var(--rule); }
.entries > li:last-child { border-bottom: 1px solid var(--rule); }
.entries .meta { font-size: .9rem; color: var(--text-3); margin: .15rem 0 .4rem; }
.entries p, .entries ul { font-size: .95rem; color: var(--text-2); max-width: var(--measure); }
.entries ul { list-style: disc; padding-left: 1.2rem; }
.entries li li + li { margin-top: .3rem; }
.citation { font-size: .95rem; color: var(--text-2); max-width: var(--measure); }
.citation strong { color: var(--text); font-weight: 600; }

/* Project pages */
.project p, .project li { max-width: var(--measure); }
.project p + p { margin-top: .8rem; }
.project .section ul { list-style: disc; padding-left: 1.2rem; }
.project .section li + li { margin-top: .4rem; }
.back { display: inline-flex; align-items: center; min-height: var(--tap); font-size: .95rem; }
figure { margin: 2rem 0; }
figure img { border: 1px solid var(--rule); }
figure.narrow img { max-width: min(100%, 620px); }
figcaption { font-size: .9rem; color: var(--text-3); margin-top: .6rem; max-width: var(--measure); }
.notes { font-size: .875rem; color: var(--text-3); }
.notes p + p { margin-top: .5rem; }
p.notes { margin-bottom: 1rem; }
/* methods table, method tags and interactive charts (charts.js) */
.glance { width: 100%; border-collapse: collapse; font-size: .92rem; margin-top: 1rem; }
.glance th, .glance td { padding: .6rem .5rem; border-bottom: 1px solid var(--rule); text-align: left; vertical-align: top; }
.glance th { font-weight: 600; color: var(--text-2); font-size: .85rem; }
.glance td:first-child { font-weight: 600; }
.glance td:nth-child(2) { color: var(--text-2); }
@media (max-width: 640px) {
  .glance thead { display: none; }
  .glance tr { display: block; padding: .6rem 0; border-bottom: 1px solid var(--rule); }
  .glance td { display: block; padding: .15rem 0; border: 0; }
  .glance td[data-label]::before { content: attr(data-label) ": "; font-weight: 600; color: var(--text-2); }
}
.project .section .tags { display: flex; flex-wrap: wrap; gap: .35rem; margin: .2rem 0 1rem; padding: 0; list-style: none; }
.project .section .tags li { margin: 0; padding: .15rem .6rem; border: 1px solid var(--rule); border-radius: 999px; background: var(--bg-2); color: var(--text-2); font-size: .8rem; }
.viz { margin: 1.5rem 0 2rem; }
.viz canvas { display: block; width: 100%; touch-action: pan-y; }
.viz .hint { font-size: .9rem; color: var(--text-3); margin-top: .4rem; }
.viz-tip { position: absolute; z-index: 10; pointer-events: none; max-width: 260px; padding: .45rem .6rem; border-radius: 4px; background: var(--text); color: #fff; font-size: .85rem; line-height: 1.35; white-space: pre-line; }
.viz-key { display: flex; flex-wrap: wrap; gap: .4rem .6rem; margin: .6rem 0; }
.viz-key button { display: inline-flex; align-items: center; gap: .45rem; min-height: var(--tap); padding: 0 .8rem; border: 1px solid var(--rule-2); border-radius: 999px; background: none; color: var(--text); font: inherit; font-size: .9rem; cursor: pointer; }
.viz-key button[aria-pressed="true"] { border-color: var(--text); background: var(--bg-2); }
.swatch { display: inline-block; width: .8rem; height: .8rem; border-radius: 2px; }
.swatch-0 { background: #2a78d6; } .swatch-1 { background: #a8a7a2; } .swatch-2 { background: #c8413b; }
.swatch-orange { background: #eb6834; } .swatch-green { background: #1baf7a; }
.viz-scale { display: grid; grid-template-columns: auto minmax(80px, 200px) auto; align-items: center; gap: .6rem; margin: .5rem 0; font-size: .85rem; color: var(--text-3); }
.viz-scale .bar { height: .7rem; border-radius: 2px; border: 1px solid var(--rule); background: linear-gradient(to right, #2a78d6, #fff, #c8413b); }
.swatch-p0 { background: #8fb8e8; } .swatch-p1 { background: #5b97dc; } .swatch-p2 { background: #2a78d6; } .swatch-p3 { background: #1d5aa6; } .swatch-p4 { background: #123b70; }
.viz label { display: block; font-size: .9rem; color: var(--text-2); margin-top: .4rem; }
.viz input[type="range"] { width: 100%; min-height: var(--tap); accent-color: var(--accent); }
.viz select { width: 100%; max-width: 26rem; min-height: var(--tap); padding: 0 .5rem; border: 1px solid var(--rule-2); border-radius: 4px; background: #fff; color: var(--text); font: inherit; font-size: .95rem; }
.viz-readout { font-size: .95rem; color: var(--text-2); margin-top: .4rem; max-width: var(--measure); }

/* About and contact */
.facts { display: grid; gap: .6rem; }
.facts div { display: grid; grid-template-columns: 8.5rem 1fr; gap: 1rem; }
.facts dt { font-weight: 600; }
.facts dd { color: var(--text-2); }
@media (max-width: 640px) { .facts div { grid-template-columns: 1fr; gap: 0; } }

.contact-list > li { padding: .8rem 0; border-top: 1px solid var(--rule); display: grid; grid-template-columns: 8.5rem 1fr; gap: 1rem; align-items: center; }
.contact-list > li:last-child { border-bottom: 1px solid var(--rule); }
.contact-list span { color: var(--text-3); }
.contact-list a { display: inline-flex; align-items: center; min-height: var(--tap); font-weight: 600; overflow-wrap: anywhere; }
@media (max-width: 640px) { .contact-list > li { grid-template-columns: 1fr; gap: 0; } }
