/* ==========================================================================
   Academic homepage — main stylesheet
   单栏居中布局，浅/深色双主题。改配色只需要动下面的 :root 变量。
   ========================================================================== */

/* --- 0. Webfonts --------------------------------------------------------- */
/* 均为自托管子集，不依赖任何 CDN（Google Fonts 在中国大陆不可达）。

   这些文件是 OFL 1.1 定义下的 Modified Version（改了格式、删了字形），
   因此一律改用中性字体名。原始版权声明保留在各文件的 name 表里，
   完整许可证见同目录 OFL-*.txt。

   size-adjust 统一用 105%：Site Serif / Site Sans 源出同一超家族，
   x-height 分别是 .456 / .461，用同一个系数才能保住两者的视觉配比
   （若各自去贴合系统回退字体，衬线与无衬线反而会大小不一）。 */

@font-face {
  font-family: "Site Serif";          /* 源自 Alegreya (OFL) */
  src: url("../fonts/serif-latin.woff2") format("woff2");
  font-weight: 400 900;               /* 可变字体，一个文件覆盖全字重 */
  font-style: normal;
  font-display: swap;                 /* 字体到达前先用回退字体渲染，不白屏 */
  size-adjust: 105%;
}

@font-face {
  font-family: "Site Sans";           /* 源自 Alegreya Sans (OFL)，含小型大写 */
  src: url("../fonts/sans-latin.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
  size-adjust: 105%;
}

@font-face {
  font-family: "Site Mono";           /* 源自 IBM Plex Mono (OFL) */
  src: url("../fonts/mono-latin.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
  /* 仅 .bib 使用，而 .bib 默认 display:none，
     浏览器要等 BibTeX 展开时才会真正下载这个文件。 */
}

@font-face {
  font-family: "Name ZH";             /* 源自 GenRyuMin2 TC (OFL) */
  src: url("../fonts/name-zh.woff2") format("woff2");
  font-weight: 400 700;               /* 实为 Bold 一档，声明范围以免浏览器再合成粗体 */
  font-style: normal;
  font-display: swap;
  unicode-range: U+738B, U+5FE0, U+51FD;   /* 王 忠 函 —— 仅这三字触发下载 */
}

/* --- 1. Design tokens ---------------------------------------------------- */

:root {
  --bg:            #ffffff;
  --bg-soft:       #f6f7f9;
  --bg-code:       #f6f7f9;
  --fg:            #1f2328;
  --fg-muted:      #5c6670;
  --fg-faint:      #858e97;
  --accent:        #0b5fa5;
  --accent-soft:   #e8f0f8;
  --border:        #e3e6ea;
  --border-strong: #cdd3d9;
  --badge-bg:      #eef2f6;
  --badge-fg:      #35414d;
  --award:         #9a6207;
  --award-bg:      #fdf4e3;

  /* 正文衬线。size-adjust 已做过视觉补偿，字号规则不必另行调整。 */
  --font-body: "Site Serif", "Name ZH", Georgia, "Liberation Serif",
               "Times New Roman", "Songti SC", "SimSun", serif;
  /* 界面元素（导航、标签、日期、按钮）用无衬线：
     小字号下更清晰，也让「内容 / 控件」在视觉上分层。 */
  --font-ui:   "Site Sans", "Name ZH", ui-sans-serif, system-ui,
               -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial,
               "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  --font-mono: "Site Mono", ui-monospace, SFMono-Regular, "SF Mono",
               Menlo, Consolas, "Liberation Mono", monospace;

  --maxw: 56rem;          /* ≈ 896px，学术主页常见宽度 */
  --radius: 6px;
}

html[data-theme="dark"] {
  --bg:            #14171a;
  --bg-soft:       #1b1f23;
  --bg-code:       #1b1f23;
  --fg:            #e4e7ea;
  --fg-muted:      #a3acb5;
  --fg-faint:      #7d868f;
  --accent:        #6cb2f0;
  --accent-soft:   #1c2b3a;
  --border:        #2a3038;
  --border-strong: #3a424b;
  --badge-bg:      #252b32;
  --badge-fg:      #c2cad2;
  --award:         #e0b24c;
  --award-bg:      #2e2617;
}

@media (prefers-color-scheme: dark) {
  html:not([data-theme="light"]) {
    --bg:            #14171a;
    --bg-soft:       #1b1f23;
    --bg-code:       #1b1f23;
    --fg:            #e4e7ea;
    --fg-muted:      #a3acb5;
    --fg-faint:      #7d868f;
    --accent:        #6cb2f0;
    --accent-soft:   #1c2b3a;
    --border:        #2a3038;
    --border-strong: #3a424b;
    --badge-bg:      #252b32;
    --badge-fg:      #c2cad2;
    --award:         #e0b24c;
    --award-bg:      #2e2617;
  }
}

/* --- 2. Base ------------------------------------------------------------- */

*, *::before, *::after { box-sizing: border-box; }

html {
  scroll-behavior: smooth;
  scroll-padding-top: 4.5rem;   /* 让锚点不被顶栏遮住 */
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font-body);
  font-size: 16.5px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--accent);
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: border-color .15s ease, color .15s ease;
}
a:hover { border-bottom-color: currentColor; }

