/* ==========================================================
   个人学术主页样式
   设计参考：jiazhenpan.me 的配色与卡片语言 + jiajunwu.com 的学术排版
   ========================================================== */

:root {
  --bg: #ffffff;
  --bg-elev: #f7f8fc;
  --text: #111827;
  --muted: #5b6472;
  --brand: #0e7490;
  --brand-2: #0891b2;
  --accent: #b45309;
  --border: #e6e8ee;
  --card: #ffffff;
  --shadow: 0 8px 24px rgba(15, 23, 42, .06);
  --news-link: #16a34a;
  --news-link-hover: #15803d;
  --radius: 14px;
  --font: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", Arial, "PingFang SC", "Microsoft YaHei", sans-serif;
  --font-serif: "Roboto Slab", Georgia, "Songti SC", serif;
}

html[data-theme="dark"] {
  --bg: #0b1020;
  --bg-elev: #11162a;
  --text: #e6e9f0;
  --muted: #a5b0c4;
  --brand: #22d3ee;
  --brand-2: #67e8f9;
  --accent: #fbbf24;
  --border: #212a44;
  --card: #0f1529;
  --shadow: 0 10px 30px rgba(2, 6, 23, .38);
  --news-link: #4ade80;
  --news-link-hover: #86efac;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 84px; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  transition: background .25s ease, color .25s ease;
}
img { max-width: 100%; display: block; }
a { color: var(--brand); text-decoration: none; }
a:hover { color: var(--brand-2); }
a:focus-visible { outline: 2px solid var(--brand-2); outline-offset: 2px; border-radius: 4px; }

.container { width: 100%; max-width: 1120px; margin: 0 auto; padding: 0 24px; }
.section { padding: 72px 0; }
.section.alt { background: var(--bg-elev); border-block: 1px solid var(--border); }
.section-title {
  font-family: var(--font-serif);
  font-size: 30px; font-weight: 600; margin: 0 0 10px 0;
  padding-bottom: 12px; border-bottom: 2px solid var(--brand);
  display: inline-block;
}
.section-desc { color: var(--muted); margin: 0 0 28px 0; max-width: 760px; }
.minor-heading { font-size: 15px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin: 28px 0 10px; font-weight: 600; }

