/* ---------- Tokens ---------- */
:root {
  --bg: #ffffff;
  --surface: #fafafa;
  --text: #111111;
  --muted: #6b6b6b;
  --line: #ececec;
  --accent: #7a1f1f;
  --accent-soft: rgba(122, 31, 31, 0.06);
  --sans: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --wrap: 1100px;
  --radius: 6px;
  color-scheme: light;
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { scroll-behavior: smooth; scroll-padding-top: 72px; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.65 var(--sans);
  -webkit-font-smoothing: antialiased;
}
img, video { max-width: 100%; height: auto; display: block; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }
h1, h2, h3 { font-family: var(--sans); font-weight: 600; line-height: 1.25; letter-spacing: -0.015em; margin: 0; }
p { margin: 0 0 1em; }
::selection { background: var(--accent); color: var(--bg); }

.wrap { max-width: var(--wrap); margin: 0 auto; padding-inline: clamp(16px, 5vw, 48px); }

/* ---------- Header ---------- */
.site-header {
  position: sticky; top: 0; z-index: 20;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.header-inner { display: flex; align-items: center; justify-content: space-between; height: 60px; }
.brand { font-size: 1rem; font-weight: 600; letter-spacing: -0.01em; color: var(--text); }
.brand:hover { text-decoration: none; }
.nav { display: flex; gap: 22px; }
.nav a { color: var(--muted); font-size: 0.9rem; }
.nav a:hover, .nav a.active { color: var(--accent); text-decoration: none; }
.nav-toggle { display: none; background: none; border: 0; padding: 8px; cursor: pointer; }
.nav-toggle span { display: block; width: 22px; height: 2px; margin: 4px 0; background: var(--text); transition: transform .2s, opacity .2s; }

@media (max-width: 860px) {
  .nav-toggle { display: block; }
  .nav {
    position: absolute; top: 60px; left: 0; right: 0;
    flex-direction: column; gap: 0;
    background: var(--bg); border-bottom: 1px solid var(--line);
    padding: 8px clamp(16px, 5vw, 48px) 16px;
    display: none;
  }
  .nav.open { display: flex; }
  .nav a { padding: 10px 0; font-size: 1rem; border-bottom: 1px solid var(--line); }
  .nav a:last-child { border-bottom: 0; }
  .nav-toggle[aria-expanded="true"] span:nth-child(1) { transform: translateY(6px) rotate(45deg); }
  .nav-toggle[aria-expanded="true"] span:nth-child(2) { opacity: 0; }
  .nav-toggle[aria-expanded="true"] span:nth-child(3) { transform: translateY(-6px) rotate(-45deg); }
}

/* ---------- Hero ---------- */
.hero {
  display: grid; grid-template-columns: 1fr 300px; gap: 56px; align-items: center;
  padding-block: clamp(48px, 9vw, 110px) clamp(40px, 6vw, 72px);
}
.eyebrow { text-transform: uppercase; letter-spacing: .14em; font-size: .75rem; color: var(--accent); margin-bottom: 14px; }
.hero h1 { font-size: clamp(2.3rem, 6vw, 3.6rem); margin-bottom: 8px; letter-spacing: -0.035em; }
.lede { font-size: clamp(1.08rem, 2vw, 1.25rem); font-weight: 300; line-height: 1.6; max-width: 40ch; }
.affil { color: var(--muted); font-size: 1.05rem; margin-bottom: 22px; }
.hero-links { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 28px; }
.hero-photo { margin: 0; }
.hero-photo img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 50%; border: 1px solid var(--line); }

@media (max-width: 760px) {
  .hero { grid-template-columns: 1fr; gap: 28px; }
  .hero-photo { order: -1; width: 150px; }
}

.btn {
  display: inline-block; padding: 10px 18px; border-radius: var(--radius);
  background: var(--accent); color: var(--bg); font-size: .9rem; font-weight: 500;
  border: 1px solid var(--accent); cursor: pointer; font-family: inherit;
}
.btn:hover { text-decoration: none; filter: brightness(1.1); }
.btn.ghost { background: transparent; color: var(--text); border-color: var(--line); }
.btn.ghost:hover { border-color: var(--accent); color: var(--accent); filter: none; }
.btn.small { padding: 6px 12px; font-size: .8rem; }

/* ---------- Sections ---------- */
.section { padding-block: clamp(44px, 7vw, 80px); border-top: 1px solid var(--line); }
.section-title { font-size: clamp(1.4rem, 2.6vw, 1.75rem); letter-spacing: -0.025em; margin-bottom: 32px; display: flex; align-items: baseline; gap: 14px; }
.section-title span { font-family: var(--sans); font-size: .8rem; color: var(--accent); letter-spacing: .08em; }
.prose { max-width: 70ch; font-size: 1rem; color: #333; }
.meta { color: var(--muted); font-size: .88rem; margin-bottom: 6px; }
.note { color: var(--muted); font-style: italic; margin-top: 24px; }

/* About services */
.services { list-style: none; padding: 0; margin: 36px 0 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; }
.services li { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; }
.services h3 { font-size: 1rem; margin-bottom: 6px; }
.services p { color: var(--muted); font-size: .92rem; margin: 0; }

/* Timeline */
.timeline { list-style: none; padding: 0; margin: 0; }
.timeline > li { display: grid; grid-template-columns: 130px 1fr; gap: 24px; padding: 20px 0; border-bottom: 1px solid var(--line); }
.timeline > li:last-child { border-bottom: 0; }
.tl-date { color: var(--accent); font-size: .9rem; padding-top: 4px; font-variant-numeric: tabular-nums; }
.tl-body h3 { font-size: 1.05rem; margin-bottom: 4px; }
.tl-body p:last-child { margin-bottom: 0; }
.bullets { margin: 10px 0 0; padding-left: 18px; color: var(--muted); font-size: .93rem; }
.bullets li { margin-bottom: 4px; }
.bullets strong { color: var(--text); font-weight: 500; }
@media (max-width: 600px) {
  .timeline > li { grid-template-columns: 1fr; gap: 4px; }
}

/* Publications */
.pubs { list-style: none; padding: 0; margin: 0; display: grid; gap: 28px; }
.pub { display: grid; grid-template-columns: 150px 1fr; gap: 24px; align-items: start; }
.pub-thumb img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: var(--radius); border: 1px solid var(--line); }
.pub-thumb-text {
  aspect-ratio: 1; display: flex; flex-direction: column; justify-content: center; align-items: center; gap: 4px;
  border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); color: var(--text);
}
.pub-thumb-text:hover { text-decoration: none; border-color: var(--accent); }
.pub-thumb-text span { font-size: 1.35rem; font-weight: 600; letter-spacing: -0.02em; }
.pub-thumb-text small { color: var(--muted); font-size: .75rem; }
.pub h3 { font-size: 1.1rem; margin-bottom: 8px; }
.pub h3 a { color: var(--text); }
.pub h3 a:hover { color: var(--accent); }
.authors { font-size: .92rem; color: var(--muted); margin-bottom: 4px; }
.authors strong { color: var(--text); font-weight: 600; }
.doi { font-size: .85rem; color: var(--muted); }
.cites {
  display: inline-block; margin-left: 10px; vertical-align: 1px;
  font-size: .75rem; font-weight: 500; padding: 2px 10px; border-radius: 99px;
  border: 1px solid var(--accent); color: var(--accent); background: var(--accent-soft);
}
.cites:hover { text-decoration: none; background: var(--accent); color: var(--bg); }
.cites.disabled { border-color: var(--line); color: #aaa; background: var(--surface); cursor: not-allowed; }
.cites.disabled:hover { background: var(--surface); color: #aaa; }
@media (max-width: 560px) {
  .pub { grid-template-columns: 1fr; gap: 12px; }
  .pub-thumb { width: 110px; }
}

/* Research accordions */
.research { border-top: 1px solid var(--line); }
.rx { border-bottom: 1px solid var(--line); }
.rx summary {
  list-style: none; cursor: pointer; padding: 18px 36px 18px 0; position: relative;
  display: flex; flex-direction: column; gap: 4px;
}
.rx summary::-webkit-details-marker { display: none; }
.rx summary::after {
  content: "+"; position: absolute; right: 4px; top: 16px;
  font-size: 1.4rem; color: var(--accent); transition: transform .2s;
}
.rx[open] summary::after { transform: rotate(45deg); }
.rx-title { font-size: 1rem; font-weight: 500; line-height: 1.4; }
.rx-who { color: var(--muted); font-size: .88rem; }
.tag { font-family: var(--sans); font-style: normal; font-size: .7rem; text-transform: uppercase; letter-spacing: .08em; color: var(--accent); background: var(--accent-soft); padding: 2px 8px; border-radius: 99px; margin-left: 6px; vertical-align: middle; white-space: nowrap; }
.rx-body { padding: 0 0 24px; max-width: 75ch; }
.rx-fig { border-radius: var(--radius); border: 1px solid var(--line); margin-top: 8px; background: #fff; }
.rx-fig.narrow { max-width: 420px; }

/* Code cards */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 20px; }
.card { display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; color: var(--text); transition: border-color .2s, transform .2s; }
.card:hover { text-decoration: none; border-color: var(--accent); transform: translateY(-2px); }
.card img { aspect-ratio: 16 / 9; object-fit: cover; width: 100%; }
.card-body { padding: 18px; }
.card h3 { font-size: 1rem; margin-bottom: 8px; }
.card p:last-child { color: var(--muted); font-size: .9rem; margin: 0; }

/* Skills */
.skills { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 28px; }
.skills h3 { font-size: 1rem; margin-bottom: 12px; }
.chips { list-style: none; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.chips li { border: 1px solid var(--line); border-radius: 99px; padding: 5px 12px; font-size: .86rem; }

/* Filters */
.filters { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 20px; }
.filter { font: inherit; font-size: .85rem; background: none; color: var(--muted); border: 1px solid var(--line); border-radius: 99px; padding: 6px 14px; cursor: pointer; }
.filter:hover { color: var(--accent); border-color: var(--accent); }
.filter.active { background: var(--text); color: var(--bg); border-color: var(--text); }

/* Tiles (design + gallery) */
.grid { display: grid; gap: 14px; }
.design-grid { grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
.gallery-grid { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }
.gallery-sub { color: var(--muted); font-size: .88rem; margin: -6px 0 16px; }
.tile { position: relative; display: block; padding: 0; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; background: var(--surface); cursor: pointer; font: inherit; color: inherit; text-align: left; }
.tile img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; transition: transform .4s ease; }
.tile:hover img { transform: scale(1.04); }
.tile:hover { text-decoration: none; }
.tile-cap { display: block; padding: 10px 12px; font-size: .82rem; color: var(--muted); }
.tile-cap strong { display: block; color: var(--text); font-weight: 500; font-size: .92rem; }
.tile.hidden { display: none; }

/* Contact */
.contact .prose { margin-bottom: 20px; }
.email-row { display: flex; flex-wrap: wrap; align-items: center; gap: 14px; margin-bottom: 24px; }
.email { font-size: clamp(1.25rem, 3.5vw, 1.7rem); font-weight: 500; letter-spacing: -0.02em; word-break: break-all; }
.socials { list-style: none; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 10px 24px; }
.socials a { color: var(--muted); }
.socials a:hover { color: var(--accent); }

/* Footer */
.site-footer { border-top: 1px solid var(--line); padding-block: 28px; color: var(--muted); font-size: .85rem; }
.site-footer .wrap { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 10px; }
.site-footer p { margin: 0; }
.credit span { color: var(--accent); }

/* Lightbox */
.lightbox { position: fixed; inset: 0; z-index: 50; background: rgba(10, 10, 10, .9); display: flex; align-items: center; justify-content: center; padding: 24px; }
.lightbox[hidden] { display: none; }
.lightbox figure { margin: 0; max-width: 1100px; }
.lightbox img { max-height: 82vh; margin: 0 auto; border-radius: 4px; }
.lightbox figcaption { color: #ddd; text-align: center; margin-top: 12px; font-size: .92rem; }
.lb-close { position: absolute; top: 14px; right: 18px; background: none; border: 0; color: #fff; font-size: 2.2rem; cursor: pointer; line-height: 1; }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  * { transition: none !important; }
}
