/* ========================================
   CSS Variables — Warm Humanities Academic Theme
   ======================================== */
:root {
  --bg: #F8F6F2;
  --card: #FFFFFF;
  --text: #3A3A3A;
  --heading: #3A3A3A;
  --muted: #6F6F6F;
  --link: #8B5E3C;
  --link-hover: #6E482D;
  --border: #E8E0D8;
  --border-muted: #E8E0D8;
  --accent: #EFE6DD;
  --btn-bg: #FFFFFF;
  --btn-border: #E8E0D8;
  --btn-hover-bg: #EFE6DD;
  --header-bg: rgba(248, 246, 242, 0.9);
  --tag-bg: #EFE6DD;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
  --timeline-dot: #8B5E3C;
  --iframe-bg: #FFFFFF;
}

[data-theme="dark"] {
  --bg: #1F1F1F;
  --card: #2A2A2A;
  --text: #E5E5E5;
  --heading: #E5E5E5;
  --muted: #A8A8A8;
  --link: #B08968;
  --link-hover: #C9A07E;
  --border: #3A3A3A;
  --border-muted: #333333;
  --accent: #3A3530;
  --btn-bg: #2A2A2A;
  --btn-border: #3A3A3A;
  --btn-hover-bg: #333333;
  --header-bg: rgba(31, 31, 31, 0.9);
  --tag-bg: #3A3530;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
  --timeline-dot: #B08968;
  --iframe-bg: #2A2A2A;
}

/* ========================================
   Base
   ======================================== */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  scroll-padding-top: 72px;
}

body {
  margin: 0;
  font-family: "Noto Sans SC", "PingFang SC", "Microsoft YaHei", "Hiragino Sans GB", sans-serif;
  font-size: 16px;
  line-height: 1.85;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  transition: background-color 0.2s ease, color 0.2s ease;
}

a {
  color: var(--link);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
  color: var(--link-hover);
}

img {
  max-width: 100%;
  height: auto;
}

.container {
  max-width: 900px;
  margin: 0 auto;
  padding: 0 24px 80px;
}

/* ========================================
   Header & Navigation
   ======================================== */
.site-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  background: var(--header-bg);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
  transition: background-color 0.2s ease, border-color 0.2s ease;
}

.nav-inner {
  max-width: 900px;
  margin: 0 auto;
  padding: 0 24px;
  height: 56px;
  display: flex;
  align-items: center;
  gap: 16px;
}

.nav-logo {
  font-weight: 600;
  font-size: 15px;
  color: var(--heading);
  text-decoration: none;
  flex-shrink: 0;
}

.nav-logo:hover {
  text-decoration: none;
  color: var(--link);
}

.nav-links {
  display: flex;
  list-style: none;
  margin: 0;
  padding: 0;
  gap: 4px;
  flex: 1;
}

.nav-link {
  display: block;
  padding: 6px 12px;
  font-size: 14px;
  font-weight: 500;
  color: var(--muted);
  text-decoration: none;
  border-radius: 6px;
  transition: color 0.15s ease, background-color 0.15s ease;
}

.nav-link:hover {
  color: var(--link);
  text-decoration: none;
  background: var(--accent);
}

.nav-link.active {
  color: var(--link);
  font-weight: 600;
}

.theme-toggle,
.nav-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--card);
  color: var(--muted);
  cursor: pointer;
  flex-shrink: 0;
  transition: background-color 0.15s ease, color 0.15s ease;
}

.theme-toggle:hover,
.nav-toggle:hover {
  background: var(--accent);
  color: var(--link);
}

.nav-toggle {
  display: none;
  margin-left: auto;
}

/* ========================================
   Sections
   ======================================== */
.section {
  padding-top: 64px;
}

.section-title {
  font-size: 24px;
  font-weight: 600;
  color: var(--heading);
  margin: 0 0 24px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border-muted);
}

.subsection-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--heading);
  margin: 32px 0 16px;
}

.subsection-title:first-of-type {
  margin-top: 0;
}

/* Fade-in animation */
.fade-in {
  opacity: 0;
  transform: translateY(12px);
  transition: opacity 0.5s ease, transform 0.5s ease;
}

.fade-in.visible {
  opacity: 1;
  transform: translateY(0);
}

/* ========================================
   Hero
   ======================================== */
.hero {
  padding-top: 96px;
}

.hero-top {
  display: flex;
  align-items: center;
  gap: 32px;
  margin-bottom: 28px;
}

.avatar {
  width: 140px;
  height: 140px;
  border-radius: 50%;
  object-fit: cover;
  border: 1px solid var(--border);
  flex-shrink: 0;
}

