/* ---------- Fonts (self-hosted) ---------- */
@font-face {
  font-family: "Source Serif 4";
  src: url("fonts/source-serif-4-latin-opsz-normal.woff2") format("woff2-variations");
  font-weight: 200 900; font-style: normal; font-display: swap;
}
@font-face {
  font-family: "Source Sans 3";
  src: url("fonts/source-sans-3-latin-wght-normal.woff2") format("woff2-variations");
  font-weight: 200 900; font-style: normal; font-display: swap;
}
@font-face {
  font-family: "Source Sans 3";
  src: url("fonts/source-sans-3-latin-wght-italic.woff2") format("woff2-variations");
  font-weight: 200 900; font-style: italic; font-display: swap;
}

/* ---------- Tokens ---------- */
:root {
  --bg: #ffffff;
  --surface: #f5f6f8;
  --text: #22262d;
  --heading: #12151a;
  --muted: #5f6672;
  --rule: #e3e6ea;
  --accent: #7b2141;        /* Bordeaux */
  --accent-hover: #5e1831;
  --accent-soft: #f7ecf0;
  --serif: "Source Serif 4", Georgia, "Times New Roman", serif;
  --sans: "Source Sans 3", -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --wrap: 68rem;
  --radius: 10px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #15171b; --surface: #1d2025; --text: #dfe2e6; --heading: #f3f4f6; --muted: #9ba2ac;
    --rule: #2d3138; --accent: #d99aae; --accent-hover: #ecbccb; --accent-soft: #2a1e24;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #15171b; --surface: #1d2025; --text: #dfe2e6; --heading: #f3f4f6; --muted: #9ba2ac;
  --rule: #2d3138; --accent: #d99aae; --accent-hover: #ecbccb; --accent-soft: #2a1e24;
  color-scheme: dark;
}

/* ---------- Page-to-page transitions (supported browsers only) ---------- */
@view-transition { navigation: auto; }
.site-header { view-transition-name: site-header; }
::view-transition-old(root) { animation: 160ms ease-out both vt-out; }
::view-transition-new(root) { animation: 220ms ease-out both vt-in; }
@keyframes vt-out { to { opacity: 0; } }
@keyframes vt-in { from { opacity: 0; transform: translateY(6px); } }
@media (prefers-reduced-motion: reduce) {
  ::view-transition-old(root), ::view-transition-new(root) { animation: none; }
  * { transition: none !important; }
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font-family: var(--sans); font-size: 1.125rem; line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  display: flex; flex-direction: column; min-height: 100vh;
}
main { flex: 1; }
h1, h2, h3 { font-family: var(--serif); color: var(--heading); font-weight: 600; line-height: 1.2; margin: 0; }
p { margin: 0 0 1em; }
a { color: var(--accent); text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: .18em; }
a:hover { color: var(--accent-hover); text-decoration-thickness: 2px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 4px; }
.wrap { max-width: var(--wrap); margin: 0 auto; padding: 0 clamp(1.25rem, 4vw, 2.5rem); }
.skip { position: absolute; left: -999px; top: .5rem; background: var(--bg); padding: .5rem 1rem; z-index: 100; }
.skip:focus { left: .5rem; }

/* ---------- Header ---------- */
.site-header {
  position: sticky; top: 0; z-index: 50;
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: saturate(1.4) blur(10px); -webkit-backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--rule);
}
.site-header .wrap { display: flex; align-items: center; justify-content: space-between; height: 4.25rem; }
.brand { font-family: var(--serif); font-size: 1.3rem; font-weight: 600; color: var(--heading); text-decoration: none; letter-spacing: -.01em; }
.brand:hover { color: var(--heading); text-decoration: none; }
.nav { display: flex; align-items: center; gap: .25rem; }
.nav ul { display: flex; gap: .25rem; list-style: none; margin: 0; padding: 0; }
.nav a {
  display: block; padding: .45rem .8rem; border-radius: 6px;
  color: var(--muted); text-decoration: none; font-size: 1rem; font-weight: 500;
  transition: color .15s, background-color .15s;
}
.nav a:hover { color: var(--heading); background: var(--surface); }
.nav a[aria-current="page"] { color: var(--accent); background: var(--accent-soft); }
.icon-btn {
  appearance: none; background: transparent; border: 1px solid var(--rule); color: var(--text);
  width: 2.4rem; height: 2.4rem; border-radius: 8px; cursor: pointer;
  display: inline-grid; place-items: center; margin-left: .5rem; transition: border-color .15s, background-color .15s;
}
.icon-btn:hover { background: var(--surface); }
.icon-btn svg { width: 1.15rem; height: 1.15rem; }
.menu-btn { display: none; }
.theme-btn .moon { display: none; }
:root[data-theme="dark"] .theme-btn .sun { display: none; }
:root[data-theme="dark"] .theme-btn .moon { display: block; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-btn .sun { display: none; }
  :root:not([data-theme="light"]) .theme-btn .moon { display: block; }
}

