/* Light theme: paper and ink (Tufte CSS palette) */
:root {
  --bg: #FFFFF8;
  --text: #111111;
  --strong: #111111;
  --muted: #4E4E4C;
  --faint: #656563;
  --rule: #C8C8C2;
  --row-rule: #E4E4DE;
  --hair: #E2E2DB;
  --tint: #F3F3EC;
  --card: #FFFFF8;
  --accent: #111111;
  --spot: #AF3029;
  /* Kind of work, shown above each publication title */
  --kind-article: #205EA6;
  --kind-course: #BC5215;
  --kind-thesis: #AF3029;
}

/* Dark theme, following the system setting */
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #151515;
    --text: #DDDDDD;
    --strong: #EEEEEE;
    --muted: #B3B3B3;
    --faint: #B3B3B3;
    --rule: #4A4A4A;
    --row-rule: #2C2C2C;
    --hair: #2E2E2E;
    --tint: #1D1D1D;
    --card: #151515;
    --accent: #DDDDDD;
    --spot: #FC9789;
    --kind-article: #76B8F5;
    --kind-course: #F0A060;
    --kind-thesis: #FC9789;
  }
  /* Ink drawings (logos, schemas) are drawn in black: flip them on dark paper */
  img.ink { filter: invert(1); }
  /* Scans keep their own ink colours: show them on a paper backing */
  img.paper { background: #FFFFF8; }
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  /* Faint Truchet texture, rendered from the concentric-arcs Truchet shader; cards keep plain paper */
  background: var(--bg) url("../figures/truchet-light.png") repeat;
  background-size: 800px 800px;
  color: var(--text);
  font-family: 'Atkinson Hyperlegible Next', system-ui, sans-serif;
  font-size: 16px;
  line-height: 1.6;
  font-kerning: normal;
}
@media (prefers-color-scheme: dark) {
  body { background-image: url("../figures/truchet-dark.png"); }
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; text-decoration-thickness: 1px; }
a:focus-visible, button:focus-visible { outline: 2px solid var(--strong); outline-offset: 3px; }

/* Links inside running text are underlined: colour alone is not enough to tell them apart */
.hero p a, .news-list a {
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
  text-decoration-color: var(--faint);
}

h1, h2, h3, p { margin: 0; }
img { display: block; max-width: 100%; }
strong { font-weight: 600; color: var(--strong); }

/* Labels and metadata: spaced capitals */
.topbar nav a, .news-toggle, .role, .venue, .links a, .award {
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.date { font-variant-numeric: tabular-nums; }

.short { display: none; }

.wrap {
  max-width: 980px;
  margin: 0 auto;
  padding: 32px 24px 0;
}

/* Top bar */
.topbar {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: baseline;
  gap: 4px 24px;
  font-size: 13px;
}
.site { color: var(--faint); }
.topbar nav { display: flex; gap: 20px; }
.topbar nav a { color: var(--muted); }
.topbar nav a:hover { color: var(--strong); }

/* Intro */
.hero { margin-top: 72px; }
.hero::after { content: ""; display: block; clear: both; }
.avatar-wrap {
  position: relative;
  float: left;
  margin: 6px 32px 12px 0;
  shape-outside: circle(50%);
}
.avatar {
  width: 168px;
  height: 168px;
  border-radius: 50%;
  border: 1px solid var(--strong);
  /* Hole of the torus cut by a vector mask, so it stays aligned with the ring below at any zoom.
     Edge at 23.3% of the radius: inside the ring, which spans 22.8-24% of the radius. */
  -webkit-mask: radial-gradient(circle closest-side, transparent 23.1%, #000 23.5%);
  mask: radial-gradient(circle closest-side, transparent 23.1%, #000 23.5%);
}
/* Same outline as the outer border, around the hole: 24% of the avatar */
.avatar-wrap::after {
  content: "";
  position: absolute;
  left: 38%;
  top: 38%;
  width: 24%;
  height: 24%;
  border: 1px solid var(--strong);
  border-radius: 50%;
  pointer-events: none;
}
.hero h1 {
  margin-bottom: 4px;
  font-size: 44px;
  line-height: 1.1;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--strong);
}
.role { margin-bottom: 6px; font-size: 14px; font-weight: 500; color: var(--strong); }
.contact {
  list-style: none;
  margin: 0 0 18px;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0 22px;
  font-size: 14px;
}
.contact a {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 36px;
  color: var(--muted);
}
.contact a:hover { color: var(--strong); text-decoration: none; }
.hero > p + p { margin-top: 12px; }

/* News */
.news { margin-top: 44px; }
.news-head {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 6px;
}
.news-head h2 {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--strong);
}
.news-rule { flex: 1; height: 1px; background: var(--strong); }
.news-toggle {
  padding: 4px 0;
  font-family: inherit;
  font-size: 12px;
  color: var(--accent);
  background: none;
  border: 0;
  cursor: pointer;
}
.news-toggle:hover { text-decoration: underline; text-underline-offset: 3px; }
.news-list {
  list-style: none;
  margin: 0;
  padding: 0;
  font-size: 14px;
  line-height: 1.45;
}
.news-list li { display: flex; gap: 14px; align-items: baseline; padding: 4px 0; box-shadow: inset 0 -1px 0 var(--hair); }
.date { flex: 0 0 104px; font-size: 12px; font-weight: 500; color: var(--strong); }
.news-list.collapsed li:nth-child(n+4) { display: none; }

/* Section titles: left-aligned capitals, with a rule running to the right */
.section-title {
  display: flex;
  align-items: center;
  gap: 14px;
  margin: 56px 0 18px;
  font-size: 22px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--strong);
}
.section-title::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--strong);
}

