/* ==========================================================================
   Site stylesheet
   Colors are set once as variables below (light theme first, then dark).
   To change the accent color or backgrounds, edit the variables only.
   ========================================================================== */

@font-face {
  font-family: "Inter";
  src: url("../fonts/inter.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

:root {
  --bg: #f3f5f7;            /* page background */
  --card: #ffffff;          /* card background */
  --text: #1d2125;
  --muted: #5d6670;         /* secondary text */
  --border: #e1e5ea;
  --accent: #0f766e;        /* links, highlights (darker teal for contrast on white) */
  --accent-soft: rgba(15, 118, 110, 0.1);
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.05), 0 2px 8px rgba(16, 24, 40, 0.05);
  --code-bg: #f1f3f5;
  --radius: 12px;
  --width: 840px;           /* max width of the page content */
  --header-bg: rgba(255, 255, 255, 0.8);   /* top bar, slightly see-through */
  /* Optional background drawing (see body.bg-network below). */
  --bg-pattern: url("../img/network-light.svg");
  color-scheme: light;
}

/* Dark theme: used when chosen with the toggle ... */
:root[data-theme="dark"] {
  --bg: #111315;
  --card: #1a1d20;
  --text: #e6e8ea;
  --muted: #9aa3ab;
  --border: #2b3035;
  --accent: #5fd0c5;
  --accent-soft: rgba(95, 208, 197, 0.12);
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 4px 12px rgba(0, 0, 0, 0.25);
  --code-bg: #121417;
  --header-bg: rgba(26, 29, 32, 0.8);
  --bg-pattern: url("../img/network-dark.svg");
  color-scheme: dark;
}

/* ... or when the computer is set to dark mode and no choice was made. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #111315;
    --card: #1a1d20;
    --text: #e6e8ea;
    --muted: #9aa3ab;
    --border: #2b3035;
    --accent: #5fd0c5;
    --accent-soft: rgba(95, 208, 197, 0.12);
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 4px 12px rgba(0, 0, 0, 0.25);
    --code-bg: #121417;
    --header-bg: rgba(26, 29, 32, 0.8);
    --bg-pattern: url("../img/network-dark.svg");
    color-scheme: dark;
  }
}

/* ---------- Base ---------- */

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

html {
  -webkit-text-size-adjust: 100%;
  scroll-padding-top: 4.5rem;   /* links to a spot on a page land below the pinned top bar */
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 17px;
  line-height: 1.65;
  overflow-wrap: break-word;
}

/* Optional background (off by default): a faint network drawing pinned to the bottom of
   the window, so the cards scroll over it. Turned on with "background_network: true" in
   _config.yml, which adds the "bg-network" class to <body>. The drawing is flipped upside
   down, so its dense edge sits at the very bottom; it thins out and fades going up (the
   fade is part of the drawing itself, made by _scripts/make-network.py). */
body.bg-network::before {
  content: "";
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 900px;
  z-index: -1;
  pointer-events: none;
  background: var(--bg-pattern) center top / 2400px 900px no-repeat;
  transform: scaleY(-1);
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
a:focus-visible, button:focus-visible, summary:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}

h1, h2, h3 { line-height: 1.25; font-weight: 650; }
h2 { font-size: 1.3rem; margin: 0 0 0.75rem; }
h3 { font-size: 1.05rem; }

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

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

.skip-link {
  position: absolute;
  left: -999px;
}
.skip-link:focus {
  left: 1rem; top: 1rem; z-index: 10;
  background: var(--card); padding: 0.5rem 1rem; border-radius: 8px;
}

/* ---------- Layout ---------- */

.container {
  max-width: var(--width);
  margin: 0 auto;
  padding: 1.5rem 1rem 2rem;
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.5rem;
  margin-bottom: 1.25rem;
}

.page-title {
  font-size: 1.8rem;
  margin: 0.5rem 0 1.25rem;
}

.prose > :first-child { margin-top: 0; }
.prose > :last-child { margin-bottom: 0; }
.prose p { margin: 0 0 1em; }

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

/* The top bar stays pinned while scrolling; the page shows faintly through it. */
.site-header {
  position: sticky;
  top: 0;
  z-index: 5;
  background: var(--header-bg);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}

.nav {
  max-width: var(--width);
  margin: 0 auto;
  padding: 0.75rem 1rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.25rem 1rem;
}

.nav-name {
  color: var(--text);
  font-weight: 650;
  font-size: 1.05rem;
}

.nav-links {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.25rem 1.1rem;
}

.nav-links a { color: var(--muted); }
.nav-links a:hover,
.nav-links a[aria-current="page"] { color: var(--accent); text-decoration: none; }
.nav-links a[aria-current="page"] { font-weight: 600; }
/* Reserve the width of the bold version of each menu item (an invisible bold copy of the
   label, from data-label), so the items don't shift when the current page turns bold. */
.nav-links a[data-label] { display: inline-flex; flex-direction: column; align-items: center; }
.nav-links a[data-label]::after {
  content: attr(data-label);
  font-weight: 600;
  height: 0;
  overflow: hidden;
  visibility: hidden;
  pointer-events: none;
  user-select: none;
}

.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}
.theme-toggle:hover { color: var(--accent); border-color: var(--accent); }
.theme-toggle .icon { width: 1.1rem; height: 1.1rem; }

