/* ============ tokens ============ */
:root {
  --bg:       #f6f3ec;   /* warm paper */
  --surface:  #fffefb;   /* card */
  --ink:      #1b2432;   /* deep navy ink */
  --muted:    #5c6675;
  --faint:    #949cA8;
  --border:   #e7e1d6;
  --rule:     #ded7ca;
  --accent:   #2c4a78;
  --badge-bg: #e9eef7;
  --badge-fg: #2c4a78;
  --badge-br: #b9c8de;
  --tag-bg:   #efeade;
  --shadow-s: 0 1px 2px rgba(35,30,20,.05);
  --shadow-m: 0 1px 3px rgba(35,30,20,.05), 0 10px 30px rgba(35,30,20,.045);
  --r-card:   16px;
  --r-media:  11px;
  --maxw:     1060px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg:       #0e1013;
    --surface:  #161a1f;
    --ink:      #e8e5df;
    --muted:    #a2a9b4;
    --faint:    #767d88;
    --border:   #262b33;
    --rule:     #2c323b;
    --accent:   #9dbdf0;
    --badge-bg: #1b2536;
    --badge-fg: #9dbdf0;
    --badge-br: #35496b;
    --tag-bg:   #1d2128;
    --shadow-s: none;
    --shadow-m: 0 1px 3px rgba(0,0,0,.4);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg:       #0e1013;
  --surface:  #161a1f;
  --ink:      #e8e5df;
  --muted:    #a2a9b4;
  --faint:    #767d88;
  --border:   #262b33;
  --rule:     #2c323b;
  --accent:   #9dbdf0;
  --badge-bg: #1b2536;
  --badge-fg: #9dbdf0;
  --badge-br: #35496b;
  --tag-bg:   #1d2128;
  --shadow-s: none;
  --shadow-m: 0 1px 3px rgba(0,0,0,.4);
  color-scheme: dark;
}

/* ============ base ============ */
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; scroll-padding-top: 80px; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Source Serif 4", "Iowan Old Style", Palatino, "Palatino Linotype",
               Georgia, "Songti SC", "Noto Serif CJK SC", serif;
  font-size: 17.5px;
  line-height: 1.66;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
img, video { max-width: 100%; display: block; }
p { margin: 0 0 1.05em; }

a { color: var(--ink); text-decoration: underline; text-decoration-thickness: 1px;
    text-underline-offset: 2.5px; text-decoration-color: var(--rule); }
a:hover { text-decoration-color: var(--ink); }

.wrap { max-width: var(--maxw); margin: 0 auto; padding: 0 26px; }

/* ============ nav ============ */
.nav {
  position: sticky; top: 0; z-index: 50;
  background: var(--bg); background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(180%) blur(14px);
  -webkit-backdrop-filter: saturate(180%) blur(14px);
}
.nav-inner {
  max-width: var(--maxw); margin: 0 auto; padding: 0 26px;
  height: 62px; display: flex; align-items: center; gap: 22px;
}
.nav-name { font-weight: 600; font-size: 17px; margin-right: auto; text-decoration: none; }
.nav a.nav-link { color: var(--muted); font-size: 16px; text-decoration: none; }
.nav a.nav-link:hover { color: var(--ink); }
.theme-btn {
  background: none; border: 1px solid var(--border); border-radius: 9px;
  width: 33px; height: 33px; cursor: pointer; color: var(--muted);
  display: grid; place-items: center; padding: 0; flex: none;
}
.theme-btn:hover { color: var(--ink); border-color: var(--faint); }
.theme-btn svg { width: 16px; height: 16px; }
:root[data-theme="dark"] .icon-sun, .icon-moon { display: none; }
:root[data-theme="dark"] .icon-moon { display: block; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .icon-sun { display: none; }
  :root:not([data-theme="light"]) .icon-moon { display: block; }
}
:root[data-theme="light"] .icon-sun { display: block; }
:root[data-theme="light"] .icon-moon { display: none; }

/* ============ hero ============ */
.hero { display: grid; grid-template-columns: 252px 1fr; gap: 44px; align-items: start; padding: 58px 0 10px; }
.hero-photo {
  width: 252px; height: 252px; border-radius: 50%; object-fit: cover;
  border: 5px solid var(--surface); box-shadow: var(--shadow-m);
}
.hero h1 { font-size: 40px; line-height: 1.12; letter-spacing: -.018em; margin: 0 0 14px; font-weight: 600; }
.hero .zh { font-size: 22px; color: var(--muted); font-weight: 400; margin-left: 10px; }
.hero p { margin-bottom: .85em; }

