/* Shengyu Cao — homepage styles (About · Research · CV).
   Navy accent = the CV's heading color (#1E4678). System Palatino stack (matches the
   CV's TeX Gyre Pagella): no web-font downloads, fast everywhere incl. mainland China. */

:root {
  color-scheme: light dark;

  --bg: #fbfaf7;
  --surface: #ffffff;
  --ink: #1c1b19;
  --ink-2: #4a4843;
  --muted: #6b6963;
  --rule: #e4e1d9;
  --rule-strong: #cfcbc0;
  --accent: #1e4678;
  --accent-ink: #12325a;
  --accent-wash: #edf1f7;
  --crimson: #9b2335;

  --serif: "Palatino Linotype", Palatino, "Book Antiqua", "URW Palladio L", P052,
           "TeX Gyre Pagella", Georgia, "Songti SC", "Noto Serif CJK SC",
           "Source Han Serif SC", SimSun, serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial,
          "PingFang SC", "Microsoft YaHei", sans-serif;

  --measure: 44rem;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #131417;
    --surface: #1c1e22;
    --ink: #ecebe6;
    --ink-2: #c6c4bc;
    --muted: #9d9a92;
    --rule: #2e3036;
    --rule-strong: #43464d;
    --accent: #9fbde6;
    --accent-ink: #c4d7f1;
    --accent-wash: #1d2735;
    --crimson: #ec97a3;
  }
}

/* ---------- base ---------- */

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

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

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--serif);
  font-size: 1.0625rem;
  line-height: 1.65;
  font-kerning: normal;
  font-variant-ligatures: common-ligatures;
  -webkit-font-smoothing: antialiased;
  border-top: 3px solid var(--accent);
}

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

a {
  color: var(--accent);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-decoration-color: var(--rule-strong);
  text-decoration-color: color-mix(in srgb, var(--accent) 35%, transparent);
  text-underline-offset: 0.18em;
}
a:hover { color: var(--accent-ink); text-decoration-color: currentColor; }

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

h1, h2, h3 { font-weight: 600; line-height: 1.25; text-wrap: balance; }
p { margin: 0 0 1em; text-wrap: pretty; }
sup { line-height: 0; }

.wrap { width: 100%; max-width: var(--measure); margin: 0 auto; padding-inline: 1.25rem; }
.wrap-wide { max-width: 60rem; }

.skip {
  position: absolute; left: 1rem; top: -3rem; z-index: 10;
  padding: 0.5rem 0.9rem;
  background: var(--surface); border: 1px solid var(--rule); border-radius: 6px;
  font-family: var(--sans); font-size: 0.875rem;
}
.skip:focus { top: 1rem; }

.cjk { font-family: "Songti SC", "STSong", "Noto Serif CJK SC", "Source Han Serif SC", SimSun, var(--serif); }

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

.site-header { border-bottom: 1px solid var(--rule); }
.header-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem 1.5rem;
  padding-top: 1.15rem;
  padding-bottom: 1.05rem;
}
.brand {
  font-size: 1.125rem;
  font-weight: 600;
  letter-spacing: 0.005em;
  color: var(--ink);
  text-decoration: none;
}
.brand:hover { color: var(--accent); }

.nav { display: flex; gap: 1.75rem; font-family: var(--sans); font-size: 0.9375rem; }
.nav a {
  position: relative;
  padding: 0.2rem 0;
  color: var(--ink-2);
  text-decoration: none;
}
.nav a:hover { color: var(--accent); }
.nav a[aria-current="page"] { color: var(--ink); }
.nav a[aria-current="page"]::after {
  content: "";
  position: absolute; left: 0; right: 0; bottom: -0.15rem;
  height: 2px; border-radius: 2px;
  background: var(--accent);
}

main { flex: 1; padding-top: 3rem; padding-bottom: 3.5rem; }

/* ---------- about ---------- */

.profile {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 1.25rem 2rem;
  align-items: center;
}
.avatar {
  display: block;
  width: 8rem; height: 8rem;
  object-fit: cover;
  border-radius: 50%;
  border: 1px solid var(--rule);
  background: var(--surface);
}
.profile h1 {
  margin: 0 0 0.3rem;
  font-size: clamp(2rem, 1.6rem + 1.8vw, 2.6rem);
  letter-spacing: -0.012em;
}
.profile h1 .cjk {
  margin-left: 0.3em;
  font-size: 0.56em;
  font-weight: 400;
  letter-spacing: 0.04em;
  color: var(--muted);
  white-space: nowrap;
}
.role { margin: 0 0 0.85rem; font-size: 1.0625rem; line-height: 1.5; color: var(--ink-2); }

.links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 1.35rem;
  margin: 0;
  padding: 0;
  list-style: none;
  font-family: var(--sans);
  font-size: 0.9375rem;
}
.links a { display: inline-flex; align-items: center; gap: 0.4rem; text-decoration: none; }
.links a:hover { text-decoration: underline; }
.links svg {
  width: 1.05em; height: 1.05em; flex: none;
  fill: none; stroke: currentColor; stroke-width: 1.6;
  stroke-linecap: round; stroke-linejoin: round;
}

.market {
  display: flex;
  align-items: baseline;
  gap: 0.65rem;
  margin: 2.25rem 0 2rem;
  padding: 0.8rem 1rem;
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: 10px;
  font-family: var(--sans);
  font-size: 0.9375rem;
  line-height: 1.5;
  color: var(--ink-2);
}
.market .dot {
  flex: none;
  width: 0.5rem; height: 0.5rem;
  border-radius: 50%;
  background: var(--crimson);
  transform: translateY(-0.05em);
}
.market strong { color: var(--ink); font-weight: 600; }
.market a { font-family: var(--serif); font-style: italic; font-size: 1.0625em; }

