/* Quiet, narrow-column look: Inter, slate text, soft grey surfaces, one muted accent. */
:root {
  --theme: #b5473f;          /* accent: links, active menu item */
  --text: #47505a;           /* body text */
  --text-strong: #15191e;    /* names, titles */
  --text-light: #8b939c;     /* dates, notes */
  --bg: #fff;
  --surface: #f5f6f7;        /* cards, boxes, pills */
  --surface-hover: #eceef0;
  --divider: #eceef0;
  --button-bg: #23292f;
  --button-text: #fff;
  --code-bg: #f5f6f7;
  --shadow: 0 1px 2px rgba(16, 24, 32, 0.04), 0 8px 24px rgba(16, 24, 32, 0.06);
}
html[data-theme="dark"] {
  --theme: #e5867d;
  --text: #b7bec6;
  --text-strong: #f2f4f6;
  --text-light: #7d858e;
  --bg: #121417;
  --surface: #1b1e22;
  --surface-hover: #23272c;
  --divider: #262a2f;
  --button-bg: #f2f4f6;
  --button-text: #121417;
  --code-bg: #1b1e22;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 24px rgba(0, 0, 0, 0.3);
}

* { box-sizing: border-box; }
/* always keep room for the scrollbar (Safari ignores scrollbar-gutter), so short pages
   like news don't shift the menu sideways compared with long ones */
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; overflow-y: scroll; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Inter", system-ui, -apple-system, sans-serif;
  font-weight: 400;
  font-size: 16px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  transition: background 0.2s, color 0.2s;
}
a { color: var(--theme); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }
strong, b { font-weight: 600; color: var(--text-strong); }
p { margin: 0 0 14px; }

.container { max-width: 680px; margin: 0 auto; padding: 0 24px; }
.sr-only {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}

/* ---------- Nav ---------- */
.navbar {
  position: sticky; top: 0; z-index: 10;
  background: color-mix(in srgb, var(--bg) 85%, transparent);
  backdrop-filter: saturate(1.5) blur(10px);
  -webkit-backdrop-filter: saturate(1.5) blur(10px);
}
.navbar .container {
  display: flex; align-items: center; gap: 8px;
  min-height: 64px;
}
.nav-links { display: flex; gap: 2px; margin-left: auto; }
.navbar a.nav-link, .navbar button {
  color: var(--text-light); background: none; border: 0; cursor: pointer;
  font: inherit; font-size: 0.875rem; padding: 6px 10px; border-radius: 999px;
  white-space: nowrap; transition: color 0.15s, background 0.15s;
}
.navbar a.nav-link:hover, .navbar button:hover {
  color: var(--text-strong); background: var(--surface); text-decoration: none;
}
/* same weight as the other links, so switching page does not change their widths */
.navbar a.nav-link.active { color: var(--text-strong); background: var(--surface); }
#theme-toggle { font-size: 1rem; line-height: 1; padding: 8px; }
#theme-toggle .ti-moon-filled { display: none; }
html[data-theme="dark"] #theme-toggle .ti-sun-filled { display: none; }
html[data-theme="dark"] #theme-toggle .ti-moon-filled { display: inline; }

/* ---------- Header ---------- */
main { padding-top: 40px; }
.post-header { margin: 0 0 28px; }
.post-title {
  font-size: 1.75rem; font-weight: 600; letter-spacing: -0.02em;
  color: var(--text-strong); margin: 0; line-height: 1.25;
}
.post-title .bold { font-weight: 600; }
.desc { color: var(--text-light); margin: 6px 0 0; }

