/* ==========================================================================
   Academic homepage — typography-first, quiet, print-friendly.
   Tweak the tokens below to re-skin the whole page.
   ========================================================================== */

:root {
  /* Surfaces & ink */
  --paper:        #fbfaf7;
  --paper-sunk:   #f3f1ea;
  --ink:          #22252a;
  --ink-soft:     #555b65;
  --ink-faint:    #8a9099;
  --rule:         #e4e0d6;

  /* Accent (muted brick — reads scholarly, not loud) */
  --accent:       #9c4032;
  --accent-soft:  #b5695c;
  --accent-wash:  rgba(156, 64, 50, 0.10);
  --accent-line:  rgba(156, 64, 50, 0.28);

  /* Chrome */
  --veil:         rgba(251, 250, 247, 0.88);
  --shadow:       0 1px 2px rgba(34, 37, 42, 0.05), 0 14px 34px -18px rgba(34, 37, 42, 0.30);

  --serif: "Source Serif 4", "Iowan Old Style", "Palatino Linotype", Palatino,
           Georgia, "Songti SC", "Noto Serif CJK SC", serif;
  --sans:  "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI",
           "PingFang SC", "Helvetica Neue", Arial, sans-serif;

  --measure: 60rem;
  --gutter:  1.5rem;
  /* Running prose is capped separately from the page width: the wide column
     suits the publication list and CV tables, but ~70 characters stays the
     comfortable reading limit for paragraphs. */
  --prose:   48rem;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper:       #15171a;
    --paper-sunk:  #1d2024;
    --ink:         #e3e1dc;
    --ink-soft:    #a5aab2;
    --ink-faint:   #747981;
    --rule:        #2b2f34;

    --accent:      #df8878;
    --accent-soft: #c87060;
    --accent-wash: rgba(223, 136, 120, 0.12);
    --accent-line: rgba(223, 136, 120, 0.32);

    --veil:        rgba(21, 23, 26, 0.86);
    --shadow:      0 1px 2px rgba(0, 0, 0, 0.3), 0 14px 34px -18px rgba(0, 0, 0, 0.7);
  }
}

/* --- Base ---------------------------------------------------------------- */

*, *::before, *::after { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background-color: var(--paper);
  color: var(--ink);
  font-family: var(--serif);
  font-size: 18.5px;
  line-height: 1.68;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

p { margin: 0 0 1.05em; }
p:last-child { margin-bottom: 0; }

a {
  color: var(--accent);
  text-decoration: none;
  border-bottom: 1px solid var(--accent-line);
  transition: color 0.15s ease, border-color 0.15s ease, background-color 0.15s ease;
}
a:hover,
a:focus-visible { color: var(--accent-soft); border-bottom-color: currentColor; }

:focus-visible { outline: 2px solid var(--accent-soft); outline-offset: 3px; border-radius: 2px; }

strong, b { font-weight: 600; }

img { max-width: 100%; height: auto; }

::selection { background: var(--accent-wash); }

.wrap {
  max-width: var(--measure);
  margin: 0 auto;
  padding: 0 var(--gutter);
}

.visually-hidden {
  position: absolute; width: 1px; height: 1px;
  margin: -1px; padding: 0; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* --- Top bar ------------------------------------------------------------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background-color: var(--veil);
  -webkit-backdrop-filter: saturate(1.4) blur(10px);
  backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--rule);
}

.topbar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
  min-height: 3.1rem;
}

.topbar-brand {
  font-family: var(--sans);
  font-size: 0.82rem;
  font-weight: 600;
  letter-spacing: 0.055em;
  color: var(--ink);
  border-bottom: 0;
  white-space: nowrap;
}
.topbar-brand:hover { color: var(--accent); }

.topbar-nav {
  display: flex;
  align-items: center;
  gap: 1.35rem;
  min-width: 0;
  margin: 0;
  padding: 0;
  list-style: none;
  overflow-x: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
}
.topbar-nav::-webkit-scrollbar { display: none; }

.topbar-nav a {
  font-family: var(--sans);
  font-size: 0.79rem;
  font-weight: 450;
  letter-spacing: 0.015em;
  color: var(--ink-soft);
  border-bottom: 0;
  white-space: nowrap;
}
.topbar-nav a:hover { color: var(--accent); }

/* --- Profile header ------------------------------------------------------ */

.profile {
  display: flex;
  align-items: flex-start;
  gap: 2.75rem;
  padding-top: 3.2rem;
}

.profile-text { flex: 1 1 auto; min-width: 0; }

.profile-figure {
  flex: 0 0 11rem;
  width: 11rem;
  margin: 0.35rem 0 0;
}

.profile-figure img {
  display: block;
  width: 100%;
  aspect-ratio: 4 / 5;
  object-fit: cover;
  border-radius: 3px;
  box-shadow: var(--shadow);
  filter: saturate(0.95);
}

.name {
  margin: 0;
  font-size: clamp(2.05rem, 6vw, 2.6rem);
  font-weight: 600;
  line-height: 1.08;
  letter-spacing: -0.018em;
}

