/* ==========================================================================
   Fonts: self-hosted Source Sans 3 and Source Serif 4 (SIL OFL, see
   assets/fonts/OFL-*.txt). Only the subsets a page actually uses are fetched.
   ========================================================================== */

@font-face {
  font-family: "Source Sans 3";
  font-style: normal;
  font-weight: 200 900;
  font-display: swap;
  src: url("../fonts/source-sans-3-normal-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
  font-family: "Source Sans 3";
  font-style: normal;
  font-weight: 200 900;
  font-display: swap;
  src: url("../fonts/source-sans-3-normal-latin-ext.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

@font-face {
  font-family: "Source Sans 3";
  font-style: italic;
  font-weight: 200 900;
  font-display: swap;
  src: url("../fonts/source-sans-3-italic-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
  font-family: "Source Sans 3";
  font-style: italic;
  font-weight: 200 900;
  font-display: swap;
  src: url("../fonts/source-sans-3-italic-latin-ext.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

@font-face {
  font-family: "Source Serif 4";
  font-style: normal;
  font-weight: 200 900;
  font-display: swap;
  src: url("../fonts/source-serif-4-normal-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
  font-family: "Source Serif 4";
  font-style: normal;
  font-weight: 200 900;
  font-display: swap;
  src: url("../fonts/source-serif-4-normal-latin-ext.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

/* ==========================================================================
   Colors: light-dark(light, dark). Every value is a named color from
   https://xkcd.com/color/rgb/ and all text pairs meet WCAG AA (4.5:1).
   The scheme follows the system unless the theme switch sets data-theme.
   ========================================================================== */

:root {
  color-scheme: light dark;

  --bg:        light-dark(#ffffff, #1b2431);   /* white / dark */
  --text:      light-dark(#343837, #d8dcd6);   /* charcoal / light grey */
  --muted:     light-dark(#59656d, #95a3a6);   /* slate grey / cool grey */
  --rule:      light-dark(#d8dcd6, #29465b);   /* light grey / dark grey blue */
  --blue:      light-dark(#056eee, #069af3);   /* cerulean blue / azure */
  --orange:    light-dark(#c65102, #fb7d07);   /* dark orange / pumpkin orange */
  --highlight: light-dark(#ffffe4, rgb(251 125 7 / 0.14));  /* off white / faint pumpkin */
  --shadow:    light-dark(rgb(0 0 0 / 0.12), rgb(0 0 0 / 0.45));
  --tile-ring: light-dark(rgb(0 0 0 / 0.08), rgb(255 255 255 / 0.1));

  --sans: "Source Sans 3", "Source Sans Pro", system-ui, -apple-system, "Segoe UI", sans-serif;
  --serif: "Source Serif 4", "Source Serif Pro", Georgia, serif;
}

:root[data-theme="light"] { color-scheme: light; }
:root[data-theme="dark"]  { color-scheme: dark; }

/* ==========================================================================
   Base
   ========================================================================== */

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 400 1.125rem/1.6 var(--sans);
}

p {
  margin: 0;
}

img {
  max-width: 100%;
  height: auto;
}

sup {
  line-height: 0;
}

a {
  color: var(--blue);
  text-decoration: none;
  border-radius: 2px;
}

a:hover {
  background-color: var(--highlight);
}

a:focus-visible,
[tabindex]:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: 2px;
}

/* Sans, so section headings stand apart from the serif entry and paper titles. */
h2 {
  margin: 2.5rem 0 1rem;
  font: 600 1.4rem/1.25 var(--sans);
}

.content > section:first-child > h2:first-child {
  margin-top: 0;
}

.icon {
  width: 1.1rem;
  height: 1.1rem;
  fill: currentColor;
  flex: none;
}

/* Hidden on screen, still announced by screen readers. */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

/* ==========================================================================
   Layout: nav + content on the left, profile on the right (top on mobile)
   ========================================================================== */

.page {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 13rem;
  grid-template-rows: auto 1fr;
  grid-template-areas:
    "nav     profile"
    "content profile";
  column-gap: clamp(2rem, 5vw, 4rem);
  max-width: 64rem;
  margin: 0 auto;
  padding: 2.5rem 2rem 4rem;
}

.site-nav { grid-area: nav; }
.content  { grid-area: content; }
.profile  { grid-area: profile; }

/* Navigation ------------------------------------------------------------- */

.site-nav {
  margin-bottom: 2rem;
  border-bottom: 1px solid var(--rule);
}

.site-nav ul {
  display: flex;
  flex-wrap: wrap;
  gap: 0 1.75rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.site-nav a {
  display: block;
  margin-bottom: -1px;
  padding: 0.2rem 0 0.5rem;
  border-bottom: 2px solid transparent;
  border-radius: 0;
  color: var(--muted);
  font-size: 1.15rem;
  font-weight: 600;
  font-variant-caps: all-small-caps;
  letter-spacing: 0.06em;
}

.site-nav a:hover {
  background: none;
  color: var(--text);
}

.site-nav a[aria-current="page"] {
  border-bottom-color: var(--orange);
  color: var(--text);
}

/* Theme switch: shown only once the script has set data-theme, so visitors
   without JavaScript simply get the system scheme. Sized to the tab text line. */
.nav-theme {
  display: none;
}

:root[data-theme] .nav-theme {
  display: block;
}

.theme-toggle {
  display: flex;
  align-items: center;
  height: calc(1.15rem * 1.6);
  margin-top: 0.2rem;
  padding: 0 0.15rem;
  border: 0;
  border-radius: 2px;
  background: none;
  color: var(--muted);
  cursor: pointer;
}

.theme-toggle:hover {
  color: var(--text);
}

.theme-toggle:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: 2px;
}

.theme-toggle .icon {
  width: 1rem;
  height: 1rem;
}

/* Moon in light mode, sun in dark mode. */
.when-light,
:root[data-theme="dark"] .when-dark {
  display: contents;
}

.when-dark,
:root[data-theme="dark"] .when-light {
  display: none;
}

/* Profile ---------------------------------------------------------------- */

.profile {
  position: sticky;
  top: 2.5rem;
  align-self: start;
  text-align: center;
}

.profile-photo {
  display: block;
  width: 100%;
  max-width: 11rem;
  margin: 0 auto 1rem;
  border: 2px solid var(--blue);
  border-radius: 0.6rem;
}

.profile-name {
  margin-bottom: 0.5rem;
  font: 400 1.25rem/1.25 var(--serif);
}

.profile-first,
.profile-last {
  display: block;
}

.profile-role {
  color: var(--muted);
  font-size: 1rem;
  line-height: 1.45;
}

.profile-links {
  display: flex;
  justify-content: center;
  gap: 0.25rem;
  margin: 0.6rem 0 0;
  padding: 0;
  list-style: none;
}

.profile-links a {
  display: grid;
  place-items: center;
  width: 2.1rem;
  height: 2.1rem;
  border-radius: 50%;
  color: var(--muted);
}

.profile-links a:hover {
  color: var(--blue);
}

/* ==========================================================================
   Home
   ========================================================================== */

.intro p + p {
  margin-top: 0.6rem;
}

.intro .contact {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 1.25rem;
}

.contact .icon {
  color: var(--muted);
}

/* News: a quiet scroll box. Hairlines top and bottom; soft shadows appear
   only on the edge that has more to scroll to (background-attachment trick). */

.news {
  max-height: min(26rem, 65vh);
  margin: 0;
  padding: 0 0.75rem 0 0;
  overflow-y: auto;
  list-style: none;
  border-block: 1px solid var(--rule);
  scrollbar-width: thin;
  scrollbar-color: var(--rule) transparent;
  background:
    linear-gradient(var(--bg) 30%, transparent) center top / 100% 2.5rem no-repeat local,
    linear-gradient(transparent, var(--bg) 70%) center bottom / 100% 2.5rem no-repeat local,
    radial-gradient(farthest-side at 50% 0, var(--shadow), transparent) center top / 100% 0.75rem no-repeat scroll,
    radial-gradient(farthest-side at 50% 100%, var(--shadow), transparent) center bottom / 100% 0.75rem no-repeat scroll;
  background-color: var(--bg);
}

.news li {
  display: grid;
  grid-template-columns: 4.25rem minmax(0, 1fr);
  align-items: baseline;
  gap: 1rem;
  padding: 0.6rem 0;
}

.news-date {
  color: var(--orange);
  font-size: 0.95rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

/* ==========================================================================
   Research, Education & Experience
   ========================================================================== */

.entries,
.pubs {
  display: grid;
  margin: 0;
  padding: 0;
  list-style: none;
}

.entries { gap: 1.5rem; }
.pubs    { gap: 1.4rem; }

.entry {
  display: grid;
  grid-template-columns: 2.75rem minmax(0, 1fr);
  gap: 1rem;
  align-items: start;
}

/* Brand tiles carry their own background, so they read the same in light
   and dark mode; the ring keeps white tiles defined on a white page. */
.entry-logo {
  width: 2.75rem;
  height: 2.75rem;
  margin-top: 0.15rem;
  border-radius: 22%;
  box-shadow: 0 0 0 1px var(--tile-ring);
  object-fit: cover;
}

.entry-head {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: baseline;
  gap: 0 1rem;
}

.entry-name {
  font: 600 1.15rem/1.35 var(--serif);
}

.entry-period {
  color: var(--muted);
  font-size: 1rem;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.entry-detail {
  font-size: 1rem;
}

.entry-role + .entry-detail {
  margin-top: 0.15rem;
}

.label {
  font-style: italic;
}

/* Advisor links stay quiet so the blue is left for the thesis links. */
.advisors a {
  color: inherit;
  text-decoration-line: underline;
  text-decoration-thickness: 1px;
  text-decoration-color: var(--muted);
  text-underline-offset: 0.2em;
}

.thesis {
  font-weight: 600;
}

.thesis.is-ongoing {
  color: var(--orange);
  font-style: italic;
}

/* Publications ----------------------------------------------------------- */

.pub-title {
  font: 600 1.125rem/1.35 var(--serif);
}

.pub-authors {
  margin-top: 0.2rem;
  color: var(--muted);
  font-size: 1rem;
  line-height: 1.5;
}

.pub-authors .me {
  color: var(--text);
  font-weight: 600;
}

.pub-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0 0.6rem;
  margin-top: 0.15rem;
  font-size: 1rem;
}

.pub-venue {
  font-weight: 600;
}

.pub-venue.is-pending {
  color: var(--orange);
  font-style: italic;
}

.pub-link {
  font-weight: 600;
  font-variant-caps: all-small-caps;
  letter-spacing: 0.04em;
}

.pub-link::before { content: "["; }
.pub-link::after  { content: "]"; }

.pub-link::before,
.pub-link::after {
  color: var(--muted);
  font-weight: 400;
}

/* Other activities ------------------------------------------------------- */

.activities {
  margin: 0;
  padding-left: 1.25rem;
  list-style: square;
}

.activities li + li {
  margin-top: 0.4rem;
}

.activities li::marker {
  color: var(--muted);
}

/* ==========================================================================
   Small screens: profile becomes a compact header above the nav
   ========================================================================== */

@media (max-width: 46rem) {
  body {
    font-size: 1.0625rem;
  }

  .page {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: none;
    grid-template-areas:
      "profile"
      "nav"
      "content";
    padding: 1.5rem 1.25rem 3rem;
  }

  .profile {
    position: static;
    display: flex;
    align-items: center;
    gap: 1.25rem;
    margin-bottom: 1.25rem;
    text-align: left;
  }

  .profile-photo {
    flex: none;
    width: 6rem;
    margin: 0;
  }

  .profile-links {
    justify-content: flex-start;
    margin-left: -0.5rem;
  }

  .site-nav {
    margin-bottom: 1.5rem;
  }

  .site-nav ul {
    gap: 0 1.25rem;
  }

  .news {
    max-height: 60vh;
  }

  .news li {
    grid-template-columns: minmax(0, 1fr);
    gap: 0;
  }
}
