/* ---------- Design tokens ---------- */
:root {
  --bg: #fafaf7;
  --bg-elev: #ffffff;
  --ink: #1a1f2e;
  --ink-soft: #4a5268;
  --ink-muted: #7a8299;
  --accent: #2b5a8c;
  --accent-soft: #e7eef6;
  --border: #e5e2d9;
  --placeholder-bg: #fff6d6;
  --placeholder-ink: #8a6d00;
  --shadow: 0 1px 2px rgba(26, 31, 46, 0.04), 0 4px 16px rgba(26, 31, 46, 0.04);
  --radius: 10px;
  --radius-sm: 6px;
  --maxw: 960px;
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  --font-serif: 'Lora', Georgia, 'Times New Roman', serif;
}

[data-theme="dark"] {
  --bg: #121722;
  --bg-elev: #1a2030;
  --ink: #e7ebf3;
  --ink-soft: #b0b8c9;
  --ink-muted: #7e8699;
  --accent: #79a8da;
  --accent-soft: #1f2c40;
  --border: #2a3247;
  --placeholder-bg: #3a321a;
  --placeholder-ink: #e8c76a;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 4px 16px rgba(0, 0, 0, 0.3);
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }

html { scroll-behavior: smooth; scroll-padding-top: 72px; }

body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.65;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  transition: background 0.2s ease, color 0.2s ease;
}

.container {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 0 1.5rem;
}

h1, h2, h3 {
  font-family: var(--font-serif);
  color: var(--ink);
  line-height: 1.25;
  margin: 0 0 0.5em;
  font-weight: 600;
}

h1 { font-size: clamp(2.2rem, 5vw, 3.2rem); letter-spacing: -0.01em; }
h2 { font-size: 1.65rem; margin-bottom: 1.25rem; }
h3 { font-size: 1.1rem; font-family: var(--font-sans); font-weight: 600; }

p { margin: 0 0 1rem; color: var(--ink-soft); }

a { color: var(--accent); text-decoration: none; transition: color 0.15s ease; }
a:hover { text-decoration: underline; }

code {
  font-family: ui-monospace, 'SF Mono', Menlo, monospace;
  font-size: 0.9em;
  background: var(--accent-soft);
  padding: 0.1em 0.35em;
  border-radius: 4px;
}

/* ---------- Placeholder styling ---------- */
.placeholder {
  background: var(--placeholder-bg);
  color: var(--placeholder-ink);
  padding: 0.05em 0.4em;
  border-radius: 3px;
  font-style: normal;
  font-size: 0.95em;
}

/* ---------- Header / Nav ---------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(180%) blur(12px);
  -webkit-backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--border);
}

.nav {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  height: 64px;
}

.nav-brand {
  font-family: var(--font-serif);
  font-weight: 600;
  font-size: 1.1rem;
  color: var(--ink);
  text-decoration: none;
  letter-spacing: -0.01em;
}
.nav-brand:hover { text-decoration: none; color: var(--accent); }

.nav-menu {
  list-style: none;
  display: flex;
  gap: 1.4rem;
  margin: 0 0 0 auto;
  padding: 0;
}

.nav-menu a {
  color: var(--ink-soft);
  font-size: 0.92rem;
  font-weight: 500;
  text-decoration: none;
  padding: 0.4rem 0;
  border-bottom: 1px solid transparent;
  transition: color 0.15s ease, border-color 0.15s ease;
}

.nav-menu a:hover {
  color: var(--ink);
  border-bottom-color: var(--accent);
  text-decoration: none;
}

.theme-toggle, .nav-toggle {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--ink-soft);
  width: 38px;
  height: 38px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s ease, color 0.15s ease;
}
.theme-toggle:hover, .nav-toggle:hover { background: var(--accent-soft); color: var(--accent); }
.theme-toggle .icon-moon { display: none; }
[data-theme="dark"] .theme-toggle .icon-sun { display: none; }
[data-theme="dark"] .theme-toggle .icon-moon { display: inline; }

.nav-toggle { display: none; flex-direction: column; gap: 4px; padding: 0; }
.nav-toggle span {
  display: block;
  width: 18px;
  height: 2px;
  background: currentColor;
  border-radius: 2px;
}

/* ---------- Hero ---------- */
.hero {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 3rem;
  align-items: center;
  padding: 5rem 1.5rem 3rem;
}

.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--accent);
  margin: 0 0 0.75rem;
}

.hero h1 { margin-bottom: 0.5rem; }