.bio p { margin-bottom: 1.1em; }

/* ---------- research ---------- */

.page-title { margin: 0 0 0.6rem; font-size: 2rem; letter-spacing: -0.01em; }
.lede { margin-bottom: 2.5rem; color: var(--ink-2); font-size: 1.0625rem; }

.group { margin-top: 2.5rem; }
.group > h2 {
  margin: 0 0 0.4rem;
  padding-bottom: 0.4rem;
  font-size: 1.25rem;
  color: var(--accent);
  border-bottom: 1px solid var(--rule-strong);
  border-bottom-color: color-mix(in srgb, var(--accent) 30%, transparent);
}

.papers { margin: 0; padding: 0; list-style: none; }
.paper { padding: 1.15rem 0; border-bottom: 1px solid var(--rule); scroll-margin-top: 1.5rem; }
.paper:last-child { border-bottom: 0; }
.paper h3 { margin: 0 0 0.3rem; font-size: 1.125rem; line-height: 1.35; }
.paper h3 a { color: var(--ink); text-decoration: none; }
.paper h3 a:hover { color: var(--accent); text-decoration: underline; text-decoration-color: currentColor; }

.meta { margin: 0 0 0.7rem; font-size: 0.96875rem; color: var(--ink-2); }
.meta .sep { padding: 0 0.35em; color: var(--muted); }
.nowrap { white-space: nowrap; }

.actions {
  display: flex; flex-wrap: wrap; gap: 0.5rem;
  margin: 0;
  font-family: var(--sans); font-size: 0.8125rem; line-height: 1;
}
.chip {
  display: inline-flex; align-items: center; gap: 0.35em;
  padding: 0.42em 0.8em;
  border: 1px solid var(--rule-strong); border-radius: 999px;
  background: transparent; color: var(--ink-2);
  font: inherit; text-decoration: none; cursor: pointer;
}
.chip:hover { border-color: var(--accent); color: var(--accent); text-decoration: none; }
.chip[aria-expanded="true"] { background: var(--accent-wash); border-color: transparent; color: var(--accent-ink); }
.chip .chev {
  width: 0.55em; height: 0.55em;
  border-right: 1.5px solid currentColor; border-bottom: 1.5px solid currentColor;
  transform: translateY(-0.15em) rotate(45deg);
  transition: transform 0.15s ease;
}
.chip[aria-expanded="true"] .chev { transform: translateY(0.1em) rotate(-135deg); }
@media (prefers-reduced-motion: reduce) { .chip .chev { transition: none; } }

.abstract {
  margin: 0.85rem 0 0.15rem;
  padding: 0.1rem 0 0.1rem 1rem;
  border-left: 2px solid var(--rule-strong);
  font-size: 0.96875rem; line-height: 1.62;
  color: var(--ink-2);
}
.abstract p:last-child { margin-bottom: 0; }
/* hidden="until-found" keeps the box rendered in Chromium — collapse it fully */
.abstract[hidden] { margin: 0; padding: 0; border: 0; }

/* ---------- CV ---------- */

.cv-head {
  display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between;
  gap: 0.75rem 1.5rem;
  margin-bottom: 1.25rem;
}
.cv-head .page-title { margin: 0; }
.cv-actions { display: flex; flex-wrap: wrap; gap: 0.6rem; margin: 0; }
.button {
  display: inline-flex; align-items: center; gap: 0.45rem;
  padding: 0.55rem 1rem;
  border: 1px solid var(--accent); border-radius: 8px;
  background: var(--accent); color: var(--surface);
  font-family: var(--sans); font-size: 0.875rem; font-weight: 500;
  text-decoration: none;
}
.button:hover { background: var(--accent-ink); border-color: var(--accent-ink); color: var(--surface); }
.button.ghost { background: transparent; color: var(--accent); border-color: var(--rule-strong); }
.button.ghost:hover { border-color: var(--accent); color: var(--accent-ink); background: transparent; }
.button svg { width: 1em; height: 1em; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.cv-frame {
  display: block;
  width: 100%;
  height: min(88vh, 70rem);
  border: 1px solid var(--rule);
  border-radius: 10px;
  background: var(--surface);
}
.cv-note { margin: 0.75rem 0 0; font-family: var(--sans); font-size: 0.8125rem; color: var(--muted); }

/* ---------- footer ---------- */

.site-footer { border-top: 1px solid var(--rule); }
.footer-inner {
  display: flex; flex-wrap: wrap; justify-content: space-between; gap: 0.25rem 1rem;
  padding-top: 1.1rem; padding-bottom: 1.6rem;
  font-family: var(--sans); font-size: 0.8125rem; color: var(--muted);
}
.footer-inner a { color: inherit; text-decoration: none; }
.footer-inner a:hover { color: var(--accent); text-decoration: underline; }

/* ---------- small screens ---------- */

@media (max-width: 34rem) {
  body { font-size: 1rem; }
  main { padding-top: 2rem; }
  .nav { gap: 1.25rem; }
  .profile { grid-template-columns: 1fr; }
  .avatar { width: 6.5rem; height: 6.5rem; }
  .market { margin-top: 1.75rem; }
}

/* PDFs don't render inline on most phones: keep just the two buttons there */
@media (max-width: 40rem) {
  .cv-frame, .cv-note { display: none; }
}

/* ---------- print ---------- */

@media print {
  :root { color-scheme: light; }
  body { border-top: 0; background: #fff; color: #000; font-size: 10.5pt; }
  .site-header .nav, .skip, .chip[aria-controls] { display: none !important; }
  a { color: inherit; text-decoration: none; }
}
