/* ------------------------------------------------------------------
   Personal site — one stylesheet for every page.
   Change the tokens below to restyle the whole site.
------------------------------------------------------------------- */
:root {
  --paper: #F4F6F8;      /* page background */
  --surface: #FFFFFF;    /* cards, panels */
  --ink: #17223B;        /* main text (deep navy) */
  --muted: #566176;      /* secondary text */
  --rule: #D6DCE4;       /* borders, graph edges */
  --accent: #0079A8;     /* links, co-author nodes */
  --mark: #C08420;       /* selected / highlighted */

  --serif: "Literata", Georgia, "Times New Roman", serif;
  --sans: "Public Sans", system-ui, -apple-system, "Segoe UI", sans-serif;

  --measure: 68ch;
  --wide: 1140px;
  --radius: 6px;
}

*, *::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.0625rem;
  line-height: 1.65;
  font-optical-sizing: auto;
}
img { max-width: 100%; display: block; }
a { color: var(--accent); text-underline-offset: 0.18em; text-decoration-thickness: 1px; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 2px solid var(--mark); outline-offset: 3px; border-radius: 2px; }

.skip { position: absolute; left: -999px; }
.skip:focus { left: 1rem; top: 1rem; background: var(--surface); padding: .5rem 1rem; z-index: 10; }

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

/* ---------- Header / nav ---------- */
.site-header { border-bottom: 1px solid var(--rule); background: var(--paper); }
.site-header .wrap {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: 1rem; flex-wrap: wrap; padding-top: 1.1rem; padding-bottom: 1.1rem;
}
.site-name {
  font-family: var(--serif); font-weight: 600; font-size: 1.15rem;
  color: var(--ink); text-decoration: none; letter-spacing: -0.01em;
}
.site-nav { display: flex; gap: 1.75rem; font-family: var(--sans); font-size: .95rem; }
.site-nav a { color: var(--muted); text-decoration: none; padding-bottom: .25rem; border-bottom: 2px solid transparent; }
.site-nav a:hover { color: var(--ink); }
.site-nav a[aria-current="page"] { color: var(--ink); border-bottom-color: var(--accent); }

main { padding: 3.5rem 0 5rem; }

/* ---------- Shared type ---------- */
h1, h2, h3 { font-family: var(--serif); line-height: 1.15; letter-spacing: -0.015em; margin: 0; }
.page-title { font-size: clamp(2.1rem, 4.5vw, 3.1rem); font-weight: 500; }
.page-intro { color: var(--muted); max-width: var(--measure); margin: .9rem 0 0; font-size: 1.1rem; }
.section-title { font-size: 1.35rem; font-weight: 600; margin-bottom: 1.25rem; }
.sans { font-family: var(--sans); }
.meta { font-family: var(--sans); font-size: .85rem; color: var(--muted); }

/* ---------- Landing ---------- */
.intro {
  display: grid; grid-template-columns: minmax(220px, 340px) 1fr;
  gap: clamp(2rem, 5vw, 4.5rem); align-items: start;
}
.portrait { position: relative; }
.portrait img {
  width: 100%; height: auto; aspect-ratio: 4 / 5; object-fit: cover;
  border-radius: var(--radius); background: var(--rule);
}
/* the one decorative touch: a small graph that links the photo to the page */
.portrait svg.graph-mark { position: absolute; right: -38px; bottom: -30px; width: 120px; height: auto; pointer-events: none; }
.intro h1 { font-size: clamp(2.6rem, 6vw, 4.2rem); font-weight: 500; letter-spacing: -0.03em; }
.intro .role { font-family: var(--sans); color: var(--muted); font-size: 1.02rem; margin: .6rem 0 1.6rem; }
.bio { max-width: var(--measure); }
.bio p { margin: 0 0 1.1rem; }
.contact { display: flex; flex-wrap: wrap; gap: .5rem 1.4rem; margin-top: 1.6rem; font-family: var(--sans); font-size: .95rem; }

