/* ============================================================
   Academic Site — Modern Minimalist Theme
   Inspired by al-folio, Pascal Michaillat's template, and
   clean math faculty sites.
   ============================================================ */

:root {
  /* Light theme */
  --bg: #ffffff;
  --bg-alt: #f8f9fa;
  --text: #212529;
  --text-secondary: #6c757d;
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --border: #e5e7eb;
  --card-bg: #ffffff;
  --card-shadow: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  --card-shadow-hover: 0 4px 12px rgba(0,0,0,0.08);
  --nav-bg: rgba(255,255,255,0.92);
  --tag-bg: #e8eef4;
  --tag-text: #2563eb;
  --max-width: 780px;
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-serif: 'Source Serif 4', Georgia, 'Times New Roman', serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', monospace;
}

[data-theme="dark"] {
  --bg: #0f172a;
  --bg-alt: #1e293b;
  --text: #e2e8f0;
  --text-secondary: #94a3b8;
  --accent: #60a5fa;
  --accent-hover: #93bbfd;
  --border: #334155;
  --card-bg: #1e293b;
  --card-shadow: 0 1px 3px rgba(0,0,0,0.3);
  --card-shadow-hover: 0 4px 12px rgba(0,0,0,0.4);
  --nav-bg: rgba(15,23,42,0.92);
  --tag-bg: #1e3a5f;
  --tag-text: #60a5fa;
}

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

html { scroll-behavior: smooth; }

body {
  font-family: var(--font-sans);
  color: var(--text);
  background: var(--bg);
  line-height: 1.7;
  font-size: 16px;
  transition: background 0.3s ease, color 0.3s ease;
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--accent);
  text-decoration: none;
  transition: color 0.15s ease;
}
a:hover { color: var(--accent-hover); }

/* ---- Navigation ---- */
.nav {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--nav-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  padding: 0 2rem;
}
.nav-inner {
  max-width: var(--max-width);
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  height: 56px;
}
.nav-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text);
  text-decoration: none;
  letter-spacing: -0.01em;
}
.nav-right {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}
.nav-links {
  display: flex;
  gap: 0.15rem;
}
.nav-links a {
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.88rem;
  font-weight: 500;
  padding: 0.35rem 0.7rem;
  border-radius: 6px;
  transition: all 0.15s ease;
}
.nav-links a:hover, .nav-links a.active {
  color: var(--text);
  background: var(--bg-alt);
}

/* Dark mode toggle */
.theme-toggle {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1.1rem;
  padding: 0.35rem;
  border-radius: 6px;
  color: var(--text-secondary);
  transition: all 0.15s ease;
  margin-left: 0.5rem;
}
.theme-toggle:hover {
  background: var(--bg-alt);
  color: var(--text);
}

/* ---- Container ---- */
.container {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 2.5rem 2rem;
}

/* ---- Profile / Hero ---- */
.profile {
  display: flex;
  gap: 2rem;
  align-items: center;
  margin-bottom: 2.5rem;
}
.profile-photo img {
  width: 130px;
  height: 130px;
  border-radius: 50%;
  object-fit: cover;
  box-shadow: var(--card-shadow);
}
.profile-info {
  flex: 1;
}
.profile-info h1 {
  font-size: 1.75rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  margin-bottom: 0.15rem;
  line-height: 1.2;
}
.subtitle {
  color: var(--text-secondary);
  font-size: 1.05rem;
  font-weight: 400;
  margin-bottom: 1rem;
}
.profile-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
}
.profile-links a {
  display: inline-flex;
  align-items: center;
  color: var(--text-secondary);
  transition: color 0.15s ease;
}
.profile-links a:hover {
  color: var(--accent);
}
.profile-links a svg {
  width: 24px;
  height: 24px;
}

/* Name pronunciation */
.pronunciation-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--accent);
  font-size: 0.95rem;
  padding: 0.1rem 0.3rem;
  border-radius: 4px;
  vertical-align: middle;
  transition: all 0.15s ease;
}
.pronunciation-btn:hover {
  background: var(--tag-bg);
}

/* ---- About / Content ---- */
.about h2 {
  font-size: 1.2rem;
  font-weight: 700;
  margin-top: 2rem;
  margin-bottom: 0.6rem;
  letter-spacing: -0.01em;
}
.about p { margin-bottom: 0.9rem; }
.about ul {
  margin-left: 1.25rem;
  margin-bottom: 1rem;
}
.about li {
  margin-bottom: 0.2rem;
}

