/* =========================================================================
   Academic homepage — single stylesheet
   Edit the tokens in :root to restyle the whole site.
   ========================================================================= */

:root {
  /* --- Colour ------------------------------------------------------- */
  --ground:        #FFFFFF;   /* page background — plain white   */
  --surface:       #FFFFFF;   /* cards                           */
  --sidebar-bg:    #F6F3EC;   /* the beige left bar              */
  --surface-alt:   #EDE8DD;   /* hover fill inside the sidebar   */
  --ink:           #1B1A18;   /* body text                       */
  --ink-soft:      #4E4A43;   /* secondary text                  */
  --ink-faint:     #7C766A;   /* captions, meta                  */
  --rule:          #E3DED3;   /* hairlines, borders              */
  --accent:        #1D4E6F;   /* links                           */
  --accent-strong: #123852;   /* hover                           */
  --accent-wash:   #E7EFF4;   /* active nav item                 */
  --highlight-bg:  #FCF6DC;   /* the "available" banner          */
  --highlight-br:  #E4D9A3;

  /* --- Type --------------------------------------------------------- */
  --font-display: "Source Serif 4", Georgia, "Times New Roman", serif;
  --font-body:    "Source Serif 4", Georgia, "Times New Roman", serif;
  --font-ui:      "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", sans-serif;

  /* --- Metrics ------------------------------------------------------ */
  --sidebar-w: 280px;
  --measure:   820px;         /* width of the centred text column */
  --radius:    8px;
}

/* Dark theme. Toggled by data-theme="dark" on <html>, set in main.js. */
html[data-theme="dark"] {
  --ground:        #14171A;
  --surface:       #1A1E22;
  --sidebar-bg:    #171B1F;
  --surface-alt:   #222830;
  --ink:           #E8EAEC;
  --ink-soft:      #B2B9BF;
  --ink-faint:     #8A9299;
  --rule:          #2A3138;
  --accent:        #7FC3E8;
  --accent-strong: #A9DCF7;
  --accent-wash:   #1E2A33;
  --highlight-bg:  #2A2716;
  --highlight-br:  #4D4525;
}

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

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

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--ground);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 17.5px;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--accent);
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: color .15s ease, border-color .15s ease;
}
a:hover { color: var(--accent-strong); border-bottom-color: currentColor; }
a:focus-visible,
button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 3px;
}

h1, h2, h3 {
  font-family: var(--font-display);
  color: var(--ink);
  line-height: 1.2;
  margin: 0;
}

p { margin: 0 0 1.1em; }
p:last-child { margin-bottom: 0; }

img { max-width: 100%; display: block; }

/* =========================================================================
   Layout shell
   ========================================================================= */

.layout { display: flex; min-height: 100vh; align-items: stretch; }

/* ---------- Sidebar ---------- */

.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--sidebar-bg);
  border-right: 1px solid var(--rule);
  padding: 20px 20px 24px;
  display: flex;
  flex-direction: column;
  gap: 5px;
  position: sticky;
  top: 0;
  height: 100vh;

  /* Down only, and only when the bar is genuinely taller than the window.
     overflow-x must be stated: a box with overflow-y:auto and overflow-x
     left at "visible" silently computes to "auto", which is where the
     stray horizontal scrollbar came from. */
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: var(--rule) transparent;
}

.sidebar::-webkit-scrollbar { width: 8px; }
.sidebar::-webkit-scrollbar-track { background: transparent; }
.sidebar::-webkit-scrollbar-thumb { background: var(--rule); border-radius: 99px; }

.sidebar__identity { display: flex; flex-direction: column; align-items: center; gap: 20px; text-align: center; }

.sidebar__photo {
  width: 98px;
  height: 98px;
  border-radius: 50%;
  object-fit: cover;
  border: 3px solid var(--ground);
  box-shadow: 0 0 0 1px var(--rule);
}

.sidebar__name {
  font-size: 24px;
  font-weight: 600;
  letter-spacing: -0.01em;
}
.sidebar__name a { color: inherit; border: 0; }
.sidebar__name a:hover { color: var(--accent); }

.sidebar__role {
  font-family: var(--font-ui);
  font-size: 13px;
  line-height: 1.5;
  color: var(--ink-faint);
}

/* ---------- Grouped nav ---------- */

.nav { display: flex; flex-direction: column; gap: 16px; }

.nav__group { display: flex; flex-direction: column; gap: 1px; }

.nav__grouptitle {
  font-family: var(--font-ui);
  font-size: 13.5px;
  font-weight: 600;
  color: var(--ink);
  padding: 0 12px 6px;
  margin-bottom: 2px;
  border-bottom: 1px solid var(--rule);
}