.lead {
  font-size: 1.2rem;
  color: var(--ink);
  margin-bottom: 1rem;
  font-family: var(--font-serif);
  font-style: italic;
}

.hero-blurb { font-size: 1rem; max-width: 52ch; margin-bottom: 1.75rem; }

.hero-actions {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-bottom: 1.75rem;
}

.btn {
  display: inline-flex;
  align-items: center;
  padding: 0.6rem 1.2rem;
  border-radius: var(--radius-sm);
  font-weight: 500;
  font-size: 0.95rem;
  text-decoration: none;
  border: 1px solid transparent;
  transition: transform 0.1s ease, background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
  cursor: pointer;
}
.btn:hover { text-decoration: none; transform: translateY(-1px); }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: color-mix(in srgb, var(--accent) 85%, #000); color: #fff; }
.btn-ghost { background: transparent; color: var(--ink); border-color: var(--border); }
.btn-ghost:hover { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }

.social-links {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 1.1rem;
}
.social-links a {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  color: var(--ink-soft);
  font-size: 0.92rem;
  padding: 0.3rem 0;
}
.social-links a:hover { color: var(--accent); text-decoration: none; }

/* Portrait */
.hero-portrait { display: flex; justify-content: center; }
.portrait-frame {
  width: 260px;
  height: 260px;
  border-radius: 50%;
  overflow: hidden;
  background: var(--accent-soft);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  position: relative;
}
.portrait-frame img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.portrait-placeholder {
  display: none;
  width: 100%;
  height: 100%;
  align-items: center;
  justify-content: center;
  text-align: center;
  color: var(--ink-muted);
  font-size: 0.85rem;
  padding: 1rem;
  line-height: 1.5;
}
.portrait-placeholder code { font-size: 0.8rem; }

/* ---------- Sections ---------- */
.section {
  padding: 3rem 1.5rem;
  border-top: 1px solid var(--border);
}

.section-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1.25rem;
}
.section-head h2 { margin: 0; }
.section-link { font-size: 0.92rem; color: var(--accent); }

.prose { max-width: 68ch; }
.prose p { color: var(--ink-soft); }

/* Research cards */
.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1rem;
}
.card {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  box-shadow: var(--shadow);
  transition: transform 0.15s ease, border-color 0.15s ease;
}
.card:hover { transform: translateY(-2px); border-color: var(--accent); }
.card h3 { margin-top: 0; margin-bottom: 0.5rem; color: var(--accent); }
.card p { margin: 0; font-size: 0.95rem; }

/* Publications */
.pub-list {
  list-style: none;
  counter-reset: pubcount;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}
.pub {
  counter-increment: pubcount;
  padding-left: 2.5rem;
  position: relative;
  border-left: 2px solid var(--border);
  padding-top: 0.1rem;
  padding-bottom: 0.1rem;
  padding-right: 0.5rem;
  transition: border-color 0.15s ease;
}
.pub:hover { border-left-color: var(--accent); }
.pub::before {
  content: counter(pubcount);
  position: absolute;
  left: -0.9rem;
  top: 0;
  background: var(--bg);
  border: 1px solid var(--border);
  width: 1.7rem;
  height: 1.7rem;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--ink-soft);
}
.pub-title { font-weight: 600; color: var(--ink); margin: 0 0 0.25rem; font-size: 1.02rem; }
.pub-authors { font-size: 0.92rem; margin: 0 0 0.15rem; color: var(--ink-soft); }
.pub-venue { font-size: 0.92rem; margin: 0 0 0.4rem; color: var(--ink-muted); }
.pub-badge {
  display: inline-block;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 0.1em 0.55em;
  border-radius: 999px;
  vertical-align: 1px;
}
.pub-links { font-size: 0.87rem; margin: 0; color: var(--ink-muted); }
.pub-links a { margin: 0 0.1rem; }

/* Publication figures — collapsed by default, small fixed-height thumbnails */
.pub-details { margin-top: 0.4rem; }
.pub-details summary {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  cursor: pointer;
  list-style: none;
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--ink-muted);
  padding: 0.15em 0.6em;
  border: 1px solid var(--border);
  border-radius: 999px;
  user-select: none;
  transition: color 0.15s ease, border-color 0.15s ease;
}
.pub-details summary::-webkit-details-marker { display: none; }
.pub-details summary::before {
  content: "";
  width: 0.4em;
  height: 0.4em;
  border-right: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  transform: rotate(-45deg);
  transition: transform 0.15s ease;
}
.pub-details[open] summary::before { transform: rotate(45deg); }
.pub-details summary:hover,
.pub-details[open] summary { color: var(--accent); border-color: var(--accent); }
.pub-figures {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin: 0.6rem 0 0.2rem;
}
.pub-figures figure { margin: 0; }
.pub-figures img {
  display: block;
  height: 9rem;
  width: auto;
  max-width: 100%;
  object-fit: contain;
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.3rem;
}

