/* ============================================================
   Design tokens
   ============================================================ */
:root {
  --bg: #fbfbf9;
  --surface: #ffffff;
  --text: #1c2329;
  --text-soft: #46525c;
  --muted: #6b7782;
  --rule: #e2e5e8;
  --accent: #0b5d7a;
  --accent-soft: #e6f1f5;
  --tag-bg: #f1f3f5;

  --serif: "Source Serif 4", Georgia, "Times New Roman", serif;
  --sans: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

  --measure: 50rem;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1417;
    --surface: #151b1f;
    --text: #e4e8eb;
    --text-soft: #bcc5cc;
    --muted: #8d99a3;
    --rule: #263038;
    --accent: #6cc3df;
    --accent-soft: #15303a;
    --tag-bg: #1c2429;
    color-scheme: dark;
  }
}

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

html {
  scroll-behavior: smooth;
  scroll-padding-top: 4.5rem;
  -webkit-text-size-adjust: 100%;
}

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

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

p { margin: 0 0 0.75rem; }

.page {
  max-width: var(--measure);
  margin: 0 auto;
  padding: 0 1.5rem 5rem;
}

/* ============================================================
   Top navigation
   ============================================================ */
.topnav {
  position: sticky;
  top: 0;
  z-index: 10;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(160%) blur(8px);
  -webkit-backdrop-filter: saturate(160%) blur(8px);
  border-bottom: 1px solid var(--rule);
}

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

.topnav-name {
  font-family: var(--serif);
  font-weight: 600;
  font-size: 1.05rem;
  color: var(--text);
  white-space: nowrap;
}
.topnav-name:hover { text-decoration: none; color: var(--accent); }

.topnav-links {
  display: flex;
  gap: 1.25rem;
  font-family: var(--mono);
  font-size: 0.78rem;
  letter-spacing: 0.02em;
}
.topnav-links a { color: var(--muted); }
.topnav-links a:hover { color: var(--accent); text-decoration: none; }

/* ============================================================
   Header / hero
   ============================================================ */
.hero {
  padding: 4rem 0 2.5rem;
  border-bottom: 1px solid var(--rule);
}

.hero h1 {
  font-family: var(--serif);
  font-weight: 600;
  font-size: clamp(2.2rem, 5vw, 3rem);
  line-height: 1.1;
  letter-spacing: -0.015em;
  margin: 0 0 0.6rem;
}

.role {
  font-size: 1.05rem;
  color: var(--text-soft);
  margin: 0 0 1.5rem;
}

.interests,
.profiles,
.pubs,
.stack {
  list-style: none;
  margin: 0;
  padding: 0;
}

.interests {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1.75rem;
}
.interests li {
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--accent);
  background: var(--accent-soft);
  padding: 0.3rem 0.75rem;
  border-radius: 999px;
}

.profiles {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}
.profiles a {
  display: inline-block;
  font-family: var(--mono);
  font-size: 0.78rem;
  color: var(--text-soft);
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: 6px;
  padding: 0.35rem 0.75rem;
  transition: border-color 0.15s, color 0.15s;
}
.profiles a:hover {
  color: var(--accent);
  border-color: var(--accent);
  text-decoration: none;
}

/* ============================================================
   Sections
   ============================================================ */
main { counter-reset: section; }

section {
  padding-top: 3rem;
}

section h2 {
  counter-increment: section;
  font-family: var(--serif);
  font-weight: 600;
  font-size: 1.6rem;
  letter-spacing: -0.01em;
  line-height: 1.2;
  margin: 0 0 1.5rem;
  display: flex;
  align-items: baseline;
  gap: 0.75rem;
}
section h2::before {
  content: counter(section, decimal-leading-zero);
  font-family: var(--mono);
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--accent);
}
section h2::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--rule);
  align-self: center;
}

section > h3 {
  font-family: var(--mono);
  font-size: 0.75rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin: 2rem 0 0.75rem;
}

.lead {
  font-size: 1.05rem;
  color: var(--text-soft);
  max-width: 44rem;
}