.nav__link {
  font-family: var(--font-ui);
  font-size: 14.5px;
  color: var(--accent);
  padding: 5px 12px;
  border-radius: 6px;
  border: 0;
}
.nav__link:hover { background: var(--surface-alt); color: var(--accent-strong); }

.nav__link[aria-current="page"] {
  background: var(--accent-wash);
  color: var(--accent-strong);
  font-weight: 600;
}

/* ---------- Icon row (the only external-links element) ---------- */

.iconrow {
  margin-top: auto;
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: center;
  padding-top: 16px;
  border-top: 1px solid var(--rule);
}

.iconrow a {
  width: 36px;
  height: 36px;
  border-radius: 6px;
  border: 1px solid var(--rule);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--ink-soft);
  background: var(--ground);
}
.iconrow a:hover { color: var(--accent); border-color: var(--accent); background: var(--accent-wash); }
.iconrow svg { width: 18px; height: 18px; }

/* =========================================================================
   Main column — centred, with air on both sides
   ========================================================================= */

.main {
  flex-grow: 1;
  min-width: 0;
  padding: 64px 56px 104px;
  display: flex;
  justify-content: center;
}

.main__inner { width: 100%; max-width: var(--measure); }

.page-title {
  font-size: 42px;
  font-weight: 600;
  letter-spacing: -0.015em;
  margin-bottom: 8px;
}

.page-sub {
  font-family: var(--font-ui);
  font-size: 14px;
  color: var(--ink-faint);
  margin-bottom: 34px;
}

.section { margin-top: 52px; }

.section__title {
  font-size: 25px;
  font-weight: 600;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--rule);
  margin-bottom: 20px;
}

.lede { font-size: 19.5px; line-height: 1.65; color: var(--ink); }

/* ---------- Availability banner ---------- */

.banner {
  background: var(--highlight-bg);
  border: 1px solid var(--highlight-br);
  border-radius: var(--radius);
  padding: 16px 20px;
  margin: 30px 0;
  font-family: var(--font-ui);
  font-size: 15px;
  line-height: 1.6;
  display: flex;
  gap: 12px;
  align-items: flex-start;
}
.banner svg { width: 19px; height: 19px; flex-shrink: 0; margin-top: 3px; stroke: currentColor; }

/* ---------- News: plain heading, quiet scrolling list ---------- */

.news__scroll {
  max-height: 250px;      /* <- the constraint; raise or lower to taste */
  overflow-y: auto;
  padding-right: 14px;
  scrollbar-width: thin;
  scrollbar-color: var(--rule) transparent;
}
.news__scroll::-webkit-scrollbar { width: 8px; }
.news__scroll::-webkit-scrollbar-thumb { background: var(--rule); border-radius: 99px; }

.news__item {
  display: flex;
  gap: 18px;
  padding: 11px 0;
  border-bottom: 1px solid var(--rule);
  line-height: 1.6;
}
.news__item:last-child { border-bottom: 0; }

.news__date {
  font-family: var(--font-ui);
  font-size: 13.5px;
  color: var(--ink-faint);
  width: 72px;
  flex-shrink: 0;
  padding-top: 3px;
}

.news__more {
  font-family: var(--font-ui);
  font-size: 14px;
  margin-top: 14px;
}

/* ---------- Two-column blocks ---------- */

.cols {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 44px;
}

.stack { display: flex; flex-direction: column; gap: 14px; }

.plainlist { margin: 0; padding-left: 20px; }
.plainlist li { margin-bottom: 6px; }

.edu { display: flex; gap: 14px; }
.edu svg { width: 20px; height: 20px; flex-shrink: 0; margin-top: 5px; color: var(--accent); }
.edu__degree { font-weight: 600; }
.edu__where { font-family: var(--font-ui); font-size: 14px; color: var(--ink-faint); line-height: 1.55; }

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

.pub {
  display: flex;
  gap: 24px;
  padding: 20px 0;
  border-bottom: 1px solid var(--rule);
}
.pub:last-child { border-bottom: 0; }

.pub__venue {
  font-family: var(--font-ui);
  font-size: 13px;
  font-weight: 600;
  color: var(--accent);
  width: 100px;
  flex-shrink: 0;
  padding-top: 4px;
  line-height: 1.45;
}
.pub__year { display: block; font-weight: 400; color: var(--ink-faint); }