/* Timeline (education + experience) */
.timeline {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 1.4rem;
}
.timeline > li {
  display: grid;
  grid-template-columns: 180px 1fr;
  gap: 1.5rem;
  align-items: start;
}
.timeline-when {
  color: var(--ink-muted);
  font-size: 0.88rem;
  font-weight: 500;
  padding-top: 0.25rem;
  letter-spacing: 0.01em;
}
.timeline-what h3 { margin: 0 0 0.2rem; color: var(--ink); }
.timeline-where { font-size: 0.95rem; color: var(--accent); margin: 0 0 0.4rem; font-weight: 500; }
.timeline-what p:last-child { margin: 0; font-size: 0.95rem; }

/* Skills */
.skills-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1.25rem;
}
.skill-group h3 { margin: 0 0 0.6rem; color: var(--ink); font-size: 0.98rem; }
.tag-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}
.tag-list li {
  background: var(--accent-soft);
  color: var(--accent);
  padding: 0.25rem 0.7rem;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 500;
}
.tag-list li .placeholder { background: transparent; color: inherit; padding: 0; }

/* Simple lists (awards, talks, teaching) */
.simple-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
}
.simple-list li {
  padding-left: 1.1rem;
  position: relative;
  color: var(--ink-soft);
  font-size: 0.96rem;
}
.simple-list li::before {
  content: "›";
  position: absolute;
  left: 0;
  color: var(--accent);
  font-weight: 600;
}

/* Contact */
.contact-intro { max-width: 60ch; margin-bottom: 1.5rem; }
.contact-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 0.8rem;
}
.contact-card {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  padding: 1rem 1.1rem;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--ink);
  text-decoration: none;
  transition: border-color 0.15s ease, transform 0.1s ease;
}
.contact-card:hover { border-color: var(--accent); transform: translateY(-1px); text-decoration: none; }
.contact-card--static { cursor: default; }
.contact-card--static:hover { border-color: var(--border); transform: none; }
.contact-label {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--ink-muted);
  font-weight: 600;
}
.contact-value { font-size: 0.98rem; color: var(--ink); }

/* Footer */
.site-footer {
  border-top: 1px solid var(--border);
  padding: 1.5rem 0;
  margin-top: 3rem;
  color: var(--ink-muted);
  font-size: 0.88rem;
}
.footer-inner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
}
.footer-inner p { margin: 0; color: var(--ink-muted); }

/* ---------- Responsive ---------- */
@media (max-width: 820px) {
  .hero {
    grid-template-columns: 1fr;
    text-align: left;
    padding: 3rem 1.5rem 2rem;
    gap: 2rem;
  }
  .hero-portrait { order: -1; }
  .portrait-frame { width: 180px; height: 180px; }

  .nav-menu {
    position: absolute;
    top: 64px;
    right: 0;
    left: 0;
    background: var(--bg-elev);
    flex-direction: column;
    gap: 0;
    padding: 0.5rem 1.5rem 1rem;
    border-bottom: 1px solid var(--border);
    box-shadow: var(--shadow);
    display: none;
  }
  .nav-menu.open { display: flex; }
  .nav-menu li { border-bottom: 1px solid var(--border); }
  .nav-menu li:last-child { border-bottom: none; }
  .nav-menu a { display: block; padding: 0.75rem 0; border-bottom: none; }
  .nav-toggle { display: inline-flex; order: 2; margin-left: auto; }
  .theme-toggle { order: 3; }

  .timeline > li { grid-template-columns: 1fr; gap: 0.3rem; }
  .timeline-when { padding-top: 0; }

  .section { padding: 2.5rem 1.5rem; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
  html { scroll-behavior: auto; }
}

/* Print */
@media print {
  .site-header, .nav, .theme-toggle, .btn, .hero-actions, .site-footer { display: none !important; }
  body { background: #fff; color: #000; }
  .section { border-top: 1px solid #ccc; padding: 1rem 0; page-break-inside: avoid; }
  a { color: #000; text-decoration: underline; }
  .placeholder { background: transparent; color: #666; }
}