.latest { margin-top: 5rem; display: grid; grid-template-columns: 1fr 1fr; gap: 3rem; }
.latest ol { list-style: none; margin: 0; padding: 0; }
.latest li { padding: .9rem 0; border-top: 1px solid var(--rule); }
.latest li a { color: var(--ink); text-decoration: none; font-weight: 500; }
.latest li a:hover { color: var(--accent); }
.latest .more { display: inline-block; margin-top: .9rem; font-family: var(--sans); font-size: .9rem; }

/* ---------- Public writing ---------- */
.filters { display: flex; flex-wrap: wrap; gap: .5rem; margin: 2.25rem 0 2rem; font-family: var(--sans); }
.filters button, .chip {
  font: inherit; font-size: .9rem; cursor: pointer;
  background: transparent; color: var(--ink);
  border: 1px solid var(--rule); border-radius: 999px; padding: .35rem .95rem;
}
.filters button:hover, .chip:hover { border-color: var(--ink); }
.filters button[aria-pressed="true"], .chip[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: var(--paper); }
.filters .count { color: inherit; opacity: .65; margin-left: .3rem; }

.posts { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 2.25rem 1.75rem; }
/* Card modeled on Substack's own post embed: cover, publication, title, subtitle, date */
.post {
  display: flex; flex-direction: column; text-decoration: none; color: inherit;
  background: var(--surface); border: 1px solid var(--rule); border-radius: var(--radius); overflow: hidden;
}
.post:hover { border-color: var(--ink); }
.post:hover h3 { text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: .15em; }
.post .cover-wrap { position: relative; border-bottom: 1px solid var(--rule); }
.post .cover { aspect-ratio: 16 / 9; width: 100%; object-fit: cover; background: #E6EBF0; }
.post .credit { position: absolute; right: .5rem; bottom: .5rem; font-family: var(--sans); font-size: .7rem;
  color: #fff; background: rgba(23, 34, 59, .72); padding: .1rem .45rem; border-radius: 3px; }
.post .body { padding: 1.1rem 1.25rem 1.3rem; display: flex; flex-direction: column; gap: .5rem; flex: 1; }
.post .pub { font-family: var(--sans); font-size: .8rem; font-weight: 600; color: var(--accent); }
.post h3 { font-size: 1.2rem; font-weight: 600; line-height: 1.25; }
.post .sub { color: var(--muted); font-size: .97rem; line-height: 1.5; margin: 0;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.post .meta { margin-top: auto; padding-top: .4rem; display: flex; gap: .6rem; align-items: baseline; }
.post .role { font-size: .75rem; border: 1px solid var(--rule); border-radius: 3px; padding: 0 .4rem; }
.post .tag { border-color: var(--accent); color: var(--accent); }
.post .pub s, .filters s { text-decoration-thickness: 1.5px; }

.empty { font-family: var(--sans); color: var(--muted); border: 1px dashed var(--rule); border-radius: var(--radius); padding: 2rem; max-width: 60ch; }

/* ---------- Formal research ---------- */
.research { display: grid; grid-template-columns: minmax(320px, 440px) 1fr; gap: 3rem; margin-top: 2.5rem; align-items: start; }
.graph-panel { position: sticky; top: 1.5rem; background: var(--surface); border: 1px solid var(--rule); border-radius: var(--radius); padding: 1rem 1rem 1.2rem; }
.graph-panel h2 { font-size: 1.05rem; font-weight: 600; }
.graph-panel .caption { font-family: var(--sans); font-size: .82rem; color: var(--muted); margin: .25rem 0 .5rem; line-height: 1.45; }
#coauthor-graph { position: relative; }
#coauthor-graph svg { width: 100%; height: auto; display: block; overflow: visible; }
#coauthor-graph .edge { stroke: var(--rule); stroke-linecap: round; pointer-events: none; stroke-opacity: .4; }
#coauthor-graph .edge.spoke { stroke-opacity: 1; }
#coauthor-graph .edge.on { stroke-opacity: 1; }
#coauthor-graph .ring { fill: none; stroke: var(--rule); stroke-dasharray: 2 4; }
#coauthor-graph .ring-label { font-family: var(--sans); font-size: 10px; fill: var(--muted); paint-order: stroke; stroke: var(--surface); stroke-width: 4px; }
#coauthor-graph .edge.on { stroke: var(--mark); }
#coauthor-graph .node circle.dot { fill: var(--accent); stroke: var(--surface); stroke-width: 2px; }
#coauthor-graph .node.me circle.dot { fill: var(--ink); }
#coauthor-graph .node.on circle.dot { fill: var(--mark); }
#coauthor-graph .node { cursor: pointer; outline: none; }
#coauthor-graph .node:focus-visible circle.dot { stroke: var(--mark); stroke-width: 3px; }
#coauthor-graph .node text {
  font-family: var(--sans); font-size: 11px; fill: var(--ink);
  paint-order: stroke; stroke: var(--surface); stroke-width: 4px; stroke-linejoin: round; pointer-events: none;
}
#coauthor-graph .node.me text { font-weight: 600; }
#coauthor-graph .dim { opacity: .2; }
#coauthor-graph .node, #coauthor-graph .edge { transition: opacity .2s; }
.tooltip {
  position: absolute; pointer-events: none; background: var(--ink); color: var(--paper);
  font-family: var(--sans); font-size: .8rem; line-height: 1.35; padding: .45rem .65rem; border-radius: 4px;
  white-space: nowrap; transform: translate(-50%, calc(-100% - 12px)); opacity: 0; transition: opacity .12s;
}
.tooltip.show { opacity: 1; }
.tooltip strong { display: block; font-weight: 600; }

.topics { display: flex; flex-wrap: wrap; gap: .4rem; margin-top: 1rem; font-family: var(--sans); }
.topics .chip { font-size: .8rem; padding: .2rem .7rem; }

.filter-note { font-family: var(--sans); font-size: .92rem; color: var(--muted); margin: 0 0 1.5rem; min-height: 1.5em; }
.filter-note button { font: inherit; color: var(--accent); background: none; border: 0; padding: 0; cursor: pointer; text-decoration: underline; text-underline-offset: .18em; }

.year-group { display: grid; grid-template-columns: 4.2rem 1fr; gap: 1rem; padding: 1.25rem 0; border-top: 1px solid var(--rule); }
.year-group:first-of-type { border-top: 0; padding-top: 0; }
.year-group h2 { font-family: var(--sans); font-size: .95rem; font-weight: 600; color: var(--muted); padding-top: .2rem; }
.pubs { list-style: none; margin: 0; padding: 0; display: grid; gap: 1.5rem; }
.pub-item h3 { font-size: 1.12rem; font-weight: 600; line-height: 1.3; }
.pub-item h3 a { color: var(--ink); text-decoration: none; }
.pub-item h3 a:hover { color: var(--accent); text-decoration: underline; }
.pub-item .authors { margin: .3rem 0 0; font-size: .96rem; }
.pub-item .authors .me { font-weight: 600; }
.pub-item .venue { font-style: italic; color: var(--muted); margin: .1rem 0 0; font-size: .96rem; }
.pub-item .links { display: flex; flex-wrap: wrap; gap: .3rem 1rem; margin-top: .45rem; font-family: var(--sans); font-size: .85rem; }
.pub-item sup { font-family: var(--sans); font-size: .7em; margin-left: 1px; }
.footnote { margin-top: 1.5rem; }
.pub-item .award { font-family: var(--sans); font-size: .8rem; color: var(--mark); font-weight: 600; margin-top: .3rem; }

/* ---------- Footer ---------- */
.site-footer { border-top: 1px solid var(--rule); padding: 1.5rem 0 2.5rem; }
.site-footer p { margin: 0; font-family: var(--sans); font-size: .85rem; color: var(--muted); }

/* ---------- Small screens ---------- */
@media (max-width: 860px) {
  .intro, .latest, .research { grid-template-columns: 1fr; }
  .portrait { max-width: 300px; }
  .portrait svg.graph-mark { right: -24px; width: 96px; }
  .graph-panel { position: static; }
  .latest { gap: 2.5rem; margin-top: 4rem; }
}
@media (max-width: 520px) {
  main { padding-top: 2.25rem; }
  .year-group { grid-template-columns: 1fr; gap: .5rem; }
  .site-nav { gap: 1.2rem; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