.hero-name {
  font-size: 32px;
  font-weight: 700;
  color: var(--heading);
  margin: 0 0 4px;
  line-height: 1.3;
}

.hero-title {
  font-size: 17px;
  color: var(--muted);
  margin: 0 0 4px;
}

.hero-affiliation {
  font-size: 17px;
  color: var(--text);
  margin: 0 0 8px;
}

.hero-email {
  margin: 0;
  font-size: 15px;
}

.hero-bio {
  margin: 0 0 28px;
  color: var(--text);
  max-width: 720px;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

/* ========================================
   Buttons (GitHub style)
   ======================================== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 5px 16px;
  font-size: 14px;
  font-weight: 500;
  line-height: 20px;
  color: var(--link);
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 6px;
  text-decoration: none;
  box-shadow: var(--shadow);
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
  white-space: nowrap;
}

.btn:hover {
  background: var(--accent);
  border-color: var(--border);
  text-decoration: none;
  color: var(--link-hover);
}

.btn-primary {
  color: #FFFFFF;
  background: var(--link);
  border-color: var(--link);
}

.btn-primary:hover {
  background: var(--link-hover);
  border-color: var(--link-hover);
  color: #FFFFFF;
}

[data-theme="dark"] .btn-primary {
  background: var(--link);
  border-color: var(--link);
}

[data-theme="dark"] .btn-primary:hover {
  background: var(--link-hover);
  border-color: var(--link-hover);
}

/* ========================================
   Timeline
   ======================================== */
.timeline {
  list-style: none;
  margin: 0;
  padding: 0 0 0 20px;
  border-left: 2px solid var(--border-muted);
}

.timeline-item {
  position: relative;
  padding: 0 0 20px 20px;
}

.timeline-item:last-child {
  padding-bottom: 0;
}

.timeline-item::before {
  content: "";
  position: absolute;
  left: -25px;
  top: 8px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid var(--timeline-dot);
}

.timeline-year {
  display: block;
  font-weight: 600;
  color: var(--heading);
  font-size: 15px;
  margin-bottom: 2px;
}

.timeline-text {
  color: var(--text);
  display: block;
}

/* ========================================
   Tags
   ======================================== */
.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.tag {
  display: inline-block;
  padding: 4px 12px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
  background: var(--tag-bg);
  border: 1px solid var(--border);
  border-radius: 20px;
}

/* ========================================
   Publications
   ======================================== */
  display: flex;
  flex-direction: column;
  gap: 32px;
}

.pub-category-title {
  font-size: 18px;
  font-weight: 600;
  color: var(--heading);
  margin: 0 0 16px;
  padding-left: 10px;
  border-left: 3px solid var(--link);
}

.loading-text,
.error-text {
  color: var(--muted);
  font-size: 15px;
}

.year-group {
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
  margin-bottom: 8px;
  background: var(--card);
  box-shadow: var(--shadow);
}

.year-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 12px 16px;
  font-family: inherit;
  font-size: 15px;
  font-weight: 600;
  color: var(--heading);
  background: var(--card);
  border: none;
  cursor: pointer;
  text-align: left;
  transition: background-color 0.15s ease;
}

.year-toggle:hover {
  background: var(--accent);
}

.year-toggle .chevron {
  font-size: 12px;
  color: var(--muted);
  transition: transform 0.2s ease;
  width: 14px;
  text-align: center;
}

.year-toggle[aria-expanded="true"] .chevron {
  transform: rotate(90deg);
}

.year-count {
  color: var(--muted);
  font-weight: 400;
}

.year-papers {
  display: none;
  padding: 4px 16px 12px;
  border-top: 1px solid var(--border-muted);
}

.year-papers.open {
  display: block;
}

.paper-item {
  padding: 16px 0;
  border-bottom: 1px solid var(--border-muted);
}

.paper-item:last-child {
  border-bottom: none;
  padding-bottom: 8px;
}

.paper-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 10px;
}

.badge {
  display: inline-block;
  padding: 2px 8px;
  font-size: 12px;
  font-weight: 500;
  line-height: 1.6;
  border-radius: 4px;
  white-space: nowrap;
}

.badge-role {
  color: var(--link);
  background: var(--accent);
  border: 1px solid var(--border);
}

[data-theme="dark"] .badge-role {
  background: var(--accent);
  border-color: var(--border);
}

.badge-tag {
  color: var(--muted);
  background: var(--tag-bg);
  border: 1px solid var(--border);
}

