/* ==========================================================================
   Design: "scientific instrument". Serif = prose/ideas, mono = data/labels.
   Cool paper, near-black ink, one restrained indigo accent, hairline rules.
   Edit the tokens below to retune the whole site from one place.
   ========================================================================== */

:root {
  /* palette */
  --paper:        #f6f7f9;
  --paper-2:      #eef0f3;
  --ink:          #17181c;
  --ink-soft:     #5b5f68;
  --line:         #e3e5ea;
  --line-strong:  #c7cbd4;
  --accent:       #3e3a8c;
  --accent-strong:#2b2769;
  --accent-soft:  #ecebf6;

  /* type */
  --serif: "Newsreader", ui-serif, Georgia, "Times New Roman", serif;
  --mono:  "JetBrains Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;

  /* metrics */
  --maxw: 68rem;
  --measure: 42rem;
  --radius: 3px;
  --step: clamp(3rem, 7vw, 5rem);   /* vertical rhythm between big blocks */
}

/* ---- reset-ish --------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--serif);
  font-size: 1.125rem;
  line-height: 1.65;
  font-optical-sizing: auto;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
img { max-width: 100%; display: block; }
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-strong); text-decoration: underline; text-underline-offset: 2px; }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 1px;
}

/* ---- layout ------------------------------------------------------------ */
.wrap {
  width: 100%;
  max-width: var(--maxw);
  margin-inline: auto;
  padding-inline: 1.5rem;
}
main.wrap { padding-block: var(--step) calc(var(--step) * 1.2); }

.eyebrow {
  font-family: var(--mono);
  font-size: 0.72rem;
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-soft);
  margin: 0 0 0.75rem;
}
.eyebrow a { color: inherit; }
.eyebrow a:hover { color: var(--accent); }
.dim { color: var(--ink-soft); }
.dot { color: var(--line-strong); padding-inline: 0.15rem; }

/* ---- header ------------------------------------------------------------ */
.site-header {
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--paper) 88%, transparent);
  backdrop-filter: saturate(1.1) blur(6px);
  position: sticky;
  top: 0;
  z-index: 10;
}
.site-header__inner {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1.5rem;
  padding-block: 1.05rem;
}
.wordmark {
  font-family: var(--serif);
  font-weight: 600;
  font-size: 1.15rem;
  letter-spacing: -0.01em;
  color: var(--ink);
}
.wordmark:hover { color: var(--ink); text-decoration: none; }
.nav {
  display: flex;
  gap: 1.4rem;
  font-family: var(--mono);
  font-size: 0.82rem;
  letter-spacing: 0.02em;
}
.nav a { color: var(--ink-soft); }
.nav a:hover { color: var(--ink); text-decoration: none; }
.nav a.is-active { color: var(--ink); }
.nav a.is-active::after {
  content: "";
  display: block;
  height: 1.5px;
  background: var(--accent);
  margin-top: 3px;
}

/* ---- hero (home) ------------------------------------------------------- */
.hero {
  display: grid;
  grid-template-columns: 1fr minmax(0, 320px);
  gap: clamp(1.5rem, 5vw, 4rem);
  align-items: center;
  padding-block: clamp(1rem, 4vw, 2.5rem) var(--step);
  border-bottom: 1px solid var(--line);
}
.hero__name {
  font-size: clamp(2.4rem, 6vw, 3.6rem);
  line-height: 1.02;
  letter-spacing: -0.02em;
  font-weight: 500;
  margin: 0;
}
.hero__tagline {
  font-family: var(--mono);
  font-size: 0.9rem;
  letter-spacing: 0.02em;
  color: var(--accent);
  margin: 1rem 0 0;
}
.hero__intro {
  max-width: 34rem;
  color: var(--ink);
  margin: 1.4rem 0 0;
  font-size: 1.16rem;
}
.hero__links { margin-top: 1.75rem; }
.hero__figure { justify-self: end; }
.herograph { width: 100%; max-width: 320px; height: auto; }

