/* ── Reset & base ──────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:        #ffffff;
  --surface:   #f7f7f7;
  --border:    #e2e2e2;
  --text:      #1a1a1a;
  --muted:     #666666;
  --accent:    #2563eb;       /* blue, easy to change */
  --nav-bg:    #1e293b;
  --nav-text:  #e2e8f0;
  --sidebar-w: 220px;
  --font:      'Georgia', serif;
  --sans:      'Helvetica Neue', Arial, sans-serif;
}

html { font-size: 16px; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.7;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

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

/* ── Top nav ───────────────────────────────────────────────────── */
.topnav {
  background: var(--nav-bg);
  position: sticky;
  top: 0;
  z-index: 100;
  border-bottom: 1px solid #0f172a;
}

.nav-inner {
  max-width: 960px;
  margin: 0 auto;
  padding: 0 1.5rem;
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.nav-name {
  font-family: var(--sans);
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--nav-text);
  letter-spacing: 0.02em;
}

.topnav ul {
  list-style: none;
  display: flex;
  gap: 2rem;
}

.topnav ul li a {
  font-family: var(--sans);
  font-size: 0.875rem;
  color: #94a3b8;
  text-decoration: none;
  letter-spacing: 0.04em;
  padding-bottom: 2px;
  border-bottom: 2px solid transparent;
  transition: color 0.15s, border-color 0.15s;
}

.topnav ul li a:hover,
.topnav ul li a.active {
  color: var(--nav-text);
  border-bottom-color: var(--accent);
}

/* ── Page wrapper ──────────────────────────────────────────────── */
.page-wrapper {
  max-width: 960px;
  margin: 2.5rem auto;
  padding: 0 1.5rem;
  flex: 1;
  display: flex;
  gap: 3rem;
  align-items: flex-start;
}

/* ── Sidebar ───────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  position: sticky;
  top: 72px;            /* below nav */
}

.avatar {
  width: 130px;
  height: 130px;
  border-radius: 50%;
  object-fit: cover;
  display: block;
  margin-bottom: 1rem;
  border: 3px solid var(--border);
}

.sidebar-name {
  font-family: var(--sans);
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 0.25rem;
}

.sidebar-title {
  font-size: 0.82rem;
  color: var(--muted);
  font-style: italic;
  margin-bottom: 0.1rem;
}

.sidebar-inst {
  font-size: 0.82rem;
  color: var(--muted);
  margin-bottom: 1.2rem;
}

.sidebar-links {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}

.sidebar-links li {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  font-size: 0.83rem;
  color: var(--muted);
}

.sidebar-links li i {
  width: 16px;
  text-align: center;
  color: #94a3b8;
  flex-shrink: 0;
}

.sidebar-links li a {
  color: var(--accent);
}

/* ── Main content ──────────────────────────────────────────────── */
.main-content {
  flex: 1;
  min-width: 0;
}

/* ── Generic section ───────────────────────────────────────────── */
.section {
  margin-bottom: 2.4rem;
}

.section-title {
  font-family: var(--sans);
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
  border-bottom: 1px solid var(--border);
  padding-bottom: 0.4rem;
  margin-bottom: 1.1rem;
}

/* ── Bio ───────────────────────────────────────────────────────── */
.bio {
  font-size: 0.95rem;
  line-height: 1.8;
}

/* ── Updates ───────────────────────────────────────────────────── */
.updates-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
}

.update-item {
  display: flex;
  gap: 1.2rem;
  font-size: 0.875rem;
}

.update-date {
  flex-shrink: 0;
  width: 80px;
  font-family: var(--sans);
  font-size: 0.78rem;
  color: var(--muted);
  padding-top: 1px;
}

.update-text { flex: 1; }

/* ── CV entries ────────────────────────────────────────────────── */
.cv-entry {
  margin-bottom: 1.2rem;
  font-size: 0.9rem;
}

.cv-entry-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1rem;
}

.cv-years {
  font-family: var(--sans);
  font-size: 0.8rem;
  color: var(--muted);
  white-space: nowrap;
  flex-shrink: 0;
}

.cv-entry-sub {
  color: var(--muted);
  font-style: italic;
  font-size: 0.88rem;
}

.cv-entry-notes {
  font-size: 0.83rem;
  color: var(--muted);
}

/* Publications */
.pub-entry { padding-bottom: 0.6rem; border-bottom: 1px solid var(--border); }
.pub-entry:last-child { border-bottom: none; }

.pub-title {
  font-weight: bold;
  margin-bottom: 0.15rem;
}

.pub-authors {
  font-size: 0.85rem;
  color: var(--muted);
}

.pub-venue {
  font-size: 0.85rem;
  font-style: italic;
  color: var(--muted);
  margin-bottom: 0.4rem;
}

.pub-links { display: flex; gap: 0.5rem; }

.pill-link {
  font-family: var(--sans);
  font-size: 0.75rem;
  padding: 2px 10px;
  border: 1px solid var(--accent);
  border-radius: 999px;
  color: var(--accent);
  transition: background 0.15s, color 0.15s;
}

