/* ---------- Theme ---------- */
:root {
  --bg: #f7f6f2;
  --surface: #ffffff;
  --text: #1c1e22;
  --muted: #5d636c;
  --faint: #6b7079;
  --rule: #e3e0d8;
  --accent: #a85a40;          /* muted terracotta */
  --banner: #f8f1ea;
  --field: 168, 90, 64;       /* banner particle color (rgb of --accent) */
  --serif: "Source Serif 4", Georgia, "Times New Roman", serif;
  --sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;

  /* Type scale: six sizes, used everywhere */
  --fs-xs: .8rem;
  --fs-sm: .9rem;
  --fs-md: 1.15rem;
  --fs-lg: 1.6rem;
  --fs-xl: 2.1rem;
}

[data-theme="dark"] {
  --bg: #111316;
  --surface: #181b1f;
  --text: #e6e4df;
  --muted: #a2a7af;
  --faint: #8c929b;
  --rule: #272b31;
  --accent: #d08a6f;
  --banner: #19171a;
  --field: 208, 138, 111;
}

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

html { font-size: 15px; scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 1rem;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  transition: background-color .25s ease, color .25s ease;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }
strong { font-weight: 600; }
p { margin: 0 0 14px; }

/* Small uppercase labels on the tiles */
.tile-k {
  font-size: var(--fs-xs);
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--muted);
}

.container {
  max-width: 940px;
  margin: 0 auto;
  padding: 32px 28px 56px;
}

/* ---------- Profile card ---------- */
.hero {
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: 18px;
  overflow: hidden;
  margin-bottom: 64px;
}

.banner {
  position: relative;
  height: 210px;
  background: var(--banner);
  border-bottom: 1px solid var(--rule);
}
#field { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }

.banner-quote {
  position: absolute;
  right: 22px;
  bottom: 16px;
  max-width: 400px;
  margin: 0;
  padding: 0;
  border: 0;
  text-align: right;
  font-family: var(--serif);
  font-style: italic;
  font-size: 1rem;
  line-height: 1.45;
  color: var(--text);
  text-shadow: 0 0 10px var(--banner), 0 0 18px var(--banner);
  text-wrap: balance;
}
.banner-quote cite {
  display: block;
  margin-top: 4px;
  font-style: normal;
  font-size: var(--fs-xs);
  color: var(--muted);
}
.banner-quote cite::before { content: "— "; }

/* Banner controls: translucent, borderless */
.theme-toggle {
  position: absolute;
  top: 14px;
  right: 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px; height: 36px;
  border: 0;
  border-radius: 10px;
  background: color-mix(in srgb, var(--surface) 78%, transparent);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  color: var(--muted);
  cursor: pointer;
}
.theme-toggle:hover { color: var(--text); }

/* Page switch (Me / Work), top-left of the banner */
.page-nav {
  position: absolute;
  top: 14px;
  left: 14px;
  display: flex;
  gap: 2px;
  padding: 4px;
  border-radius: 10px;
  background: color-mix(in srgb, var(--surface) 78%, transparent);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  font-size: var(--fs-xs);
  font-weight: 500;
}
.page-nav a {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 12px;
  border-radius: 7px;
  color: var(--text);
}
.page-nav a:hover { text-decoration: none; background: color-mix(in srgb, var(--text) 6%, transparent); }
.page-nav a[aria-current="page"] { background: var(--accent); color: var(--surface); }

/* Comfortable thumb targets on touch screens */
@media (pointer: coarse) {
  .theme-toggle { width: 44px; height: 44px; }
  .page-nav a { min-height: 36px; }
}

.icon-sun { display: none; }
[data-theme="dark"] .icon-sun { display: block; }
[data-theme="dark"] .icon-moon { display: none; }

.profile {
  display: flex;
  gap: 28px;
  padding: 0 36px 30px;
}
.avatar {
  width: 136px;
  height: 136px;
  margin-top: -68px;          /* overlap the banner */
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  position: relative;
  border: 5px solid var(--surface);
}
.profile-text { padding-top: 18px; min-width: 0; }

h1 {
  font-family: var(--serif);
  font-weight: 600;
  font-size: var(--fs-xl);
  line-height: 1.15;
  letter-spacing: -0.01em;
  margin: 0 0 4px;
}
.role { margin: 0 0 12px; color: var(--muted); }
.role .org { color: var(--text); font-weight: 500; }
.tagline { margin: 0 0 16px; font-family: var(--serif); font-size: var(--fs-md); line-height: 1.5; text-wrap: balance; }

.profile-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 22px; }
.links { list-style: none; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 6px 18px; }
.links a { font-size: var(--fs-sm); font-weight: 500; }
.meta { color: var(--faint); font-size: var(--fs-xs); }

/* Compact header for secondary pages */
.hero.compact .banner { height: 120px; }
.hero.compact .profile { align-items: flex-end; gap: 22px; padding-bottom: 22px; }
.hero.compact .avatar { width: 80px; height: 80px; margin-top: -40px; border-width: 4px; }
.hero.compact .profile-text { padding-top: 12px; }
.hero.compact h1 { font-size: var(--fs-lg); }
.hero.compact .role { margin: 0; }
.avatar-link { display: block; flex-shrink: 0; }

