/* Layout and visual system follow tianxingchen.github.io's public homepage template. */
@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@400;500;600&family=Source+Serif+4:ital,opsz,wght@0,8..60,300;0,8..60,400;0,8..60,600;1,8..60,300;1,8..60,400&family=JetBrains+Mono:wght@400;500&display=swap');

:root {
  --bg: #f8f7f4;
  --grid-color: rgba(90, 80, 70, .14);
  --text: #1a1a1a;
  --text-muted: #666;
  --text-light: #73706b;
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --border: #d4d0c8;
  --tag-bg: #f0ede8;
  --tag-border: #d4d0c8;
  --max-width: 920px;
  --section-gap: 32px;
  --panel-bg: rgba(255, 255, 255, .52);
  --font-serif: 'Source Serif 4', 'Noto Serif SC', 'Songti SC', Georgia, serif;
  --font-hand: 'Poppins', 'PingFang SC', 'Microsoft YaHei', 'Segoe UI', sans-serif;
  --font-mono: 'JetBrains Mono', 'Courier New', monospace;
  /* One 1.125 type scale: metadata, supporting text, body, paper, section, name. */
  --type-ratio: 1.125;
  --font-base: 1rem;
  --font-sm: calc(var(--font-base) / var(--type-ratio));
  --font-xs: calc(var(--font-sm) / var(--type-ratio));
  --font-paper: calc(var(--font-base) * var(--type-ratio));
  --font-section: calc(var(--font-paper) * var(--type-ratio) * var(--type-ratio) * var(--type-ratio) * var(--type-ratio));
  --font-name: calc(var(--font-section) * var(--type-ratio) * var(--type-ratio) * var(--type-ratio) * var(--type-ratio) * var(--type-ratio));
  --font-name-compact: calc(var(--font-name) / var(--type-ratio) / var(--type-ratio));
  --radius-sm: 4px;
  --radius-md: 8px;
  --transition: 150ms ease;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; scroll-padding-top: 56px; }
body {
  font-family: var(--font-serif);
  font-size: var(--font-base);
  line-height: 1.65;
  color: var(--text);
  background-color: var(--bg);
  background-image:
    radial-gradient(circle, var(--grid-color) 1px, transparent 1px),
    linear-gradient(180deg, rgba(255,255,255,.4) 0%, transparent 260px);
  background-size: 24px 24px, 100% 100%;
  min-height: 100vh;
}
a { color: var(--accent); text-decoration: none; transition: color var(--transition); }
a:hover { color: var(--accent-hover); text-decoration: underline; }
a:focus-visible, button:focus-visible, summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; border-radius: var(--radius-sm); }
strong { font-weight: 600; }
img { max-width: 100%; }

