/* ==========================================================================
   Personal research site — stylesheet
   Edit the variables in :root to restyle the whole site.
   ========================================================================== */

/* --- Design tokens ------------------------------------------------------ */

:root {
  --bg: #fbfbf9;
  --surface: #ffffff;
  --surface-alt: #f4f4f1;
  --text: #1b1b19;
  --muted: #6d6d66;
  --faint: #93938b;
  --border: #e5e4df;
  --accent: #2f5aa8;
  --accent-hover: #21437f;
  --accent-soft: #eaf0fa;

  --font-serif: Charter, "Bitstream Charter", "Sitka Text", Cambria, Georgia,
    "Times New Roman", serif;
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto,
    "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas,
    "Liberation Mono", monospace;

  --measure: 44rem;   /* reading column width  */
  --wide: 66rem;      /* wide column (grids)   */
  --radius: 8px;
  --gap: 1.25rem;

  --shadow: 0 1px 2px rgba(0, 0, 0, 0.04), 0 4px 12px rgba(0, 0, 0, 0.04);
}

:root[data-theme="dark"] {
  --bg: #121212;
  --surface: #191918;
  --surface-alt: #202020;
  --text: #e9e8e3;
  --muted: #9d9c93;
  --faint: #78776f;
  --border: #2b2b28;
  --accent: #8fb3f0;
  --accent-hover: #b0cbf7;
  --accent-soft: #1c2536;

  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 4px 14px rgba(0, 0, 0, 0.25);
}

/* Follow the OS when the visitor has not chosen a theme. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #121212;
    --surface: #191918;
    --surface-alt: #202020;
    --text: #e9e8e3;
    --muted: #9d9c93;
    --faint: #78776f;
    --border: #2b2b28;
    --accent: #8fb3f0;
    --accent-hover: #b0cbf7;
    --accent-soft: #1c2536;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 4px 14px rgba(0, 0, 0, 0.25);
  }
}

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

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

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

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-serif);
  font-size: 1.0625rem;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

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

a {
  color: var(--accent);
  text-decoration: none;
  text-underline-offset: 0.18em;
  text-decoration-thickness: 1px;
}

a:hover {
  color: var(--accent-hover);
  text-decoration: underline;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 3px;
}

h1, h2, h3, h4 {
  line-height: 1.25;
  font-weight: 600;
  letter-spacing: -0.012em;
  margin: 0 0 0.5em;
}

h1 { font-size: 2rem; }
h2 { font-size: 1.4rem; }
h3 { font-size: 1.125rem; }

p { margin: 0 0 1.1em; }

ul, ol { margin: 0 0 1.1em; padding-left: 1.3em; }
li { margin-bottom: 0.35em; }

hr {
  border: 0;
  border-top: 1px solid var(--border);
  margin: 3rem 0;
}

code {
  font-family: var(--font-mono);
  font-size: 0.875em;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.1em 0.35em;
}

pre {
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  line-height: 1.6;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  overflow-x: auto;
  margin: 0 0 1.1em;
}

pre code {
  background: none;
  border: 0;
  padding: 0;
  font-size: inherit;
}

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  background: var(--accent);
  color: #fff;
  padding: 0.6rem 1rem;
  z-index: 100;
  border-radius: 0 0 var(--radius) 0;
}

.skip-link:focus {
  left: 0;
}

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

.wrap {
  width: 100%;
  max-width: var(--measure);
  margin: 0 auto;
  padding: 0 1.5rem;
}

.wrap--wide {
  max-width: var(--wide);
}

main {
  padding-bottom: 4rem;
}

section {
  margin-bottom: 3.25rem;
}

/* Section heading with a hairline rule */
.section-title {
  font-family: var(--font-sans);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  padding-bottom: 0.6rem;
  margin-bottom: 1.4rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
}

.section-title a {
  font-weight: 500;
  letter-spacing: 0.04em;
  text-transform: none;
}

/* --- Header / navigation ------------------------------------------------ */

.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(160%) blur(10px);
  -webkit-backdrop-filter: saturate(160%) blur(10px);
  border-bottom: 1px solid var(--border);
}

@supports not (backdrop-filter: blur(10px)) {
  .site-header { background: var(--bg); }
}

.nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  height: 3.75rem;
}

.nav__brand {
  font-family: var(--font-sans);
  font-weight: 650;
  font-size: 0.95rem;
  letter-spacing: -0.01em;
  color: var(--text);
  white-space: nowrap;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.nav__brand:hover {
  color: var(--accent);
  text-decoration: none;
}

.nav__links {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-family: var(--font-sans);
  font-size: 0.875rem;
}

.nav__links a {
  color: var(--muted);
  padding: 0.35rem 0.6rem;
  border-radius: 6px;
}

.nav__links a:hover {
  color: var(--text);
  background: var(--surface-alt);
  text-decoration: none;
}

.nav__links a[aria-current="page"] {
  color: var(--text);
  font-weight: 600;
}

.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  margin-left: 0.25rem;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--muted);
  cursor: pointer;
  flex: none;
}

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

