/* ==========================================================================
   Yuchong Zhang — personal website
   Clean academic style. Edit the tokens in :root to retheme.
   ========================================================================== */

:root {
  --bg: #fbfaf7;
  --bg-elev: #ffffff;
  --bg-soft: #f3f1eb;
  --ink: #1b1b1f;
  --ink-2: #4a4a52;
  --ink-3: #7a7a84;
  --line: #e4e1d8;
  --accent: #1f4e79;
  --accent-soft: #e6eef6;
  --accent-ink: #163a5a;
  --gold: #b8860b;
  --gold-soft: #fbf3dc;
  --shadow: 0 1px 2px rgba(20, 20, 30, .04), 0 8px 24px -12px rgba(20, 20, 30, .12);
  --radius: 10px;
  --font-serif: "Newsreader", Georgia, "Times New Roman", serif;
  --font-sans: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --maxw: 1080px;
}

:root[data-theme="dark"] {
  --bg: #121316;
  --bg-elev: #1a1b20;
  --bg-soft: #202128;
  --ink: #ececf1;
  --ink-2: #b9bac4;
  --ink-3: #82838e;
  --line: #2b2c34;
  --accent: #8fb8e6;
  --accent-soft: #1c2a3b;
  --accent-ink: #b7d3f2;
  --gold: #e0b34a;
  --gold-soft: #2e2716;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px -12px rgba(0, 0, 0, .6);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #121316;
    --bg-elev: #1a1b20;
    --bg-soft: #202128;
    --ink: #ececf1;
    --ink-2: #b9bac4;
    --ink-3: #82838e;
    --line: #2b2c34;
    --accent: #8fb8e6;
    --accent-soft: #1c2a3b;
    --accent-ink: #b7d3f2;
    --gold: #e0b34a;
    --gold-soft: #2e2716;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px -12px rgba(0, 0, 0, .6);
  }
}

/* ---------- base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 76px; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 16.5px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }
img { max-width: 100%; display: block; }
h1, h2, h3, h4 { font-family: var(--font-serif); font-weight: 500; line-height: 1.15; margin: 0; letter-spacing: -0.01em; }
p { margin: 0 0 1em; }
ul { margin: 0; padding: 0; list-style: none; }
.wrap { max-width: var(--maxw); margin: 0 auto; padding: 0 24px; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- nav ---------- */
.nav {
  position: sticky; top: 0; z-index: 50;
  background: color-mix(in srgb, var(--bg) 85%, transparent);
  backdrop-filter: saturate(140%) blur(10px);
  -webkit-backdrop-filter: saturate(140%) blur(10px);
  border-bottom: 1px solid var(--line);
}
.nav .wrap { display: flex; align-items: center; justify-content: space-between; height: 60px; gap: 16px; }
.brand { font-family: var(--font-serif); font-size: 1.15rem; color: var(--ink); font-weight: 500; white-space: nowrap; }
.brand:hover { text-decoration: none; color: var(--accent); }
.brand .cjk { color: var(--ink-3); font-weight: 400; margin-left: .4em; font-size: .95em; }
.nav-links { display: flex; gap: 4px; align-items: center; }
.nav-links a {
  color: var(--ink-2); font-size: .9rem; padding: 6px 10px; border-radius: 6px; font-weight: 500;
}
.nav-links a:hover { background: var(--bg-soft); text-decoration: none; color: var(--ink); }
.nav-links a.active { color: var(--accent); background: var(--accent-soft); }
.nav-right { display: flex; align-items: center; gap: 6px; }
.icon-btn {
  appearance: none; border: 1px solid var(--line); background: var(--bg-elev); color: var(--ink-2);
  width: 36px; height: 36px; border-radius: 8px; display: inline-grid; place-items: center; cursor: pointer;
}
.icon-btn:hover { color: var(--ink); border-color: var(--ink-3); }
.icon-btn svg { width: 18px; height: 18px; }
.menu-btn { display: none; }
.moon { display: block; } .sun { display: none; }
:root[data-theme="dark"] .moon { display: none; }
:root[data-theme="dark"] .sun { display: block; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .moon { display: none; }
  :root:not([data-theme="light"]) .sun { display: block; }
}

@media (max-width: 820px) {
  .menu-btn { display: inline-grid; }
  .nav-links {
    display: none; position: absolute; left: 0; right: 0; top: 60px;
    flex-direction: column; align-items: stretch; padding: 10px 16px 16px;
    background: var(--bg); border-bottom: 1px solid var(--line);
  }
  .nav.open .nav-links { display: flex; }
  .nav-links a { padding: 10px 12px; font-size: 1rem; }
}