h1, h2, h3, h4 { line-height: 1.3; font-weight: 650; }

img { max-width: 100%; height: auto; }

.muted  { color: var(--fg-muted); }
.note   { color: var(--fg-muted); font-size: .95em; }

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  background: var(--bg);
  padding: .6rem 1rem;
  z-index: 100;
}
.skip-link:focus { left: .5rem; top: .5rem; outline: 2px solid var(--accent); }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 3px;
}

.icon {
  width: 1em;
  height: 1em;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
  vertical-align: -0.13em;
  flex: none;
}

/* --- 3. Top navigation --------------------------------------------------- */

.topnav {
  position: sticky;
  top: 0;
  z-index: 20;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(180%) blur(8px);
  border-bottom: 1px solid var(--border);
}

.topnav__inner {
  font-family: var(--font-ui);
  max-width: var(--maxw);
  margin: 0 auto;
  padding: .55rem 1.5rem;
  display: flex;
  align-items: center;
  gap: 1.25rem;
}

.topnav__brand {
  font-weight: 650;
  color: var(--fg);
  letter-spacing: -0.01em;
}

.topnav__links {
  display: flex;
  gap: 1.1rem;
  margin: 0 0 0 auto;
  padding: 0;
  list-style: none;
  font-size: .9rem;
}
.topnav__links a { color: var(--fg-muted); }
.topnav__links a:hover { color: var(--fg); }

.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  padding: 0;
  font-size: 1rem;
  color: var(--fg-muted);
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
}
.theme-toggle:hover { color: var(--fg); border-color: var(--border-strong); }

.icon-moon { display: none; }
html[data-theme="dark"] .icon-sun  { display: none; }
html[data-theme="dark"] .icon-moon { display: inline; }
@media (prefers-color-scheme: dark) {
  html:not([data-theme="light"]) .icon-sun  { display: none; }
  html:not([data-theme="light"]) .icon-moon { display: inline; }
}

/* --- 4. Layout ----------------------------------------------------------- */

.wrap {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 3rem 1.5rem 4rem;
}

.section { margin-top: 3rem; }

.section > h2 {
  margin: 0 0 1.1rem;
  padding-bottom: .4rem;
  font-family: var(--font-ui);
  font-size: 1.32rem;
  font-weight: 600;
  /* 真·小型大写：由 Site Sans 的 smcp 特性提供，
     比 text-transform: uppercase 把小写字母拉高变形要正得多，
     笔画粗细也和周围文字匹配 —— 期刊标题常用的做法。 */
  font-variant-caps: small-caps;
  letter-spacing: .04em;
  color: var(--fg);
  border-bottom: 1px solid var(--border);
}

.section p { margin: 0 0 .85rem; }

