@font-face {
  font-family: "Libre Franklin";
  src: url("fonts/LibreFranklin.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Libre Franklin";
  src: url("fonts/LibreFranklin-Italic.woff2") format("woff2");
  font-weight: 100 900;
  font-style: italic;
  font-display: swap;
}

:root {
  --ink: #1b2230;
  --muted: #5c6677;
  --paper: #ffffff;
  --side: #eaf0f8;
  --side-line: #cdd8e8;
  --blue: #1d4f9c;
  --line: #e1e6ee;
  color-scheme: light dark;
}

/* Dark mode follows the system setting. Screen only, so printing stays dark-on-white.
   All text colours keep a contrast ratio of 6.4:1 or more against both backgrounds. */
@media screen and (prefers-color-scheme: dark) {
  :root {
    --ink: #e3e8f0;
    --muted: #9aa5b6;
    --paper: #12161d;
    --side: #1b222d;
    --side-line: #2e3847;
    --blue: #7eaaf0;
    --line: #262e3a;
  }
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 400 1rem/1.65 "Libre Franklin", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
}

a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: .15em; }
a:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; border-radius: 3px; }

h1, h2 { letter-spacing: -.02em; }
h2 { font-size: 1.7rem; font-weight: 700; line-height: 1.2; margin: 0 0 1.2rem; }
h3 { font-size: 1.05rem; font-weight: 600; margin: 1.8rem 0 .8rem; }
h2 + h3 { margin-top: 0; }
h1, h2, h3 { text-wrap: balance; }
p, li, dd { text-wrap: pretty; }
p { margin: .6rem 0; }
ul, ol { padding-left: 1.2rem; }
li { margin: .4rem 0; }

.visually-hidden {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap;
}

/* ---------- Home page: sidebar + content ---------- */

.layout { display: grid; grid-template-columns: 20rem minmax(0, 1fr); }

/* Sidebar: five groups (photo, name and roles, contact, profiles, nav) on one vertical rhythm.
   The gap between groups is --side-gap. Each position and contact line hangs an icon in the
   left margin, so the icons form a rail that marks where every item starts. */
.side {
  --side-gap: 1.5rem;
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
  display: flex; flex-direction: column; gap: var(--side-gap);
  background: var(--side); padding: 2.5rem 2rem; font-size: .95rem; line-height: 1.5;
}
.side > * { margin: 0; }
/* The photo is the one flexible item: shown at its natural size (242px) when there is room,
   and shrinking (never below 6rem tall) so that the rest of the sidebar always fits. */
.side img {
  display: block; border-radius: 10px; align-self: flex-start;
  width: auto; height: auto; max-width: 100%; aspect-ratio: 242 / 206;
  flex: 0 1 auto; min-height: 6rem;
}
.side h1 { font-size: 1.9rem; font-weight: 700; line-height: 1.1; margin: 0 0 .75rem; }
.side ul { list-style: none; padding: 0; margin: 0; }
.side .roles li { margin: .75rem 0 0; font-weight: 600; }
.side .roles li:first-child { margin-top: 0; }
.side .roles .org { display: block; font-weight: 400; }   /* role on one line, institution below */
.side .roles a { white-space: nowrap; }           /* never split an institution's name */
.side .contact { font-style: normal; color: var(--muted); }
.side .contact a { display: inline-block; margin-bottom: .35rem; }
.side .contact .email { white-space: nowrap; }
.side .contact .postal { display: block; }
.side .roles li, .side .contact .email, .side .contact .postal { position: relative; }
.side .roles .icon, .side .contact .icon { position: absolute; left: -1.5em; top: .28em; margin: 0; color: var(--blue); }
.icon {
  width: 1em; height: 1em; margin-right: .4em; vertical-align: -.14em;
  fill: none; stroke: currentColor; stroke-width: 1.3; stroke-linecap: round; stroke-linejoin: round;
}
.side .profiles { display: flex; flex-wrap: wrap; gap: .1rem 1rem; }
.side .profiles li { margin: 0; }
.side nav { padding-top: var(--side-gap); border-top: 1px solid var(--side-line); }
.side nav li { margin: 0; }
.side nav a {
  display: block; padding: .15rem 0 .15rem .75rem; margin-left: calc(-.75rem - 3px);
  border-left: 3px solid transparent; color: var(--ink); font-weight: 500;
}
.side nav a:hover { color: var(--blue); text-decoration: none; }

.content { padding: 2.5rem 4rem 4rem; max-width: 56rem; }
.content p { max-width: 70ch; }
/* Sections touch each other (padding, not margin) so exactly one is "current" at any scroll position */
.content section { display: flow-root; scroll-margin-top: 2rem; }
.content h3[id] { scroll-margin-top: 2rem; }
.content section + section { padding-top: 4rem; scroll-margin-top: -2rem; }

