/* ============================================================
   邓钧元 · 个人主页 — 白底黑白极简风格
   主题: 纯白/浅灰底 + 黑白对比 + 大量留白 + 细分割线
   字体: 标题 Inter(几何无衬线) + 正文系统无衬线 + 等宽 mono
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

:root {
  /* 色板（黑白灰） */
  --bg: #ffffff;
  --bg-soft: #fafafa;
  --bg-card: #ffffff;
  --ink: #111111;
  --ink-soft: #3a3a3a;
  --ink-dim: #6b6b6b;
  --ink-faint: #9a9a9a;
  --line: #e5e5e5;
  --line-soft: #eeeeee;
  --accent: #000000;
  --accent-rev: #ffffff;

  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 18px 48px rgba(0, 0, 0, .06);

  --display: "Inter", "PingFang SC", "Source Han Sans SC", "Microsoft YaHei",
             -apple-system, "Helvetica Neue", sans-serif;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
          "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", sans-serif;
  --mono: "JetBrains Mono", "SFMono-Regular", ui-monospace, Consolas, "Courier New", monospace;

  --nav-h: 72px;
  --maxw: 1020px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
  font-family: var(--sans);
  background: var(--bg);
  color: var(--ink-soft);
  line-height: 1.66;
  letter-spacing: .01em;
  font-size: 1rem;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a { color: var(--ink); text-decoration: none; transition: opacity .2s; border-bottom: 1px solid var(--line); }
a:hover { opacity: .55; }

img { max-width: 100%; display: block; }
::selection { background: var(--ink); color: var(--accent-rev); }

/* ---------- 布局容器 ---------- */
.container { max-width: var(--maxw); margin: 0 auto; padding: 0 20px; }

/* ---------- 顶部导航 ---------- */
.nav {
  position: sticky;
  top: 0;
  z-index: 100;
  height: var(--nav-h);
  background: rgba(255, 255, 255, .9);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.nav-inner {
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  border: none;
}
.brand .logo {
  width: 38px;
  height: 38px;
  flex-shrink: 0;
  border: 1px solid var(--ink);
  display: grid;
  place-items: center;
  font-family: var(--display);
  font-size: .95rem;
  font-weight: 600;
  letter-spacing: .5px;
}
.brand-name { display: flex; flex-direction: column; line-height: 1.15; }
.brand .name-cn {
  font-family: var(--display);
  font-size: 1.02rem;
  font-weight: 600;
  letter-spacing: 1px;
  color: var(--ink);
}
.brand small {
  font-size: .6rem;
  font-weight: 400;
  color: var(--ink-faint);
  letter-spacing: 2px;
  text-transform: uppercase;
}
.nav-links { display: flex; gap: 26px; align-items: center; }
.nav-links a {
  color: var(--ink-dim);
  border: none;
  padding: 6px 0;
  font-size: .92rem;
  letter-spacing: .5px;
  position: relative;
}
.nav-links a::after {
  content: "";
  position: absolute;
  left: 0; bottom: 0;
  width: 0; height: 1px;
  background: var(--ink);
  transition: width .25s;
}
.nav-links a:hover { opacity: 1; }
.nav-links a:hover::after { width: 100%; }
.nav-links a.active { color: var(--ink); }
.nav-links a.active::after { width: 100%; }

.nav-toggle {
  display: none;
  background: none;
  border: none;
  color: var(--ink);
  font-size: 1.5rem;
  cursor: pointer;
  line-height: 1;
}

/* ---------- Hero ---------- */
.hero { padding: 56px 0 34px; }
.hero-grid {
  display: grid;
  grid-template-columns: 1.3fr 1fr;
  gap: 44px;
  align-items: center;
}
.eyebrow {
  font-family: var(--mono);
  font-size: .72rem;
  color: var(--ink-faint);
  letter-spacing: 3px;
  text-transform: uppercase;
  margin-bottom: 16px;
}
h1.hero-title {
  font-family: var(--display);
  font-size: clamp(2rem, 4.4vw, 3rem);
  font-weight: 600;
  line-height: 1.22;
  letter-spacing: -.02em;
  color: var(--ink);
  margin-bottom: 18px;
}
.hero .lead {
  color: var(--ink-dim);
  font-size: 1.06rem;
  max-width: 500px;
  margin-bottom: 26px;
}
.hero .lead strong { color: var(--ink); font-weight: 600; }

.hero-actions { display: flex; gap: 16px; flex-wrap: wrap; }

/* 按钮 */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 13px 26px;
  font-family: var(--display);
  font-size: .92rem;
  font-weight: 500;
  letter-spacing: .4px;
  cursor: pointer;
  border: 1px solid var(--ink);
  transition: all .2s;
}
.btn-primary { background: var(--ink); color: var(--accent-rev); border-bottom: 1px solid var(--ink); }
.btn-primary:hover { background: transparent; color: var(--ink); opacity: 1; }
.btn-ghost { background: transparent; color: var(--ink); }
.btn-ghost:hover { background: var(--ink); color: var(--accent-rev); opacity: 1; }

