/* ---------- Fonts (self hosted, latin subset, two files) ---------- */
@font-face {
  font-family: "Fraunces";
  font-style: normal;
  font-weight: 300 700;
  font-display: swap;
  src: url("../assets/fonts/fraunces.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Fraunces";
  font-style: italic;
  font-weight: 300 700;
  font-display: swap;
  src: url("../assets/fonts/fraunces-italic.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

/* ---------- Design tokens ---------- */
:root {
  color-scheme: light;

  /* colors */
  --bg: #fdfcfa;
  --text: #1c1917;
  --text-muted: #57534e;
  --rule: #e7e2db;
  --surface: #f4f1ec;
  --accent: #c2410c;
  --accent-strong: #9a3412;
  --accent-soft: #fbe9df;
  --on-accent: #ffffff;
  --shadow: 0 6px 18px rgba(28, 25, 23, 0.10);

  /* type */
  --font-heading: "Fraunces", "Iowan Old Style", "Palatino Linotype", Georgia, serif;
  --font-body: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --size-base: 17px;
  --lh: 1.6;
  --size-sm: 0.86rem;   /* dates, link rows, labels */
  --size-2: 0.94rem;    /* secondary text inside lists */
  --size-h1: 2.2rem;
  --size-h2: 1.4rem;

  /* layout */
  --measure: 740px;
  --gutter: 1.25rem;
  --portrait: 148px;

  /* spacing scale */
  --s-1: 0.25rem;
  --s-2: 0.5rem;
  --s-3: 0.75rem;
  --s-4: 1rem;
  --s-5: 1.5rem;
  --s-6: 2.5rem;
  --s-7: 3.5rem;

  /* motion */
  --dur-fast: 150ms;
  --dur: 250ms;
  --dur-reveal: 300ms;
  --ease: cubic-bezier(0.2, 0.7, 0.2, 1);
}

@media (prefers-reduced-motion: reduce) {
  :root {
    --dur-fast: 0ms;
    --dur: 0ms;
    --dur-reveal: 0ms;
  }
  *, *::before, *::after {
    animation: none !important;
    transition: none !important;
    scroll-behavior: auto !important;
  }
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html {
  font-size: var(--size-base);
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  scroll-padding-top: var(--s-4);
}
body {
  margin: 0;
  font-family: var(--font-body);
  line-height: var(--lh);
  color: var(--text);
  background: var(--bg);
  font-feature-settings: "kern";
  text-rendering: optimizeLegibility;
}
::selection { background: var(--accent-soft); }
.wrap {
  max-width: var(--measure);
  margin-inline: auto;
  padding-inline: var(--gutter);
}
@media (min-width: 600px) { :root { --gutter: 1.5rem; } }

h1, h2 {
  font-family: var(--font-heading);
  font-optical-sizing: auto;
  font-weight: 600;
  line-height: 1.15;
  letter-spacing: -0.015em;
  margin: 0;
  text-wrap: balance;
}
h1 { font-size: var(--size-h1); }
h2 { font-size: var(--size-h2); }
h3, h4 {
  font-family: var(--font-body);
  font-size: 1rem;
  font-weight: 600;
  line-height: 1.4;
  margin: 0;
}
p { margin: 0 0 var(--s-4); text-wrap: pretty; }
p:last-child { margin-bottom: 0; }
ul, dl { margin: 0; padding: 0; list-style: none; }
img { max-width: 100%; height: auto; display: block; }
strong { font-weight: 600; }
.muted { color: var(--text-muted); }
.small { font-size: var(--size-sm); }
[hidden] { display: none !important; }

/* ---------- Links ---------- */
a {
  color: var(--accent);
  text-decoration: none;
  transition: color var(--dur-fast) var(--ease);
}
a:hover { color: var(--accent-strong); }

/* Content links: a faint underline, and a full one that draws in from the left on hover. */
main a:not(.pub-title a), .link-btn, .site-footer a {
  /* first declaration is the fallback for browsers without color-mix */
  background-image:
    linear-gradient(currentColor, currentColor),
    linear-gradient(rgba(194, 65, 12, 0.3), rgba(194, 65, 12, 0.3));
  background-image:
    linear-gradient(currentColor, currentColor),
    linear-gradient(color-mix(in srgb, currentColor 30%, transparent), color-mix(in srgb, currentColor 30%, transparent));
  background-repeat: no-repeat;
  background-position: 0 100%, 0 100%;
  background-size: 0% 1px, 100% 1px;
  padding-bottom: 1px;
  -webkit-box-decoration-break: clone;
  box-decoration-break: clone;
  transition: background-size var(--dur) var(--ease), color var(--dur-fast) var(--ease);
}
main a:not(.pub-title a):hover, .link-btn:hover, .site-footer a:hover { background-size: 100% 1px, 100% 1px; }

/* ---------- Focus ---------- */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 2px;
}
:focus:not(:focus-visible) { outline: none; }

.skip-link {
  position: absolute;
  left: var(--s-4);
  top: -100px;
  padding: var(--s-2) var(--s-3);
  background: var(--accent);
  color: var(--on-accent);
  z-index: 10;
}
.skip-link:focus { top: var(--s-4); color: var(--on-accent); }

/* ---------- Header: a quiet nav, nothing else ---------- */
.site-header {
  padding-top: var(--s-5);
  display: flex;
  justify-content: flex-end;
}
.site-nav {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s-1) var(--s-5);
  font-size: var(--size-sm);
}
.site-nav a {
  color: var(--text-muted);
  padding-block: var(--s-1);
}
.site-nav a:hover { color: var(--accent); }

/* ---------- Sections ---------- */
.section {
  padding-block: var(--s-6);
  border-top: 1px solid var(--rule);
}
.section > h2 { margin-bottom: var(--s-5); }

/* ---------- Hero ---------- */
.hero {
  border-top: 0;
  display: grid;
  grid-template-columns: var(--portrait) 1fr;
  gap: var(--s-6);
  align-items: start;
  padding-block: var(--s-6) var(--s-7);
}
.hero-portrait:empty { display: none; }
.hero-portrait:empty + .hero-text { grid-column: 1 / -1; }
.hero-portrait img {
  width: var(--portrait);
  height: var(--portrait);
  object-fit: cover;
  border-radius: 50%;
  background: var(--surface);
}
.hero-text h1 { margin-bottom: var(--s-2); }
.role { font-size: 1.05rem; margin-bottom: 0.15rem; }
.interests { font-size: var(--size-sm); color: var(--text-muted); margin-bottom: var(--s-5); }
.interests:empty { display: none; }
.link-row { font-size: var(--size-2); color: var(--text-muted); }
.hero .link-row { margin-top: var(--s-5); }
.link-row a { white-space: nowrap; }

/* ---------- Publications ---------- */
.pub-year {
  font-size: var(--size-sm);
  font-weight: 600;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.04em;
  margin: var(--s-5) 0 var(--s-3);
}
.pub-year:first-child { margin-top: 0; }
.pub + .pub { margin-top: var(--s-5); }
.pub.has-thumb {
  display: grid;
  grid-template-columns: 120px 1fr;
  gap: var(--s-5);
  align-items: start;
}
.pub-thumb img {
  width: 120px;
  height: 90px;
  object-fit: cover;
  border-radius: 4px;
  border: 1px solid var(--rule);
  background: var(--surface);
  transition: transform var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
.pub:hover .pub-thumb img { transform: translateY(-2px); box-shadow: var(--shadow); }
.pub-title { margin-bottom: var(--s-1); }
.pub-title a { color: inherit; }
.pub-title a:hover { color: var(--accent); }
.pub-authors, .pub-venue, .pub-summary { font-size: var(--size-2); margin: 0; }
.pub-venue { color: var(--text-muted); }
.pub-links { margin: var(--s-1) 0 0; color: var(--text-muted); }
.pub-summary { margin-top: var(--s-2); color: var(--text-muted); }
.pub-note { margin: var(--s-5) 0 0; }
.link-btn {
  appearance: none;
  background-color: transparent;
  border: 0;
  padding: 0 0 1px;
  font: inherit;
  color: var(--accent);
  cursor: pointer;
}
.link-btn:hover { color: var(--accent-strong); }
.pub-bibtex {
  margin: var(--s-3) 0 0;
  padding: var(--s-3) var(--s-4);
  background: var(--surface);
  border-radius: 4px;
  overflow-x: auto;
  white-space: pre-wrap;
  word-break: break-word;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  line-height: 1.5;
}

/* ---------- Experience and Education ---------- */
.entry {
  display: grid;
  grid-template-columns: 9.5rem 1fr;
  gap: var(--s-1) var(--s-5);
}
.entry + .entry { margin-top: var(--s-5); }
.entry-when { padding-top: 0.2em; white-space: nowrap; font-variant-numeric: tabular-nums; }
.entry-org { font-size: var(--size-2); margin: 0 0 var(--s-2); }
.entry-desc { font-size: var(--size-2); margin: 0; }
.entry-desc + .entry-desc { margin-top: var(--s-1); }
.entry-desc.small { font-size: var(--size-sm); }

/* ---------- Contact ---------- */
.contact-list {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: var(--s-2) var(--s-5);
  margin: 0 0 var(--s-5);
  font-size: var(--size-2);
}
.contact-list > div { display: contents; }
.contact-list dt { color: var(--text-muted); }
.contact-list dd { margin: 0; overflow-wrap: anywhere; }

/* ---------- Scroll reveal (only with JS, only below the fold, once) ---------- */
.js .reveal {
  opacity: 0;
  transform: translateY(8px);
  transition: opacity var(--dur-reveal) var(--ease), transform var(--dur-reveal) var(--ease);
}
.js .reveal.is-visible { opacity: 1; transform: none; }
@media (prefers-reduced-motion: reduce) {
  .js .reveal { opacity: 1; transform: none; }
}

/* ---------- Footer ---------- */
.site-footer {
  border-top: 1px solid var(--rule);
  padding-block: var(--s-5) var(--s-6);
  font-size: var(--size-sm);
  color: var(--text-muted);
}
.site-footer a { color: inherit; }
.site-footer a:hover { color: var(--accent); }

/* ---------- Small screens ---------- */
@media (max-width: 599px) {
  :root { --size-h1: 1.85rem; --portrait: 112px; }
  .site-header { justify-content: flex-start; padding-top: var(--s-4); }
  .site-nav { gap: var(--s-1) var(--s-4); }
  .hero { grid-template-columns: 1fr; gap: var(--s-5); padding-block: var(--s-5) var(--s-6); }
  .section { padding-block: var(--s-5); }
  .section > h2 { margin-bottom: var(--s-4); }
  .pub.has-thumb { grid-template-columns: 1fr; gap: var(--s-3); }
  .entry { grid-template-columns: 1fr; gap: 0; }
  .contact-list { gap: var(--s-2) var(--s-4); }
  .entry-when { padding-top: 0; }
}

/* ---------- Print ---------- */
@media print {
  html { font-size: 11pt; }
  body { background: #fff; color: #000; }
  .skip-link, .site-header, .link-btn, .pub-bibtex, .site-footer a { display: none !important; }
  .js .reveal { opacity: 1 !important; transform: none !important; }
  a { color: inherit; background: none !important; }
  .link-row a::after { content: " (" attr(href) ")"; font-size: 0.85em; }
  .link-row a[href^="#"]::after, .link-row a[href^="mailto"]::after { content: ""; }
  .section { padding-block: 1.2rem; }
  .pub, .entry { break-inside: avoid; }
  .hero-portrait img { width: 90px; height: 90px; }
}