/* ---------- hero ---------- */
.hero { padding: 72px 0 56px; }
.hero .wrap { display: grid; grid-template-columns: 1fr 260px; gap: 48px; align-items: start; }
.eyebrow { color: var(--accent); font-weight: 600; font-size: .8rem; letter-spacing: .12em; text-transform: uppercase; margin-bottom: 14px; }
.hero h1 { font-size: clamp(2.4rem, 5vw, 3.6rem); margin-bottom: 6px; }
.hero h1 .cjk { color: var(--ink-3); font-weight: 400; font-size: .55em; margin-left: .35em; vertical-align: .18em; }
.hero .role { font-size: 1.2rem; color: var(--ink-2); margin-bottom: 22px; font-family: var(--font-serif); }
.hero .role a { color: var(--ink); border-bottom: 1px solid var(--line); }
.hero .role a:hover { text-decoration: none; border-color: var(--accent); color: var(--accent); }
.hero .lede { font-size: 1.05rem; color: var(--ink-2); max-width: 62ch; }
.hero .lede strong { color: var(--ink); font-weight: 600; }

.links { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 22px; }
.chip {
  display: inline-flex; align-items: center; gap: 7px; padding: 7px 12px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--bg-elev); color: var(--ink-2); font-size: .86rem; font-weight: 500;
  transition: border-color .15s, color .15s, transform .15s;
}
.chip:hover { border-color: var(--accent); color: var(--accent); text-decoration: none; transform: translateY(-1px); }
.chip svg { width: 15px; height: 15px; }
.chip.primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.chip.primary:hover { background: var(--accent-ink); border-color: var(--accent-ink); color: #fff; }

.portrait { position: relative; margin: 0; }
.portrait img, .portrait .placeholder {
  width: 260px; height: 300px; object-fit: cover; border-radius: 14px; box-shadow: var(--shadow); border: 1px solid var(--line);
}
.portrait .placeholder {
  display: grid; place-items: center; background: linear-gradient(160deg, var(--accent-soft), var(--bg-soft));
  color: var(--accent); font-family: var(--font-serif); font-size: 4rem;
}
.portrait figcaption { font-size: .8rem; color: var(--ink-3); margin-top: 10px; text-align: center; }

@media (max-width: 820px) {
  .hero { padding: 44px 0 40px; }
  .hero .wrap { grid-template-columns: 1fr; gap: 28px; }
  .portrait { order: -1; }
  .portrait img, .portrait .placeholder { width: 160px; height: 184px; font-size: 2.6rem; }
  .portrait figcaption { text-align: left; }
}

/* ---------- sections ---------- */
section { padding: 56px 0; border-top: 1px solid var(--line); }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; margin-bottom: 28px; flex-wrap: wrap; }
.section-head h2 { font-size: 1.9rem; }
.section-head .aside { color: var(--ink-3); font-size: .9rem; }
.section-head .aside a { color: var(--ink-2); }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 40px; }
@media (max-width: 820px) { .two-col { grid-template-columns: 1fr; gap: 32px; } }
h3.sub { font-size: 1.2rem; margin: 0 0 14px; color: var(--ink); }
h3.sub small { font-family: var(--font-sans); font-size: .78rem; color: var(--ink-3); font-weight: 500; margin-left: 8px; letter-spacing: .04em; text-transform: uppercase; }

/* ---------- news ---------- */
.news li { display: grid; grid-template-columns: 96px 1fr; gap: 16px; padding: 12px 0; border-bottom: 1px dashed var(--line); }
.news li:last-child { border-bottom: 0; }
.news time { color: var(--ink-3); font-size: .85rem; font-variant-numeric: tabular-nums; padding-top: 2px; }
.news .award { color: var(--gold); font-weight: 600; }
@media (max-width: 560px) { .news li { grid-template-columns: 1fr; gap: 2px; } }
.more-toggle {
  appearance: none; border: 1px solid var(--line); background: var(--bg-elev); color: var(--ink-2);
  font: inherit; font-size: .88rem; font-weight: 500; padding: 8px 14px; border-radius: 8px; cursor: pointer; margin-top: 14px;
}
.more-toggle:hover { border-color: var(--accent); color: var(--accent); }
[hidden] { display: none !important; }

/* ---------- research ---------- */
.tags { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 28px; }
.tag { background: var(--accent-soft); color: var(--accent-ink); padding: 5px 11px; border-radius: 6px; font-size: .86rem; font-weight: 500; }
.cards { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; }
.card {
  background: var(--bg-elev); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px 22px;
  transition: transform .15s, box-shadow .15s, border-color .15s;
}
.card:hover { transform: translateY(-2px); box-shadow: var(--shadow); border-color: var(--ink-3); }
.card .kicker { font-size: .74rem; letter-spacing: .1em; text-transform: uppercase; color: var(--ink-3); font-weight: 600; margin-bottom: 8px; }
.card h4 { font-size: 1.15rem; margin-bottom: 8px; }
.card p { color: var(--ink-2); font-size: .95rem; margin: 0 0 12px; }
.card .card-link { font-size: .88rem; font-weight: 500; }
.card .card-link::after { content: " →"; }
@media (max-width: 820px) { .cards { grid-template-columns: 1fr; } }