/* Phones: tighten the bar, and let it wrap rather than overflow the page. */
@media (max-width: 30rem) {
  .nav {
    height: auto;
    min-height: 3.25rem;
    flex-wrap: wrap;
    padding: 0.5rem 0;
    gap: 0.25rem 0.5rem;
  }
  .nav__brand { font-size: 0.875rem; }
  .nav__links { font-size: 0.8125rem; gap: 0.1rem; margin-left: auto; }
  .nav__links a { padding: 0.3rem 0.45rem; }
  .theme-toggle { width: 1.85rem; height: 1.85rem; margin-left: 0.15rem; }
}

.theme-toggle svg { width: 15px; height: 15px; }
.theme-toggle .icon-sun { display: none; }
:root[data-theme="dark"] .theme-toggle .icon-sun { display: block; }
:root[data-theme="dark"] .theme-toggle .icon-moon { display: none; }

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-toggle .icon-sun { display: block; }
  :root:not([data-theme="light"]) .theme-toggle .icon-moon { display: none; }
}

/* --- Hero / intro ------------------------------------------------------- */

.hero {
  display: grid;
  grid-template-columns: 8.5rem 1fr;
  gap: 2rem;
  align-items: start;
  padding: 3.5rem 0 0;
  margin-bottom: 3.25rem;
}

.hero__photo {
  width: 8.5rem;
  height: 8.5rem;
  border-radius: 50%;
  object-fit: cover;
  border: 1px solid var(--border);
  background: var(--surface-alt);
}

.hero__name {
  font-size: 2.1rem;
  margin-bottom: 0.15em;
}

.hero__role {
  font-family: var(--font-sans);
  font-size: 0.95rem;
  color: var(--muted);
  margin-bottom: 1.1em;
}

.hero__bio p:last-child { margin-bottom: 0; }

@media (max-width: 40rem) {
  .hero {
    grid-template-columns: 1fr;
    gap: 1.25rem;
    padding-top: 2.5rem;
  }
  .hero__photo { width: 6.5rem; height: 6.5rem; }
  .hero__name { font-size: 1.75rem; }
}

/* --- Inline link row ---------------------------------------------------- */

.links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  font-family: var(--font-sans);
  font-size: 0.8125rem;
  margin-top: 1.4rem;
  padding: 0;
  list-style: none;
}

.links li { margin: 0; }

.links a {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.3rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
}

.links a:hover {
  color: var(--accent);
  border-color: var(--accent);
  background: var(--accent-soft);
  text-decoration: none;
}

/* --- News --------------------------------------------------------------- */

.news {
  list-style: none;
  padding: 0;
  margin: 0;
  font-size: 0.975rem;
  max-height: 16rem;
  overflow-y: auto;
}

.news li {
  display: grid;
  grid-template-columns: 6rem 1fr;
  gap: 1rem;
  padding: 0.55rem 0;
  border-bottom: 1px dashed var(--border);
  margin: 0;
}

.news li:last-child { border-bottom: 0; }

.news time {
  font-family: var(--font-sans);
  font-size: 0.8125rem;
  color: var(--faint);
  padding-top: 0.2em;
  white-space: nowrap;
}

@media (max-width: 34rem) {
  .news li { grid-template-columns: 1fr; gap: 0.15rem; }
}

/* --- Publication list --------------------------------------------------- */

.pub-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.pub {
  padding: 1rem 0;
  border-bottom: 1px solid var(--border);
  margin: 0;
}

.pub:last-child { border-bottom: 0; }

.pub__title {
  font-size: 1.0625rem;
  font-weight: 600;
  margin: 0 0 0.2em;
  line-height: 1.4;
}

.pub__authors {
  font-size: 0.9375rem;
  color: var(--muted);
  margin: 0 0 0.25em;
}

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

.pub__venue {
  font-family: var(--font-sans);
  font-size: 0.8125rem;
  color: var(--faint);
  margin: 0;
}

.pub__venue em { color: var(--muted); font-style: italic; }

.pub__links {
  margin-top: 0.45rem;
  font-family: var(--font-sans);
  font-size: 0.8125rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.9rem;
}

/* --- Project cards ------------------------------------------------------ */

.project-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(17rem, 1fr));
  gap: 1.5rem;
  padding: 0;
  margin: 0;
  list-style: none;
}

.card {
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  margin: 0;
  transition: border-color 0.18s ease, transform 0.18s ease,
    box-shadow 0.18s ease;
}

.card:hover {
  border-color: var(--faint);
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}

.card__media {
  aspect-ratio: 16 / 9;
  width: 100%;
  object-fit: cover;
  background: var(--surface-alt);
  border-bottom: 1px solid var(--border);
}

.card__body {
  padding: 1rem 1.1rem 1.15rem;
  display: flex;
  flex-direction: column;
  flex: 1;
}