.skip-link { position: absolute; left: -9999px; }
.skip-link:focus { position: static; width: auto; height: auto; padding: 10px 14px; background: var(--brand); color: #fff; }

/* ---------- Header ---------- */
.site-header {
  position: sticky; top: 0; z-index: 50;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(10px) saturate(1.4);
  border-bottom: 1px solid var(--border);
}
.header-inner { display: flex; align-items: center; justify-content: space-between; min-height: 64px; gap: 16px; }
.brand { font-family: var(--font-serif); font-size: 20px; font-weight: 600; color: var(--text); letter-spacing: .01em; }
.brand:hover { color: var(--brand); }
.primary-nav { position: relative; display: flex; align-items: center; gap: 8px; }
.nav-toggle { display: none; flex-direction: column; gap: 4px; background: transparent; border: 0; color: var(--text); cursor: pointer; padding: 8px; }
.nav-toggle .bar { width: 22px; height: 2px; background: var(--text); border-radius: 2px; transition: transform .25s ease, opacity .25s ease; }
.nav-list { display: flex; gap: 4px; list-style: none; margin: 0; padding: 0; }
.nav-link { color: var(--text); text-decoration: none; padding: 7px 12px; border-radius: 9px; font-size: 15px; transition: all .2s ease; }
.nav-link:hover { background: var(--bg-elev); color: var(--brand); }
.nav-link.active { color: var(--brand); font-weight: 600; background: var(--bg-elev); }
.theme-toggle { background: transparent; border: 1px solid var(--border); border-radius: 10px; padding: 6px; cursor: pointer; color: var(--text); }
.theme-toggle:hover { border-color: var(--brand); color: var(--brand); }
.theme-toggle .icon { width: 20px; height: 20px; display: block; }

/* ---------- Hero ---------- */
.hero { padding-top: 56px; padding-bottom: 64px; }
.hero-inner { display: grid; grid-template-columns: 260px 1fr; gap: 48px; align-items: start; }
.avatar-container {
  width: 220px; height: 220px; border-radius: 18px; overflow: hidden;
  background: var(--bg-elev); border: 1px solid var(--border); box-shadow: var(--shadow);
}
.avatar-container img { width: 100%; height: 100%; object-fit: cover; object-position: top center; }
.socials { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 18px; }
.social {
  display: inline-flex; align-items: center; gap: 6px; padding: 7px 12px;
  border: 1px solid var(--border); border-radius: 999px; color: var(--brand);
  background: var(--card); text-decoration: none; font-size: 13px; font-weight: 500;
  transition: all .2s ease;
}
.social:hover { color: var(--brand-2); border-color: var(--brand-2); transform: translateY(-1px); }
.social .icon { width: 16px; height: 16px; flex-shrink: 0; }
.hero-content .title { font-family: var(--font-serif); font-size: 40px; margin: 0 0 6px 0; letter-spacing: -.01em; }
.hero-content .subtitle { margin: 0 0 20px 0; color: var(--brand); font-weight: 500; font-size: 16px; }
.hero-content .description p { margin: 0 0 14px 0; }
/* bio 里的 Note 段落：红色字体，整句加粗 */
.bio-note {
  color: #c0392b;
  font-weight: 600;
}
html[data-theme="dark"] .bio-note { color: #ff6b6b; }
/* bio 里的合作者姓名：与副标题同色 */
.hero-content .description a {
  color: var(--brand);
  font-weight: 500;
  text-decoration: none;
}
.hero-content .description a:hover { color: var(--brand-2); text-decoration: underline; }
.keyword-row { display: flex; flex-wrap: wrap; gap: 8px; margin: 20px 0; }
.keyword {
  font-size: 13px; padding: 5px 12px; border-radius: 999px;
  background: var(--bg-elev); border: 1px solid var(--border); color: var(--muted);
}
.cv-row { display: flex; gap: 10px; flex-wrap: wrap; margin: 18px 0 4px; }
.btn {
  display: inline-block; padding: 9px 20px; border-radius: 10px; font-size: 14px; font-weight: 600;
  border: 1px solid var(--brand); color: var(--brand); background: transparent; transition: all .2s ease;
}
.btn:hover { background: var(--brand); color: #fff; border-color: var(--brand); }
.affil-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.affil-list li { padding-left: 16px; position: relative; color: var(--muted); font-size: 15px; font-weight: 600; }
.affil-list li::before { content: "▸"; position: absolute; left: 0; color: var(--brand); }

/* ---------- Timeline ---------- */
.timeline { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; max-height: 440px; overflow-y: auto; padding-right: 6px; }
.timeline li {
  display: flex; gap: 16px; align-items: flex-start;
  padding: 11px 14px; border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--card); transition: border-color .2s ease;
}
.timeline li:hover { border-color: var(--brand); }
.timeline .time { flex: 0 0 110px; font-weight: 600; color: var(--brand); font-variant-numeric: tabular-nums; font-size: 14px; }
.timeline .event { opacity: .92; font-weight: 500; font-size: 15px; }
.timeline .event p { margin: 0 0 4px 0; }
.timeline .event p:last-child { margin-bottom: 0; }
/* 新闻里的论文/项目链接：饱满的绿色 */
.timeline .event a { color: var(--news-link); font-weight: 600; text-underline-offset: 3px; text-decoration-thickness: 1.5px; }
.timeline .event a:hover { color: var(--news-link-hover); text-decoration: underline; }
.timeline::-webkit-scrollbar { width: 8px; }
.timeline::-webkit-scrollbar-thumb { background: var(--border); border-radius: 8px; }
.timeline::-webkit-scrollbar-thumb:hover { background: var(--brand); }

/* ---------- Scroll pane（滚动窗格）---------- */
.scroll-pane {
  max-height: 460px;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding-right: 10px;
  /* 底部渐隐，提示还有更多内容 */
  -webkit-mask-image: linear-gradient(to bottom, #000 0, #000 calc(100% - 28px), transparent 100%);
  mask-image: linear-gradient(to bottom, #000 0, #000 calc(100% - 28px), transparent 100%);
}
.scroll-pane::-webkit-scrollbar { width: 8px; }
.scroll-pane::-webkit-scrollbar-track { background: transparent; }
.scroll-pane::-webkit-scrollbar-thumb { background: var(--border); border-radius: 8px; }
.scroll-pane::-webkit-scrollbar-thumb:hover { background: var(--brand); }
.scroll-pane > li:last-child { margin-bottom: 28px; }
/* 滚到底部后取消底部渐隐，表明内容已读完 */
.scroll-pane.is-end {
  -webkit-mask-image: none;
  mask-image: none;
}
.scroll-pane.is-end > li:last-child { margin-bottom: 0; }

/* talks 里的附加链接 */
.event-links { display: inline-flex; flex-wrap: wrap; gap: 6px; margin-left: 8px; vertical-align: middle; }
.event-links a {
  display: inline-block; padding: 1px 9px; border: 1px solid var(--border);
  border-radius: 999px; font-size: 12px; font-weight: 500; text-decoration: none;
  color: var(--brand); transition: all .2s ease;
}
.event-links a:hover { border-color: var(--brand); background: var(--brand); color: #fff; }

/* ---------- Logo 墙 ---------- */
.logo-wall {
  display: flex; flex-wrap: wrap; align-items: center;
  gap: 18px 30px; padding: 20px 0 4px;
}
.logo-item {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 44px; padding: 6px 10px; border-radius: 10px;
  flex: 0 0 auto;                     /* 不被 flex 压缩 */
  transition: transform .2s ease, opacity .2s ease;
}
.logo-item img {
  max-height: 42px; max-width: 220px; width: auto; height: auto;
  object-fit: contain; flex: 0 0 auto;
}
/* 方形/圆形徽标（如 SJTU 校徽）单独放大，避免被统一高度压得太小 */
.logo-item img[src*="sjtu"] {
  max-height: 68px; max-width: 68px;
}
/* 深色 logo 在浅色主题显示，浅色 logo 在深色主题显示 */
html[data-theme="dark"] .logo-item .logo-light { display: none; }
html:not([data-theme="dark"]) .logo-item .logo-dark { display: none; }
.logo-item:hover { transform: translateY(-2px); opacity: .78; }

/* ---------- Talks 子板块 ---------- */
.sub-section { margin-bottom: 34px; }
.sub-section:last-child { margin-bottom: 0; }
.sub-section .minor-heading { margin-top: 0; margin-bottom: 12px; }
.sub-section .timeline { max-height: none; overflow: visible; }

/* ---------- Research tabs ---------- */
.research-tabs { display: flex; gap: 10px; flex-wrap: wrap; margin: 0 0 24px 0; }
.research-tab {
  appearance: none; border: 1px solid var(--border); background: var(--card); color: var(--text);
  padding: 9px 18px; border-radius: 999px; cursor: pointer; font-size: 14px; font-family: inherit;
  line-height: 1.2; transition: all .2s ease;
}
.research-tab:hover { border-color: var(--brand); color: var(--brand); }
.research-tab.is-active { background: var(--brand); color: #fff; border-color: var(--brand); font-weight: 600; }

/* ---------- Publication cards ---------- */
.pub-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 14px; }
.pub-item { border: 1px solid var(--border); background: var(--card); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); transition: border-color .2s ease, transform .2s ease; }
.pub-item:hover { border-color: var(--brand); transform: translateY(-2px); }
.pub-title { font-weight: 600; font-size: 17px; margin-bottom: 8px; line-height: 1.45; }
.pub-authors { color: var(--muted); font-size: 14.5px; margin-bottom: 10px; }
.pub-venue { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; font-size: 14px; }
.venue-text { color: var(--muted); }
.badge {
  display: inline-block; background: var(--brand); color: #fff; border-radius: 6px;
  padding: 3px 10px; font-size: 12px; font-weight: 700; letter-spacing: .02em;
}
.pub-links a {
  display: inline-block; margin-right: 8px; padding: 4px 12px; border: 1px solid var(--border);
  border-radius: 8px; font-size: 13px; text-decoration: none; color: var(--brand); transition: all .2s ease;
}
.pub-links a:hover { border-color: var(--brand); background: var(--brand); color: #fff; }
/* ---------- Footer ---------- */
.site-footer { border-top: 1px solid var(--border); padding: 26px 0; background: var(--bg-elev); }
.footer-inner { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.footer-inner p { margin: 0; color: var(--muted); font-size: 14px; }
.back-to-top { font-size: 14px; }

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .hero-inner { grid-template-columns: 1fr; gap: 28px; }
  .avatar-container { width: 150px; height: 150px; }
  .hero-content .title { font-size: 32px; }
}
@media (max-width: 640px) {
  .container { padding: 0 16px; }
  .section { padding: 52px 0; }
  .section-title { font-size: 24px; }
  .nav-toggle { display: flex; }
  .nav-list {
    position: absolute; right: 0; top: 110%; flex-direction: column; gap: 2px;
    background: var(--card); border: 1px solid var(--border); border-radius: 12px;
    padding: 8px; display: none; min-width: 200px; box-shadow: var(--shadow);
  }
  .nav-list.open { display: flex; }
  .timeline li { flex-direction: column; gap: 4px; }
  .timeline .time { flex: none; }
  .scroll-pane { max-height: 400px; }
  .event-links { margin-left: 0; margin-top: 6px; }
}

.topic-desc {
  color: var(--muted); margin: 0 0 22px 0; max-width: 780px;
  min-height: 26px; transition: opacity .2s ease;
}

/* 某个方向暂时没有论文时的占位提示 */
.topic-empty {
  border: 1px dashed var(--border); border-radius: var(--radius);
  padding: 28px 24px; text-align: center; color: var(--muted);
  font-size: 15px; background: var(--card);
}
.topic-empty[hidden] { display: none; }