/* ---------- publications ---------- */
.pub-tools { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 20px; }
.filter {
  appearance: none; border: 1px solid var(--line); background: var(--bg-elev); color: var(--ink-2);
  font: inherit; font-size: .86rem; font-weight: 500; padding: 6px 12px; border-radius: 999px; cursor: pointer;
}
.filter:hover { border-color: var(--accent); color: var(--accent); }
.filter.active { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.pubs { counter-reset: pub; }
.pub {
  display: grid; grid-template-columns: 64px 1fr; gap: 18px; padding: 18px 0; border-bottom: 1px solid var(--line);
}
.pub:last-child { border-bottom: 0; }
.pub .venue-tag {
  align-self: start; text-align: center; font-size: .78rem; font-weight: 600; color: var(--accent-ink);
  background: var(--accent-soft); border-radius: 6px; padding: 6px 4px; line-height: 1.2;
}
.pub .venue-tag .yr { display: block; font-weight: 500; color: var(--ink-3); font-size: .72rem; margin-top: 2px; }
.pub .title { font-family: var(--font-serif); font-size: 1.15rem; color: var(--ink); margin-bottom: 4px; }
.pub .title a { color: inherit; }
.pub .title a:hover { color: var(--accent); }
.pub .authors { color: var(--ink-2); font-size: .93rem; margin-bottom: 3px; }
.pub .authors b { color: var(--ink); font-weight: 600; }
.pub .where { color: var(--ink-3); font-size: .88rem; font-style: italic; }
.pub .badges { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.badge { font-size: .72rem; font-weight: 600; padding: 3px 8px; border-radius: 5px; background: var(--bg-soft); color: var(--ink-2); letter-spacing: .02em; }
.badge.award { background: var(--gold-soft); color: var(--gold); }
.badge.rank { background: var(--accent-soft); color: var(--accent-ink); }
.pub .plinks { display: inline-flex; gap: 12px; margin-top: 6px; font-size: .85rem; font-weight: 500; }
@media (max-width: 560px) {
  .pub { grid-template-columns: 1fr; gap: 8px; }
  .pub .venue-tag { display: inline-block; justify-self: start; padding: 4px 10px; }
  .pub .venue-tag .yr { display: inline; margin-left: 6px; }
}

/* ---------- service ---------- */
.service-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 32px; }
.service-grid ul li { padding: 8px 0; border-bottom: 1px dashed var(--line); color: var(--ink-2); font-size: .95rem; }
.service-grid ul li:last-child { border-bottom: 0; }
.service-grid ul li b { color: var(--ink); font-weight: 600; }
.venue-cloud { display: flex; flex-wrap: wrap; gap: 6px; }
.venue-cloud span { font-size: .84rem; padding: 4px 9px; border: 1px solid var(--line); border-radius: 6px; color: var(--ink-2); background: var(--bg-elev); }
@media (max-width: 900px) { .service-grid { grid-template-columns: 1fr; gap: 28px; } }

/* ---------- timeline (about) ---------- */
.timeline li { position: relative; padding: 0 0 22px 26px; }
.timeline li::before {
  content: ""; position: absolute; left: 6px; top: 8px; width: 9px; height: 9px; border-radius: 50%;
  background: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft);
}
.timeline li::after { content: ""; position: absolute; left: 10px; top: 20px; bottom: -4px; width: 1px; background: var(--line); }
.timeline li:last-child::after { display: none; }
.timeline .when { font-size: .82rem; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.timeline .what { font-weight: 600; color: var(--ink); }
.timeline .where { color: var(--ink-2); font-size: .95rem; }
.timeline .note { color: var(--ink-3); font-size: .88rem; margin-top: 2px; }
.interests { color: var(--ink-2); }
.interests span { display: inline-block; margin: 0 10px 8px 0; padding: 4px 10px; background: var(--bg-soft); border-radius: 6px; font-size: .9rem; }

/* ---------- contact / footer ---------- */
.contact .wrap { display: grid; grid-template-columns: 1fr 1fr; gap: 40px; }
.contact address { font-style: normal; color: var(--ink-2); line-height: 1.8; }
.contact address a { color: var(--ink); border-bottom: 1px solid var(--line); }
.contact address a:hover { text-decoration: none; border-color: var(--accent); color: var(--accent); }
@media (max-width: 820px) { .contact .wrap { grid-template-columns: 1fr; } }
footer { border-top: 1px solid var(--line); padding: 26px 0 40px; color: var(--ink-3); font-size: .85rem; }
footer .wrap { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 10px; }
footer a { color: var(--ink-2); }

/* ---------- reveal on scroll (subtle) ---------- */
@media (prefers-reduced-motion: no-preference) {
  .reveal { opacity: 0; transform: translateY(10px); transition: opacity .5s ease, transform .5s ease; }
  .reveal.in { opacity: 1; transform: none; }
}

@media print {
  .nav, .icon-btn, .more-toggle, .pub-tools { display: none !important; }
  body { font-size: 11pt; }
  [hidden] { display: block !important; }
}