@media (max-width: 860px) {
  .menu-btn { display: inline-grid; }
  .nav ul {
    position: absolute; top: 4.25rem; left: 0; right: 0; flex-direction: column; gap: 0;
    background: var(--bg); border-bottom: 1px solid var(--rule); padding: .5rem clamp(1.25rem, 4vw, 2.5rem) 1rem;
    display: none;
  }
  .nav.open ul { display: flex; }
  .nav a { padding: .75rem .5rem; font-size: 1.1rem; }
}

/* ---------- Page heading ---------- */
.page-head { padding: clamp(3rem, 7vw, 5rem) 0 2rem; }
.page-head h1 { font-size: clamp(2.25rem, 5vw, 3.25rem); letter-spacing: -.02em; margin-bottom: .75rem; }
.page-head p { color: var(--muted); font-size: 1.2rem; max-width: 40rem; margin: 0; }

/* ---------- Home ---------- */
.intro {
  display: grid; grid-template-columns: minmax(0, 17rem) minmax(0, 1fr); gap: clamp(2rem, 5vw, 4.5rem);
  align-items: start; padding: clamp(3rem, 8vw, 6rem) 0 clamp(3rem, 6vw, 4.5rem);
}
.portrait { width: 100%; height: auto; aspect-ratio: 4 / 5; object-fit: cover; border-radius: var(--radius); background: var(--surface); }
.intro h1 { font-size: clamp(2.6rem, 6vw, 4rem); letter-spacing: -.025em; margin-bottom: .4rem; }
.role { font-size: 1.25rem; color: var(--muted); margin-bottom: 1.75rem; }
.role a { color: var(--heading); font-weight: 200; text-decoration-color: color-mix(in srgb, var(--accent) 55%, transparent); text-underline-offset: .2em; }
.role a:hover { color: var(--accent); text-decoration-color: var(--accent); }
.bio { max-width: 38rem; }
.bio p:first-child { font-size: 1.25rem; color: var(--heading); }
.profiles { display: flex; flex-wrap: wrap; gap: .6rem; margin-top: 1.75rem; padding: 0; list-style: none; }
.btn {
  display: inline-flex; align-items: center; gap: .5rem;
  padding: .55rem 1.05rem; border-radius: 8px; border: 1px solid var(--rule);
  color: var(--heading); background: var(--bg); text-decoration: none; font-size: 1rem; font-weight: 500;
  font-family: var(--sans); cursor: pointer; line-height: 1.3;
  transition: border-color .15s, background-color .15s, color .15s;
}
.btn:hover { border-color: var(--accent); color: var(--accent); text-decoration: none; }
.btn svg { width: 1rem; height: 1rem; flex: none; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--bg); }
.btn.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: var(--bg); }
:root[data-theme="dark"] .btn.primary { background: var(--accent-soft); color: var(--accent); }
:root[data-theme="dark"] .btn.primary:hover { border-color: var(--accent-hover); color: var(--accent-hover); }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .btn.primary { background: var(--accent-soft); color: var(--accent); }
  :root:not([data-theme="light"]) .btn.primary:hover { border-color: var(--accent-hover); color: var(--accent-hover); }
}
@media (max-width: 720px) {
  .intro { grid-template-columns: 1fr; }
  .portrait { max-width: 13rem; }
}

.home-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: clamp(2rem, 5vw, 4.5rem);
  padding: clamp(2.5rem, 5vw, 3.5rem) 0 clamp(3rem, 6vw, 5rem); border-top: 1px solid var(--rule);
}
@media (max-width: 820px) { .home-grid { grid-template-columns: 1fr; } }
.section-title { font-size: 1.5rem; margin-bottom: 1.25rem; }

.topics { list-style: none; margin: 0; padding: 0; }
.topics li { padding: .9rem 0; border-bottom: 1px solid var(--rule); }
.topics li:first-child { padding-top: 0; }
.topics strong { display: block; color: var(--heading); font-weight: 600; }
.topics span { display: block; color: var(--muted); font-size: 1rem; line-height: 1.5; margin-top: .1rem; }

.news { list-style: none; margin: 0; padding: 0; }
.news li { display: grid; grid-template-columns: 6.5rem 1fr; gap: 1rem; padding: .9rem 0; border-bottom: 1px solid var(--rule); }
.news li:first-child { padding-top: 0; }
.news time { color: var(--muted); font-size: 1rem; font-variant-numeric: tabular-nums; padding-top: .1rem; }
@media (max-width: 520px) { .news li { grid-template-columns: 1fr; gap: .1rem; } }