/* ---- home sections ----------------------------------------------------- */
.home-section { padding-block: var(--step) 0; }
.home-section:last-child { padding-bottom: 0; }
.home-section__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.75rem;
  border-bottom: 1px solid var(--line);
  padding-bottom: 0.75rem;
}
.home-section__head .eyebrow { margin: 0; }
.seeall {
  font-family: var(--mono);
  font-size: 0.78rem;
  color: var(--ink-soft);
}
.seeall:hover { color: var(--accent); text-decoration: none; }

/* ---- page headers (list pages) ----------------------------------------- */
.page-head { margin-bottom: var(--step); }
.page-title {
  font-size: clamp(2rem, 4.5vw, 2.9rem);
  line-height: 1.05;
  letter-spacing: -0.02em;
  font-weight: 500;
  margin: 0;
}
.page-intro {
  max-width: var(--measure);
  color: var(--ink-soft);
  margin-top: 1rem;
  font-size: 1.12rem;
}
.page-intro p { margin: 0.4rem 0 0; }

/* ---- card grid --------------------------------------------------------- */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(16rem, 1fr));
  gap: 1.75rem 1.5rem;
}
.card {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  overflow: hidden;
  transition: border-color 0.18s ease, transform 0.18s ease, box-shadow 0.18s ease;
}
.card:hover {
  border-color: var(--line-strong);
  transform: translateY(-2px);
  box-shadow: 0 8px 24px -18px rgba(23, 24, 28, 0.5);
}
.card__media {
  display: block;
  aspect-ratio: 5 / 3;
  background: var(--paper-2);
  border-bottom: 1px solid var(--line);
  overflow: hidden;
}
.card__media img,
.card__media .ph { width: 100%; height: 100%; object-fit: cover; }
.card__body { padding: 1.1rem 1.15rem 1.25rem; display: flex; flex-direction: column; gap: 0.5rem; flex: 1; }
.card__meta {
  font-family: var(--mono);
  font-size: 0.72rem;
  letter-spacing: 0.03em;
  color: var(--ink-soft);
  text-transform: uppercase;
}
.card__title {
  font-size: 1.28rem;
  line-height: 1.2;
  font-weight: 500;
  letter-spacing: -0.01em;
  margin: 0;
}
.card__title a { color: var(--ink); }
.card__title a:hover { color: var(--accent); text-decoration: none; }
.card__teaser { color: var(--ink-soft); font-size: 1rem; line-height: 1.55; margin: 0; }
.card__links {
  margin-top: auto;
  padding-top: 0.5rem;
  display: flex;
  gap: 1rem;
  font-family: var(--mono);
  font-size: 0.76rem;
}

/* ---- long-form prose --------------------------------------------------- */
.post { max-width: var(--measure); margin-inline: auto; }
.post--narrow { max-width: 40rem; }
.post-head { margin-bottom: 2.25rem; }
.post-title {
  font-size: clamp(2rem, 4.5vw, 2.9rem);
  line-height: 1.08;
  letter-spacing: -0.02em;
  font-weight: 500;
  margin: 0.3rem 0 0;
}
.post-meta {
  font-family: var(--mono);
  font-size: 0.78rem;
  color: var(--ink-soft);
  margin-top: 1rem;
}
.post-meta .tags { display: inline; }
.tag { color: var(--ink-soft); }
.tag + .tag { margin-left: 0.5rem; }
.tag:hover { color: var(--accent); text-decoration: none; }
.post-links {
  margin-top: 1.1rem;
  display: flex;
  flex-wrap: wrap;
  gap: 1.25rem;
  font-family: var(--mono);
  font-size: 0.82rem;
}