/* ============ chips ============ */
.chips { display: flex; flex-wrap: wrap; gap: 9px; margin-top: 20px; }
.chip {
  display: inline-flex; align-items: center; gap: 7px;
  border: 1px solid var(--border); background: var(--surface);
  border-radius: 999px; padding: 7px 16px;
  font-size: 15px; color: var(--ink); text-decoration: none;
  box-shadow: var(--shadow-s); transition: transform .12s, box-shadow .12s;
}
.chip:hover { transform: translateY(-1px); box-shadow: var(--shadow-m); }
.chip svg { width: 15px; height: 15px; flex: none; opacity: .75; }

/* ============ sections ============ */
section { padding-top: 66px; }
h2 { font-size: 28px; font-weight: 600; letter-spacing: -.015em; margin: 0 0 22px; }
h3 { font-size: 23px; line-height: 1.3; margin: 0 0 8px; font-weight: 600; letter-spacing: -.012em; }
h3 a { text-decoration: none; }
h3 a:hover { text-decoration: underline; text-decoration-color: var(--rule); }

.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-card); box-shadow: var(--shadow-m);
}

/* ============ news ============ */
.news { padding: 26px 30px; }
.news-item { display: grid; grid-template-columns: 92px 1fr; gap: 18px; padding: 6px 0; }
.news-date { color: var(--faint); font-size: 15px; padding-top: 2px; white-space: nowrap; }

/* ============ publications ============ */
.pub { display: grid; grid-template-columns: 430px 1fr; gap: 28px; padding: 22px; margin-bottom: 22px; align-items: start; }
.pub:last-child { margin-bottom: 0; }
.pub.no-media { grid-template-columns: 1fr; }
.media { position: relative; border-radius: var(--r-media); overflow: hidden; background: var(--tag-bg); }
.media > img, .media > video { width: 100%; aspect-ratio: 16 / 10; object-fit: cover; }
.pub-authors { font-size: 16px; color: var(--muted); margin: 0 0 9px; line-height: 1.5; }
.pub-authors .me { color: var(--ink); font-weight: 600; }
.pub-authors .eq { display: block; color: var(--faint); font-size: 14px; margin-top: 2px; }
.venue { margin: 0 0 10px; }
.vbadge {
  display: inline-block; font-size: 13.5px; font-weight: 600; letter-spacing: .03em;
  border-radius: 6px; padding: 2px 9px;
  color: var(--badge-fg); border: 1px solid var(--badge-br); background: var(--badge-bg);
  font-family: "Source Serif 4", Georgia, serif;
}
.vbadge.plain {                       /* not published yet - deliberately quieter */
  color: var(--faint); border-color: var(--border); background: transparent;
}
.pub-tldr { font-size: 16.5px; color: var(--muted); margin: 0 0 13px; }
.pub-links { display: flex; flex-wrap: wrap; gap: 16px; font-size: 15px; }
.pub-links a { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); text-decoration: none; }
.pub-links a:hover { color: var(--ink); }
.pub-links svg { width: 14px; height: 14px; opacity: .7; }

/* ============ row lists ============ */
.row-list { list-style: none; padding: 26px 30px; margin: 0; }
.row-list li {
  display: flex; justify-content: space-between; align-items: baseline; gap: 22px;
  padding: 9px 0; border-bottom: 1px solid var(--border);
}
.row-list li:first-child { padding-top: 0; }
.row-list li:last-child { border-bottom: none; padding-bottom: 0; }
.row-list .where { color: var(--muted); font-size: 15.5px; display: block; }
.row-list .when { color: var(--faint); font-size: 15px; white-space: nowrap; flex: none; }
.row-list .note { color: var(--faint); font-size: 15px; }

/* ============ footer ============ */
footer {
  margin-top: 80px; padding: 26px 0 48px; border-top: 1px solid var(--border);
  color: var(--faint); font-size: 15px; display: flex; justify-content: space-between; gap: 14px; flex-wrap: wrap;
}

/* ============ responsive ============ */
@media (max-width: 720px) {
  body { font-size: 17px; }
  .hero { grid-template-columns: 1fr; gap: 24px; padding-top: 40px; }
  .hero-photo { width: 148px; height: 148px; }
  .hero h1 { font-size: 32px; }
  .hero .zh { display: block; margin-left: 0; font-size: 19px; }
  .pub { grid-template-columns: 1fr; gap: 18px; padding: 16px; }
  .news { padding: 20px 22px; }
  .row-list { padding: 20px 22px; }
  .news-item { grid-template-columns: 80px 1fr; gap: 12px; }
  .row-list li { flex-direction: column; gap: 3px; }
  section { padding-top: 50px; }
  h2 { font-size: 24px; }
  h3 { font-size: 19px; }
  .nav a.nav-link[data-optional] { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .chip { transition: none; }
}


/* figure thumbnails are printed on white; take the glare off in dark mode */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .media > img { filter: brightness(.88); }
}
:root[data-theme="dark"] .media > img { filter: brightness(.88); }