.container { max-width: var(--max-width); margin: 0 auto; padding: 56px 32px 80px; }
.site-header { position: relative; margin-bottom: 16px; }
.site-header h1 {
  font-family: var(--font-hand);
  font-size: var(--font-name);
  font-weight: 500;
  letter-spacing: -.5px;
  line-height: 1.1;
  margin-bottom: 12px;
  padding-right: 160px;
}
.language-switch { position: absolute; top: 8px; right: 0; display: inline-flex; padding: 4px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--tag-bg); }
.language-switch button { min-width: 48px; min-height: 28px; padding: 4px 8px; border: 0; border-radius: var(--radius-sm); background: transparent; color: var(--text-muted); font-family: var(--font-hand); font-size: var(--font-xs); font-weight: 400; line-height: 1.4; cursor: pointer; transition: background var(--transition), color var(--transition); }
.language-switch button:hover { color: var(--accent); }
.language-switch button[aria-pressed="true"] { background: #fff; color: var(--accent); font-weight: 500; box-shadow: 0 1px 2px rgba(0,0,0,.06); }
.language-switch[hidden], .news-toggle[hidden] { display: none; }
.visually-hidden { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }
.site-header .tagline {
  font-family: var(--font-mono);
  font-size: var(--font-xs);
  color: var(--text-muted);
  letter-spacing: .02em;
  line-height: 1.65;
}
.site-header .tagline span { margin: 0 8px; color: var(--text-light); }

section { margin-bottom: var(--section-gap); }
section:last-of-type { margin-bottom: 0; }
hr.unseen-section-divider { border: none; margin: 0 0 var(--section-gap); }

.bio-section { display: flex; gap: 24px; align-items: flex-start; margin-bottom: 16px; }
.bio-avatar { flex-shrink: 0; }
.bio-text { min-width: 0; }
.bio-avatar img {
  width: 120px;
  height: 120px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--border);
  display: block;
}
.bio-text p { margin-bottom: 12px; font-size: var(--font-base); text-wrap: pretty; }
.bio-text p:last-child { margin-bottom: 0; }
.bio-badges { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.stat-badge { display: inline-flex; overflow: hidden; border-radius: var(--radius-sm); font-family: var(--font-hand); font-size: var(--font-xs); line-height: 24px; white-space: nowrap; color: #fff; }
.stat-label { padding: 0 8px; background: #555; }
.stat-value { padding: 0 8px; font-weight: 500; }
.stat-dark { background: #181717; }
.stat-blue { background: var(--accent); }
.profile-details { margin-top: 12px; }
.profile-details summary {
  cursor: pointer;
  font-family: var(--font-mono);
  font-size: var(--font-xs);
  line-height: 1.4;
  color: var(--text-muted);
  user-select: none;
}
.profile-details-body { margin-top: 12px; line-height: 1.7; color: var(--text-muted); }
.profile-details-body p { font-size: var(--font-sm); }

.contact-invite { margin: 0 0 8px; font-size: var(--font-sm); color: var(--text-muted); line-height: 1.65; text-wrap: pretty; }
.social-links { display: flex; flex-wrap: wrap; gap: 8px; margin: 4px 0; }
.social-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: var(--font-xs);
  line-height: 1.4;
  color: var(--text);
  background: rgba(255,255,255,.6);
  transition: border-color var(--transition), background var(--transition), color var(--transition);
  text-decoration: none;
  letter-spacing: .01em;
  cursor: pointer;
}
.social-btn:hover { border-color: var(--accent); color: var(--accent); background: rgba(255,255,255,.9); text-decoration: none; }
.social-btn span { width: 16px; height: 16px; display: inline-flex; align-items: center; justify-content: center; font-size: var(--font-xs); }

.wechat-popover {
  position: fixed;
  inset: 0;
  margin: auto;
  width: min(320px, calc(100vw - 32px));
  max-height: calc(100dvh - 32px);
  padding: 16px;
  overflow: auto;
  overscroll-behavior: contain;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text);
  background: var(--bg);
  font-family: var(--font-serif);
  box-shadow: 0 16px 48px rgba(26,26,26,.16);
}
.wechat-popover::backdrop { background: rgba(26,26,26,.24); }
.wechat-popover-header { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.wechat-popover-header h2 { font-family: var(--font-hand); font-size: var(--font-paper); font-weight: 500; line-height: 1.4; }
.wechat-close { display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; width: 44px; height: 44px; border: 0; border-radius: var(--radius-sm); background: transparent; color: var(--text-muted); font: inherit; font-size: 24px; cursor: pointer; }
.wechat-close:hover { color: var(--accent); background: var(--tag-bg); }
.wechat-card-image { display: block; width: 256px; max-width: 100%; height: auto; margin: 8px auto 0; border-radius: var(--radius-sm); background: #fff; }
.wechat-note { margin-top: 8px; font-size: var(--font-xs); line-height: 1.6; color: var(--text-muted); }
.wechat-full-link { display: inline-block; margin-top: 8px; font-family: var(--font-mono); font-size: var(--font-xs); line-height: 1.5; }

.section-title {
  font-family: var(--font-hand);
  font-size: var(--font-section);
  font-weight: 500;
  color: var(--text);
  margin-bottom: 16px;
  line-height: 1.15;
}
.section-heading { display: flex; align-items: baseline; flex-wrap: wrap; gap: 8px 16px; margin-bottom: 16px; }
.section-heading .section-title { margin-bottom: 0; }
.section-head-link { font-family: var(--font-mono); font-size: var(--font-xs); font-weight: 400; line-height: 1.4; }
.news-panel { background: var(--panel-bg); border: 1px solid var(--border); border-radius: var(--radius-md); padding: 8px 12px; }

#news .section-title { margin-bottom: 16px; }
.news-list { list-style: none; display: flex; flex-direction: column; gap: 4px; }
.news-item {
  display: flex;
  align-items: baseline;
  gap: 12px;
  padding: 4px;
  font-size: var(--font-sm);
  line-height: 1.55;
  border-radius: var(--radius-sm);
  transition: background var(--transition);
}
.news-item:hover { background: rgba(0,0,0,.035); }
.news-date {
  flex-shrink: 0;
  font-family: var(--font-mono);
  font-size: var(--font-xs);
  font-weight: 400;
  color: var(--text-muted);
  letter-spacing: .03em;
  line-height: 1.25;
  padding: 4px;
  background: var(--tag-bg);
  border: 1px solid var(--tag-border);
  border-radius: var(--radius-sm);
}
.news-content { color: var(--text); min-width: 0; }
.news-content a { font-weight: 600; }
.news-hidden { display: none; }
.news-list.news-expanded .news-hidden { display: flex; }
.news-toggle {
  margin-top: 8px;
  width: 100%;
  min-height: 40px;
  background: none;
  border: none;
  border-top: 1px dashed var(--border);
  padding: 8px 0;
  font-family: var(--font-mono);
  font-size: var(--font-xs);
  line-height: 1.4;
  color: var(--text-muted);
  cursor: pointer;
}
.news-toggle:hover { color: var(--accent); }

.edu-list, .exp-list, .pub-list { list-style: none; }
.edu-item, .exp-item {
  display: grid;
  grid-template-columns: 84px 104px minmax(0, 1fr);
  gap: 0 16px;
  padding: 16px 0;
  border-bottom: 1px solid var(--border);
  align-items: center;
}
.edu-item:first-child, .exp-item:first-child, .pub-item:first-child { border-top: 1px solid var(--border); }
.edu-years, .exp-period {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-family: var(--font-mono);
  font-size: var(--font-xs);
  font-weight: 400;
  color: var(--text-light);
  line-height: 1.4;
}
.edu-years time, .exp-period time { white-space: nowrap; }
.edu-logo, .exp-logo {
  width: 92px;
  height: 92px;
  object-fit: contain;
  background: transparent;
  display: block;
  justify-self: center;
}
.edu-content, .exp-content { min-width: 0; }
.edu-content .school, .exp-content .org { font-size: var(--font-base); font-weight: 600; line-height: 1.4; }
.edu-content .dept, .edu-content .degree, .exp-content .role, .experience-desc { margin-top: 4px; font-size: var(--font-sm); color: var(--text-muted); line-height: 1.65; }
.edu-content .degree { font-style: italic; }

/* Each paper has one figure and one information block; no duplicate showcase. */
.pub-item { padding: 24px 0; border-bottom: 1px solid var(--border); display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 3fr); gap: 24px; align-items: start; }
.pub-thumb { display: block; width: 100%; aspect-ratio: 8 / 5; overflow: hidden; background: transparent; border: 1px solid var(--border); border-radius: var(--radius-md); cursor: zoom-in; transition: border-color var(--transition); }
.pub-thumb:hover { border-color: var(--accent); }
.pub-thumb img { width: 100%; height: 100%; object-fit: contain; background: transparent; mix-blend-mode: multiply; display: block; }
.pub-body { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.pub-title { font-size: var(--font-paper); font-weight: 600; color: var(--text); line-height: 1.35; text-wrap: pretty; }
.pub-title a { color: var(--text); }
.pub-title a:hover { color: var(--accent); text-decoration: none; }
.pub-authors { font-size: var(--font-sm); color: var(--text-muted); line-height: 1.5; }
.pub-authors .self { color: var(--text); font-weight: 600; text-decoration: underline; text-decoration-style: dotted; text-underline-offset: 3px; }
.pub-venue { font-size: var(--font-sm); font-style: italic; color: var(--text-muted); line-height: 1.5; }
.pub-venue .venue-name { font-weight: 600; font-style: normal; color: var(--text); }
.pub-desc { font-size: var(--font-sm); color: var(--text-muted); line-height: 1.65; text-wrap: pretty; }
.pub-links { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 4px; }
.pub-link { display: inline-flex; align-items: center; justify-content: center; min-height: 32px; font-family: var(--font-mono); font-size: var(--font-xs); line-height: 1.4; padding: 4px 12px; border: 1px solid var(--tag-border); border-radius: var(--radius-sm); color: var(--text-muted); background: var(--tag-bg); text-decoration: none; transition: border-color var(--transition), color var(--transition); }
.pub-link:hover { border-color: var(--accent); color: var(--accent); text-decoration: none; }

/* Life notes: share the page's content width and type treatment across personal sections. */
.personal-section .section-title { margin-bottom: 16px; }
.personal-prose {
  width: 100%;
  font-family: var(--font-serif);
  font-size: var(--font-base);
  font-weight: 400;
  line-height: 1.7;
  color: var(--text-muted);
  text-align: left;
  text-wrap: pretty;
}
.personal-prose p + p { margin-top: 16px; }

/* Personal photo gallery: same type, border, and color system as the research sections. */
.inspiration-intro { margin-bottom: 24px; }
.messi-gallery { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.messi-photo { min-width: 0; }
.messi-photo a { display: block; aspect-ratio: 4 / 3; overflow: hidden; border: 1px solid var(--border); border-radius: var(--radius-md); background: var(--tag-bg); transition: border-color var(--transition); }
.messi-photo a:hover { border-color: var(--accent); }
.messi-photo a:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; }
.messi-photo img { display: block; width: 100%; height: 100%; object-fit: cover; }

.site-footer { margin-top: 48px; padding-top: 24px; border-top: 1px solid var(--border); font-family: var(--font-mono); font-size: var(--font-xs); color: var(--text-light); text-align: center; line-height: 1.4; }
.site-footer p { margin-bottom: 8px; }

/* Keep the same type hierarchy, with CJK-specific leading and upright metadata. */
html[lang="zh-CN"] body { line-height: 1.8; }
html[lang="zh-CN"] .bio-text p,
html[lang="zh-CN"] .edu-content .dept,
html[lang="zh-CN"] .edu-content .degree,
html[lang="zh-CN"] .exp-content .role,
html[lang="zh-CN"] .experience-desc,
html[lang="zh-CN"] .pub-desc { line-height: 1.8; line-break: strict; }
html[lang="zh-CN"] .news-item { line-height: 1.7; }
html[lang="zh-CN"] .edu-content .degree,
html[lang="zh-CN"] .pub-venue { font-style: normal; }
html[lang="zh-CN"] .personal-prose { line-height: 1.9; line-break: strict; }

@media (max-width: 700px) {
  .container { padding: 32px 20px 64px; }
  html { scroll-padding-top: 48px; }
  .site-header { padding-top: 64px; }
  .site-header h1 { font-size: var(--font-name-compact); padding-right: 0; }
  .language-switch { top: 0; }
  .language-switch button { min-height: 44px; }
  .bio-section { flex-direction: column; align-items: stretch; gap: 24px; text-align: left; }
  .bio-avatar { align-self: center; }
  .bio-avatar img { width: 104px; height: 104px; }
  .bio-badges, .social-links { justify-content: flex-start; }
  .social-btn, .pub-link, .news-toggle { min-height: 44px; }
  .profile-details summary { padding: 8px 0; }
  .pub-item { grid-template-columns: minmax(0, 1fr); gap: 16px; }
  .section-heading { align-items: flex-start; flex-direction: column; }
  .section-head-link { padding: 4px 0; }
  .edu-item, .exp-item { grid-template-columns: 56px minmax(0, 1fr); gap: 8px 16px; align-items: start; }
  .edu-years, .exp-period { grid-column: 2; grid-row: 1; flex-direction: row; flex-wrap: wrap; gap: 4px 8px; }
  .edu-logo, .exp-logo { grid-column: 1; grid-row: 1 / span 2; width: 56px; height: 56px; }
  .edu-content, .exp-content { display: contents; }
  .edu-content .school, .exp-content .org { grid-column: 2; grid-row: 2; }
  .edu-content .dept, .edu-content .degree, .exp-content .role, .experience-desc { grid-column: 1 / -1; margin-top: 0; }
  .exp-content .role { grid-row: 3; }
  .experience-desc { grid-row: 4; }
  .news-item { flex-direction: column; align-items: flex-start; gap: 8px; padding: 8px 4px; }
  .news-list.news-expanded .news-hidden { flex-direction: column; align-items: flex-start; }
  .messi-gallery { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
  .messi-photo:last-child { grid-column: 1 / -1; width: calc((100% - 12px) / 2); justify-self: center; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { transition: none !important; }
}