.paper-citation {
  margin: 0;
  font-size: 15px;
  line-height: 1.9;
  color: var(--text);
  text-align: justify;
}

.paper-authors .author-self {
  font-weight: 700;
  color: var(--link);
}

.paper-title {
  font-weight: 600;
  color: var(--heading);
}

.paper-links {
  margin: 8px 0 0;
  font-size: 14px;
}

.paper-links a {
  font-weight: 500;
}

.paper-links .sep {
  color: var(--muted);
  margin: 0 6px;
}

/* ========================================
   Talks / News
   ======================================== */
.talks-list {
  margin: 0;
}

.talk-items {
  list-style: none;
  margin: 0;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
  background: var(--card);
  box-shadow: var(--shadow);
}

.talk-item {
  display: flex;
  align-items: flex-start;
  gap: 20px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-muted);
  transition: background-color 0.15s ease;
}

.talk-item:last-child {
  border-bottom: none;
}

.talk-item:hover {
  background: var(--accent);
}

.talk-date {
  flex-shrink: 0;
  width: 112px;
  font-size: 14px;
  font-weight: 500;
  color: var(--muted);
  line-height: 1.6;
  padding-top: 2px;
}

.talk-date-empty {
  width: 112px;
}

.talk-body {
  flex: 1;
  min-width: 0;
}

.talk-title {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 16px;
  font-weight: 600;
  color: var(--heading);
  text-decoration: none;
  line-height: 1.5;
}

.talk-title:hover {
  color: var(--link);
  text-decoration: none;
}

.talk-icon {
  font-size: 12px;
  color: var(--muted);
  flex-shrink: 0;
}

.talk-source {
  display: block;
  margin-top: 4px;
  font-size: 13px;
  color: var(--muted);
}

@media (max-width: 640px) {
  .talk-item {
    flex-direction: column;
    gap: 6px;
    padding: 14px 16px;
  }

  .talk-date,
  .talk-date-empty {
    width: auto;
  }
}

/* ========================================
   CV
   ======================================== */
.cv-intro {
  margin: 0 0 24px;
}

.cv-preview {
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
  background: var(--card);
  box-shadow: var(--shadow);
}

.cv-preview iframe {
  display: block;
  width: 100%;
  height: 600px;
  border: none;
}

/* ========================================
   Contact
   ======================================== */
.contact-list {
  margin: 0 0 32px;
}

.contact-item {
  margin-bottom: 16px;
}

.contact-item dt {
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  margin-bottom: 2px;
}

.contact-item dd {
  margin: 0;
  color: var(--text);
}

.social-links {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
}

.social-links a {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 15px;
  font-weight: 500;
  color: var(--text);
  text-decoration: none;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--card);
  box-shadow: var(--shadow);
  transition: background-color 0.15s ease, color 0.15s ease;
}

.social-links a:hover {
  background: var(--accent);
  text-decoration: none;
  color: var(--link);
}

.social-links i {
  font-size: 18px;
  color: var(--muted);
}

/* ========================================
   Footer
   ======================================== */
.site-footer {
  max-width: 900px;
  margin: 0 auto;
  padding: 24px;
  text-align: center;
  font-size: 14px;
  color: var(--muted);
  border-top: 1px solid var(--border-muted);
}

.site-footer p {
  margin: 0;
}

.site-footer .site-beian {
  margin-top: 8px;
  font-size: 13px;
}

.site-footer .site-beian a {
  color: var(--muted);
  text-decoration: none;
}

.site-footer .site-beian a:hover {
  color: var(--link);
  text-decoration: underline;
}

/* ========================================
   Responsive
   ======================================== */
@media (max-width: 640px) {
  html {
    scroll-padding-top: 56px;
  }

  .nav-toggle {
    display: flex;
  }

  .nav-links {
    display: none;
    position: absolute;
    top: 56px;
    left: 0;
    right: 0;
    flex-direction: column;
    background: var(--header-bg);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border);
    padding: 8px 16px 16px;
    gap: 2px;
  }

  .nav-links.open {
    display: flex;
  }

  .nav-link {
    padding: 10px 12px;
  }

  .theme-toggle {
    margin-left: auto;
  }

  .hero-top {
    flex-direction: column;
    text-align: center;
    gap: 20px;
  }

  .hero-name {
    font-size: 26px;
  }

  .hero-actions {
    justify-content: center;
  }

  .hero-bio {
    text-align: center;
  }

  .cv-preview iframe {
    height: 400px;
  }

  .social-links {
    flex-direction: column;
  }

  .social-links a {
    justify-content: center;
  }
}