/* ---------- Entries: publications and software ---------- */
.year-group { display: grid; grid-template-columns: 7rem minmax(0, 1fr); gap: 2rem; padding: 2rem 0; border-top: 1px solid var(--rule); }
.year-group > h2 { font-size: 1.5rem; color: var(--muted); font-weight: 500; }
@media (max-width: 720px) { .year-group { grid-template-columns: 1fr; gap: 1rem; } }

.entry {
  border: 1px solid var(--rule); border-radius: var(--radius); padding: 1.5rem 1.6rem;
  transition: border-color .2s; background: var(--bg);
}
.entry + .entry { margin-top: 1rem; }
.entry:hover { border-color: color-mix(in srgb, var(--accent) 45%, var(--rule)); }
.tag {
  display: inline-block; font-size: .85rem; font-weight: 600; color: var(--accent);
  background: var(--accent-soft); padding: .15rem .6rem; border-radius: 999px; margin-bottom: .75rem;
}
.entry h3 { font-size: 1.35rem; line-height: 1.35; margin-bottom: .6rem; }
.entry h3 a { color: var(--heading); text-decoration: none; }
.entry h3 a:hover { color: var(--accent); text-decoration: underline; }
.authors { margin-bottom: .2rem; }
.authors .me { font-weight: 600; color: var(--heading); }
.venue { color: var(--muted); font-size: 1rem; font-style: italic; }
.entry-actions { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: 1.1rem; }
.entry-actions .btn { padding: .4rem .85rem; font-size: .95rem; }

.code {
  position: relative; margin-top: 1rem; background: var(--surface); border-radius: 8px;
  border: 1px solid var(--rule);
}
.code pre { margin: 0; padding: 1rem 5.5rem 1rem 1.1rem; overflow-x: auto; font-family: var(--mono); font-size: .88rem; line-height: 1.55; color: var(--text); }
.code .copy { position: absolute; top: .55rem; right: .55rem; padding: .3rem .7rem; font-size: .88rem; }
.code[hidden] { display: none; }

.facts { display: flex; flex-wrap: wrap; gap: .5rem 1.5rem; margin: .25rem 0 0; padding: 0; list-style: none; color: var(--muted); font-size: 1rem; }
.facts b { color: var(--heading); font-weight: 600; }

.page-body { padding-bottom: clamp(3rem, 6vw, 5rem); }
.lead-note { color: var(--muted); font-size: 1rem; margin-top: 2rem; }

/* ---------- Scientific communication ---------- */
.filters { display: flex; flex-wrap: wrap; gap: .5rem; margin-bottom: 1.5rem; }
.filter .count { color: var(--muted); font-variant-numeric: tabular-nums; }
.filter[aria-pressed="true"] { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.filter[aria-pressed="true"] .count { color: inherit; }
.comm-list .year-group:first-child { border-top: 1px solid var(--rule); }
.comm-list .entry[data-type] .tag { margin-bottom: .6rem; }
.empty { border: 1px dashed var(--rule); border-radius: var(--radius); padding: 2.5rem 1.5rem; text-align: center; color: var(--muted); }

.viewer {
  width: min(1100px, 94vw); height: 90vh; max-height: 90vh; padding: 0;
  border: 1px solid var(--rule); border-radius: 12px; background: var(--bg); color: var(--text); overflow: hidden;
}
.viewer[open] { display: flex; flex-direction: column; }
.viewer::backdrop { background: rgb(10 12 16 / .6); }
.viewer-bar { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: .75rem 1rem; border-bottom: 1px solid var(--rule); }
.viewer-bar h2 { font-size: 1.05rem; font-family: var(--sans); font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.viewer-actions { display: flex; gap: .5rem; flex: none; }
.viewer-actions .btn { padding: .35rem .8rem; font-size: .95rem; }
.viewer iframe { flex: 1; width: 100%; border: 0; background: var(--surface); }

/* ---------- Footer ---------- */
.site-footer { border-top: 1px solid var(--rule); padding: 2rem 0; color: var(--muted); font-size: .95rem; }
.site-footer .wrap { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 1rem; }
.site-footer ul { display: flex; gap: 1.25rem; list-style: none; margin: 0; padding: 0; }
.site-footer a { color: var(--muted); text-decoration: none; }
.site-footer a:hover { color: var(--accent); text-decoration: underline; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: 1.5rem; transform: translate(-50%, .75rem); opacity: 0;
  background: var(--heading); color: var(--bg); padding: .55rem 1.1rem; border-radius: 8px; font-size: .95rem;
  transition: opacity .2s, transform .2s; pointer-events: none; z-index: 100;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
