/* ---------- Design tokens ---------- */
:root {
  --bg: #10141b;
  --bg-alt: #161b24;
  --bg-card: #1a202b;
  --text: #d6dce5;
  --text-muted: #8d97a6;
  --heading: #f2f5f9;
  --border: #2a323f;
  --link: #7cc0ff;
  --radius: 10px;
  --content-width: 46rem;

  /* Accent palette — cool ramp from green through blue to purple */
  --c1: #4ade80; /* green  */
  --c2: #2dd4bf; /* teal   */
  --c3: #38bdf8; /* blue   */
  --c4: #818cf8; /* indigo */
  --c5: #c084fc; /* purple */
  --accent: var(--c3);
  --accent-soft: rgba(56, 189, 248, 0.12);
  --rainbow: linear-gradient(90deg, var(--c1), var(--c2), var(--c3), var(--c4), var(--c5));
  font-size: 16px;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  line-height: 1.65;
  background:
    radial-gradient(60rem 30rem at 110% -10%, rgba(192, 132, 252, 0.06), transparent 60%),
    radial-gradient(50rem 25rem at -20% 10%, rgba(74, 222, 128, 0.05), transparent 60%),
    var(--bg);
  background-attachment: fixed;
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

/* ---------- Header & navigation (mobile first) ---------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: rgba(16, 20, 27, 0.92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}
.site-header::before {
  content: "";
  display: block;
  height: 3px;
  background: var(--rainbow);
}

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

.site-title {
  font-weight: 700;
  font-size: 1.1rem;
  text-decoration: none;
  letter-spacing: 0.02em;
  background: linear-gradient(90deg, var(--c1), var(--c2) 60%, var(--c3));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.nav-toggle {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  width: 44px;
  height: 44px;
  padding: 10px;
  background: none;
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
}
.nav-toggle span {
  display: block;
  height: 2px;
  background: var(--text);
  border-radius: 2px;
  transition: transform 0.2s, opacity 0.2s;
}
.nav-toggle[aria-expanded="true"] span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.nav-toggle[aria-expanded="true"] span:nth-child(2) { opacity: 0; }
.nav-toggle[aria-expanded="true"] span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

.site-nav {
  display: none;
  flex-basis: 100%;
  flex-direction: column;
  padding: 0.5rem 0 0.75rem;
}
.site-nav.open { display: flex; }

.site-nav a {
  color: var(--text);
  text-decoration: none;
  padding: 0.65rem 0.5rem;
  border-radius: 8px;
  font-size: 1rem;
}
.site-nav a:hover { background: var(--bg-alt); color: var(--accent); }
.site-nav a.active { color: var(--accent); font-weight: 600; }

/* Per-page nav accent */
.site-nav a[data-route="/publications"].active { color: var(--c4); }
.site-nav a[data-route="/projects"].active { color: var(--c5); }
.site-nav a[data-route="/thesis"].active { color: var(--c3); }
.site-nav a[data-route="/contacts"].active { color: var(--c2); }

@media (min-width: 720px) {
  .nav-toggle { display: none; }
  .header-inner { flex-wrap: nowrap; }
  .site-nav {
    display: flex !important;
    flex-basis: auto;
    flex-direction: row;
    gap: 0.15rem;
    padding: 0;
  }
  .site-nav a { padding: 0.4rem 0.6rem; font-size: 0.92rem; white-space: nowrap; }
}

/* ---------- Main content ---------- */
.site-main {
  max-width: var(--content-width);
  margin: 0 auto;
  padding: 1.5rem 1rem 3rem;
}

.loading { color: var(--text-muted); }

h1 {
  color: var(--heading);
  font-size: 1.7rem;
  line-height: 1.25;
  margin: 0.5rem 0 1rem;
  padding-bottom: 0.6rem;
  border-bottom: 2px solid;
  border-image: var(--rainbow) 1;
}

h2 {
  color: var(--heading);
  font-size: 1.25rem;
  margin: 2.2rem 0 0.6rem;
}

h3 { color: var(--heading); font-size: 1.05rem; margin: 1.6rem 0 0.5rem; }

a { color: var(--link); }
a:hover { color: var(--accent); }

strong { color: var(--heading); }

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

code {
  background: var(--accent-soft);
  color: var(--accent);
  padding: 0.1em 0.45em;
  border-radius: 6px;
  font-size: 0.82em;
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}

ul { padding-left: 1.3rem; }
li { margin: 0.3rem 0; }
li::marker { color: var(--c3); }

blockquote {
  margin: 1rem 0;
  padding: 0.5rem 1rem;
  border-left: 3px solid var(--c3);
  background: var(--bg-alt);
  border-radius: 0 var(--radius) var(--radius) 0;
  color: var(--text-muted);
}

/* Images & captions (a *caption* paragraph right after an image) */
img {
  max-width: 100%;
  height: auto;
  border-radius: var(--radius);
  border: 1px solid var(--border);
}
.site-main p:has(> img) { margin: 1.5rem 0; }
/* A caption is an <em> in the same paragraph as the image, or in the next one */
.site-main p:has(> img) > em,
.site-main p:has(> img) + p:has(> em:only-child) {
  display: block;
  margin-top: 0.5rem;
  text-align: center;
  font-size: 0.85rem;
  font-style: italic;
  color: var(--text-muted);
}

/* ---------- Home page hero ---------- */
.hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.2rem;
  text-align: center;
  margin: 1rem 0 2rem;
}
.hero img {
  width: 168px;
  height: 168px;
  border-radius: 50%;
  border: none;
  padding: 4px;
  background: conic-gradient(from 210deg, var(--c1), var(--c2), var(--c3), var(--c4), var(--c5), var(--c1));
  object-fit: cover;
}
.hero .hero-text h1 {
  border: none;
  margin-bottom: 0.2rem;
  padding-bottom: 0;
  background: linear-gradient(90deg, var(--c1), var(--c2) 55%, var(--c3));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.hero .hero-text p { color: var(--text-muted); margin: 0; }

@media (min-width: 720px) {
  .hero { flex-direction: row; text-align: left; gap: 2rem; }
}

/* ---------- Section cards (Projects & Thesis pages) ---------- */
.card {
  position: relative;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-top: 3px solid var(--card-accent);
  border-radius: var(--radius);
  padding: 0.4rem 1.2rem 0.9rem;
  margin: 1.3rem 0;
}
.card h2 { color: var(--card-accent); margin: 0.7rem 0 0.6rem; font-size: 1.2rem; padding-right: 3.2rem; }

.card-icon {
  position: absolute;
  top: 1rem;
  right: 1rem;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--card-accent-soft);
  border: 1px solid var(--card-accent);
  color: var(--card-accent);
}
.card-icon svg { width: 22px; height: 22px; }
.card code { color: var(--card-accent); background: var(--card-accent-soft); }