.name-cn {
  display: inline-block;
  margin-left: 0.45rem;
  font-size: 0.6em;
  font-weight: 400;
  letter-spacing: 0.04em;
  color: var(--ink-soft);
  white-space: nowrap;
}

.role {
  margin: 0.75rem 0 0;
  font-family: var(--sans);
  font-size: 0.95rem;
  line-height: 1.55;
  color: var(--ink-soft);
}
.role a { color: var(--ink); border-bottom-color: var(--rule); }
.role a:hover { color: var(--accent); }

/* Contact / profile links */
.linkrow {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin: 1.05rem 0 0;
  padding: 0;
  list-style: none;
}

.linkrow a {
  display: inline-block;
  padding: 0.3rem 0.72rem;
  font-family: var(--sans);
  font-size: 0.775rem;
  font-weight: 450;
  letter-spacing: 0.015em;
  color: var(--ink-soft);
  border: 1px solid var(--rule);
  border-radius: 999px;
}
.linkrow a:hover {
  color: var(--accent);
  border-color: var(--accent-line);
  background-color: var(--accent-wash);
}

/* --- Sections ------------------------------------------------------------ */

.section {
  margin-top: 3.5rem;
  scroll-margin-top: 4.5rem;
}
.section:first-of-type { margin-top: 2.3rem; }

.section-title {
  display: flex;
  align-items: center;
  gap: 0.95rem;
  margin: 0 0 1.5rem;
  font-family: var(--sans);
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.17em;
  color: var(--ink-faint);
}
.section-title::after {
  content: "";
  flex: 1 1 auto;
  height: 1px;
  background-color: var(--rule);
}

.section-note {
  margin: 1.5rem 0 0;
  font-family: var(--sans);
  font-size: 0.82rem;
  color: var(--ink-faint);
}
.section-note a { color: var(--ink-soft); border-bottom-color: var(--rule); }
.section-note a:hover { color: var(--accent); }

/* Running prose keeps a readable line length even though the page is wide. */
.prose p { max-width: var(--prose); }

/* Obfuscated contact line — deliberately not a mailto: link, so the address
   never appears in the markup for scrapers to harvest. */
.contact {
  margin: 0.8rem 0 0;
  font-family: var(--sans);
  font-size: 0.85rem;
  letter-spacing: 0.01em;
  color: var(--ink);
}
.contact .obf {
  color: var(--ink-faint);
  font-size: 0.88em;
  letter-spacing: 0.04em;
}

/* --- Publications -------------------------------------------------------- */

.pub-list { margin: 0; padding: 0; list-style: none; }

.pub {
  display: grid;
  grid-template-columns: 5.6rem 1fr;
  gap: 0 1.7rem;
  padding: 0.95rem 0;
  border-top: 1px solid var(--rule);
}
.pub:first-child { border-top: 0; padding-top: 0; }

.pub-venue {
  font-family: var(--sans);
  font-size: 0.72rem;
  font-weight: 500;
  line-height: 1.75;
  letter-spacing: 0.055em;
  text-align: right;
  text-transform: uppercase;
  color: var(--ink-faint);
  white-space: nowrap;
}

.pub-title {
  font-size: 1.02rem;
  font-weight: 600;
  line-height: 1.42;
  color: var(--ink);
}
.pub-title a { color: inherit; border-bottom-color: transparent; }
.pub-title a:hover { color: var(--accent); border-bottom-color: var(--accent-line); }

.pub-authors {
  margin: 0.2rem 0 0;
  font-size: 0.875rem;
  line-height: 1.5;
  color: var(--ink-soft);
}
.pub-authors strong { color: var(--ink); font-weight: 600; }

.pub-flag {
  display: inline-block;
  margin: 0.4rem 0 0;
  padding: 0.1rem 0.45rem;
  font-family: var(--sans);
  font-size: 0.68rem;
  font-weight: 500;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--accent);
  background-color: var(--accent-wash);
  border-radius: 2px;
}

.pub-links {
  margin: 0.45rem 0 0;
  font-family: var(--sans);
  font-size: 0.765rem;
  color: var(--ink-faint);
}
.pub-links a {
  color: var(--ink-soft);
  border-bottom-color: var(--rule);
}
.pub-links a:hover { color: var(--accent); border-bottom-color: var(--accent-line); }

.pub-sep {
  margin: 0 0.62rem;
  color: var(--ink-faint);
}

/* Optional teaser-figure column. The third column only appears when at least
   one entry has a `figure:`, so the two-column layout is unaffected until then.
   The thumbnail is not forced into a fixed ratio — paper figures range from
   near-square architecture diagrams to very wide benchmark charts, and letting
   each one fill the box on its long edge keeps them all legible. */
.pub-list.has-figures .pub { grid-template-columns: 5.4rem 1fr 11.5rem; }