/* ---- Section Headers (list pages) ---- */
h1.page-title {
  font-size: 1.5rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  margin-bottom: 1.5rem;
  padding-bottom: 0.75rem;
  border-bottom: 2px solid var(--border);
}

/* ---- Publication / Talk Cards ---- */
.entry {
  padding: 1.25rem;
  margin-bottom: 1rem;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: var(--card-shadow);
  transition: all 0.2s ease;
}
.entry:hover {
  box-shadow: var(--card-shadow-hover);
  border-color: var(--accent);
}
.entry h3 {
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: 0.3rem;
  line-height: 1.4;
}
.entry h3 a {
  color: var(--text);
  text-decoration: none;
}
.entry h3 a:hover { color: var(--accent); }
.entry-authors {
  color: var(--text-secondary);
  font-size: 0.88rem;
  margin-bottom: 0.2rem;
}
.entry-journal {
  font-style: italic;
  color: var(--text-secondary);
  font-size: 0.85rem;
  margin-bottom: 0.4rem;
}
.entry-meta {
  color: var(--text-secondary);
  font-size: 0.88rem;
  margin-bottom: 0.3rem;
}
.entry-desc {
  font-size: 0.85rem;
  line-height: 1.5;
  margin-bottom: 0.5rem;
  color: var(--text-secondary);
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.entry-links {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.5rem;
}
.entry-links a {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--accent);
  padding: 0.2rem 0.6rem;
  background: var(--tag-bg);
  border-radius: 5px;
  transition: all 0.15s ease;
}
.entry-links a:hover {
  background: var(--accent);
  color: #fff;
}

/* Year grouping */
.year-group {
  margin-top: 2rem;
}
.year-label {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 0.75rem;
}