.pub__body { flex-grow: 1; min-width: 0; }
.pub__title { font-size: 19.5px; font-weight: 600; line-height: 1.35; margin-bottom: 4px; }
.pub__authors { font-size: 16.5px; color: var(--ink-soft); margin-bottom: 9px; }
.pub__authors .me { font-weight: 600; color: var(--ink); }

.pub__links { display: flex; gap: 7px; flex-wrap: wrap; }

.chip {
  font-family: var(--font-ui);
  font-size: 12.5px;
  font-weight: 600;
  padding: 4px 11px;
  border: 1px solid var(--rule);
  border-radius: 99px;
  color: var(--ink-soft);
  background: var(--ground);
}
.chip:hover { color: var(--accent); border-color: var(--accent); background: var(--accent-wash); }

/* ---------- Projects ---------- */

.project {
  display: flex;
  gap: 28px;
  padding: 28px 0;
  border-bottom: 1px solid var(--rule);
}
.project:last-child { border-bottom: 0; }

.project__thumb {
  width: 230px;
  height: 150px;
  flex-shrink: 0;
  border-radius: var(--radius);
  border: 1px solid var(--rule);
  background: var(--sidebar-bg);
  object-fit: cover;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-ui);
  font-size: 12px;
  color: var(--ink-faint);
}

.project__title { font-size: 21px; font-weight: 600; margin-bottom: 6px; }
.project__meta { font-family: var(--font-ui); font-size: 13px; color: var(--ink-faint); margin-bottom: 8px; }

/* ---------- Definition rows ---------- */

.rows { display: flex; flex-direction: column; }

.row {
  display: flex;
  gap: 26px;
  padding: 15px 0;
  border-bottom: 1px solid var(--rule);
}
.row:last-child { border-bottom: 0; }

.row__key {
  font-family: var(--font-ui);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ink-faint);
  width: 160px;
  flex-shrink: 0;
  padding-top: 4px;
}
.row__val { flex-grow: 1; min-width: 0; }

.year-head {
  font-family: var(--font-ui);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-faint);
  margin: 30px 0 6px;
}
.year-head:first-child { margin-top: 0; }

/* =========================================================================
   Controls
   ========================================================================= */

.theme-toggle {
  position: fixed;
  top: 20px;
  right: 24px;
  z-index: 40;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1px solid var(--rule);
  background: var(--ground);
  color: var(--ink-soft);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.theme-toggle:hover { color: var(--accent); border-color: var(--accent); }
.theme-toggle svg { width: 18px; height: 18px; }
.theme-toggle .icon-moon { display: none; }
html[data-theme="dark"] .theme-toggle .icon-moon { display: block; }
html[data-theme="dark"] .theme-toggle .icon-sun  { display: none; }

.menu-toggle {
  display: none;
  position: fixed;
  top: 14px;
  left: 16px;
  z-index: 60;
  width: 42px;
  height: 42px;
  border-radius: var(--radius);
  border: 1px solid var(--rule);
  background: var(--ground);
  color: var(--ink);
  cursor: pointer;
  align-items: center;
  justify-content: center;
}
.menu-toggle svg { width: 20px; height: 20px; }

.scrim {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.4);
  z-index: 45;
}
.scrim.is-open { display: block; }

/* =========================================================================
   Responsive
   ========================================================================= */

@media (max-width: 1180px) {
  .main { padding: 60px 40px 88px; }
}

@media (max-width: 820px) {
  .menu-toggle { display: flex; }

  .sidebar {
    position: fixed;
    top: 0; left: 0; bottom: 0;
    z-index: 50;
    transform: translateX(-100%);
    transition: transform .25s ease;
    box-shadow: 0 0 40px rgba(0,0,0,.18);
  }
  .sidebar.is-open { transform: translateX(0); }

  .main { padding: 76px 24px 72px; }
  .cols { grid-template-columns: minmax(0, 1fr); gap: 34px; }
  .page-title { font-size: 33px; }
  .project { flex-direction: column; gap: 16px; }
  .project__thumb { width: 100%; height: 170px; }
  .pub { flex-direction: column; gap: 8px; }
  .pub__venue { width: auto; }
  .pub__year { display: inline; }
  .pub__year::before { content: " · "; }
  .row { flex-direction: column; gap: 4px; }
  .row__key { width: auto; }
  .theme-toggle { top: 14px; right: 16px; }
}

@media print {
  .sidebar, .theme-toggle, .menu-toggle { display: none; }
  .main { padding: 0; }
  body { font-size: 11pt; }
  .news__scroll { max-height: none; overflow: visible; padding-right: 0; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; scroll-behavior: auto !important; }
}