.prose { font-size: 1.15rem; line-height: 1.72; }
.prose > * + * { margin-top: 1.35rem; }
.prose h2 {
  font-size: 1.6rem;
  line-height: 1.2;
  font-weight: 600;
  letter-spacing: -0.01em;
  margin-top: 2.75rem;
}
.prose h3 { font-size: 1.3rem; font-weight: 600; margin-top: 2rem; }
.prose h2 + *, .prose h3 + * { margin-top: 0.9rem; }
.prose a { text-decoration: underline; text-underline-offset: 2px; text-decoration-color: var(--line-strong); }
.prose a:hover { text-decoration-color: currentColor; }
.prose strong { font-weight: 600; }
.prose blockquote {
  border-left: 2px solid var(--accent);
  padding-left: 1.1rem;
  margin-left: 0;
  color: var(--ink-soft);
  font-style: italic;
}
.prose ul, .prose ol { padding-left: 1.3rem; }
.prose li + li { margin-top: 0.4rem; }
.prose img { border-radius: var(--radius); border: 1px solid var(--line); margin-inline: auto; }
.prose figure { margin: 2rem 0; }
.prose figcaption {
  font-family: var(--mono);
  font-size: 0.78rem;
  color: var(--ink-soft);
  text-align: center;
  margin-top: 0.6rem;
}
.prose hr { border: 0; border-top: 1px solid var(--line); margin: 2.5rem 0; }

/* inline + block code */
.prose code {
  font-family: var(--mono);
  font-size: 0.86em;
  background: var(--paper-2);
  padding: 0.12em 0.35em;
  border-radius: 3px;
}
.prose pre {
  font-family: var(--mono);
  font-size: 0.86rem;
  line-height: 1.6;
  background: #fbfbfd;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1rem 1.15rem;
  overflow-x: auto;
}
.prose pre code { background: none; padding: 0; font-size: inherit; }

/* tables */
.prose table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.98rem;
}
.prose th, .prose td { text-align: left; padding: 0.5rem 0.75rem; border-bottom: 1px solid var(--line); }
.prose th { font-family: var(--mono); font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--ink-soft); }

/* KaTeX display math: let it scroll on small screens instead of overflowing */
.prose .katex-display { overflow-x: auto; overflow-y: hidden; padding-block: 0.4rem; }

/* ---- about ------------------------------------------------------------- */
.about {
  display: grid;
  grid-template-columns: 15rem 1fr;
  gap: clamp(1.5rem, 5vw, 3.5rem);
  align-items: start;
}
.about__aside { position: sticky; top: 6rem; }
.about__portrait {
  width: 100%;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--paper-2);
  aspect-ratio: 4 / 5;
  object-fit: cover;
}
.about__contact { margin-top: 1.5rem; }
.about__contact .eyebrow { margin-bottom: 0.6rem; }
.about__cv { margin-top: 1rem; font-family: var(--mono); font-size: 0.82rem; }
.about__main .page-title { margin-bottom: 1.5rem; }
.about__main .prose { max-width: var(--measure); }

/* ---- social list ------------------------------------------------------- */
.sociallist {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.9rem 1rem;
}
.sociallist li { display: flex; }
.sociallist a {
  color: var(--ink-soft);
  display: inline-flex;
  align-items: center;
  transition: color 0.15s ease;
}
.sociallist a:hover { color: var(--accent); text-decoration: none; }
.sociallist .ic { width: 1.2rem; height: 1.2rem; display: block; }
.about__contact .sociallist { gap: 0.9rem; }

/* ---- footer ------------------------------------------------------------ */
.site-footer {
  border-top: 1px solid var(--line);
  margin-top: var(--step);
}
.site-footer__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
  padding-block: 2rem;
}
.site-footer__meta {
  font-family: var(--mono);
  font-size: 0.76rem;
  color: var(--ink-soft);
  margin: 0;
}
.site-footer__meta a { color: var(--ink-soft); }
.site-footer__meta a:hover { color: var(--accent); }

/* ---- misc -------------------------------------------------------------- */
.postnav {
  max-width: var(--measure);
  margin: 3rem auto 0;
  font-family: var(--mono);
  font-size: 0.82rem;
}
.postnav a { color: var(--ink-soft); }
.postnav a:hover { color: var(--accent); text-decoration: none; }
.empty { color: var(--ink-soft); }