.pub-fig {
  grid-column: 3;
  grid-row: 1;
  display: flex;
  justify-content: flex-end;
  align-items: flex-start;
  margin: 0.25rem 0 0;
}
.pub-fig a { display: block; border-bottom: 0; }
.pub-fig img {
  display: block;
  max-width: 100%;
  max-height: 8.5rem;
  width: auto;
  height: auto;
  padding: 3px;
  /* Paper figures are black-on-white line art, so they keep a light card even
     in dark mode; dimmed slightly there so they don't glare. */
  background-color: #fff;
  border: 1px solid var(--rule);
  border-radius: 2px;
  transition: border-color 0.15s ease, opacity 0.15s ease;
}
.pub-fig a:hover img { border-color: var(--accent-line); }

@media (prefers-color-scheme: dark) {
  .pub-fig img { opacity: 0.88; }
  .pub-fig a:hover img { opacity: 1; }
}

/* --- CV blocks (experience / education) ---------------------------------- */

.cv-list { margin: 0; padding: 0; list-style: none; }

.cv-item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0 1.5rem;
  align-items: baseline;
  padding: 0.85rem 0;
  border-top: 1px solid var(--rule);
}
.cv-item:first-child { border-top: 0; padding-top: 0; }

.cv-org {
  font-size: 1.02rem;
  font-weight: 600;
  line-height: 1.4;
}
.cv-org a { color: inherit; border-bottom-color: transparent; }
.cv-org a:hover { color: var(--accent); border-bottom-color: var(--accent-line); }

.cv-date {
  font-family: var(--sans);
  font-size: 0.77rem;
  font-weight: 450;
  letter-spacing: 0.02em;
  color: var(--ink-faint);
  white-space: nowrap;
}

.cv-detail {
  grid-column: 1 / -1;
  max-width: 46rem;
  margin: 0.2rem 0 0;
  font-size: 0.9rem;
  line-height: 1.6;
  color: var(--ink-soft);
}
.cv-detail a { border-bottom-color: var(--rule); color: var(--ink); }
.cv-detail a:hover { color: var(--accent); border-bottom-color: var(--accent-line); }

/* --- Honours ------------------------------------------------------------- */

.award-list { margin: 0; padding: 0; list-style: none; }

.award-list li {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1.5rem;
  padding: 0.5rem 0;
  font-size: 0.95rem;
  border-top: 1px solid var(--rule);
}
.award-list li:first-child { border-top: 0; }
.award-list a { color: var(--ink); border-bottom-color: var(--rule); }
.award-list a:hover { color: var(--accent); border-bottom-color: var(--accent-line); }

.award-year {
  font-family: var(--sans);
  font-size: 0.77rem;
  letter-spacing: 0.02em;
  color: var(--ink-faint);
  white-space: nowrap;
}

/* --- Footer -------------------------------------------------------------- */

.site-footer {
  margin-top: 4.5rem;
  border-top: 1px solid var(--rule);
}

.site-footer-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.6rem 1.5rem;
  padding-top: 1.7rem;
  padding-bottom: 3.2rem;
  font-family: var(--sans);
  font-size: 0.765rem;
  color: var(--ink-faint);
}
.site-footer-inner a { color: var(--ink-faint); border-bottom-color: var(--rule); }
.site-footer-inner a:hover { color: var(--accent); border-bottom-color: var(--accent-line); }

/* --- Narrow screens ------------------------------------------------------ */

@media (max-width: 40rem) {
  body { font-size: 17px; }

  .profile {
    flex-direction: column-reverse;
    align-items: flex-start;
    gap: 1.65rem;
    padding-top: 2.4rem;
  }  .profile-figure { flex-basis: 8.5rem; width: 8.5rem; margin-top: 0; }

  .topbar-nav { gap: 1.05rem; }
  .topbar-nav .is-secondary { display: none; }

  .pub {
    grid-template-columns: 1fr;
    gap: 0.3rem 0;
  }
  .pub-list.has-figures .pub { grid-template-columns: 1fr; }
  .pub-venue { text-align: left; line-height: 1.4; }
  .pub-fig { grid-column: 1; grid-row: auto; justify-content: flex-start; margin: 0.55rem 0 0; }

  .cv-item { grid-template-columns: 1fr; }
  .cv-date { margin-top: 0.1rem; }

  .award-list li { flex-direction: column; gap: 0.1rem; }
}

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

/* --- Print (so the page doubles as a CV handout) ------------------------- */

@media print {
  :root {
    --paper: #fff; --ink: #000; --ink-soft: #333;
    --ink-faint: #555; --rule: #ccc; --accent: #000; --accent-line: transparent;
  }
  .topbar, .site-footer, .profile-figure, .linkrow, .pub-fig { display: none; }
  .pub-list.has-figures .pub { grid-template-columns: 5.4rem 1fr; }
  body { font-size: 10.5pt; }
  .profile { padding-top: 0; }
  .section { margin-top: 1.4rem; }
  /* Protect individual entries, not whole sections — a section-level
     `avoid` pushes the entire publication list onto a fresh page. */
  .pub, .cv-item, .award-list li { page-break-inside: avoid; break-inside: avoid; }
  .section-title { page-break-after: avoid; break-after: avoid; }
  a { color: #000; border-bottom: 0; }
}