.subhead {
  margin: 1.8rem 0 .8rem;
  font-size: 1rem;
  color: var(--fg-muted);
  font-weight: 600;
}
.publist + .subhead { margin-top: 2.2rem; }

.section-note {
  font-size: .9rem;
  color: var(--fg-muted);
}

.bullets { margin: 0 0 .9rem; padding-left: 1.25rem; }
.bullets li { margin-bottom: .4rem; }

/* --- 5. Masthead --------------------------------------------------------- */

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

.masthead__text { flex: 1 1 auto; min-width: 0; }

.name {
  margin: 0;
  font-size: 2.1rem;
  letter-spacing: -0.02em;
}
.name-alt {
  font-size: .55em;
  font-weight: 400;
  color: var(--fg-muted);
  letter-spacing: 0;
}

.role {
  margin: .35rem 0 .15rem;
  font-size: 1.05rem;
  color: var(--fg);
}

.affil {
  margin: 0;
  color: var(--fg-muted);
  font-size: .97rem;
}
.affil a { color: var(--fg-muted); border-bottom: 1px solid var(--border-strong); }
.affil a:hover { color: var(--accent); }

.linklist {
  font-family: var(--font-ui);
  display: flex;
  flex-wrap: wrap;
  gap: .45rem .5rem;
  margin: 1.1rem 0 0;
  padding: 0;
  list-style: none;
  font-size: .88rem;
}
.linklist a {
  display: inline-flex;
  align-items: center;
  gap: .38rem;
  padding: .25rem .6rem;
  color: var(--fg-muted);
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 100px;
}
.linklist a:hover {
  color: var(--accent);
  border-color: var(--accent);
  background: var(--accent-soft);
}

.masthead__photo { margin: .3rem 0 0; flex: none; }
.masthead__photo img {
  width: 180px;
  height: 180px;
  object-fit: cover;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--bg-soft);
}

/* --- 6. News ------------------------------------------------------------- */

.news {
  margin: 0;
  padding: 0;
  list-style: none;
  /* 条目多的时候内部滚动，不撑长页面；不想要滚动就删掉下面两行 */
  max-height: 15rem;
  overflow-y: auto;
}
.news li {
  display: flex;
  gap: 1rem;
  padding: .32rem 0;
  font-size: .96rem;
}
.news time {
  flex: none;
  width: 6.2rem;
  color: var(--fg-faint);
  font-family: var(--font-ui);
  font-variant-numeric: tabular-nums lining-nums;
  font-size: .9rem;
  padding-top: .08rem;
}

/* --- 7. Publications ----------------------------------------------------- */

.publist {
  margin: 0;
  padding: 0;
  list-style: none;
  counter-reset: pub;
}

.pub {
  display: flex;
  gap: 1.4rem;
  padding: 1.1rem 0;
  border-top: 1px solid var(--border);
}
.publist > .pub:first-child { border-top: none; padding-top: .3rem; }

.pub--highlight {
  border-left: 3px solid var(--accent);
  padding-left: 1rem;
  margin-left: -1rem;
  background: linear-gradient(90deg, var(--accent-soft), transparent 55%);
  border-radius: 0 var(--radius) var(--radius) 0;
}

.pub__teaser { flex: none; width: 190px; }
.pub__teaser img {
  width: 100%;
  aspect-ratio: 16 / 10;
  object-fit: cover;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-soft);
}

.pub__body { flex: 1 1 auto; min-width: 0; }

.pub__title {
  margin: 0 0 .3rem;
  font-size: 1.02rem;
  font-weight: 650;
}
.pub__title a { color: var(--fg); }
.pub__title a:hover { color: var(--accent); }

.pub .pub__authors {
  margin: 0 0 .3rem;
  font-size: .93rem;
  color: var(--fg-muted);
}
.pub__authors strong { color: var(--fg); font-weight: 650; }

.pub .pub__venue {
  margin: 0 0 .45rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .5rem;
}