/* ---- hero graph animation ---------------------------------------------- */
.herograph__edges path,
.herograph__trace path {
  stroke-dasharray: 400;      /* larger than any single path length here */
  stroke-dashoffset: 400;
  animation: draw 1.1s ease forwards;
}
.herograph__edges path { opacity: 0.85; }
.herograph__trace path { opacity: 0; animation: draw 0.9s ease 0.5s forwards, fade 0.01s linear 0.5s forwards; }
.herograph__nodes circle { opacity: 0; animation: pop 0.5s ease forwards; }
.herograph__nodes .n-in  { animation-delay: 0.1s; }
.herograph__nodes .n-mid { animation-delay: 0.45s; }
.herograph__nodes .n-out { animation-delay: 0.9s; }
.herograph .n-in  { fill: var(--paper); stroke: var(--ink); stroke-width: 1.5; }
.herograph .n-mid { fill: var(--paper); stroke: var(--line-strong); stroke-width: 1.5; }
.herograph .n-out { fill: var(--paper); stroke: var(--ink); stroke-width: 1.5; }
.herograph .n-hot { fill: var(--accent); }

@keyframes draw  { to { stroke-dashoffset: 0; } }
@keyframes fade  { to { opacity: 1; } }
@keyframes pop   { from { opacity: 0; transform: scale(0.6); } to { opacity: 1; transform: scale(1); } }

/* ---- responsive -------------------------------------------------------- */
@media (max-width: 46rem) {
  body { font-size: 1.06rem; }
  .hero { grid-template-columns: 1fr; }
  .hero__figure { display: none; }         /* keep mobile lean */
  .about { grid-template-columns: 1fr; }
  .about__aside { position: static; max-width: 15rem; }
  .site-header__inner { flex-direction: column; align-items: flex-start; gap: 0.6rem; }
  .nav { gap: 1.1rem; }
}

/* ---- accessibility: honour reduced-motion ------------------------------ */
@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
  .herograph__edges path,
  .herograph__trace path { stroke-dashoffset: 0; opacity: 1; }
  .herograph__trace path { opacity: 1; }
  .herograph__nodes circle { opacity: 1; }
}

/* ---- taxonomy index ---------------------------------------------------- */
.taxo { list-style: none; margin: 0; padding: 0; columns: 2; column-gap: 2rem; max-width: var(--measure); }
.taxo li { margin-bottom: 0.5rem; font-family: var(--mono); font-size: 0.9rem; break-inside: avoid; }
.taxo .dim { font-size: 0.78rem; }

.pubs { list-style: none; margin: 0; padding: 0; }
.pub { border-bottom: 1px solid var(--line); }
.pub:first-child { border-top: 1px solid var(--line); }
 
.pub__summary {
  list-style: none;                     /* hide default disclosure triangle */
  cursor: pointer;
  display: flex;
  align-items: baseline;
  gap: 1rem;
  padding: 1.05rem 0.15rem;
  transition: color 0.15s ease;
}
.pub__summary::-webkit-details-marker { display: none; }
.pub__summary::marker { content: ""; }
.pub__summary:hover { color: var(--accent); }
.pub__d[open] > .pub__summary { color: var(--accent); }
 
.pub__ref { flex: 1; line-height: 1.55; }
.pub__authors { color: var(--ink); }
.pub__year { color: var(--ink-soft); }
.pub__title { font-weight: 500; }
.pub__venue { color: var(--ink-soft); font-style: italic; }
 
/* chevron drawn in CSS; rotates when the entry is open */
.pub__chev {
  flex: none;
  width: 0.55rem; height: 0.55rem;
  border-right: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  transform: rotate(45deg);
  transition: transform 0.2s ease;
  margin-top: 0.3rem;
  color: var(--ink-soft);
}
.pub__d[open] .pub__chev { transform: rotate(-135deg); color: var(--accent); }
 
.pub__body { padding: 0 0.15rem 1.4rem; }
.pub__abstract { color: var(--ink-soft); font-size: 1.04rem; line-height: 1.65; }
.pub__abstract > *:first-child { margin-top: 0; }
.pub__links {
  margin-top: 1.1rem;
  display: flex;
  flex-wrap: wrap;
  gap: 1.25rem;
  font-family: var(--mono);
  font-size: 0.82rem;
}

details.pub__d > summary {
  list-style: none;
}
 
/* subtle open/close reveal (skipped under reduced-motion via the global rule) */
.pub__d[open] .pub__body { animation: pub-reveal 0.22s ease; }
@keyframes pub-reveal { from { opacity: 0; transform: translateY(-3px); } to { opacity: 1; transform: none; } }