.accent-1 { --card-accent: var(--c1); --card-accent-soft: rgba(74, 222, 128, 0.12); }
.accent-2 { --card-accent: var(--c2); --card-accent-soft: rgba(45, 212, 191, 0.12); }
.accent-3 { --card-accent: var(--c3); --card-accent-soft: rgba(56, 189, 248, 0.12); }
.accent-4 { --card-accent: var(--c4); --card-accent-soft: rgba(129, 140, 248, 0.14); }
.accent-5 { --card-accent: var(--c5); --card-accent-soft: rgba(192, 132, 252, 0.14); }

/* ---------- Publications ---------- */
.pub-controls {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  margin: 1rem 0 1.5rem;
}
@media (min-width: 720px) {
  .pub-controls { flex-direction: row; align-items: center; }
  .pub-controls input { flex: 1; }
}

.pub-controls input {
  width: 100%;
  padding: 0.6rem 0.9rem;
  font-size: 1rem;
  background: var(--bg-alt);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
}
.pub-controls input:focus { outline: 2px solid var(--c4); border-color: transparent; }

.pub-filters { display: flex; gap: 0.4rem; flex-wrap: wrap; }
.pub-filters button {
  padding: 0.4rem 0.8rem;
  font-size: 0.85rem;
  background: var(--bg-alt);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 999px;
  cursor: pointer;
}
.pub-filters button.active {
  background: var(--accent);
  color: #12151a;
  border-color: transparent;
  font-weight: 600;
}
.pub-filters button[data-filter="journal"].active { background: var(--c1); }
.pub-filters button[data-filter="conference"].active { background: var(--c3); }
.pub-filters button[data-filter="preprint"].active { background: var(--c4); }
.pub-filters button[data-filter="other"].active { background: var(--c5); }

.pub-count { color: var(--text-muted); font-size: 0.9rem; margin: 0 0 1rem; }

.pub-year { margin-top: 1.8rem; }
.pub-year h2 {
  font-size: 1.15rem;
  margin: 0 0 0.8rem;
  color: var(--c1);
}

.pub-item {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-left: 3px solid var(--border);
  border-radius: var(--radius);
  padding: 0.9rem 1rem;
  margin-bottom: 0.7rem;
}
.pub-item:has(.pub-badge.journal) { border-left-color: var(--c1); }
.pub-item:has(.pub-badge.conference) { border-left-color: var(--c3); }
.pub-item:has(.pub-badge.preprint) { border-left-color: var(--c4); }
.pub-item:has(.pub-badge.other) { border-left-color: var(--c5); }

.pub-title { font-weight: 600; color: var(--heading); margin: 0 0 0.25rem; }
.pub-title a { color: inherit; text-decoration: none; }
.pub-title a:hover { color: var(--accent); }

.pub-authors { font-size: 0.9rem; color: var(--text-muted); margin: 0 0 0.25rem; }
.pub-authors .me { color: var(--text); font-weight: 600; }

.pub-venue { font-size: 0.88rem; font-style: italic; color: var(--text-muted); margin: 0 0 0.5rem; }

.pub-meta { display: flex; gap: 0.5rem; flex-wrap: wrap; align-items: center; }

.pub-badge {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 0.15rem 0.55rem;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
}
.pub-badge.journal { background: rgba(74, 222, 128, 0.12); color: var(--c1); }
.pub-badge.conference { background: rgba(56, 189, 248, 0.12); color: var(--c3); }
.pub-badge.preprint { background: rgba(129, 140, 248, 0.14); color: var(--c4); }
.pub-badge.other { background: rgba(192, 132, 252, 0.14); color: var(--c5); }

.pub-meta a, .pub-meta button {
  font-size: 0.8rem;
  color: var(--link);
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  text-decoration: underline;
  font-family: inherit;
}
.pub-meta a:hover, .pub-meta button:hover { color: var(--accent); }

.pub-bibtex {
  display: none;
  margin-top: 0.6rem;
  padding: 0.7rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.75rem;
  overflow-x: auto;
  white-space: pre;
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  color: var(--text-muted);
}
.pub-bibtex.open { display: block; }

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