/* Show the moon in light mode and the sun in dark mode. */
.icon-sun { display: none; }
:root[data-theme="dark"] .icon-sun { display: inline-flex; }
:root[data-theme="dark"] .icon-moon { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .icon-sun { display: inline-flex; }
  :root:not([data-theme="light"]) .icon-moon { display: none; }
}
.icon-sun, .icon-moon { line-height: 0; }

.icon { width: 1.1em; height: 1.1em; flex-shrink: 0; }

/* ---------- About page ---------- */

.profile {
  display: flex;
  align-items: center;
  gap: 1.5rem;
}

.profile-photo {
  width: 150px;
  height: 150px;
  object-fit: cover;
  object-position: 50% 30%;
  border-radius: 50%;
  border: 3px solid var(--accent-soft);
  flex-shrink: 0;
}

.profile-name { font-size: 1.7rem; margin: 0; }
.profile-position { color: var(--muted); margin: 0.2rem 0 0.9rem; }

.profile-links {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.profile-links a {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.3rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--text);
  font-size: 0.9rem;
}
.profile-links a:hover {
  border-color: var(--accent);
  color: var(--accent);
  text-decoration: none;
}

/* Lists in the Professional training and Awards cards:
   title on the left, years on the right, extra lines below. */
.entries { list-style: none; margin: 0; padding: 0; font-size: 0.95rem; line-height: 1.5; }
.entries li + li { margin-top: 0.75rem; padding-top: 0.75rem; border-top: 1px solid var(--border); }
.entries p { margin: 0; }
.entry-head { display: flex; justify-content: space-between; align-items: baseline; gap: 0 1rem; }
.entry-title { font-weight: 600; }
.entry-years { color: var(--accent); font-weight: 550; white-space: nowrap; }
.entry-detail { color: var(--muted); font-size: 0.9rem; }
.btn.btn-small { margin-left: 0.4rem; font-size: 0.72rem; padding: 0 0.45rem; vertical-align: 0.1em; }

/* ---------- Research page ---------- */

/* Topic cards sit inside the main Research card. They are flat (no shadow) with a
   gray fill, so they read as part of that card. The whole topic card is a link. */