/* Intro: lead paragraph and a row of key figures */
.intro .lead { font-size: 1.25rem; line-height: 1.55; margin-top: 0; text-wrap: pretty; }
.facts {
  display: flex; flex-wrap: wrap; align-items: baseline; gap: .4rem 1.75rem; list-style: none;
  margin: 1.5rem 0; padding: 1rem 0; border-block: 1px solid var(--line); color: var(--muted);
}
.facts li { margin: 0; }
.facts b { color: var(--ink); font-size: 1.15rem; font-weight: 700; font-variant-numeric: tabular-nums; margin-right: .2em; }

.pubs li { margin: .6rem 0; }
.pubs .venue { color: var(--muted); font-size: .92rem; margin-left: .2rem; white-space: nowrap; }
.badge {
  display: inline-block; margin-left: .35rem; padding: 0 .5rem; border-radius: 999px;
  background: var(--side); color: var(--blue); font-size: .78rem; font-weight: 600;
  line-height: 1.6; white-space: nowrap; vertical-align: .08em;
}

.projects { display: grid; grid-template-columns: 1fr 1fr; gap: 1.25rem; }
.projects > div { border-left: 3px solid var(--blue); padding: .2rem 0 .2rem 1.1rem; }
.projects b { font-size: 1.2rem; display: block; }
.projects p { margin: .2rem 0; color: var(--muted); }
.projects .links { display: flex; flex-wrap: wrap; gap: .1rem 1rem; list-style: none; padding: 0; margin: .5rem 0 0; }
.projects .links li { margin: 0; white-space: nowrap; }
/* Past projects: the same card shape as current ones, smaller and quieter */
.past-projects {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(14rem, 1fr)); gap: 1rem 1.25rem;
  list-style: none; padding: 0; margin: 0;
}
.past-projects li { margin: 0; border-left: 3px solid var(--side-line); padding: .1rem 0 .1rem 1rem; }
.past-projects a { display: block; font-weight: 600; }
.past-projects span { display: block; color: var(--muted); font-size: .92rem; line-height: 1.45; }

.topics strong { font-weight: 600; }

.people { list-style: none; padding: 0; margin: 0; }
.people li { margin: .5rem 0; }
.people .who { font-weight: 600; }
.people .who a, .timeline .who a { color: var(--ink); }
.people .who a:hover, .timeline .who a:hover { color: var(--blue); }
/* Titles (papers, theses) read as text; blue is kept for actions */
a.title, #students .timeline li > div > a { color: var(--ink); font-weight: 500; }
a.title:hover, #students .timeline li > div > a:hover { color: var(--blue); }

.timeline { list-style: none; padding: 0; margin: 0; position: relative; }
.timeline::before {
  content: ""; position: absolute; left: 4.4rem; top: .5rem; bottom: .5rem; width: 1px; background: var(--line);
}
.timeline li { display: grid; grid-template-columns: 3.4rem 1fr; gap: 2.1rem; padding: .55rem 0; margin: 0; position: relative; }
.timeline li::before {
  content: ""; position: absolute; left: calc(4.4rem - 5px); top: 1.05rem;
  width: 9px; height: 9px; border-radius: 50%; background: var(--paper); border: 2px solid var(--blue);
}
.timeline .year { color: var(--muted); font-weight: 600; font-variant-numeric: tabular-nums; }
/* Repeated years stay in the markup (and for screen readers) but are not drawn */
.timeline li.same-year .year { color: transparent; user-select: none; }
.timeline li + li:not(.same-year) { margin-top: .8rem; }
.timeline .who { font-weight: 600; }
.award { display: block; color: var(--muted); font-size: .92rem; }

.sponsors {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(11rem, 1fr)); gap: .75rem;
  list-style: none; padding: 0; margin: 1.2rem 0;
}
.sponsors li { padding: .85rem 1rem; margin: 0; border: 1px solid var(--side-line); border-radius: 8px; }
.sponsors a { font-weight: 600; display: block; }
.sponsors span { color: var(--muted); font-size: .92rem; }

.service { margin: 0; }
.service dt { font-weight: 600; margin-top: .9rem; }
.service dt:first-child { margin-top: 0; }
.service dd { margin: .1rem 0 0; }

/* Highlight the current section in the sidebar while scrolling (CSS only).
   Each section exposes a view timeline measured against a thin line 25% down the screen;
   its sidebar link is styled while the section crosses that line.
   Browsers without scroll-driven animations simply show no highlight. */