/* Hero 右侧头像卡 */
.avatar-card {
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 28px 24px;
  text-align: center;
}
.avatar-photo {
  width: 100%;
  max-width: 230px;
  aspect-ratio: 4 / 5;
  margin: 0 auto 16px;
  border-radius: 10px;
  overflow: hidden;
  background: #f0f0f0;
  border: 1px solid var(--line);
  display: grid;
  place-items: center;
}
.avatar-photo img { width: 100%; height: 100%; object-fit: cover; }
.avatar-photo .avatar-initials {
  font-family: var(--display);
  font-size: 3rem;
  font-weight: 600;
  color: var(--ink-faint);
  letter-spacing: 2px;
}
.avatar-photo.has-photo .avatar-initials { display: none; }
.avatar-name {
  font-family: var(--display);
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--ink);
  margin-bottom: 4px;
}
.avatar-name-en {
  font-family: var(--mono);
  font-size: .72rem;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--ink-faint);
  margin-bottom: 10px;
}
.avatar-title { font-size: .96rem; color: var(--ink); margin-bottom: 6px; }
.avatar-headline { font-size: .84rem; color: var(--ink-dim); margin-bottom: 16px; line-height: 1.6; }
.avatar-email {
  display: inline-block;
  font-family: var(--mono);
  font-size: .8rem;
  color: var(--ink-dim);
  border-bottom: 1px solid var(--ink);
  padding-bottom: 2px;
  word-break: break-all;
}
.avatar-email:hover { opacity: .6; }

/* 经历卡片 */
.exp-list {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1px;
  background: var(--line);
  border: 1px solid var(--line);
}
.exp-card { background: var(--bg-card); padding: 22px; transition: background .2s; }
.exp-card:hover { background: var(--bg-soft); }
.exp-head { margin-bottom: 8px; }
.exp-title {
  font-family: var(--display);
  font-size: 1.14rem;
  font-weight: 600;
  color: var(--ink);
  margin-bottom: 3px;
}
.exp-role { font-size: .92rem; color: var(--ink-dim); margin-bottom: 4px; }
.exp-period {
  font-family: var(--mono);
  font-size: .74rem;
  color: var(--ink-faint);
  letter-spacing: .5px;
}
.exp-desc { font-size: .92rem; color: var(--ink-dim); margin-bottom: 10px; }
.exp-detail {
  font-size: .9rem;
  color: var(--ink-dim);
  margin-bottom: 12px;
  line-height: 1.7;
}
.exp-link-wrap { margin-top: 14px; }
.exp-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: .84rem;
  color: var(--ink);
  border: 1px solid var(--ink);
  padding: 6px 14px;
  border-radius: 6px;
  transition: all .18s;
}
.exp-link:hover { background: var(--ink); color: var(--accent-rev); opacity: 1; }

