/* ---------- Design tokens ---------- */
:root {
  /* warm paper, ink text, deep blue accent */
  --bg: #faf8f4;
  --fg: #1d1c1a;
  --muted: #6b6761;
  --accent: #1f5f8b;
  --accent-hover: #15445f;
  --card: #ffffff;
  --border: #e6e1d8;
  --rule: #d9d3c8;

  --max: 760px;
  --radius: 12px;

  --sans: "Source Sans 3", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial,
          "PingFang SC", "Noto Sans CJK SC", "Microsoft YaHei", sans-serif;
  --serif: "Source Serif 4", "Iowan Old Style", "Palatino Linotype", Georgia,
           "Songti SC", "Noto Serif CJK SC", "SimSun", serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    /* deep navy night */
    --bg: #0f1520;
    --fg: #e6e4df;
    --muted: #9aa0a8;
    --accent: #8fbbe8;
    --accent-hover: #b7d3f2;
    --card: #161e2c;
    --border: #273146;
    --rule: #2f3a52;
  }
}

/* Kai-style (楷书) face for the Chinese name only: a 3-glyph subset of AR PL KaitiM GB
   (the LaTeX CJK `gkai` font; Arphic Public License, see fonts/ARPHICPL.txt) */
@font-face {
  font-family: "AR PL KaitiM GB Name";
  src: url("../fonts/ARPLKaitiMGB-name.woff2") format("woff2");
  font-weight: 400; font-style: normal; font-display: swap;
  unicode-range: U+674E, U+4E9A, U+5149;  /* 李 亚 光 */
}

/* ---------- Base ---------- */
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; scroll-padding-top: 64px; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }
body {
  margin: 0;
  font-family: var(--sans);
  font-size: 18px;
  line-height: 1.65;
  color: var(--fg);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); text-decoration: underline; }
img { max-width: 100%; height: auto; display: block; }
h1, h2, h3 { font-family: var(--serif); font-weight: 600; line-height: 1.2; letter-spacing: -0.005em; }
h2 { font-size: 1.6rem; margin: 2.2rem 0 0.8rem; }
h3 { font-size: 1.2rem; margin: 1.8rem 0 0.6rem; }
p { margin: 0 0 1rem; }
ul { padding-left: 1.3rem; }
li { margin: 0.4rem 0; }
.wrap { max-width: var(--max); margin: 0 auto; padding: 0 20px; }

/* Links inside running text get a quiet underline */
.bio a, .project p a, main ul:not(.list) a {
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
  text-decoration-color: color-mix(in srgb, var(--accent) 45%, transparent);
}
.bio a:hover, .project p a:hover, main ul:not(.list) a:hover {
  text-decoration-color: var(--accent-hover);
}

/* ---------- Header / nav ---------- */
.site-header {
  position: sticky; top: 0; z-index: 10;
  background: color-mix(in srgb, var(--bg) 90%, transparent);
  backdrop-filter: saturate(180%) blur(12px);
  -webkit-backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--border);
}
.site-header .wrap {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; flex-wrap: wrap; min-height: 58px; padding-top: 8px; padding-bottom: 8px;
}
.brand { font-family: var(--serif); font-weight: 600; font-size: 1.15rem; color: var(--fg); white-space: nowrap; }
.brand:hover { text-decoration: none; color: var(--accent); }
.nav { display: flex; gap: 2px; flex-wrap: wrap; }
.nav a {
  color: var(--fg); padding: 6px 10px; border-radius: 8px;
  font-size: 0.95rem; font-weight: 600; letter-spacing: 0.01em;
}
.nav a:hover { background: color-mix(in srgb, var(--fg) 6%, transparent); text-decoration: none; }
.nav a[aria-current="page"] { color: var(--accent); }

/* ---------- Hero banner (Resources page) ---------- */
.hero {
  position: relative;
  min-height: 200px; height: 26vh; max-height: 300px;
  background-size: cover; background-position: center 62%;
  display: flex; align-items: flex-end;
  color: #fff;
}
.hero::before {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(to top, rgba(0,0,0,0.62) 0%, rgba(0,0,0,0.15) 55%, rgba(0,0,0,0) 100%);
}
.hero .wrap { position: relative; width: 100%; padding-bottom: 28px; }
.hero h1 {
  margin: 0; font-size: clamp(2rem, 5vw, 3rem); color: #fff;
  text-shadow: 0 2px 12px rgba(0,0,0,0.45);
}
.hero .caption {
  margin: 6px 0 0; font-size: 0.85rem; opacity: 0.9;
  text-shadow: 0 1px 6px rgba(0,0,0,0.6);
}