@supports (animation-timeline: view()) and (timeline-scope: none) {
  @media (min-width: 56.01rem) {
    .layout {
      timeline-scope: --s-about, --s-publications, --s-projects, --s-funding, --s-prospective,
                      --s-students, --s-service;
    }
    .content section { view-timeline-axis: block; view-timeline-inset: 25% calc(75% - 1px); }
    #about        { view-timeline-name: --s-about; }
    #publications { view-timeline-name: --s-publications; }
    #projects     { view-timeline-name: --s-projects; }
    #funding      { view-timeline-name: --s-funding; }
    #prospective  { view-timeline-name: --s-prospective; }
    #students     { view-timeline-name: --s-students; }
    #service      { view-timeline-name: --s-service; }

    .side nav a[href="#about"]        { --tl: --s-about; }
    .side nav a[href="#publications"] { --tl: --s-publications; }
    .side nav a[href="#projects"]     { --tl: --s-projects; }
    .side nav a[href="#funding"]      { --tl: --s-funding; }
    .side nav a[href="#prospective"]  { --tl: --s-prospective; }
    .side nav a[href="#students"]     { --tl: --s-students; }
    .side nav a[href="#service"]      { --tl: --s-service; }

    /* The last section is too short to reach the line, so over the last few rem
       of scrolling it becomes current instead (and every other link is reset) */
    .side nav a {
      animation: current-section linear none, not-current linear none;
      animation-timeline: var(--tl), scroll(root);
      animation-range: cover 0% cover 100%, calc(100% - 5rem) 100%;
    }
    .side nav a:hover { animation-name: current-section, none; }
    .side nav a[href="#service"] { animation-name: current-section, current-section; }
  }
}
@keyframes current-section {
  from, to { color: var(--blue); border-left-color: var(--blue); }
}
@keyframes not-current {
  from, to { color: var(--ink); border-left-color: transparent; }
}

/* Shorter screens: tighten the rhythm, then put a small photo beside the name */
@media (min-width: 56.01rem) and (max-height: 62rem) {
  .side { --side-gap: 1.1rem; padding-top: 1.75rem; padding-bottom: 1.75rem; }
  .side h1 { font-size: 1.7rem; }
}
@media (min-width: 56.01rem) and (max-height: 57rem) {
  .side { --side-gap: .85rem; font-size: .9rem; line-height: 1.4; padding-top: 1.25rem; padding-bottom: 1.25rem; }
  .side .roles li { margin-top: .5rem; }
  .side h1 { font-size: 1.5rem; margin-bottom: .5rem; }
  .side nav a { padding-top: .05rem; padding-bottom: .05rem; }
}

/* Tablets and phones: sidebar becomes a header, section links wrap below it */
@media (max-width: 56rem) {
  .layout { grid-template-columns: 1fr; }
  .side {
    position: static; height: auto;
    display: grid; grid-template-columns: 9rem 1fr; gap: 1.25rem 2.5rem; align-items: start;   /* room for the icon rail */
    padding: 1.75rem 1.25rem;
  }
  .side img { grid-row: span 3; max-width: 9rem; }
  .side nav { grid-column: 1 / -1; }
  .side nav ul { display: flex; flex-wrap: wrap; gap: .3rem 1.1rem; }
  .side nav a { padding-left: 0; margin-left: 0; border-left: 0; }
  .content { padding: 2.5rem 1.25rem 4rem; }
  .projects { grid-template-columns: 1fr; }
}
/* Phones: a compact header so the intro shows on the first screen.
   Small photo beside the name, roles below, email only, and the section
   links as a single row that scrolls sideways (fading out at the edge). */
