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

html {
  scroll-behavior: smooth;
  scroll-padding-top: 64px;
}

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  font-size: 1.06rem;
  line-height: 1.7;
  color: #1a1a2e;
  background: #ffffff;
  -webkit-font-smoothing: antialiased;
}

/* ── Variables ── */
:root {
  --accent:      #4a6fa5;
  --accent-dark: #3a5a8a;
  --text:        #1a1a2e;
  --text-muted:  #555577;
  --bg:          #ffffff;
  --bg-alt:      #f7f8fb;
  --border:      #e4e7ef;
  --nav-h:       60px;
  --max-w:       1100px;
  --radius:      8px;
}

/* ── Typography ── */
h1 { font-size: 2.5rem;   font-weight: 700; line-height: 1.2; }
h2 { font-size: 1.75rem; font-weight: 700; line-height: 1.3; margin-bottom: 1.25rem; }
h3 { font-size: 1.1rem; font-weight: 600; }

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

/* ── Layout ── */
.container {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 0 1.5rem;
}

section {
  padding: 5rem 0;
}

section.alt-bg {
  background: var(--bg-alt);
}

/* ── Navigation ── */
#navbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--nav-h);
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 2rem;
  gap: 1rem;
}

.nav-brand {
  font-weight: 600;
  font-size: 1rem;
  color: var(--text);
  white-space: nowrap;
  flex-shrink: 0;
}
.nav-brand:hover { color: var(--accent); }

.nav-links {
  list-style: none;
  display: flex;
  gap: 0.25rem;
  align-items: center;
}

.nav-links a {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-muted);
  padding: 0.3rem 0.65rem;
  border-radius: 6px;
  transition: color 0.15s, background 0.15s;
}
.nav-links a:hover,
.nav-links a.active {
  color: var(--accent);
  background: rgba(74, 111, 165, 0.08);
}

.nav-toggle {
  display: none;
  flex-direction: column;
  gap: 5px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
}
.nav-toggle span {
  display: block;
  width: 22px;
  height: 2px;
  background: var(--text);
  border-radius: 2px;
  transition: transform 0.25s, opacity 0.25s;
}
.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);
}

/* ── About Section ── */
#about {
  padding-top: calc(var(--nav-h) + 4rem);
}

.about-layout {
  display: flex;
  align-items: flex-start;
  gap: 2.5rem;
}

.about-photo-wrap {
  flex-shrink: 0;
}

.about-photo,
.about-photo-fallback {
  width: 190px;
  height: 190px;
  border-radius: 50%;
  object-fit: cover;
  border: 3px solid var(--border);
  box-shadow: 0 4px 16px rgba(0,0,0,0.1);
}

.about-photo-fallback {
  display: none;
  align-items: center;
  justify-content: center;
  background: var(--bg-alt);
  color: var(--accent);
  font-size: 2rem;
  font-weight: 700;
}

.about-text h1 {
  margin-bottom: 0.35rem;
}

.about-position {
  font-size: 1.1rem;
  font-weight: 500;
  color: var(--text);
  margin-bottom: 0.25rem;
}

.about-affil {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-bottom: 1rem;
}

.about-bio {
  margin-bottom: 1.5rem;
  color: var(--text);
}

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

.social-link {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-muted);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 0.3rem 0.75rem;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}
.social-link:hover {
  color: var(--accent);
  border-color: var(--accent);
  background: rgba(74, 111, 165, 0.06);
}
.social-link i {
  font-size: 0.95em;
}

/* ── Research Section ── */
.research-blurb {
  margin-bottom: 1.5rem;
}

.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.tag {
  font-size: 0.8rem;
  font-weight: 500;
  background: rgba(74, 111, 165, 0.1);
  color: var(--accent-dark);
  border-radius: 20px;
  padding: 0.25rem 0.75rem;
}

/* ── Education Timeline ── */
.timeline {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 0;
}

.timeline::before {
  content: '';
  position: absolute;
  left: 9px;
  top: 14px;
  bottom: 14px;
  width: 2px;
  background: var(--border);
}

.timeline-item {
  display: flex;
  gap: 1.25rem;
  padding-bottom: 2rem;
  position: relative;
}
.timeline-item:last-child {
  padding-bottom: 0;
}

.timeline-dot {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--accent);
  border: 3px solid var(--bg);
  box-shadow: 0 0 0 2px var(--accent);
  flex-shrink: 0;
  margin-top: 2px;
  position: relative;
  z-index: 1;
}

.alt-bg .timeline-dot {
  border-color: var(--bg-alt);
}

.timeline-body {
  flex: 1;
}

.timeline-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 0.2rem;
}

.timeline-degree {
  font-weight: 600;
  font-size: 1rem;
}

.timeline-date {
  font-size: 0.85rem;
  color: var(--text-muted);
  white-space: nowrap;
}

.timeline-inst {
  font-weight: 500;
  color: var(--text);
  margin-bottom: 0.15rem;
  font-size: 0.95rem;
}

.timeline-detail {
  font-size: 0.875rem;
  color: var(--text-muted);
}

/* ── Publications ── */
.section-note {
  font-size: 0.875rem;
  color: var(--text-muted);
  margin-bottom: 1.75rem;
}