/* ============ background ============ */
.sub {
  font-size: 15px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase;
  color: var(--faint); margin: 0 0 4px;
}
#background .tl-wrap + .sub { margin-top: 42px; }
.edu { list-style: none; margin: 14px 0 0; padding: 0; display: grid; gap: 18px; grid-template-columns: 1fr 1fr; }
.edu-card {
  display: flex; gap: 13px; align-items: flex-start;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 14px; padding: 15px 17px; box-shadow: var(--shadow-m);
}
.tl-when.plain { color: var(--faint); font-weight: 400; }

/* ============ background timeline ============ */
/* A real time axis, Jan 2021 -> Sep 2026. Every position below is a date:
   each entry draws its whole span as a coloured bar, so the Cornell visit
   visibly sits inside the SJTU years. Cards live on a 100-column grid so
   the browser still computes honest row heights when text wraps. */
:root {
  --c-cyberc3: #c8803a;
  --c-emprise: #b8433a;
  --c-rl2:     #3f8f7a;
  --c-lecar:   #3a6ea8;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) { --c-cyberc3:#dd9b52; --c-emprise:#d4625a; --c-rl2:#57ab94; --c-lecar:#6fa0d8; }
}
:root[data-theme="dark"] { --c-cyberc3:#dd9b52; --c-emprise:#d4625a; --c-rl2:#57ab94; --c-lecar:#6fa0d8; }

.c-cyberc3 { --c: var(--c-cyberc3); }
.c-emprise { --c: var(--c-emprise); }
.c-rl2     { --c: var(--c-rl2); }
.c-lecar   { --c: var(--c-lecar); }

.tl-wrap { padding: 26px 0 24px; }
.tl { position: relative; }
.tl-row { display: grid; grid-template-columns: repeat(100, minmax(0, 1fr)); }
.tl-top { padding-bottom: 26px; }
.tl-bot { padding-top: 46px; }          /* clears the year labels */

.tl-axis {
  position: relative; height: 8px; border-radius: 4px;
  background: var(--rule);
}
.tl-bar {
  position: absolute; top: 0; height: 8px; border-radius: 4px;
  left: var(--a); width: calc(var(--b) - var(--a));
  background: var(--c);
}
.tl-tick {
  position: absolute; top: 12px; left: var(--x); width: 1px; height: 5px;
  background: var(--rule); transform: translateX(-50%);
}
.tl-year {
  position: absolute; top: 19px; left: var(--x); transform: translateX(-50%);
  font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap;
}
.tl-year:first-of-type { transform: none; }
.tl-year:last-of-type  { transform: translateX(-100%); }
.tl-link {
  position: absolute; left: var(--x); width: 0;
  border-left: 2px dotted var(--c); opacity: .6;
}
.tl-link.up   { bottom: 100%; height: 26px; }
.tl-link.down { top: 100%;    height: 46px; }

.tl-card {
  display: flex; gap: 13px; align-items: flex-start;
  background: var(--surface); border: 1px solid var(--border);
  border-left: 3px solid var(--c);
  border-radius: 14px; padding: 15px 17px; box-shadow: var(--shadow-m);
}
.tl-logo {
  width: 38px; height: 38px; object-fit: contain; flex: none; margin-top: 1px;
  border-radius: 8px; background: var(--bg); padding: 3px; border: 1px solid var(--border);
}
.tl-body { display: flex; flex-direction: column; min-width: 0; }
.tl-body b { font-size: 16px; line-height: 1.3; }
.tl-when  { color: var(--c); font-size: 13.5px; font-weight: 500; }
.tl-where { color: var(--muted); font-size: 14.5px; }
.tl-adv   { color: var(--faint); font-size: 13.5px; margin-top: 3px; line-height: 1.45; }


@media (max-width: 780px) {
  /* the axis cannot survive a narrow column - fall back to a plain stack.
     `display: contents` lifts the cards out of their rows so all three can be
     ordered chronologically instead of top-row-then-bottom-row. */
  .tl-wrap { padding: 4px 0 0; }
  .tl-axis { display: none; }
  .tl { display: flex; flex-direction: column; }
  .tl-row { display: contents; }
  .tl-card { margin-bottom: 16px; }
  .tl-card.c-cyberc3 { order: 1; }
  .tl-card.c-emprise { order: 2; }
  .tl-card.c-rl2     { order: 3; }
  .tl-card.c-lecar   { order: 4; margin-bottom: 0; }
  .edu { grid-template-columns: 1fr; gap: 14px; }
}

/* the timeline needs more room per column than the reading column allows */
/* the 2x2 montages are native 16:9; giving them their own ratio avoids letterboxing */
.media.wide > video, .media.wide > img { aspect-ratio: 16 / 9; }