.topics-heading {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin: 2.75rem 0 0.75rem;   /* space above "TOPICS" */
}
.topic-card {
  display: flex;
  gap: 1.25rem;
  align-items: flex-start;
  padding: 1rem 1.1rem;
  margin-top: 0.75rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.topic-card:hover { text-decoration: none; border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }
.topic-thumb {
  width: 180px;
  aspect-ratio: 4 / 3;
  object-fit: contain;          /* show the whole figure, never crop */
  flex-shrink: 0;
  border-radius: 8px;
  background: #ffffff;           /* figures have white backgrounds, also in dark mode */
  border: 1px solid var(--border);
}
.topic-title { font-size: 1.1rem; margin: 0 0 0.4rem; color: var(--accent); }
.topic-summary { margin: 0 0 0.5rem; }
.topic-more { color: var(--accent); font-size: 0.9rem; font-weight: 550; }
.topic-card:hover .topic-more { text-decoration: underline; }

/* A topic's own page. */
.back-link { margin: 0.25rem 0 0.75rem; font-size: 0.95rem; }
.topic-page-title { font-size: 1.6rem; margin: 0 0 1rem; }
.topic-figure { margin: 0 0 1.25rem; text-align: center; }
.topic-figure img {
  max-height: 480px;
  border-radius: 8px;
  background: #ffffff;
  border: 1px solid var(--border);
}
.topic-figure figcaption { color: var(--muted); font-size: 0.85rem; margin-top: 0.4rem; }

/* Highlighted paper on a topic page: a gray inner card holding the publication
   details (same as on the Publications page) plus extra text and a figure. */
.highlight {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1rem 1.1rem;
  margin-bottom: 0.75rem;
}
.highlight .pub { background: none; border: 0; box-shadow: none; padding: 0; margin: 0; }
.highlight .pub p { margin: 0; }
.highlight .pub .pub-links { margin-top: 0.5rem; }
/* Below the paper details: a divider, then the figure (with caption) and your text. */
.highlight-body {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}
.highlight-figure { margin: 0 0 0.9rem; text-align: center; }
.highlight-figure img {
  max-height: 320px;
  border-radius: 8px;
  background: #ffffff;
  border: 1px solid var(--border);
}
.highlight-figure a img { cursor: zoom-in; }   /* clicking opens the full-size image */
.highlight-figure figcaption {
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.45;
  margin-top: 0.45rem;
  text-align: left;
}
.highlight .highlight-text { margin: 0; }   /* ".highlight" makes this win over the general paragraph spacing */

.related-heading {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin: 2.5rem 0 0.6rem;   /* space above "HIGHLIGHTED PAPER" and "RELATED PAPERS" */
}
.related { margin: 0; padding-left: 1.1rem; font-size: 0.95rem; }
.related li { margin-bottom: 0.35rem; }

/* ---------- Gallery page ---------- */

.gallery-intro { margin-bottom: 1.25rem; }

/* Two tiles per row; one per row on phones (see "Phones" below). */
.gallery {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.9rem;
}
.gallery-item {
  margin: 0;
  padding: 0.6rem 0.6rem 0.75rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.gallery-item:hover { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }
.gallery-item > a { display: block; }
.gallery-item img {
  display: block;
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;              /* fill the tile; clicking shows the whole picture */
  border-radius: 6px;
  cursor: zoom-in;
}
.gallery-item figcaption {
  margin-top: 0.55rem;
  font-size: 0.88rem;
  line-height: 1.45;
  color: var(--muted);
}
.gallery-title { display: block; color: var(--text); font-weight: 600; margin-bottom: 0.1rem; }
/* Paper links in a row, with a dot between them (flex ignores stray spaces, so the dot sits evenly). */
.gallery-papers { display: flex; flex-wrap: wrap; gap: 0 0.4rem; margin-top: 0.3rem; font-size: 0.82rem; }

/* ---------- Image viewer (lightbox, see _includes/lightbox.html) ---------- */

/* Fills the window; the picture and caption sit in the middle on a dark backdrop. */
.lightbox {
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  max-width: none;
  max-height: none;
  margin: 0;
  padding: 3rem 1.5rem 1.5rem;
  border: 0;
  background: rgba(10, 12, 14, 0.78);   /* darkens the page behind; raise 0.78 for darker */
  -webkit-backdrop-filter: blur(3px);
  backdrop-filter: blur(3px);           /* slight blur so the page behind doesn't distract */
  color: #e6e8ea;
}
.lightbox[open] { display: flex; align-items: center; justify-content: center; }
.lightbox::backdrop { background: transparent; }
.lightbox figure {
  margin: 0;
  max-width: 100%;
  max-height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
}
.lightbox img {
  min-height: 0;                /* lets the picture shrink so the caption still fits */
  max-width: 100%;
  object-fit: contain;
  border-radius: 6px;
  box-shadow: 0 12px 48px rgba(0, 0, 0, 0.6);   /* soft shadow lifting the picture off the page */
}
.lightbox figcaption {
  max-width: 46rem;
  margin-top: 0.9rem;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.8);   /* keeps the caption readable over the page behind */
  font-size: 0.9rem;
  line-height: 1.45;
  color: #b8c0c7;
  text-align: center;
}
.lightbox figcaption .gallery-title { color: #ffffff; }
.lightbox figcaption .gallery-papers { justify-content: center; }
.lightbox figcaption a { color: #5fd0c5; }
.lightbox-close {
  position: fixed;
  top: 0.75rem;
  right: 1rem;
  width: 2.5rem;
  height: 2.5rem;
  padding: 0;
  border: 0;
  border-radius: 999px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.15);
  color: #ffffff;
  cursor: pointer;
}
.lightbox-close .icon { width: 1.4rem; height: 1.4rem; }
.lightbox-close:hover { background: rgba(255, 255, 255, 0.25); }
.lightbox-close:focus:not(:focus-visible) { outline: none; }
/* The page behind doesn't scroll while the viewer is open. */
html:has(.lightbox[open]) { overflow: hidden; }

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

.pub-year { margin-top: 2rem; }

/* Year on the right, above a thin line. */
.year-heading {
  text-align: right;
  color: var(--accent);
  font-size: 1.6rem;
  font-weight: 600;
  margin: 0 0 1rem;
  padding-bottom: 0.4rem;
  border-bottom: 1px solid var(--border);
}

/* Each paper is its own card. */
.pub {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.1rem 1.25rem;
  margin-bottom: 0.9rem;
}
/* Highlight a paper when linked to from the Research page. */
.pub:target { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }

.pub-title { font-size: 1rem; font-weight: 600; margin: 0 0 0.25rem; }
.pub-authors, .pub-venue { margin: 0; font-size: 0.92rem; }
.pub-authors { color: var(--muted); }
.pub-authors strong { color: var(--text); font-weight: 650; }

/* Small label such as "Editors' Pick", after the journal name. */
.badge {
  display: inline-block;
  margin-left: 0.4rem;
  padding: 0 0.5rem;
  font-size: 0.75rem;
  font-weight: 600;
  line-height: 1.6;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  vertical-align: 0.1em;
}

.pub-links {
  position: relative;   /* keeps the hidden checkboxes next to their buttons */
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 0.5rem;
}
.pub-links:empty { display: none; }

.btn {
  display: inline-block;
  padding: 0.1rem 0.6rem;
  font-size: 0.8rem;
  font-weight: 550;
  border: 1px solid var(--accent);
  border-radius: 6px;
  color: var(--accent);
}
.btn:hover { background: var(--accent-soft); text-decoration: none; }

/* BibTeX button. The real checkbox is hidden; its label is the button. */
.toggle {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
  pointer-events: none;
}
label.btn { cursor: pointer; user-select: none; }
.toggle:checked + .btn { background: var(--accent); color: var(--card); }
.toggle:focus-visible + .btn { outline: 2px solid var(--accent); outline-offset: 2px; }

/* The BibTeX panel stays hidden until its button is switched on. */
.pub-panel { display: none; margin-top: 0.6rem; font-size: 0.9rem; }
.pub:has(.toggle-bibtex:checked) .pub-bibtex { display: block; }
.pub-bibtex pre {
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.75rem;
  overflow-x: auto;
  font-size: 0.8rem;
  line-height: 1.5;
  margin: 0;
}

/* ---------- Math (KaTeX, on pages with "math: true") ---------- */

/* Long displayed equations scroll sideways on narrow screens instead of overflowing. */
.katex-display { overflow-x: auto; overflow-y: hidden; padding: 0.15rem 0; }

/* ---------- Footer ---------- */

.site-footer {
  text-align: center;
  color: var(--muted);
  font-size: 0.8rem;
  padding: 0 1rem 2rem;
}
.site-footer p { margin: 0; }

.not-found { text-align: center; }

/* ---------- Phones ---------- */

@media (max-width: 600px) {
  body { font-size: 16px; }
  .card { padding: 1.15rem; }
  .profile { flex-direction: column; text-align: center; }
  .profile-links { justify-content: center; }
  .research-card { padding: 1rem 0.85rem; }   /* less padding so the inner cards keep their width */
  .topic-card { flex-direction: column; padding: 0.9rem; }
  .topic-thumb { width: 100%; max-height: 220px; }
  .gallery { grid-template-columns: 1fr; }
  .nav { justify-content: center; padding: 0.4rem 1rem; row-gap: 0; }
  .nav-links { justify-content: center; }   /* on small phones the menu wraps onto a second line */
  html { scroll-padding-top: 7.5rem; }   /* the top bar is two or three lines on phones */
}