/* ---------- Sections: label column + body ---------- */
section {
  display: grid;
  grid-template-columns: 190px minmax(0, 1fr);
  gap: 36px;
  margin-bottom: 64px;
}

.label {
  margin: 0;
  position: sticky;
  top: 24px;
  align-self: start;
  font-family: var(--serif);
  font-weight: 600;
  font-size: var(--fs-md);
  line-height: 1.3;
}

.body { max-width: 660px; padding-top: 1px; }
.note { color: var(--faint); font-size: var(--fs-sm); margin-top: 14px; }

/* Off the clock: borderless tiles + callout */
.lead-in { color: var(--muted); margin-bottom: 16px; }
.tiles {
  list-style: none;
  padding: 0;
  margin: 0 0 40px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}
.tile {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 14px 16px;
  background: var(--surface);   /* tone-on-tone block, no border */
  border-radius: 10px;
}
.tile-v { font-size: var(--fs-sm); line-height: 1.55; }
.callout {
  margin: 0;
  padding: 2px 0 2px 16px;
  border-left: 2px solid var(--accent);
  font-family: var(--serif);
  font-style: italic;
  font-size: 1rem;
  line-height: 1.6;
  color: var(--text);
}

/* Lately */
.news { list-style: none; padding: 0; margin: 0; }
.news li { display: grid; grid-template-columns: 76px 20px 1fr; gap: 10px; padding: 5px 0; }
.news-icon { font-size: var(--fs-sm); line-height: calc(1rem * 1.7); text-align: center; }
.news-icon svg { display: inline-block; vertical-align: -2px; }
.date, .when {
  color: var(--faint);
  font-size: var(--fs-xs);
  font-variant-numeric: tabular-nums;
  padding-top: 3px;
  white-space: nowrap;
}

/* Papers */
.pubs { list-style: none; padding: 0; margin: 0; }
.pubs li { padding: 14px 0; border-bottom: 1px solid var(--rule); }
.pubs li:first-child { padding-top: 0; }
.pubs li:last-child { border-bottom: 0; }
.pub-title { color: var(--text); font-weight: 600; line-height: 1.4; }
.pub-title:hover { color: var(--text); }
.authors { color: var(--muted); font-size: var(--fs-sm); margin-top: 3px; }
.authors strong { color: var(--text); }
.venue { color: var(--faint); font-size: var(--fs-sm); }
.pub-links { margin-top: 6px; display: flex; gap: 16px; font-size: var(--fs-xs); font-weight: 500; }

/* The path so far: a vertical line with nodes */
.path { list-style: none; padding: 0; margin: 0; position: relative; }
.path::before {
  content: "";
  position: absolute;
  left: 5px; top: 10px; bottom: 10px;
  width: 1px;
  background: var(--rule);
}
.path li {
  position: relative;
  display: grid;
  grid-template-columns: 92px 1fr;
  gap: 12px;
  padding: 6px 0 6px 26px;
}
.path li::before {
  content: "";
  position: absolute;
  left: 1px; top: 14px;
  width: 9px; height: 9px;
  border-radius: 50%;
  background: var(--bg);
  border: 1px solid var(--faint);
}
.path li:first-child::before { border-color: var(--text); background: var(--text); }
.sub { color: var(--muted); font-size: var(--fs-sm); }

/* Footer */
.footer {
  border-top: 1px solid var(--rule);
  padding-top: 18px;
  color: var(--faint);
  font-size: var(--fs-xs);
}

/* ---------- Responsive ---------- */
@media (max-width: 760px) {
  .container { padding: 16px 16px 40px; }
  .hero { margin-bottom: 44px; }
  .banner { height: 205px; }
  .banner-quote { left: 146px; right: 14px; bottom: 12px; max-width: none; font-size: var(--fs-sm); line-height: 1.35; }
  .tiles { grid-template-columns: 1fr; gap: 8px; }
  .tile {
    display: grid;
    grid-template-columns: 64px 1fr;
    gap: 10px;
    padding: 12px 14px;
  }
  .tile-k { padding-top: 2px; }
  .profile { flex-direction: column; gap: 0; padding: 0 22px 24px; }
  .avatar { width: 112px; height: 112px; margin-top: -56px; }
  .profile-text { padding-top: 12px; }
  h1 { font-size: var(--fs-lg); }
  .hero.compact .banner { height: 100px; }
  .hero.compact .profile { flex-direction: row; align-items: flex-end; gap: 16px; }
  .hero.compact .avatar { width: 68px; height: 68px; margin-top: -34px; }
  section { grid-template-columns: 1fr; gap: 12px; margin-bottom: 48px; }
  .label { position: static; }
  .news li { grid-template-columns: 20px 1fr; gap: 0 10px; }
  .news li .date { grid-column: 1 / -1; }
  .path li { grid-template-columns: 1fr; gap: 0; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
}