/* Publications: index cards */
.pubs { display: flex; flex-direction: column; gap: 14px; }
.pub {
  display: flex;
  align-items: stretch;
  background: var(--card);
  border: 1px solid var(--rule);
  transition: border-color .15s;
}
.pub:hover { border-color: var(--strong); }
.pub-img {
  flex: 0 0 236px;
  display: flex;
  align-items: center;
  background: var(--tint);
  border-right: 1px solid var(--hair);
}
.pub-img img { width: 236px; height: 150px; object-fit: contain; }
.pub-img video { display: block; width: 236px; height: 150px; object-fit: cover; }
.pub-body {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 3px;
  padding: 16px 24px;
  font-size: 14px;
  color: var(--muted);
}
.pub-body h3 { font-size: 17px; font-weight: 600; line-height: 1.35; letter-spacing: -0.005em; }
.pub-body h3 a { color: var(--strong); }

/* Venue line, moved above the title and led by the kind of work in its colour */
.venue { order: -1; font-size: 12.5px; font-weight: 500; color: var(--muted); }
.venue[data-kind="Article"] { --kind: var(--kind-article); }
.venue[data-kind="Course"] { --kind: var(--kind-course); }
.venue[data-kind="PhD Thesis"] { --kind: var(--kind-thesis); }
.venue::before { content: attr(data-kind) "\2002\00b7\2002"; color: var(--kind); font-weight: 600; }

.award { font-weight: 600; color: var(--spot); }
.links { margin-top: 6px; display: flex; flex-wrap: wrap; gap: 0 18px; font-size: 15px; }
.links a { color: var(--strong); font-weight: 500; }
.links a::after { content: "\00a0\2192"; color: var(--faint); }

/* Side projects */
.projects {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 24px 20px;
}
.project { display: flex; flex-direction: column; gap: 4px; font-size: 13px; line-height: 1.5; color: var(--muted); }
.project-img {
  display: block;
  aspect-ratio: 16 / 10;
  margin-bottom: 4px;
  overflow: hidden;
  border: 1px solid var(--rule);
  background: var(--tint);
}
.project-img img { width: 100%; height: 100%; object-fit: cover; }
.project-img.contain img { object-fit: contain; }
.project h3 { font-size: 15px; font-weight: 600; }
.project h3 a { color: var(--strong); }

/* Footer */
.footer {
  margin-top: 64px;
  padding: 16px 0 32px;
  border-top: 1px solid var(--strong);
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 4px 24px;
  font-size: 13px;
  color: var(--faint);
}

/* Phone */
@media (max-width: 640px) {
  body { font-size: 15px; }
  .wrap { padding: 20px 20px 0; }
  .long { display: none; }
  .short { display: inline; }

  .topbar { font-size: 12px; align-items: center; }
  .topbar nav { gap: 2px; }
  .topbar nav a { padding: 10px 6px; }
  .topbar nav a:last-child { padding-right: 0; }

  .hero { margin-top: 28px; }
  .avatar-wrap { margin: 0 16px 0 0; shape-outside: none; }
  .avatar { width: 84px; height: 84px; }
  .hero h1 { min-height: 84px; display: flex; align-items: center; margin: 0; font-size: 26px; line-height: 1.15; }
  .role { clear: both; margin: 16px 0 0; font-size: 13px; text-align: center; }
  .contact { justify-content: center; gap: 10px; margin: 14px 0 22px; }
  .contact a {
    width: 36px;
    height: 36px;
    min-height: 0;
    justify-content: center;
    border: 1px solid var(--faint);
    border-radius: 50%;
  }
  .contact a span { display: none; }

  .news { margin-top: 36px; }
  .news-head h2 { font-size: 11px; }
  .news-list li { flex-direction: column; gap: 0; padding: 5px 0; }
  .date { flex: none; font-size: 11.5px; }
  .news-list.collapsed li:nth-child(n+3) { display: none; }

  .section-title { margin: 32px 0 16px; font-size: 19px; gap: 12px; }

  .pub { flex-direction: column; }
  .pub-img { flex: none; border-right: 0; border-bottom: 1px solid var(--hair); }
  .pub-img img, .pub-img video { width: 100%; height: auto; aspect-ratio: 236 / 150; }
  .pub-body { padding: 14px 16px 16px; font-size: 13.5px; }
  .pub-body h3 { font-size: 16px; }
  .venue { font-size: 12px; }
  .links a { padding: 6px 0; }

  .projects { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px 14px; }
  .project { font-size: 12.5px; }
  .project h3 { font-size: 14px; }
}