/* ---------- 段落通用 ---------- */
section { padding: 32px 0; }
.section-head { margin-bottom: 20px; }
.section-head h2 {
  font-family: var(--display);
  font-weight: 600;
  font-size: clamp(1.55rem, 2.6vw, 1.95rem);
  color: var(--ink);
  letter-spacing: -.02em;
  margin-bottom: 8px;
}
.section-head p { color: var(--ink-dim); max-width: 580px; font-size: .97rem; }
.section-foot { margin-top: 22px; }

/* ---------- 统计条 ----------
   列数由卡片数量决定（JS 写入 --stat-cols），这样增删统计项都不用改 CSS */
.stats-row {
  display: grid;
  grid-template-columns: repeat(var(--stat-cols, 4), 1fr);
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}
.stat-card { padding: 24px 8px; text-align: center; border-right: 1px solid var(--line); }
.stat-card:last-child { border-right: none; }
.stat-card .num {
  font-family: var(--display);
  font-size: 2.2rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
  line-height: 1.1;
}
.stat-card .lbl {
  color: var(--ink-faint);
  font-size: .72rem;
  letter-spacing: 1px;
  margin-top: 8px;
  text-transform: uppercase;
}

/* ---------- 卡片网格（细线框） ---------- */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1px; background: var(--line); border: 1px solid var(--line); }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1px; background: var(--line); border: 1px solid var(--line); }

/* 奇数张卡片时最后一张横跨整行，避免网格出现空白格 */
.grid-2 > :last-child:nth-child(odd) { grid-column: 1 / -1; }

/* 三列布局：最后一行不满 3 张时让末张卡片加宽，避免右侧留空白格。
   4 张（余 1）→ 末张跨 3 列；5 张（余 2）→ 末张跨 2 列；6 张 → 正好两行不变。
   用 :has() 精确判断最后一个子元素在 3 列网格中的位置；
   旧浏览器忽略此规则，退化为普通网格，不影响内容可读性。 */
.grid-3:has(> :last-child:nth-child(3n + 1)):not(:has(> :nth-child(6))) > :last-child { grid-column: 1 / -1; }
.grid-3:has(> :last-child:nth-child(3n + 2)) > :last-child { grid-column: span 2; }

.card { background: var(--bg-card); padding: 24px; transition: background .2s; }
.card:hover { background: var(--bg-soft); }
.card .chip {
  display: inline-block;
  font-family: var(--mono);
  font-size: .64rem;
  letter-spacing: 1.5px;
  color: var(--ink-faint);
  text-transform: uppercase;
  border-bottom: 1px solid var(--ink);
  padding-bottom: 3px;
  margin-bottom: 12px;
}
.card h3 { font-size: 1.12rem; font-family: var(--display); color: var(--ink); font-weight: 600; margin-bottom: 8px; line-height: 1.4; }
.card p { font-size: .91rem; color: var(--ink-dim); }
.card .meta { font-family: var(--mono); font-size: .72rem; color: var(--ink-faint); margin-top: 12px; }
.card .tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 14px; }
.tag {
  font-family: var(--mono);
  font-size: .67rem;
  letter-spacing: .5px;
  padding: 3px 10px;
  border: 1px solid var(--line);
  color: var(--ink-dim);
}

/* ---------- 出版物 ---------- */
.pub-item {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 20px;
  padding: 20px 0;
  border-bottom: 1px solid var(--line);
}
.pub-item:last-child { border-bottom: none; }
.pub-badge { min-width: 66px; }
.pub-badge .yr { display: block; font-family: var(--display); font-size: 1.2rem; font-weight: 600; color: var(--ink); }
.pub-badge .type { font-family: var(--mono); font-size: .64rem; letter-spacing: 1px; color: var(--ink-faint); margin-top: 4px; display: block; }
.pub-title { font-family: var(--display); font-size: 1.08rem; font-weight: 600; color: var(--ink); margin-bottom: 6px; line-height: 1.45; }
.pub-authors { font-size: .86rem; color: var(--ink-dim); margin-bottom: 4px; }
.pub-authors .me { font-weight: 600; color: var(--ink); text-decoration: underline; text-underline-offset: 3px; }
.pub-venue { font-size: .77rem; color: var(--ink-faint); font-family: var(--mono); line-height: 1.6; }
.pub-badges { margin-top: 8px; display: flex; flex-wrap: wrap; gap: 6px; }
.pub-detail { font-size: .89rem; color: var(--ink-dim); margin-top: 8px; line-height: 1.7; }