/* ============================================================
   Publications
   ============================================================ */
.pubs li {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  padding: 0.9rem 0 0.9rem 1rem;
  border-left: 2px solid var(--rule);
  margin-bottom: 0.5rem;
  transition: border-color 0.15s;
}
.pubs li:hover { border-left-color: var(--accent); }

.pub-title {
  font-weight: 600;
  line-height: 1.4;
}
.pub-translation {
  font-weight: 400;
  color: var(--muted);
}
.pub-authors,
.pub-venue {
  font-size: 0.9rem;
  color: var(--text-soft);
}
.pub-authors b { color: var(--text); font-weight: 600; }

.pub-links {
  font-family: var(--mono);
  font-size: 0.78rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.6rem;
  margin-top: 0.2rem;
}
.pub-note {
  font-size: 0.82rem;
  font-style: italic;
  color: var(--muted);
}

.tag {
  font-family: var(--mono);
  font-size: 0.7rem;
  font-weight: 500;
  letter-spacing: 0.03em;
  color: var(--muted);
  background: var(--tag-bg);
  border: 1px solid var(--rule);
  border-radius: 4px;
  padding: 0.05rem 0.45rem;
}

/* ============================================================
   Entries (education, research, industry)
   ============================================================ */
.entry {
  display: grid;
  grid-template-columns: 10.5rem 1fr;
  gap: 1.5rem;
  padding: 1.25rem 0;
  border-bottom: 1px solid var(--rule);
}
.entry:last-child { border-bottom: none; }

.entry-date {
  font-family: var(--mono);
  font-size: 0.8rem;
  color: var(--muted);
  margin: 0;
  padding-top: 0.2rem;
  white-space: nowrap;
}

.entry h3 {
  font-size: 1.05rem;
  font-weight: 600;
  margin: 0;
  line-height: 1.35;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
}

.status {
  font-family: var(--mono);
  font-size: 0.68rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--accent);
  border: 1px solid currentColor;
  border-radius: 4px;
  padding: 0.05rem 0.4rem;
}

.entry-org {
  color: var(--text-soft);
  font-size: 0.92rem;
  margin: 0.15rem 0 0.6rem;
}

.entry h4 {
  font-size: 0.92rem;
  font-weight: 600;
  margin: 0.9rem 0 0.3rem;
}

.entry ul {
  margin: 0 0 0.5rem;
  padding-left: 1.1rem;
}
.entry ul li {
  font-size: 0.92rem;
  color: var(--text-soft);
  margin-bottom: 0.25rem;
}
.entry ul li::marker { color: var(--accent); }

.stack {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin: 0.25rem 0 0.5rem;
}
.stack span {
  font-family: var(--mono);
  font-size: 0.72rem;
  color: var(--text-soft);
  background: var(--tag-bg);
  border: 1px solid var(--rule);
  border-radius: 4px;
  padding: 0.1rem 0.45rem;
}

/* ============================================================
   Responsive
   ============================================================ */
@media (max-width: 680px) {
  .page,
  .topnav-inner { padding-left: 1rem; padding-right: 1rem; }

  .topnav-inner { flex-direction: column; align-items: flex-start; gap: 0.35rem; }
  .topnav-links {
    gap: 1rem;
    overflow-x: auto;
    max-width: 100%;
    scrollbar-width: none;
  }
  .topnav-links::-webkit-scrollbar { display: none; }

  .hero { padding-top: 2.5rem; }

  .entry {
    grid-template-columns: 1fr;
    gap: 0.25rem;
  }
}

/* ============================================================
   Print — clean CV output
   ============================================================ */
@media print {
  :root { --bg: #fff; --surface: #fff; --text: #000; --text-soft: #222; --muted: #555; --accent: #000; --accent-soft: #fff; --tag-bg: #fff; }
  .topnav { display: none; }
  .hero { padding-top: 0; }
  section { padding-top: 1.5rem; break-inside: avoid-page; }
  .entry, .pubs li { break-inside: avoid; }
  a { color: inherit; }
}
