/* ==========================================================================
   yijia-xiao.com — site design system
   Quiet cool paper, graphite-green ink, one emerald accent (Tauric #14C290)
   used sparingly: link ink, hairline marks, section ticks. Never as a fill.
   ========================================================================== */

/* ---- Fonts (self-hosted, latin subsets, variable) ---------------------- */
@font-face {
  font-family: "Newsreader";
  src: url("/assets/fonts/research/newsreader-latin.woff2") format("woff2");
  font-weight: 200 800;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Newsreader";
  src: url("/assets/fonts/research/newsreader-latin-italic.woff2") format("woff2");
  font-weight: 200 800;
  font-style: italic;
  font-display: swap;
}
@font-face {
  font-family: "Lato";
  src: url("/assets/fonts/research/lato-latin-400.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Lato";
  src: url("/assets/fonts/research/lato-latin-700.woff2") format("woff2");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

/* ---- Tokens -------------------------------------------------------------- */
:root {
  --r-paper: #FCFDFC;
  --r-ink: #15211C;
  --r-muted: #5B6A64;
  --r-rule: #E3E9E6;
  --r-emerald: #14C290;
  --r-emerald-ink: #0A7A55;

  --r-serif: "Newsreader", "Iowan Old Style", Georgia, serif;
  --r-sans: "Lato", -apple-system, "Helvetica Neue", Arial, sans-serif;

  --r-site: 75rem;     /* 1200px site chrome / homepage width */
  --header-h: 3rem;    /* measured at runtime; fallback for no-JS */
}

/* ---- Base ---------------------------------------------------------------- */
.r-page, .r-page * { box-sizing: border-box; }
.r-page {
  margin: 0;
  background: var(--r-paper);
  color: var(--r-ink);
  font-family: var(--r-serif);
  font-size: 1.0625rem;
  line-height: 1.75;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
.r-page a { color: var(--r-emerald-ink); text-decoration: none; }
.r-page a:hover { text-decoration: underline; text-underline-offset: 3px; }
.r-page :focus-visible {
  outline: 2px solid var(--r-emerald);
  outline-offset: 3px;
  border-radius: 2px;
}
.r-page img { max-width: 100%; height: auto; }
@media (prefers-reduced-motion: no-preference) {
  .r-page { scroll-behavior: smooth; }
}

/* ---- Header ---------------------------------------------------------------
   Quiet top bar: wordmark left, small sans nav right, hairline below. */
.r-header {
  border-bottom: 1px solid var(--r-rule);
  background: var(--r-paper);
  position: sticky;
  top: 0;
  z-index: 50;
  transition: box-shadow 0.22s ease;
}
.r-header.is-floating { box-shadow: 0 1px 10px rgba(21, 33, 28, 0.06); }
@media (prefers-reduced-motion: reduce) {
  .r-header { transition: none; }
}
/* Anchor targets clear the sticky bar */
.r-page [id] { scroll-margin-top: calc(var(--header-h) + 1rem); }
.r-header__inner {
  max-width: var(--r-site);
  margin: 0 auto;
  padding: 0.85rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 1rem;
  flex-wrap: wrap;
}
.r-header__nav { display: flex; gap: 1.25rem; flex-wrap: wrap; row-gap: 0.3rem; }
.r-header__nav a {
  font-family: var(--r-sans);
  font-weight: 400;
  font-size: 0.84rem;
  white-space: nowrap;
  letter-spacing: 0.02em;
  color: var(--r-muted);
}
.r-header__nav a:hover { color: var(--r-emerald-ink); text-decoration: none; }
.r-header__nav a[aria-current="page"] { color: var(--r-ink); }

/* Small screens: compact two-line header, nav swipes horizontally */
@media (max-width: 56rem) {
  .r-header__inner {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.4rem;
    padding: 0.75rem 1.25rem 0.6rem;
  }
  .r-header__nav {
    max-width: 100%;
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .r-header__nav::-webkit-scrollbar { display: none; }
}

/* ---- Footer --------------------------------------------------------------------------- */
.r-footer { border-top: 1px solid var(--r-rule); margin-top: 2rem; }
.r-footer__inner {
  max-width: var(--r-site);
  margin: 0 auto;
  padding: 1.4rem 1.25rem;
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  font-family: var(--r-sans);
  font-weight: 400;
  font-size: 0.8rem;
  color: var(--r-muted);
}
.r-footer__links { display: flex; gap: 1.3rem; }
.r-footer__links a { color: var(--r-muted); }
.r-footer__links a:hover { color: var(--r-emerald-ink); }

/* ==========================================================================
   Homepage — same system, quieter application.
   Emerald appears only as ink-dark link color, hairline marks, and the
   section tick; never as an area fill.
   ========================================================================== */

.h-main { padding: 0 1.25rem 4rem; }
.h-grid {
  max-width: var(--r-site);
  margin: 3rem auto 0;
  display: grid;
  grid-template-columns: 15rem minmax(0, 1fr);
  gap: 3.5rem;
  align-items: start;
}

/* ---- Identity rail ---- */
.h-rail { position: sticky; top: calc(var(--header-h) + 3rem); }
.h-avatar {
  display: block;
  width: 9.25rem;
  height: 9.25rem;
  border-radius: 50%;
  object-fit: cover;
  border: 1px solid var(--r-rule);
}
.h-name {
  font-family: var(--r-sans);
  font-weight: 700;
  font-size: 1.28rem;
  letter-spacing: -0.01em;
  margin: 1.1rem 0 0.1rem;
}
.h-role {
  font-family: var(--r-sans);
  font-weight: 400;
  font-size: 0.85rem;
  color: var(--r-muted);
  margin: 0 0 0.7rem;
}
.h-tagline { font-size: 0.98rem; line-height: 1.55; margin: 0 0 0.55rem; }
.h-location {
  font-family: var(--r-sans);
  font-weight: 400;
  font-size: 0.8rem;
  color: var(--r-muted);
  margin: 0 0 1.2rem;
}
.h-links {
  display: flex;
  flex-direction: column;
  gap: 0.32rem;
  padding: 1rem 0;
  border-top: 1px solid var(--r-rule);
}
.h-links a {
  font-family: var(--r-sans);
  font-weight: 400;
  font-size: 0.85rem;
  color: var(--r-muted);
  width: fit-content;
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
}
/* Monochrome marks: inherit the link colour, never brand colours */
.h-links svg {
  width: 15px;
  height: 15px;
  flex: none;
  fill: currentColor;
  opacity: 0.75;
}
.h-links a:hover { color: var(--r-emerald-ink); text-decoration: none; }


/* ---- Content column ---- */
.h-article { min-width: 0; }
.h-article > p:first-of-type { font-size: 1.14rem; line-height: 1.7; }
.h-article p { margin: 0 0 1.05rem; }
.h-article strong { font-weight: 600; }

/* Section headings: sans, hairline rule, small emerald tick */
.h-article h1 {
  font-family: var(--r-sans);
  font-weight: 700;
  font-size: 1.42rem;
  letter-spacing: -0.012em;
  line-height: 1.25;
  margin: 3rem 0 1.1rem;
  padding-bottom: 0.55rem;
  border-bottom: 1px solid var(--r-rule);
  position: relative;
}
.h-article h1::after {
  content: "";
  position: absolute;
  left: 0;
  bottom: -1px;
  width: 2.2rem;
  height: 2px;
  background: var(--r-emerald);
}

/* Lists (news, honors, education, talks, internships) */
.h-article > ul , .h-article > .fold > ul { list-style: none; margin: 0 0 1.2rem; padding: 0; }
.h-article > ul > li , .h-article > .fold > ul > li { margin: 0 0 0.55rem; padding-left: 0; }
.h-article > ul > li > em:first-child , .h-article > .fold > ul > li > em:first-child {
  font-family: var(--r-sans);
  font-style: normal;
  font-weight: 400;
  font-size: 0.82rem;
  color: var(--r-muted);
  white-space: nowrap;
}
.h-article ul ul { list-style: disc; margin: 0.35rem 0 0.3rem; padding-left: 1.3rem; }
.h-article ul ul li { margin-bottom: 0.2rem; font-size: 0.98rem; }
.h-article ul ul li::marker { color: var(--r-emerald-ink); font-size: 0.8em; }

/* Research-pillar bullets in the intro keep emerald markers */
.h-article > ul:first-of-type{ list-style: disc; padding-left: 1.3rem; }
.h-article > ul:first-of-type > li{ margin-bottom: 0.6rem; }
.h-article > ul:first-of-type > li::marker{ color: var(--r-emerald-ink); font-size: 0.85em; }

/* Publications: open editorial rows, hairline-separated (no boxes, no pills) */
.h-article .paper-box {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(0, 3fr);
  gap: 2rem;
  align-items: start;
  padding: 1.8rem 0;
  border-bottom: 1px solid var(--r-rule);
  margin: 0;
}
.h-article .paper-box:last-of-type { border-bottom: none; }
.h-article .paper-box-image { min-width: 0; align-self: center; }
.h-article .paper-box-image img {
  display: block;
  width: 100%;
  background: #fff;
  border: 1px solid var(--r-rule);
  border-radius: 6px;
  padding: 0.45rem;
}
.h-article .pub-venue {
  display: block;
  font-family: var(--r-sans);
  font-weight: 400;
  font-size: 0.72rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--r-emerald-ink);
  margin-bottom: 0.35rem;
}
.h-article .paper-box-text { min-width: 0; }
.h-article .paper-box-text p { margin: 0 0 0.55rem; }
.h-article .paper-box-text > p:first-child {
  font-family: var(--r-sans);
  font-weight: 400;
  font-size: 0.82rem;
  line-height: 1.5;
  color: var(--r-muted);
}
.h-article .paper-box-text > p:first-child a:first-of-type {
  display: block;
  font-weight: 700;
  font-size: 1.05rem;
  line-height: 1.4;
  letter-spacing: -0.008em;
  color: var(--r-ink);
  margin-bottom: 0.15rem;
}
.h-article .paper-box-text > p:first-child a:first-of-type:hover { color: var(--r-emerald-ink); text-decoration: none; }
.h-article .paper-box-text > p:first-child a:not(:first-of-type) { font-weight: 400; }
.h-article .paper-box-text > p:first-child strong { font-weight: 400; }
.h-article .paper-box-text p:not(:first-child) { font-size: 0.95rem; line-height: 1.62; }

/* Visitors block: hairline-separated, map sized and on-palette */
.h-article p[align="center"] {
  margin: 3.5rem 0 0;
  padding-top: 1.9rem;
  border-top: 1px solid var(--r-rule);
  font-family: var(--r-sans);
  font-size: 0.85rem;
  color: var(--r-muted);
}
.h-article p[align="center"] img {
  display: block;
  width: 360px;
  max-width: 100%;
  height: auto;
  margin: 0 auto;
  border: 1px solid var(--r-rule);
  border-radius: 10px;
  background: var(--r-paper);
}
.h-article p[align="center"] br { display: none; }
/* Visit counter — content injected at the edge; hidden when absent */
.h-article .h-visits {
  display: block;
  margin-top: 0.9rem;
  font-family: var(--r-sans);
  font-size: 0.8rem;
  letter-spacing: 0.04em;
  color: var(--r-muted);
}
.h-article .h-visits:empty { display: none; }
.h-article .h-visits strong { font-weight: 700; color: var(--r-ink); }

/* ---- Responsive ---- */
@media (max-width: 56rem) {
  .h-grid { grid-template-columns: 1fr; gap: 2rem; margin-top: 2.2rem; }
  .h-rail { position: static; }
  .h-rail__inner { text-align: center; }
  .h-avatar { margin: 0 auto; width: 8rem; height: 8rem; }
  .h-links { flex-direction: row; flex-wrap: wrap; justify-content: center; gap: 0.9rem; }
  .h-article { max-width: none; }
}
@media (max-width: 46rem) {
  .h-article .paper-box { grid-template-columns: 1fr; gap: 0.9rem; }
}

/* ---- 404 --------------------------------------------------------------- */
.e-main {
  max-width: var(--r-site);
  margin: 0 auto;
  padding: 7rem 1.25rem 9rem;
  text-align: center;
}
.e-code {
  font-family: var(--r-sans);
  font-weight: 700;
  font-size: 3.2rem;
  line-height: 1;
  letter-spacing: -0.02em;
  color: var(--r-emerald-ink);
  margin: 0 0 0.7rem;
}
.e-title {
  font-family: var(--r-sans);
  font-weight: 700;
  font-size: 1.42rem;
  letter-spacing: -0.012em;
  margin: 0 0 0.5rem;
}
.e-note { color: var(--r-muted); margin: 0 0 1.7rem; }
.e-home { font-family: var(--r-sans); font-size: 0.88rem; }

/* ---- Folded entries (older News / Publications) ------------------------- */
.fold.is-collapsed { display: none; }
.fold > ul:first-child { margin-top: 0; }
.h-showmore {
  display: block;
  margin: 0.4rem 0 1.4rem;
  padding: 0;
  border: 0;
  background: none;
  font-family: var(--r-sans);
  font-size: 0.85rem;
  letter-spacing: 0.02em;
  color: var(--r-muted);
  cursor: pointer;
}
.h-showmore:hover { color: var(--r-emerald-ink); text-decoration: underline; text-underline-offset: 3px; }
@media print {
  .fold.is-collapsed { display: block; }
  .h-showmore { display: none; }
}