/* ---------- Topics strip ---------- */
.topics {
  overflow: hidden; margin: 0 0 36px; padding: 10px 0;
  -webkit-mask-image: linear-gradient(90deg, transparent, #000 12%, #000 88%, transparent);
  mask-image: linear-gradient(90deg, transparent, #000 12%, #000 88%, transparent);
}
.topics-track {
  display: flex; width: max-content;
  animation: topics-slide 40s linear infinite;
}
.topics:hover .topics-track { animation-play-state: paused; }
.topics-track span {
  font-size: 0.875rem; color: var(--text-light); white-space: nowrap;
  padding: 4px 14px; margin-right: 8px;
  background: var(--surface); border-radius: 999px;
}
@keyframes topics-slide { to { transform: translateX(-50%); } }

/* ---------- About ---------- */
.profile {
  float: right; width: 148px;
  margin: 4px 0 16px 28px;
  cursor: pointer;
}
/* a playful little wobble when the photo is clicked */
.profile.nudge { animation: nudge 0.45s ease; }
@keyframes nudge {
  30% { transform: rotate(-6deg) scale(0.97); }
  65% { transform: rotate(3deg); }
}
.profile img {
  width: 100%; aspect-ratio: 1; object-fit: cover; display: block;
  border-radius: 50%;
  box-shadow: var(--shadow);
}
.clearfix::after { content: ""; display: table; clear: both; }

h2 {
  font-size: 1rem; font-weight: 600; margin: 56px 0 14px;
  color: var(--text-strong); letter-spacing: -0.01em;
}
h2 a { color: inherit; }

/* ---------- Date lists (news, writing, talks) ---------- */
.news table, .news-all table, .post-list { width: 100%; border-collapse: collapse; }
.news th, .news-all th, .post-list th {
  width: 120px; text-align: left; vertical-align: top;
  font-weight: 400; font-size: 0.875rem; color: var(--text-light);
  padding: 8px 16px 8px 0; white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.news td, .news-all td, .post-list td { padding: 8px 0; vertical-align: top; }
.muted { color: var(--text-light); }
.more { display: inline-block; margin-top: 10px; font-size: 0.875rem; font-weight: 500; }
/* second part of the writing box, styled like the newsletter header above it */
.subhead { margin: 18px 0 0; padding-top: 18px; border-top: 1px solid var(--divider); }
.subhead .newsletter-title { color: var(--text-strong); }

/* ---------- Publications ---------- */
.bibliography { list-style: none; padding: 0; margin: 0; }
.bibliography > li { padding: 4px 0 16px; }
.pub { display: grid; grid-template-columns: 180px 1fr; gap: 20px; align-items: start; }
.pub .preview {
  width: 100%; border-radius: 12px; display: block;
  background: #fff; padding: 8px; border: 1px solid var(--divider);
  cursor: zoom-in;
}
.pub .title { font-weight: 600; color: var(--text-strong); line-height: 1.4; }
.pub .author { margin-top: 4px; }
.pub .author em { font-style: normal; }
.pub .periodical { color: var(--text-light); font-size: 0.9rem; }
.links { margin-top: 10px; display: flex; flex-wrap: wrap; gap: 6px; }
.links a, .links button {
  font: inherit; font-size: 0.8rem; font-weight: 500;
  color: var(--text); background: var(--surface); cursor: pointer;
  border: 0; border-radius: 999px; padding: 3px 12px;
}
.links a:hover, .links button:hover {
  background: var(--surface-hover); color: var(--text-strong); text-decoration: none;
}
.hidden { display: none; }
.abstract-text, .bibtex-text {
  margin-top: 10px; padding: 12px 14px; border-radius: 12px;
  font-size: 0.9rem; background: var(--surface);
}
.bibtex-text {
  font-family: ui-monospace, Menlo, monospace;
  white-space: pre-wrap; overflow-x: auto;
}

/* ---------- Writing ---------- */
#writing { scroll-margin-top: 80px; }
.newsletter {
  background: var(--surface); border-radius: 16px; padding: 20px 22px;
}
.newsletter-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; }
.newsletter-title { font-size: 1.05rem; font-weight: 600; }
.newsletter-brand { display: flex; align-items: center; gap: 16px; margin-bottom: 10px; }
.newsletter-logo { display: block; width: 76px; height: 76px; border-radius: 16px; background: #fff; border: 1.5px solid #f2c4c4; box-shadow: var(--shadow); }
.newsletter-desc { margin: 2px 0 10px; color: var(--text-light); }
.badge {
  display: inline-block; vertical-align: middle;
  font-size: 0.7rem; font-weight: 500; letter-spacing: 0.02em;
  color: #2f7d4f; background: rgba(47, 125, 79, 0.1); border-radius: 999px;
  padding: 1px 8px; margin-left: 4px;
}
html[data-theme="dark"] .badge { color: #7fd1a0; background: rgba(127, 209, 160, 0.12); }
.subscribe {
  flex-shrink: 0; background: var(--button-bg); color: var(--button-text);
  font-size: 0.875rem; font-weight: 500; border-radius: 999px; padding: 8px 18px;
  transition: transform 0.15s, opacity 0.15s;
}
.subscribe:hover { text-decoration: none; opacity: 0.9; transform: translateY(-1px); }
.newsletter .post-list th { width: 120px; }

/* ---------- Projects ---------- */
.projects-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px; margin-top: 8px;
}
.card {
  background: var(--surface); border-radius: 16px; overflow: hidden;
  color: var(--text); transition: transform 0.2s, box-shadow 0.2s;
}
.card:hover { transform: translateY(-3px); box-shadow: var(--shadow); text-decoration: none; }
.card img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; display: block; }
.card .card-body { padding: 14px 18px 18px; }
.card h3 { margin: 0 0 4px; font-weight: 600; font-size: 1rem; color: var(--text-strong); }
.card .award { color: var(--theme); font-size: 0.8rem; font-weight: 500; margin: 2px 0 8px; line-height: 1.5; }
.card p { margin: 0; color: var(--text); font-size: 0.9rem; }

/* ---------- Talks ---------- */
.talks { table-layout: fixed; }
.talks th { width: 120px; }
.talks td { padding-bottom: 16px; }
.talk-title { font-weight: 600; color: var(--text-strong); }

/* cv: roles held in one place, then what I did there */
.cv p { margin: 8px 0 0; }
.cv .note { font-style: italic; }
.cv ul { margin: 8px 0 0; padding-left: 18px; }
.cv li { margin-bottom: 4px; }
.cv li::marker { color: var(--theme); }
.cv ul.roles { list-style: none; padding: 0; margin-top: 6px; }
.cv ul.roles li { margin-bottom: 0; }
.cv ul.roles .muted { white-space: nowrap; }
.cv .duration { display: block; font-size: 0.8rem; margin-top: 2px; }
.tag {
  font-size: 0.75rem; font-weight: 500;
  color: var(--text); background: var(--surface);
  border-radius: 999px; padding: 1px 9px; margin-left: 4px; white-space: nowrap;
}
.tag:hover { background: var(--surface-hover); color: var(--text-strong); text-decoration: none; }

/* ---------- Social ---------- */
.social { margin-top: 56px; }
.contact-icons { font-size: 1.35rem; display: flex; flex-wrap: wrap; gap: 6px; }
.contact-icons a {
  color: var(--text); background: var(--surface);
  width: 42px; height: 42px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  transition: background 0.15s, color 0.15s, transform 0.15s;
}
.contact-icons a:hover { color: var(--text-strong); background: var(--surface-hover); transform: translateY(-2px); text-decoration: none; }
.contact-note { color: var(--text-light); margin-top: 10px; font-size: 0.875rem; }

/* ---------- Footer ---------- */
footer {
  color: var(--text-light); font-size: 0.8rem;
  margin-top: 72px; padding: 24px 0 40px;
}
footer a { color: inherit; text-decoration: underline; text-underline-offset: 2px; }

/* ---------- Image zoom ---------- */
.zoom-overlay {
  position: fixed; inset: 0; background: rgba(10, 12, 14, 0.8);
  display: flex; align-items: center; justify-content: center;
  z-index: 100; cursor: zoom-out;
}
.zoom-overlay img { max-width: 90vw; max-height: 90vh; border-radius: 12px; background: #fff; }

/* ---------- Phones ---------- */
@media (max-width: 576px) {
  .container { padding: 0 20px; }
  /* menu: one row like on desktop */
  .navbar .container { gap: 0; min-height: 56px; padding: 0 6px; }
  .nav-links { margin-left: 0; margin-right: auto; gap: 0; overflow-x: auto; scrollbar-width: none; }
  .nav-links::-webkit-scrollbar { display: none; }
  .navbar a.nav-link { font-size: 0.8rem; padding: 5px 7px; }
  #theme-toggle { padding: 6px; }
  main { padding-top: 24px; }
  .post-title { font-size: 1.6rem; }
  .topics { margin-bottom: 24px; }
  /* photo sits small beside the intro instead of on its own line */
  .profile { width: 84px; margin: 2px 0 8px 16px; }
  .pub { grid-template-columns: 1fr; gap: 12px; }
  .news th, .news-all th, .post-list th, .talks th {
    width: auto; display: block; padding: 10px 0 0;
  }
  .news td, .news-all td, .post-list td { display: block; padding: 0 0 8px; }
  .talks td { padding-bottom: 14px; }
  .cv .duration { display: inline; margin-left: 3px; }
  .cv .duration::before { content: "· "; }
  .newsletter { padding: 18px; }
  .newsletter-head { flex-direction: column; gap: 4px; }
  .subscribe { margin-bottom: 8px; }
  h2 { margin-top: 44px; }
}

/* smaller phones: tighter menu so all six links still fit on one row */
@media (max-width: 400px) {
  .navbar a.nav-link { font-size: 0.78rem; padding: 5px 5px; }
  #theme-toggle { padding: 4px; }
}

/* ---------- "Data point" cursor ---------- */
html.has-custom-cursor, html.has-custom-cursor * { cursor: none !important; }
#cursor-dot {
  position: fixed; top: 0; left: 0; z-index: 1000;
  pointer-events: none; opacity: 0;
}
#cursor-dot::after {
  content: ""; position: absolute;
  width: 10px; height: 10px; left: -5px; top: -5px;
  border-radius: 50%; background: var(--theme);
  border: 1.5px solid var(--theme);
  transition: width 0.18s, height 0.18s, left 0.18s, top 0.18s, background 0.18s;
}
#cursor-dot.visible { opacity: 1; }
#cursor-dot.hovering::after {
  width: 30px; height: 30px; left: -15px; top: -15px;
  background: color-mix(in srgb, var(--theme) 20%, transparent);
}
#cursor-dot.pressed::after { width: 8px; height: 8px; left: -4px; top: -4px; }

@media (prefers-reduced-motion: reduce) {
  #cursor-dot::after { transition: none; }
  .topics-track, .profile.nudge { animation: none; }
  .card, .subscribe, .contact-icons a { transition: none; }
}