.pub-list {
  display: flex;
  flex-direction: column;
  gap: 0.875rem;
  margin-bottom: 2rem;
}

.pub-card {
  padding: 1rem 0;
  border-bottom: 1px solid var(--border);
}
.pub-list .pub-card:first-child {
  border-top: 1px solid var(--border);
}

.pub-authors {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 0.25rem;
}
.pub-authors strong {
  color: var(--text);
}

.pub-title {
  font-weight: 600;
  font-size: 0.95rem;
  line-height: 1.4;
  margin-bottom: 0.3rem;
}

.pub-venue {
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-bottom: 0.6rem;
}

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

.pub-badge {
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  padding: 2px 10px;
  border-radius: 20px;
  background: rgba(0, 0, 0, 0.05);
  color: var(--text-muted);
  border: 1px solid rgba(0, 0, 0, 0.12);
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.pub-badge:hover {
  background: rgba(0, 0, 0, 0.1);
  color: var(--text);
  border-color: rgba(0, 0, 0, 0.2);
}

.subsection-title {
  font-size: 1.05rem;
  font-weight: 600;
  margin-bottom: 0.875rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-size: 0.8rem;
}

.subsection-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.4em;
  padding: 0 0.45em;
  margin-left: 0.35em;
  border-radius: 20px;
  background: rgba(74, 111, 165, 0.12);
  color: var(--accent-dark);
  font-size: 0.9em;
  font-weight: 700;
  letter-spacing: 0;
  vertical-align: middle;
  position: relative;
  top: -0.08em;
}
.subsection-count:empty {
  display: none;
}

/* Spaced variant — used when a subsection heading follows another block */
.subsection-title--spaced {
  margin-top: 2.5rem;
}

/* ── Collapsible publication subsections (native <details>) ──
   Kept visually identical to the old <h3> headings when open;
   only a small chevron is appended as the toggle affordance.       */
.pub-section > summary.subsection-title {
  cursor: pointer;
  list-style: none;          /* remove default disclosure triangle */
  user-select: none;
}
.pub-section > summary.subsection-title::-webkit-details-marker {
  display: none;             /* WebKit/Safari default triangle */
}
.pub-section > summary.subsection-title::after {
  content: "";
  display: inline-block;
  width: 0.42em;
  height: 0.42em;
  margin-left: 0.55em;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(45deg);        /* chevron pointing down when open */
  opacity: 0.5;
  vertical-align: middle;
  position: relative;
  top: -0.15em;
  transition: transform 0.2s ease;
}
.pub-section:not([open]) > summary.subsection-title::after {
  transform: rotate(-45deg);       /* chevron points right when collapsed */
}
.pub-section > summary.subsection-title:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 4px;
}

/* ── Collapsible talks subsections (native <details>) ── */
.talks-section > summary.talks-subheading {
  cursor: pointer;
  list-style: none;
  user-select: none;
  margin-top: 0;             /* inter-section gap handled by the wrapper below */
}
.talks-section > summary.talks-subheading::-webkit-details-marker {
  display: none;
}
.talks-section > summary.talks-subheading::after {
  content: "";
  display: inline-block;
  width: 0.42em;
  height: 0.42em;
  margin-left: 0.55em;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(45deg);        /* chevron pointing down when open */
  opacity: 0.5;
  vertical-align: middle;
  position: relative;
  top: -0.15em;
  transition: transform 0.2s ease;
}
.talks-section:not([open]) > summary.talks-subheading::after {
  transform: rotate(-45deg);       /* chevron points right when collapsed */
}
.talks-section > summary.talks-subheading:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 4px;
}
.talks-section + .talks-section {
  margin-top: 1.75rem;             /* preserves the original gap before "Past Events" */
}

/* ── Teaching (card grid, distinct from the timeline) ── */
.teaching-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 0.875rem;
}

.teaching-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.35rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.1rem;
  transition: box-shadow 0.15s, border-color 0.15s;
}
.teaching-card:hover {
  box-shadow: 0 3px 12px rgba(0,0,0,0.07);
  border-color: rgba(74, 111, 165, 0.4);
}

.teaching-year {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  color: var(--accent-dark);
  background: rgba(74, 111, 165, 0.12);
  border-radius: 20px;
  padding: 1px 0.65em;
}

.teaching-course {
  font-weight: 600;
  font-size: 0.95rem;
  line-height: 1.3;
}

.teaching-inst {
  font-size: 0.83rem;
  color: var(--text-muted);
}

/* ── Talks ── */
.talks-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0;
}

.talk-item {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  padding: 1rem 0;
  border-bottom: 1px solid var(--border);
}
.talk-item:first-child {
  border-top: 1px solid var(--border);
}

.talk-date {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  min-width: 58px;
}

.talk-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
}

.talk-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.talk-role-badge {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 600;
  padding: 1px 8px;
  border-radius: 20px;
  background: rgba(0, 0, 0, 0.05);
  color: var(--text-muted);
  border: 1px solid rgba(0, 0, 0, 0.12);
  white-space: nowrap;
}