.badge {
  font-family: var(--font-ui);
  display: inline-block;
  padding: .1rem .5rem;
  font-size: .8rem;
  font-weight: 600;
  color: var(--badge-fg);
  background: var(--badge-bg);
  border-radius: 4px;
  white-space: nowrap;
}
.badge--preprint {
  background: transparent;
  color: var(--fg-muted);
  border: 1px solid var(--border-strong);
}

.pub__extra { font-size: .85rem; color: var(--fg-muted); }
.pub__extra--award {
  color: var(--award);
  background: var(--award-bg);
  padding: .1rem .45rem;
  border-radius: 4px;
  font-weight: 600;
}

.pub .pub__tldr {
  margin: 0 0 .5rem;
  font-size: .92rem;
  color: var(--fg-muted);
}

.pub__links {
  font-family: var(--font-ui);
  display: flex;
  flex-wrap: wrap;
  gap: .4rem;
  margin: 0;
  padding: 0;
  list-style: none;
  font-size: .84rem;
}
.pub__links a,
.bib-toggle {
  display: inline-block;
  padding: .1rem .5rem;
  font: inherit;
  color: var(--accent);
  background: transparent;
  border: 1px solid var(--border-strong);
  border-radius: 4px;
  cursor: pointer;
}
.pub__links a:hover,
.bib-toggle:hover { background: var(--accent-soft); border-color: var(--accent); }

.bib {
  margin: .7rem 0 0;
  padding: .75rem .9rem;
  font-family: var(--font-mono);
  font-size: .8rem;
  line-height: 1.55;
  color: var(--fg-muted);
  background: var(--bg-code);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow-x: auto;
  white-space: pre;
}

/* --- 8. Timeline (education / awards) ------------------------------------ */

.timeline { margin: 0; padding: 0; list-style: none; }
.timeline li {
  display: flex;
  gap: 1.2rem;
  padding: .5rem 0;
}
.timeline--compact li { padding: .25rem 0; }
.timeline__when {
  flex: none;
  width: 8.5rem;
  color: var(--fg-faint);
  font-family: var(--font-ui);
  font-size: .9rem;
  /* lining-nums：Alegreya 默认是 old-style 数字（3/4/7/9 带降部），
     用在日期列会高低参差、破坏对齐，这里切回等高数字。 */
  font-variant-numeric: tabular-nums lining-nums;
  padding-top: .12rem;
}
.timeline__what { flex: 1 1 auto; font-size: .96rem; }

/* --- 9. Footer ----------------------------------------------------------- */

.footer {
  font-family: var(--font-ui);
  margin-top: 3.5rem;
  padding-top: 1.2rem;
  border-top: 1px solid var(--border);
  font-size: .85rem;
  color: var(--fg-faint);
  text-align: center;
}
.footer p { margin: 0; }

/* --- 10. Responsive ------------------------------------------------------ */

@media (max-width: 720px) {
  body { font-size: 16px; }

  .wrap { padding: 2rem 1.15rem 3rem; }

  .topnav__links { display: none; }
  .topnav__inner { padding: .5rem 1.15rem; }
  .theme-toggle { margin-left: auto; }

  .masthead {
    flex-direction: column-reverse;
    align-items: center;
    text-align: center;
    gap: 1.2rem;
  }
  .masthead__photo img { width: 140px; height: 140px; border-radius: 50%; }
  .linklist { justify-content: center; }
  .name { font-size: 1.75rem; }

  .pub { flex-direction: column; gap: .8rem; }
  .pub__teaser { width: 100%; max-width: 320px; }
  .pub--highlight { margin-left: 0; padding-left: .9rem; }

  .news li,
  .timeline li { flex-direction: column; gap: .1rem; }
  .news time,
  .timeline__when { width: auto; }
  .news { max-height: none; }
}

/* --- 11. Print ----------------------------------------------------------- */

@media print {
  .topnav, .theme-toggle, .skip-link { display: none; }
  .wrap { max-width: none; padding: 0; }
  a { color: inherit; border: none; }
  .pub { break-inside: avoid; }
  .news { max-height: none; overflow: visible; }
}