.pill-link:hover {
  background: var(--accent);
  color: #fff;
  text-decoration: none;
}

/* Awards */
.award-list {
  list-style: disc;
  padding-left: 1.3rem;
  font-size: 0.9rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

/* ── Blog ──────────────────────────────────────────────────────── */
.blog-entry {
  margin-bottom: 1.6rem;
  padding-bottom: 1.4rem;
  border-bottom: 1px solid var(--border);
}

.blog-entry:last-child { border-bottom: none; }

.blog-date {
  font-family: var(--sans);
  font-size: 0.78rem;
  color: var(--muted);
  display: block;
  margin-bottom: 0.2rem;
}

.blog-title {
  font-size: 1rem;
  font-weight: bold;
  display: block;
  margin-bottom: 0.4rem;
}

.blog-summary {
  font-size: 0.88rem;
  color: var(--muted);
  line-height: 1.65;
}

/* ── Blog post reading layout ──────────────────────────────────── */
.reading-shell {
  max-width: 1100px;
  margin: 2.5rem auto;
  padding: 0 1.5rem;
  display: flex;
  gap: 3.5rem;
  align-items: flex-start;
}

/* TOC */
.reading-toc {
  width: 210px;
  flex-shrink: 0;
  position: sticky;
  top: 72px;
  max-height: calc(100vh - 90px);
  overflow-y: auto;
}

.toc-inner {
  border-right: 1px solid var(--border);
  padding-right: 1.5rem;
}

.toc-label {
  font-family: var(--sans);
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
  margin-bottom: 0.6rem;
}

/* TOC generated by python-markdown toc extension */
.toc-inner .toc { list-style: none; }
.toc-inner .toc li { margin: 0; }
.toc-inner .toc a {
  font-family: var(--sans);
  font-size: 0.8rem;
  color: var(--muted);
  text-decoration: none;
  display: block;
  padding: 0.2rem 0;
  line-height: 1.4;
  border-left: 2px solid transparent;
  padding-left: 0.5rem;
  transition: color 0.12s, border-color 0.12s;
}
.toc-inner .toc a:hover { color: var(--accent); border-left-color: var(--accent); }
/* Nested levels */
.toc-inner .toc ul { list-style: none; padding-left: 0.8rem; }
.toc-inner .toc ul a { font-size: 0.76rem; }

.toc-back {
  margin-top: 1.2rem;
  padding-top: 0.8rem;
  border-top: 1px solid var(--border);
}
.toc-back a {
  font-family: var(--sans);
  font-size: 0.78rem;
  color: var(--muted);
  text-decoration: none;
}
.toc-back a:hover { color: var(--accent); }

/* Article */
.reading-article {
  flex: 1;
  min-width: 0;
  max-width: 680px;
}

.article-header {
  margin-bottom: 2.5rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--border);
}

.article-date {
  font-family: var(--sans);
  font-size: 0.78rem;
  color: var(--muted);
  display: block;
  margin-bottom: 0.5rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.article-title {
  font-family: 'Lora', Georgia, serif;
  font-size: 2rem;
  font-weight: 600;
  line-height: 1.25;
  color: var(--text);
  margin-bottom: 0.8rem;
}

.article-summary {
  font-family: 'Lora', Georgia, serif;
  font-size: 1.05rem;
  color: var(--muted);
  font-style: italic;
  line-height: 1.7;
}

/* Article body typography */
.article-body {
  font-family: 'Lora', Georgia, serif;
  font-size: 1.05rem;
  line-height: 1.85;
  color: #1e293b;
}

.article-body h1,
.article-body h2,
.article-body h3,
.article-body h4 {
  font-family: 'Lora', Georgia, serif;
  font-weight: 600;
  color: var(--text);
  margin-top: 2rem;
  margin-bottom: 0.6rem;
  line-height: 1.3;
}

.article-body h1 { font-size: 1.6rem; }
.article-body h2 { font-size: 1.3rem; border-bottom: 1px solid var(--border); padding-bottom: 0.3rem; }
.article-body h3 { font-size: 1.1rem; }
.article-body h4 { font-size: 1rem; color: var(--muted); }

.article-body p { margin-bottom: 1.2rem; }

.article-body a { color: var(--accent); text-decoration: underline; text-underline-offset: 2px; }

.article-body strong { font-weight: 600; }
.article-body em { font-style: italic; }

.article-body ul,
.article-body ol {
  padding-left: 1.5rem;
  margin-bottom: 1.2rem;
}
.article-body li { margin-bottom: 0.3rem; }

.article-body blockquote {
  border-left: 3px solid var(--accent);
  margin: 1.4rem 0;
  padding: 0.6rem 1.2rem;
  background: #f0f5ff;
  border-radius: 0 4px 4px 0;
  font-style: italic;
  color: #334155;
}

.article-body code {
  font-family: 'Courier New', monospace;
  font-size: 0.87em;
  background: #f1f5f9;
  border: 1px solid #e2e8f0;
  border-radius: 3px;
  padding: 0.15em 0.4em;
}

.article-body pre {
  background: #1e293b;
  border-radius: 6px;
  padding: 1.2rem 1.4rem;
  overflow-x: auto;
  margin-bottom: 1.4rem;
}
.article-body pre code {
  background: none;
  border: none;
  padding: 0;
  color: #e2e8f0;
  font-size: 0.875rem;
  line-height: 1.65;
}

.article-body table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 1.4rem;
  font-size: 0.93rem;
}
.article-body th {
  background: #f8fafc;
  padding: 0.55rem 0.9rem;
  text-align: left;
  border: 1px solid var(--border);
  font-family: var(--sans);
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
}
.article-body td {
  padding: 0.55rem 0.9rem;
  border: 1px solid var(--border);
}
.article-body tr:nth-child(even) td { background: #f8fafc; }

.article-body hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 2rem 0;
}