/* ---------- Content ---------- */
main.wrap { padding-top: 2rem; padding-bottom: 3rem; }
section > .wrap { padding-top: 1.6rem; padding-bottom: 1.6rem; }
#about > .wrap { padding-top: 3rem; }
#code > .wrap { padding-bottom: 3.5rem; }

/* Section headings on the long page */
section + section > .wrap { border-top: 1px solid var(--rule); margin-top: 1.2rem; padding-top: 3rem; }
.section-title { margin: 0 0 1.8rem; font-size: 2rem; text-align: center; }
.section-title::after {
  content: ""; display: block; width: 44px; height: 3px; border-radius: 2px;
  background: var(--accent); margin: 0.7rem auto 0;
}

/* Home: profile header (portrait + name/role/links), bio below */
.profile { display: grid; grid-template-columns: 1fr; justify-items: center; text-align: center; gap: 22px; }
.profile-photo {
  width: 300px; aspect-ratio: 1 / 1; object-fit: cover;
  border-radius: var(--radius); box-shadow: 0 10px 32px rgba(40,30,10,0.18);
}
.profile h1 { margin: 0 0 0.4rem; font-size: clamp(2rem, 4.2vw, 2.7rem); }
.cn {
  font-family: "AR PL KaitiM GB Name", "AR PL KaitiM GB", "Kaiti SC", "STKaiti", "KaiTi", "AR PL UKai CN", "Noto Serif CJK SC", serif;
  font-weight: 400; font-size: 1em; line-height: 1;
  vertical-align: -0.05em;  /* centres the ideographs on the Latin cap height (measured from glyph bounds) */
}
.role { margin: 0 0 0.7rem; color: var(--muted); font-size: 1.05rem; line-height: 1.45; }
.profile-links { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin: 0; }
.profile-links .tag { margin: 0; padding: 3px 12px; font-size: 0.9rem; }
.pub-links { justify-content: flex-start; align-items: center; margin: -0.2rem 0 1.4rem; }
.pub-links .pub-label { color: var(--muted); margin-right: 2px; }
.bio { margin-top: 2.2rem; }
@media (max-width: 680px) {
  .profile-photo { width: 220px; }
}

/* Research: two labelled groups of project cards */
.group-title { margin: 2.2rem 0 0.2rem; font-size: 1.35rem; }
.group-title .group-sub { font-family: var(--sans); font-weight: 400; font-size: 0.95rem; color: var(--muted); letter-spacing: 0.01em; }
.projects { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-top: 1rem; }
.project {
  display: grid; grid-template-rows: auto 1fr;
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); overflow: hidden;
  box-shadow: 0 1px 2px rgba(40,30,10,0.04);
}
.project img { width: 100%; aspect-ratio: 3 / 2; object-fit: cover; }
.project .body { padding: 16px 18px 18px; }
.project h3 { margin: 0 0 0.4rem; font-size: 1.25rem; }
.project p { margin: 0; font-size: 0.97rem; }
@media (max-width: 680px) { .projects { grid-template-columns: 1fr; } }

/* Talks / code lists */
.list { list-style: none; padding: 0; }
.list li { padding: 12px 0; border-bottom: 1px solid var(--border); margin: 0; }
.list li:last-child { border-bottom: none; }
.year { display: inline-block; min-width: 3.4em; color: var(--muted); font-variant-numeric: tabular-nums; }
.venue { color: var(--muted); font-size: 0.92rem; }
.tag {
  display: inline-block; padding: 1px 9px; margin-left: 4px;
  border: 1px solid var(--border); border-radius: 999px;
  font-size: 0.82rem; font-weight: 600; background: var(--card);
}
.tag:hover { text-decoration: none; border-color: var(--accent); }

/* ---------- Footer ---------- */
.site-footer { border-top: 1px solid var(--border); color: var(--muted); font-size: 0.88rem; }
.site-footer .wrap { padding: 20px; display: flex; justify-content: space-between; flex-wrap: wrap; gap: 8px; }