/* ---- Tables (travel page) ---- */
table {
  width: 100%;
  border-collapse: collapse;
  margin: 1rem 0;
  font-size: 0.9rem;
}
th {
  text-align: left;
  padding: 0.6rem 0.75rem;
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-secondary);
  border-bottom: 2px solid var(--border);
}
td {
  padding: 0.6rem 0.75rem;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
tr:hover { background: var(--bg-alt); }
td a { font-weight: 500; }

/* ---- Article / Single ---- */
article {
  max-width: 100%;
}
article h1 {
  font-size: 1.4rem;
  font-weight: 800;
  margin-bottom: 1rem;
  line-height: 1.3;
}
article p { margin-bottom: 1rem; }
article h3 {
  font-size: 1.05rem;
  font-weight: 700;
  margin-top: 1.5rem;
  margin-bottom: 0.5rem;
}
article strong { font-weight: 600; }
article em { font-style: italic; }

/* Back link */
.back-link {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 1.5rem;
}
.back-link:hover { color: var(--accent); }

/* ---- Teaching ---- */
.about li strong {
  font-weight: 600;
}

/* ---- Footer ---- */
.footer {
  text-align: center;
  padding: 2rem;
  color: var(--text-secondary);
  font-size: 0.8rem;
  border-top: 1px solid var(--border);
  margin-top: 3rem;
}
.footer a { color: var(--accent); }
.build-info { font-size: 0.7em; opacity: 0.45; margin-top: 0.5rem; }

/* ---- Mobile hamburger ---- */
.nav-toggle {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.35rem;
  color: var(--text);
  font-size: 1.3rem;
}

/* ---- Responsive ---- */
@media (max-width: 640px) {
  .nav-inner { height: auto; padding: 0.75rem 0; flex-wrap: wrap; }
  .nav-toggle { display: block; }
  .nav-links {
    display: none;
    width: 100%;
    flex-direction: column;
    gap: 0;
    padding-top: 0.5rem;
  }
  .nav-links.open { display: flex; }
  .nav-links a {
    padding: 0.5rem 0;
    border-radius: 0;
  }
  .profile {
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 1.5rem;
  }
  .profile-photo img { width: 110px; height: 110px; }
  .profile-links { justify-content: center; }
  .container { padding: 1.5rem 1.25rem; }
  .entry { padding: 1rem; }
  table { font-size: 0.82rem; }
  th, td { padding: 0.4rem 0.5rem; }
}

/* ---- Scroll progress (subtle) ---- */
.scroll-progress {
  position: fixed;
  top: 56px;
  left: 0;
  height: 2px;
  background: var(--accent);
  z-index: 99;
  transition: width 0.1s linear;
}

/* ---- Print ---- */
@media print {
  .nav, .footer, .theme-toggle, .scroll-progress { display: none; }
  body { font-size: 12pt; background: white; color: black; }
  .entry { box-shadow: none; border: 1px solid #ccc; }
}

/* ---- Publication images ---- */
.entry.has-image {
  display: flex;
  gap: 1.2rem;
  align-items: flex-start;
}
.entry-image {
  flex: 0 0 140px;
  max-width: 140px;
}
.entry-image img {
  width: 100%;
  height: auto;
  border-radius: 6px;
  border: 1px solid var(--border);
}
.entry-content {
  flex: 1;
  min-width: 0;
}
@media (max-width: 600px) {
  .entry.has-image { flex-direction: column; }
  .entry-image { flex: none; max-width: 200px; }
}

/* ---- Upcoming highlight ---- */
.upcoming-section .entry {
  border-left: 3px solid var(--accent);
}
.section-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-top: 2rem;
  margin-bottom: 0.5rem;
}
.section-header h2 { margin: 0; }
.see-all-btn {
  font-size: 0.9rem;
  color: var(--accent);
  text-decoration: none;
  font-weight: 500;
}
.see-all-btn:hover { text-decoration: underline; }
.past-label {
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-top: 2rem;
  margin-bottom: 0.5rem;
  padding-bottom: 0.3rem;
  border-bottom: 1px solid var(--border);
}

/* ---- Talk & Travel Cards ---- */
.talk-item, .travel-item {
  padding: 0.8rem 1rem;
  margin-bottom: 0.5rem;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  transition: all 0.15s ease;
}
.talk-item:hover, .travel-item:hover {
  border-color: var(--accent);
  box-shadow: var(--card-shadow);
}
.talk-item h3, .travel-item h3 {
  font-size: 0.95rem;
  font-weight: 600;
  margin: 0 0 0.2rem 0;
  line-height: 1.35;
}
.talk-item h3 a, .travel-item h3 a {
  color: var(--text);
  text-decoration: none;
}
.talk-item h3 a:hover, .travel-item h3 a:hover {
  color: var(--accent);
}
.talk-meta, .travel-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.15rem 0.5rem;
  font-size: 0.82rem;
  color: var(--text-secondary);
}
.talk-meta span::after, .travel-meta span::after {
  content: " · ";
  color: var(--border);
}
.talk-meta span:last-child::after, .travel-meta span:last-child::after {
  content: "";
}

/* Upcoming/Past section headers on talk/travel pages */
.upcoming-past-section h2 {
  font-size: 1rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-secondary);
  margin: 1.5rem 0 0.75rem 0;
  padding-bottom: 0.3rem;
  border-bottom: 2px solid var(--accent);
}

/* Upcoming items on dedicated pages get accent left border */
.upcoming-past-section:first-of-type .talk-item,
.upcoming-past-section:first-of-type .travel-item {
  border-left: 3px solid var(--accent);
}

/* ---- Compact upcoming list on main page ---- */
.upcoming-compact {
  margin: 0.5rem 0 1.5rem 0;
}
.upcoming-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 0.4rem 0;
  border-bottom: 1px solid var(--border);
  gap: 1rem;
}
.upcoming-row:last-child { border-bottom: none; }
.upcoming-row-title {
  font-size: 0.9rem;
  font-weight: 600;
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.upcoming-row-title a {
  color: var(--text);
  text-decoration: none;
}
.upcoming-row-title a:hover { color: var(--accent); }
.upcoming-row-meta {
  font-size: 0.8rem;
  color: var(--text-secondary);
  white-space: nowrap;
  flex-shrink: 0;
}
.upcoming-talk .upcoming-row-title {
  font-weight: 400;
}
@media (max-width: 640px) {
  .upcoming-row { flex-direction: column; gap: 0; }
  .upcoming-row-title { white-space: normal; }
}

.bibtex-btn {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.15rem 0.5rem;
  font-size: 0.8rem;
  cursor: pointer;
  color: var(--accent);
  transition: all 0.2s;
}
.bibtex-btn:hover {
  background: var(--accent);
  color: white;
}
.bibtex-btn.copied {
  background: #2d8a4e;
  color: white;
  border-color: #2d8a4e;
}