@media (max-width: 30rem) {
  .side { grid-template-columns: 6rem 1fr; gap: .9rem 1rem; padding: 1.25rem 1.25rem 1rem; }
  .side .who { display: contents; }
  .side img { grid-row: auto; max-width: 6rem; min-height: 0; }
  .side h1 { align-self: center; margin: 0; font-size: 1.65rem; }
  .side .roles, .side .contact, .side .profiles, .side nav { grid-column: 1 / -1; }
  .side .roles, .side .contact { padding-left: 1.5em; }   /* no page margin to hang the icons into */
  .side .roles li { margin-top: .45rem; }
  .side .contact a { margin-bottom: 0; }
  .side .contact .postal { display: none; }
  .side .profiles { gap: .1rem .8rem; }
  .side nav { padding-top: .75rem; }
  .side nav ul {
    flex-wrap: nowrap; gap: 1.25rem; overflow-x: auto; scrollbar-width: none;
    padding-right: 2rem; mask-image: linear-gradient(to right, #000 calc(100% - 2rem), transparent);
  }
  .side nav ul::-webkit-scrollbar { display: none; }
  .side nav a { white-space: nowrap; }
  .timeline li { gap: 1.6rem; }
  .timeline::before { left: 4.15rem; }
  .timeline li::before { left: calc(4.15rem - 5px); }
}

@media print {
  :root { color-scheme: light; }
  .layout { display: block; }
  .side { position: static; height: auto; background: none; padding: 0 0 1rem; }
  .side img { max-width: 8rem; }
  .side nav, .copy { display: none; }
  .content { padding: 0; max-width: none; }
  a { color: inherit; }
}

/* ---------- Publications pages (pubs.php) ---------- */

.topbar { background: var(--side); }
.topbar > div {
  max-width: 52rem; margin: 0 auto; padding: .9rem 1.5rem;
  display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: .3rem 1.5rem;
}
.topbar a { color: var(--ink); font-weight: 500; }
.topbar a.home { font-weight: 600; }
.topbar a:hover { color: var(--blue); text-decoration: none; }
.topbar nav { display: flex; gap: 1.25rem; }
.topbar nav a[aria-current="page"] { color: var(--blue); }

.page { max-width: 52rem; margin: 0 auto; padding: 3rem 1.5rem 5rem; }
.page h1 { font-size: 2.2rem; font-weight: 700; line-height: 1.15; margin: 0 0 1.5rem; }
.page h2 { font-size: 1.25rem; margin: 2.5rem 0 .8rem; }

.timeline.publist li, .timeline.talks li { padding: .6rem 0; }
.timeline.publist li[id], .timeline.talks li[id] { scroll-margin-top: 1.5rem; }
.timeline.publist li::before, .timeline.talks li::before { top: 1.1rem; }
.publist b { font-weight: 600; }
.publist .me { font-weight: 600; }
.publist .pdf, .talks .formats a, .pub-links a {
  padding: 0 .4rem; border: 1px solid var(--side-line); border-radius: 4px;
  font-size: .8rem; font-weight: 600; white-space: nowrap;
}
.publist .pdf { margin-left: .3rem; }
.publist .pdf:hover, .talks .formats a:hover, .pub-links a:hover { background: var(--side); text-decoration: none; }
.page blockquote .me { font-weight: 600; }

.bibtex-head { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; margin: 2.5rem 0 .8rem; }
.bibtex-head h2 { margin: 0; }
.copy {
  font: inherit; font-size: .85rem; font-weight: 600; color: var(--blue); cursor: pointer;
  background: var(--paper); border: 1px solid var(--side-line); border-radius: 6px; padding: .2rem .75rem;
}
.copy:hover { background: var(--side); }
.copy:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }

.pub-title { font-size: 2rem; }
.pub-authors { font-size: 1.1rem; color: var(--muted); margin-top: -.6rem; }
.pub-awards { margin: .8rem 0 0; }
.pub-awards .badge { margin: 0 .35rem 0 0; font-size: .85rem; }
.pub-links { display: flex; flex-wrap: wrap; gap: .4rem; margin: .9rem 0 0; }
.pub-links a { font-size: .9rem; padding: .1rem .6rem; }
.pub-links a.primary { background: var(--blue); border-color: var(--blue); color: var(--paper); }
.pub-links a.primary:hover { background: var(--blue); filter: brightness(1.15); }

/* Long author lists: "+N more" expands them (pubs/authors.js) */
.more-toggle { display: none; }
.authors.collapsed .more { display: none; }
.authors.collapsed .more-toggle { display: inline; }
.more-toggle button {
  font: inherit; font-weight: 600; color: var(--blue); cursor: pointer;
  background: none; border: 0; padding: 0;
}
.more-toggle button:hover { text-decoration: underline; }
.more-toggle button:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; border-radius: 2px; }
.page blockquote { margin: 0; padding: 0 0 0 1.1rem; border-left: 3px solid var(--blue); }
/* Paper pages: every block shares one comfortable measure */
.paper > * { max-width: 42rem; }
.page blockquote.abstract { text-align: justify; hyphens: auto; }
.page blockquote.abstract p { margin: 0 0 .75em; }
.page blockquote.abstract p:last-child { margin-bottom: 0; }
.page pre {
  background: var(--side); border-radius: 8px; padding: 1rem 1.2rem;
  font-size: .88rem; line-height: 1.5;
  white-space: pre-wrap; overflow-wrap: anywhere;   /* wrap long BibTeX lines instead of scrolling */
}
.page .copyright-title { font-size: .9rem; }
.page .copyright { font-size: .85rem; color: var(--muted); }
.page .back { margin-top: 3rem; }

/* ---------- Slides page (pres/index.php) ---------- */

.talks .row { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: .3rem 1.25rem; }
.talks .talk { flex: 1 1 22rem; }
.talks .title { display: block; font-weight: 500; }
.talks .venue, .talks .note { display: block; color: var(--muted); font-size: .92rem; }
.talks .formats { display: flex; gap: .35rem; flex-wrap: wrap; }
.icon.play { fill: currentColor; stroke: none; width: .9em; height: .9em; margin: 0 .2em 0 -.1em; vertical-align: -.12em; }