.card__meta {
  font-family: var(--font-sans);
  font-size: 0.75rem;
  letter-spacing: 0.02em;
  color: var(--faint);
  margin-bottom: 0.4rem;
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.card__title {
  font-size: 1.0625rem;
  margin: 0 0 0.35rem;
  line-height: 1.35;
}

.card__title a { color: var(--text); }
.card__title a:hover { color: var(--accent); text-decoration: none; }

.card__summary {
  font-size: 0.9375rem;
  color: var(--muted);
  margin: 0 0 0.9rem;
  flex: 1;
}

.card__tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  list-style: none;
  padding: 0;
  margin: 0;
}

.tag {
  font-family: var(--font-sans);
  font-size: 0.6875rem;
  letter-spacing: 0.02em;
  color: var(--muted);
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.15rem 0.55rem;
  margin: 0;
  white-space: nowrap;
}

/* Status pill */
.status {
  font-family: var(--font-sans);
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 0.1rem 0.45rem;
  border-radius: 4px;
  background: var(--accent-soft);
  color: var(--accent);
  white-space: nowrap;
}

.status--wip {
  background: color-mix(in srgb, #d98324 18%, transparent);
  color: #a35f10;
}

:root[data-theme="dark"] .status--wip { color: #e8a860; }

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .status--wip { color: #e8a860; }
}

/* --- Filter bar --------------------------------------------------------- */

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-bottom: 1.75rem;
}

.filter {
  font-family: var(--font-sans);
  font-size: 0.8125rem;
  padding: 0.3rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  cursor: pointer;
  transition: all 0.15s ease;
}

.filter:hover {
  color: var(--text);
  border-color: var(--faint);
}

.filter[aria-pressed="true"] {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

:root[data-theme="dark"] .filter[aria-pressed="true"] { color: #10161f; }

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .filter[aria-pressed="true"] {
    color: #10161f;
  }
}

/* --- Project detail page ------------------------------------------------ */

.page-head {
  padding: 3rem 0 0;
  margin-bottom: 2.5rem;
}

.back-link {
  font-family: var(--font-sans);
  font-size: 0.8125rem;
  color: var(--muted);
  display: inline-block;
  margin-bottom: 1.25rem;
}

.page-head h1 { font-size: 2rem; }

.page-head__lede {
  font-size: 1.1rem;
  color: var(--muted);
  margin: 0;
}

.detail__authors {
  font-size: 1rem;
  color: var(--muted);
  margin: 0.75rem 0 0.35rem;
}

.detail__venue {
  font-family: var(--font-sans);
  font-size: 0.875rem;
  color: var(--faint);
  margin: 0;
}

/* Link row on a project page needs room before the first section heading. */
.detail__links {
  margin: 1rem 0 2.75rem;
  gap: 1.1rem;
  font-size: 0.875rem;
}

.figure {
  margin: 2rem 0;
}

.figure img {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

.figure figcaption,
.caption {
  font-family: var(--font-sans);
  font-size: 0.8125rem;
  line-height: 1.55;
  color: var(--muted);
  margin-top: 0.6rem;
}

.figure figcaption b,
.caption b { color: var(--text); font-weight: 600; }

.table-scroll {
  overflow-x: auto;
  margin: 1.5rem 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

table {
  border-collapse: collapse;
  width: 100%;
  font-family: var(--font-sans);
  font-size: 0.875rem;
}

th, td {
  text-align: left;
  padding: 0.6rem 0.9rem;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

th {
  background: var(--surface-alt);
  font-weight: 600;
  font-size: 0.8125rem;
}

tbody tr:last-child td { border-bottom: 0; }
td:not(:first-child), th:not(:first-child) { text-align: right; }

.bibtex-wrap { position: relative; }

.copy-btn {
  position: absolute;
  top: 0.55rem;
  right: 0.55rem;
  font-family: var(--font-sans);
  font-size: 0.75rem;
  padding: 0.25rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: 5px;
  background: var(--surface);
  color: var(--muted);
  cursor: pointer;
}

.copy-btn:hover { color: var(--text); border-color: var(--faint); }

/* --- Utility ------------------------------------------------------------ */

.empty {
  color: var(--muted);
  font-style: italic;
  padding: 2rem 0;
  text-align: center;
}

.lede {
  font-size: 1.1rem;
  color: var(--muted);
  margin-bottom: 2rem;
}

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

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

.site-footer {
  border-top: 1px solid var(--border);
  padding: 2rem 0 3rem;
  font-family: var(--font-sans);
  font-size: 0.8125rem;
  color: var(--faint);
}

.site-footer .wrap {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1.5rem;
  justify-content: space-between;
}

.site-footer a { color: var(--muted); }

/* --- Print -------------------------------------------------------------- */

@media print {
  .site-header, .site-footer, .theme-toggle, .filters, .copy-btn {
    display: none !important;
  }
  body { background: #fff; color: #000; font-size: 11pt; }
  .wrap { max-width: none; padding: 0; }
  a { color: #000; text-decoration: underline; }
}