.talk-slides-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  flex-shrink: 0;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 3px 10px;
  transition: color 0.15s, border-color 0.15s;
}
.talk-slides-btn:hover {
  color: var(--accent);
  border-color: var(--accent);
}

.talk-name {
  font-weight: 600;
  font-size: 0.95rem;
}

.talk-name-link {
  color: inherit;
  transition: color 0.15s;
}
.talk-name-link:hover {
  color: var(--accent);
}

.talk-loc {
  font-size: 0.83rem;
  color: var(--text-muted);
}

/* ── Talks subheadings ── */
.talks-subheading {
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-muted);
  margin-top: 1.75rem;
  margin-bottom: 0.25rem;
}
.talks-subheading:first-of-type {
  margin-top: 0;
}

/* ── Author links — inherit muted color, only accent on hover ── */
.pub-authors a {
  color: inherit;
}
.pub-authors a:hover {
  color: var(--accent);
}

/* ── Cite button (inherits .pub-badge, just needs button resets) ── */
button.pub-badge {
  cursor: pointer;
  font-family: inherit;
  line-height: 1;
}

/* ── Citation Modal ── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(10, 10, 20, 0.55);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}
.modal-overlay[hidden] {
  display: none;
}

.modal-box {
  background: #fff;
  border-radius: 10px;
  box-shadow: 0 16px 48px rgba(0,0,0,0.18);
  width: 100%;
  max-width: 640px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.875rem 1.25rem;
  border-bottom: 1px solid var(--border);
}

.modal-title {
  font-weight: 600;
  font-size: 0.9rem;
}

.modal-close {
  background: none;
  border: none;
  font-size: 1.4rem;
  line-height: 1;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0 0.25rem;
  transition: color 0.15s;
}
.modal-close:hover {
  color: var(--text);
}

.modal-pre {
  margin: 0;
  padding: 1.25rem;
  background: #f5f6f9;
  font-family: 'Fira Mono', 'Consolas', 'Menlo', monospace;
  font-size: 0.8rem;
  line-height: 1.6;
  white-space: pre;
  overflow-x: auto;
  border-bottom: 1px solid var(--border);
}

.modal-footer {
  padding: 0.75rem 1.25rem;
  display: flex;
  justify-content: flex-end;
}

.copy-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 0.45rem 1rem;
  cursor: pointer;
  transition: background 0.15s;
}
.copy-btn:hover {
  background: var(--accent-dark);
}
.copy-btn.copied {
  background: #2d6a4f;
}

/* ── About text fill ── */
.about-text {
  flex: 1;
  min-width: 0;
}

/* ── Secondary page first sections (cv.html, events.html) ── */
#education,
#upcoming {
  padding-top: calc(var(--nav-h) + 4rem);
}

.cv-section {
  text-align: center;
}
.cv-section h2 { margin-bottom: 0.5rem; }
.cv-section p { color: var(--text-muted); margin-bottom: 1.5rem; }

.cv-button {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--accent);
  color: #fff;
  font-weight: 600;
  font-size: 0.95rem;
  padding: 0.65rem 1.75rem;
  border-radius: 8px;
  transition: background 0.15s, transform 0.1s;
}
.cv-button:hover { background: var(--accent-dark); color: #fff; transform: translateY(-1px); }

/* ── "See all" link below truncated lists ── */
.see-all-link {
  display: inline-block;
  margin-top: 0.75rem;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--accent);
}
.see-all-link:hover {
  color: var(--accent-dark);
}

/* ── Loading placeholder ── */
.loading-msg {
  color: var(--text-muted);
  font-size: 0.875rem;
  padding: 0.5rem 0;
}

/* ── Footer ── */
footer {
  background: var(--text);
  color: rgba(255,255,255,0.72);
  font-size: 0.82rem;
  padding: 1.5rem 0;
}
.footer-inner {
  text-align: center;
}

/* ── Mobile ── */
@media (max-width: 640px) {
  h1 { font-size: 1.6rem; }
  h2 { font-size: 1.3rem; }

  section { padding: 3.5rem 0; }
  #about  { padding-top: calc(var(--nav-h) + 2.5rem); }

  #navbar {
    padding: 0 1.25rem;
  }

  .nav-toggle {
    display: flex;
    order: 2;
  }

  .nav-links {
    display: none;
    position: fixed;
    top: var(--nav-h);
    left: 0;
    right: 0;
    background: rgba(255,255,255,0.97);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    flex-direction: column;
    align-items: stretch;
    padding: 1rem 1.5rem 1.5rem;
    border-bottom: 1px solid var(--border);
    gap: 0.25rem;
    box-shadow: 0 8px 24px rgba(0,0,0,0.08);
  }

  .nav-links.open {
    display: flex;
  }

  .nav-links a {
    font-size: 1rem;
    padding: 0.6rem 0.75rem;
  }

  .about-layout {
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 1.5rem;
  }

  .social-links {
    justify-content: center;
  }

  .about-bio {
    max-width: 100%;
  }

  .timeline-row {
    flex-direction: column;
    gap: 0.1rem;
  }

  .talk-item {
    flex-direction: column;
    gap: 0.3rem;
  }
}
