:root {
  --bg: #fbfaf7;
  --surface: #ffffff;
  --text: #1f2328;
  --muted: #5f6670;
  --border: #e4e1da;
  --accent: #1d4e89;
  --accent-soft: #e8eef7;
  --todo: #b45309;
  --serif: "Source Serif 4", Georgia, "Times New Roman", serif;
  --sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --maxw: 820px;
}

/* Dark palette: follows the system setting unless the visitor picked a theme with the toggle */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #15171a;
    --surface: #1d2024;
    --text: #e6e6e3;
    --muted: #9aa0a8;
    --border: #2d3137;
    --accent: #8db4e8;
    --accent-soft: #22303f;
    --todo: #f0a85a;
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg: #15171a;
  --surface: #1d2024;
  --text: #e6e6e3;
  --muted: #9aa0a8;
  --border: #2d3137;
  --accent: #8db4e8;
  --accent-soft: #22303f;
  --todo: #f0a85a;
  color-scheme: dark;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html { scroll-behavior: smooth; scroll-padding-top: 4.5rem; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.65;
}

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

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

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

.brand {
  font-family: var(--serif);
  font-weight: 600;
  font-size: 1.1rem;
  color: var(--text);
}

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

.nav ul { align-items: center; }
.nav ul a { color: var(--muted); font-size: 0.92rem; font-weight: 500; }
.nav ul a:hover { color: var(--accent); text-decoration: none; }

.theme-toggle {
  display: grid;
  place-items: center;
  width: 2rem;
  height: 2rem;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: var(--surface);
  color: var(--muted);
  cursor: pointer;
}
.theme-toggle:hover { color: var(--accent); border-color: var(--accent); }
.theme-toggle svg { width: 1rem; height: 1rem; }
/* Show the moon in light mode, the sun in dark mode */
.theme-toggle .sun { display: none; }
:root[data-theme="dark"] .theme-toggle .sun { display: block; }
:root[data-theme="dark"] .theme-toggle .moon { display: none; }

/* ---------- Layout ---------- */
main {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 2.5rem 1.25rem 3rem;
}

section { margin-bottom: 3.25rem; }

main p, .card p, .timeline div {
  text-align: justify;
  hyphens: auto;
}

h1, h2, h3 { font-family: var(--serif); font-weight: 600; line-height: 1.25; }

h2 {
  font-size: 1.5rem;
  margin: 0 0 1.1rem;
  padding-bottom: 0.4rem;
  border-bottom: 1px solid var(--border);
}

h3.sub {
  font-family: var(--sans);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin: 1.5rem 0 0.75rem;
}

/* ---------- Hero ---------- */
.hero {
  display: flex;
  gap: 2rem;
  align-items: flex-start;
}

.photo {
  flex: 0 0 170px;
  width: 170px;
  height: 170px;
  border-radius: 50%;
  object-fit: cover;
  border: 1px solid var(--border);
}

.photo.placeholder {
  display: grid;
  place-items: center;
  background: var(--accent-soft);
  color: var(--accent);
  font-family: var(--serif);
  font-size: 3rem;
  font-weight: 600;
}

.hero h1 { font-size: 2.1rem; margin: 0 0 0.2rem; }
.role { color: var(--muted); margin: 0 0 1rem; font-weight: 500; }

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

.links a {
  display: inline-block;
  padding: 0.3rem 0.8rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  font-size: 0.88rem;
  font-weight: 500;
}

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

/* Placeholder text you still need to edit — remove class="todo" once done */
.todo { color: var(--todo); }

/* ---------- News ---------- */
.news { list-style: none; padding: 0; margin: 0; }
.news li {
  display: grid;
  grid-template-columns: 5.5rem 1fr;
  gap: 1rem;
  padding: 0.35rem 0;
}
.news time { color: var(--muted); font-size: 0.9rem; font-variant-numeric: tabular-nums; padding-top: 0.1rem; }

/* ---------- Research cards ---------- */
.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1.1rem 1.2rem;
}
.card h3 { margin: 0 0 0.4rem; font-size: 1.08rem; }
.card p { margin: 0; color: var(--muted); font-size: 0.93rem; }

/* ---------- Publications ---------- */
.pubs { list-style: none; padding: 0; margin: 0; }
.pubs li {
  padding: 0.9rem 0 0.9rem 1rem;
  border-left: 3px solid var(--accent-soft);
  margin-bottom: 0.6rem;
}
.pubs li:hover { border-left-color: var(--accent); }
.pubs p { margin: 0; }
.pub-title { font-family: var(--serif); font-weight: 600; font-size: 1.05rem; }
.pub-authors, .pub-venue { color: var(--muted); font-size: 0.93rem; }
.pub-authors strong { color: var(--text); }
.pub-links { margin-top: 0.35rem !important; display: flex; gap: 0.75rem; font-size: 0.88rem; font-weight: 500; }
.pub-links a::before { content: "["; color: var(--muted); }
.pub-links a::after { content: "]"; color: var(--muted); }

/* ---------- Talks / CV timeline ---------- */
.timeline { list-style: none; padding: 0; margin: 0; }
.timeline li {
  display: grid;
  grid-template-columns: 7rem 1fr;
  gap: 1rem;
  padding: 0.55rem 0;
  border-bottom: 1px dashed var(--border);
}
.timeline li:last-child { border-bottom: none; }
.timeline time { color: var(--muted); font-size: 0.9rem; font-variant-numeric: tabular-nums; padding-top: 0.1rem; }
.meta { color: var(--muted); font-size: 0.92rem; }

.cv-download a {
  display: inline-block;
  padding: 0.45rem 1rem;
  border-radius: 8px;
  background: var(--accent);
  color: var(--bg);
  font-weight: 500;
  font-size: 0.92rem;
}
.cv-download a:hover { text-decoration: none; opacity: 0.9; }

/* ---------- Footer ---------- */
.site-footer {
  border-top: 1px solid var(--border);
  text-align: center;
  color: var(--muted);
  font-size: 0.85rem;
  padding: 1.5rem 1.25rem;
}

/* ---------- Mobile ---------- */
@media (max-width: 640px) {
  .hero { flex-direction: column; align-items: center; text-align: center; }
  .links { justify-content: center; }
  .photo { flex-basis: 130px; width: 130px; height: 130px; }
  .hero h1 { font-size: 1.75rem; }
  .hero .role { text-align: center; }
  .news li, .timeline li { grid-template-columns: 1fr; gap: 0; }
  .nav { justify-content: center; }
}