/* 论文卡片（首页） */
.paper-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1px; background: var(--line); border: 1px solid var(--line); }
.paper-card {
  background: var(--bg-card);
  padding: 22px;
  transition: background .2s;
  display: flex;
  flex-direction: column;
}
.paper-card:hover { background: var(--bg-soft); }
.paper-meta { display: flex; align-items: baseline; gap: 10px; margin-bottom: 12px; }
.paper-year { font-family: var(--display); font-size: 1.22rem; font-weight: 600; color: var(--ink); }
.paper-type { font-family: var(--mono); font-size: .68rem; letter-spacing: 1px; color: var(--ink-faint); }
.paper-title {
  font-family: var(--display);
  font-weight: 600;
  font-size: 1.02rem;
  line-height: 1.45;
  color: var(--ink);
  margin-bottom: 10px;
  flex: 1;
}
.paper-authors { font-size: .84rem; color: var(--ink-dim); margin-bottom: 8px; }
.paper-authors .me { font-weight: 600; color: var(--ink); text-decoration: underline; text-underline-offset: 3px; }
.paper-more { font-style: normal; color: var(--ink-faint); }
.paper-venue { font-family: var(--mono); font-size: .73rem; color: var(--ink-faint); margin-bottom: 10px; line-height: 1.6; }
.paper-badges { display: flex; flex-wrap: wrap; gap: 6px; margin-top: auto; }
.paper-detail { font-size: .89rem; color: var(--ink-dim); margin-bottom: 12px; line-height: 1.7; }
.paper-link-wrap { margin-top: 14px; }
.paper-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: .83rem;
  color: var(--ink);
  border: 1px solid var(--ink);
  padding: 6px 14px;
  border-radius: 6px;
  transition: all .18s;
}
.paper-link:hover { background: var(--ink); color: var(--accent-rev); opacity: 1; }

/* 整卡可点 */
.u-card-clickable { position: relative; }
.u-card-clickable.is-clickable { cursor: pointer; }
.card-corner {
  position: absolute;
  top: 12px;
  right: 14px;
  font-size: .8rem;
  color: var(--ink-faint);
  transition: color .18s;
}
.u-card-clickable.is-clickable:hover .card-corner { color: var(--ink); }
.u-card-clickable.is-clickable:focus-visible { outline: 2px solid var(--ink); outline-offset: -2px; }

/* ---------- 博客 ---------- */
.blog-list { display: grid; gap: 1px; background: var(--line); border: 1px solid var(--line); }
.blog-item { background: var(--bg-card); padding: 24px; transition: background .2s; }
.blog-item:hover { background: var(--bg-soft); }
.blog-meta {
  display: flex;
  align-items: center;
  gap: 12px;
  font-family: var(--mono);
  font-size: .71rem;
  color: var(--ink-faint);
  letter-spacing: .5px;
  margin-bottom: 10px;
}
.blog-meta .cat { color: var(--ink); font-weight: 600; }
.blog-item h3 { margin-bottom: 8px; }
.blog-item h3 a {
  font-family: var(--display);
  font-weight: 600;
  font-size: 1.18rem;
  color: var(--ink);
  border: none;
  line-height: 1.4;
}
.blog-item h3 a:hover { opacity: .5; }
.blog-item p { color: var(--ink-dim); font-size: .91rem; margin-bottom: 12px; }
.blog-read {
  font-size: .84rem;
  color: var(--ink);
  border-bottom: 1px solid var(--ink);
  padding-bottom: 2px;
}