.article-body img { max-width: 100%; border-radius: 6px; }

/* Footer */
.article-footer {
  margin-top: 3rem;
  padding-top: 1.2rem;
  border-top: 1px solid var(--border);
}
.article-back {
  font-family: var(--sans);
  font-size: 0.85rem;
  color: var(--muted);
}
.article-back:hover { color: var(--accent); }

/* ── Footer ────────────────────────────────────────────────────── */
footer {
  background: var(--surface);
  border-top: 1px solid var(--border);
  text-align: center;
  padding: 1.2rem;
  font-family: var(--sans);
  font-size: 0.78rem;
  color: var(--muted);
  margin-top: auto;
}

/* ── Responsive ────────────────────────────────────────────────── */

/* Tablet */
@media (max-width: 800px) {
  .reading-shell { gap: 2rem; }
  .reading-toc { width: 170px; }
  .article-title { font-size: 1.7rem; }
}

/* Mobile */
@media (max-width: 640px) {

  /* Nav */
  .nav-inner { padding: 0 1rem; }
  .nav-name { font-size: 0.85rem; }
  .topnav ul { gap: 1.2rem; }
  .topnav ul li a { font-size: 0.8rem; }

  /* Page layout — stack sidebar above content */
  .page-wrapper {
    flex-direction: column;
    margin: 1.5rem auto;
    padding: 0 1rem;
    gap: 1.5rem;
  }

  /* Sidebar — horizontal card on mobile */
  .sidebar {
    width: 100%;
    position: static;
    display: grid;
    grid-template-columns: auto 1fr;
    grid-template-rows: auto auto auto auto;
    column-gap: 1rem;
    row-gap: 0.15rem;
    align-items: start;
    padding-bottom: 1.2rem;
    border-bottom: 1px solid var(--border);
  }

  .avatar {
    width: 72px;
    height: 72px;
    grid-row: 1 / 5;
    margin-bottom: 0;
  }

  .sidebar-name  { font-size: 1rem; align-self: end; }
  .sidebar-title { font-size: 0.78rem; }
  .sidebar-inst  { font-size: 0.78rem; margin-bottom: 0; }

  .sidebar-links {
    grid-column: 1 / -1;
    flex-direction: row;
    flex-wrap: wrap;
    gap: 0.5rem 1.2rem;
    margin-top: 0.8rem;
  }

  .sidebar-links li { font-size: 0.8rem; }

  /* Main content */
  .main-content { width: 100%; }

  /* Updates — stack date above text */
  .update-item { flex-direction: column; gap: 0.1rem; }
  .update-date { width: auto; }

  /* Blog list */
  .blog-entry { margin-bottom: 1.2rem; padding-bottom: 1rem; }

  /* Footer */
  footer { padding: 1rem; font-size: 0.75rem; }

  /* Blog post reading layout — TOC above article */
  .reading-shell {
    flex-direction: column;
    margin: 1.2rem auto;
    padding: 0 1rem;
    gap: 0;
  }

  .reading-toc {
    width: 100%;
    position: static;
    max-height: none;
    overflow: visible;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border);
  }

  .toc-inner {
    border-right: none;
    padding-right: 0;
  }

  /* Show TOC as horizontal scrolling pill row on mobile */
  .toc-inner .toc,
  .toc-inner .toc ul {
    display: flex;
    flex-wrap: wrap;
    gap: 0.3rem;
    list-style: none;
    padding: 0;
  }

  .toc-inner .toc a {
    border-left: none;
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 0.2rem 0.7rem;
    font-size: 0.75rem;
    white-space: nowrap;
    background: var(--surface);
  }

  .toc-inner .toc a:hover {
    border-color: var(--accent);
    background: #eff6ff;
  }

  .toc-back { margin-top: 0.8rem; padding-top: 0; border-top: none; }

  /* Article */
  .reading-article { max-width: 100%; }
  .article-title { font-size: 1.45rem; }
  .article-body { font-size: 0.97rem; }

  /* Scrollable tables in articles */
  .article-body table {
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
}

/* Very small phones */
@media (max-width: 380px) {
  .topnav ul { gap: 0.8rem; }
  .nav-name { display: none; } /* hide name, keep links */
  .article-title { font-size: 1.25rem; }
}