/* 文章正文 */
.post-wrap { max-width: 720px; margin: 0 auto; }
.post-title {
  font-family: var(--display);
  font-size: clamp(1.6rem, 3.4vw, 2.1rem);
  font-weight: 600;
  line-height: 1.38;
  margin-bottom: 16px;
  color: var(--ink);
  letter-spacing: -.01em;
}
.post-body { border-top: 1px solid var(--line); padding-top: 26px; }
.post-body p {
  margin-bottom: 1.4em;
  color: var(--ink-soft);
  font-size: 1.03rem;
  line-height: 1.85;
}
.post-foot { margin-top: 40px; }

/* ---------- 联系 ---------- */
.contact-intro { max-width: 620px; }
/* 卡片数量为奇数时，最后一张横跨整行，避免出现空白格 */
.contact-links {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1px;
  background: var(--line);
  border: 1px solid var(--line);
  margin-top: 22px;
}
.contact-links > :last-child:nth-child(odd) { grid-column: 1 / -1; }
.contact-card {
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--bg-card);
  padding: 20px 18px;
  border: none;
  transition: background .2s;
}
.contact-card:hover { background: var(--bg-soft); opacity: 1; }
.contact-card .ic {
  width: 42px; height: 42px;
  border: 1px solid var(--line);
  display: grid;
  place-items: center;
  font-size: 1.1rem;
  flex-shrink: 0;
}
.contact-card .tt { font-family: var(--display); font-weight: 600; color: var(--ink); }
.contact-card .ss { font-size: .78rem; color: var(--ink-faint); word-break: break-all; font-family: var(--mono); }

/* ---------- 页脚 ---------- */
.footer { border-top: 1px solid var(--line); padding: 28px 0; margin-top: 30px; }
.footer-inner { display: flex; justify-content: space-between; align-items: center; gap: 20px; flex-wrap: wrap; }
.footer .copy { color: var(--ink-faint); font-size: .83rem; }
.footer .nav-links { gap: 20px; }
.footer .nav-links a { font-size: .8rem; color: var(--ink-dim); }

/* ---------- 动画 ---------- */
.reveal { opacity: 0; transform: translateY(18px); transition: opacity .6s ease, transform .6s ease; }
.reveal.in { opacity: 1; transform: none; }

/* 减少动效偏好 */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .reveal { opacity: 1; transform: none; transition: none; }
}

/* ---------- 响应式 ---------- */
@media (max-width: 860px) {
  .hero { padding: 32px 0 24px; }
  .hero-grid { grid-template-columns: 1fr; gap: 30px; }
  .grid-3 { grid-template-columns: repeat(2, 1fr); }
  /* 移动端统计改为两列；用 nth-child 处理任意卡片数量的分隔线 */
  .stats-row { grid-template-columns: repeat(2, 1fr); }
  .stat-card { border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); }
  .stat-card:nth-child(2n) { border-right: none; }
  .stat-card:last-child { border-bottom: none; }
  /* 最后一行只有一个时，横跨整行 */
  .stat-card:last-child:nth-child(odd) { grid-column: 1 / -1; border-right: none; }
  .nav-links {
    position: fixed;
    top: var(--nav-h);
    left: 0; right: 0;
    flex-direction: column;
    align-items: flex-start;
    background: var(--bg);
    border-bottom: 1px solid var(--line);
    padding: 14px 26px;
    gap: 6px;
    transform: translateY(-10px);
    opacity: 0;
    pointer-events: none;
    transition: opacity .2s, transform .2s;
  }
  .nav-links.open { transform: none; opacity: 1; pointer-events: auto; }
  .nav-links a { width: 100%; }
  .nav-toggle { display: block; }
  .contact-links, .exp-list, .paper-grid { grid-template-columns: 1fr; }
  section { padding: 24px 0; }
  .container { padding: 0 16px; }
}

@media (max-width: 560px) {
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .stats-row { grid-template-columns: repeat(2, 1fr); }
  .pub-item { grid-template-columns: 1fr; gap: 8px; }
  .hero-actions .btn { width: 100%; justify-content: center; }
}

/* ---------- 打印 ---------- */
@media print {
  .nav, .footer, .hero-actions { display: none; }
  body { color: #000; }
  .reveal { opacity: 1; transform: none; }
}
