/* =========================================================
   Yunchu Zhang — personal site
   Single stylesheet, no framework dependencies.
   ========================================================= */

:root {
  --bg: #ffffff;
  --bg-elev: #f8f8f8;
  --bg-soft: #f3f3f3;
  --fg: #111111;
  --fg-muted: #555555;
  --fg-faint: #999999;
  --border: #e8e8e8;
  --accent: #2563eb;
  --accent-soft: #dbeafe;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.06);
  --radius: 10px;
  --radius-sm: 6px;
  --maxw: 900px;
  --font-sans: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "PingFang SC", "Hiragino Sans GB", sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1014;
    --bg-elev: #161a21;
    --bg-soft: #1c2129;
    --fg: #e7e9ec;
    --fg-muted: #b3b8c2;
    --fg-faint: #7c8492;
    --border: #262b34;
    --accent: #7aa2f7;
    --accent-soft: #1d2a44;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow-md: 0 6px 18px rgba(0, 0, 0, 0.4);
  }
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

img, video { max-width: 100%; display: block; }

a {
  color: var(--accent);
  text-decoration: none;
  transition: color .15s ease;
}
a:hover { text-decoration: underline; }

h1, h2, h3, h4 {
  line-height: 1.25;
  margin: 0 0 0.5em;
  font-weight: 700;
  letter-spacing: -0.01em;
}
h1 { font-size: 2rem; }
h2 { font-size: 1.4rem; }
h3 { font-size: 1.05rem; }
p { margin: 0 0 1em; }

hr {
  border: 0;
  border-top: 1px solid var(--border);
  margin: 2.5rem 0;
}

::selection { background: var(--accent-soft); color: var(--fg); }

/* ---------- Layout ---------- */
.site {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 2rem 1.5rem 5rem;
}

/* ---------- Navigation ---------- */
.nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.25rem 0 2.5rem;
  font-size: 0.9rem;
}
.nav:not(:has(.brand)) {
  justify-content: flex-end;
}
.nav .brand {
  font-weight: 700;
  color: var(--fg);
  letter-spacing: -0.01em;
  font-size: 0.95rem;
}
.nav .brand:hover { text-decoration: none; color: var(--accent); }
.nav-links {
  display: flex;
  gap: 1.75rem;
  align-items: center;
}
.nav-links a {
  color: var(--fg-muted);
  font-weight: 500;
}
.nav-links a:hover {
  color: var(--fg);
  text-decoration: none;
}
.nav-links a[aria-current="page"] {
  color: var(--fg);
  text-decoration: none;
}

/* ---------- Hero / About ---------- */
.hero {
  display: grid;
  grid-template-columns: 190px 1fr;
  gap: 2.75rem;
  align-items: start;
  margin-bottom: 3.5rem;
}
.hero h1 {
  font-size: 2rem;
  margin-bottom: 0.7em;
}
.hero .avatar {
  width: 190px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 1px solid var(--border);
  background: var(--bg-elev);
}
.hero .avatar img {
  width: 100%;
  height: auto;
}
.hero .role {
  color: var(--fg-muted);
  font-size: 0.95rem;
  margin-bottom: 1rem;
}
.hero .bio { color: var(--fg-muted); max-width: 58ch; font-size: 0.95rem; }
.hero .bio p { margin-bottom: 0.65em; }
.hero .bio strong { color: var(--fg); font-weight: 600; }

/* ---------- Contact row ---------- */
.contact {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.1rem 0;
  margin-top: 1.25rem;
}
.contact a {
  display: inline-flex;
  align-items: center;
  gap: 0.35em;
  color: var(--fg-muted);
  font-size: 0.88rem;
  font-weight: 500;
  padding: 0.15em 0;
}
.contact a:hover {
  color: var(--accent);
  text-decoration: none;
}
.contact a + a::before {
  content: "·";
  display: inline-block;
  margin: 0 0.6em;
  color: var(--fg-faint);
  font-weight: 400;
}
.contact svg {
  width: 14px;
  height: 14px;
  flex: none;
}

/* ---------- Sections ---------- */
.section { margin-top: 3.5rem; }
.section > h2 {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  font-size: 0.85rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #777;
  margin-bottom: 1.5rem;
  padding-bottom: 0.6rem;
  border-bottom: 1px solid var(--border);
}
.section > h2 .see-all {
  font-size: 0.9rem;
  font-weight: 500;
  letter-spacing: 0;
  text-transform: none;
  color: var(--accent);
}

/* ---------- News list ---------- */
.news {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 0;
}
.news li {
  display: grid;
  grid-template-columns: 100px 1fr;
  gap: 1.25rem;
  align-items: baseline;
  padding: 0.6rem 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.93rem;
}
.news li:last-child { border-bottom: 0; }
.news time {
  color: var(--fg-faint);
  font-variant-numeric: tabular-nums;
  font-size: 0.85rem;
  font-weight: 500;
}
.news a:has(strong) {
  color: var(--fg);
}
.news a:has(strong):hover {
  color: var(--accent);
}
.news .badge {
  display: inline-block;
  border: 1px solid color-mix(in srgb, var(--accent) 40%, transparent);
  color: var(--accent);
  padding: 0 0.45em;
  border-radius: 3px;
  font-size: 0.7rem;
  font-weight: 600;
  margin-right: 0.35em;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  vertical-align: 1px;
}

/* ---------- Publication list ---------- */
.pubs {
  display: grid;
  gap: 0;
}
.pub {
  display: grid;
  grid-template-columns: 200px 1fr;
  gap: 1.5rem;
  padding: 1.5rem 0;
  border-bottom: 1px solid var(--border);
  background: none;
}
.pub:first-child { padding-top: 0; }
.pub:last-child { border-bottom: 0; }
.pub .media {
  position: relative;
  align-self: start;
  background: var(--bg-soft);
  border-radius: var(--radius-sm);
  overflow: hidden;
  aspect-ratio: 16 / 10;
}
.pub .media img,
.pub .media video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.pub .body { min-width: 0; }
.pub .title {
  font-size: 0.97rem;
  font-weight: 700;
  color: var(--fg);
  line-height: 1.35;
  margin: 0 0 0.3em;
}
.pub .title a { color: inherit; }
.pub .title a:hover { color: var(--accent); text-decoration: none; }
.pub .venue {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--fg-muted);
  margin-bottom: 0.3em;
}
.pub .venue .award {
  color: #dc2626;
  font-size: 0.88rem;
  font-weight: 700;
  margin-left: 0.35em;
}
@media (prefers-color-scheme: dark) {
  .pub .venue .award { color: #f87171; }
}
.pub .authors {
  font-size: 0.88rem;
  color: var(--fg-faint);
  margin-bottom: 0.6em;
  line-height: 1.5;
}
.pub .authors .me { font-weight: 600; color: var(--fg-muted); }
.pub .authors a { color: var(--fg-faint); }
.pub .authors a:hover { color: var(--accent); }
.pub .desc {
  font-size: 0.88rem;
  color: var(--fg-muted);
  margin: 0.7em 0 0;
  line-height: 1.55;
}
.pub .links {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0;
}
.pub .links a,
.pub .links .summary-toggle {
  color: var(--accent);
  font-size: 0.88rem;
  font-weight: 500;
}
.pub .links .summary-toggle {
  appearance: none;
  background: none;
  border: 0;
  padding: 0;
  font-family: inherit;
  line-height: inherit;
  cursor: pointer;
}
.pub .links a:hover,
.pub .links .summary-toggle:hover { text-decoration: underline; }
.pub .links > * + *::before {
  content: "·";
  display: inline-block;
  margin: 0 0.55em;
  color: var(--fg-faint);
  font-weight: 400;
}

/* ---------- Two-column grid variant (homepage) ---------- */
.pubs-grid {
  grid-template-columns: repeat(2, 1fr);
  gap: 1.75rem 1.5rem;
}
.pubs-grid .pub {
  grid-template-columns: 1fr;
  gap: 0.65rem;
  padding: 0;
  border-bottom: 0;
}
.pubs-grid .pub:first-child { padding-top: 0; }
.pubs-grid .pub .media { aspect-ratio: 16 / 8; }
.pubs-grid .pub .title {
  font-size: 0.9rem;
  min-height: 2.7em; /* reserve two lines so rows align */
}
.pubs-grid .pub .venue { display: none; }
.pubs-grid .pub .authors { display: none; }
.pubs-grid .pub .desc { display: none; }
.pubs-grid .pub .links { display: none; }

/* ---------- Filter controls ---------- */
.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
}
.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}
.filters button {
  appearance: none;
  border: 1px solid var(--border);
  background: none;
  color: var(--fg-muted);
  font: inherit;
  font-size: 0.82rem;
  font-weight: 500;
  padding: 0.3em 0.8em;
  border-radius: 999px;
  cursor: pointer;
  transition: all .15s ease;
}
.filters button:hover { color: var(--fg); border-color: var(--fg-muted); }
.filters button.active {
  background: var(--fg);
  color: var(--bg);
  border-color: var(--fg);
}
.sort {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--fg-muted);
  font-size: 0.82rem;
}
.sort select {
  appearance: none;
  -webkit-appearance: none;
  border: 1px solid var(--border);
  background: none;
  color: var(--fg);
  border-radius: 6px;
  padding: 0.3em 1.8em 0.3em 0.65em;
  font: inherit;
  font-size: 0.82rem;
  cursor: pointer;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='%23888'><path d='M4 6l4 4 4-4z'/></svg>");
  background-repeat: no-repeat;
  background-position: right 0.5em center;
  background-size: 14px;
}

/* ---------- Experience timeline ---------- */
.exp {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 0;
}
.exp li {
  display: grid;
  grid-template-columns: 160px 1fr;
  gap: 1.25rem;
  padding: 0.85rem 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.93rem;
}
.exp li:last-child { border-bottom: 0; }
.exp .when {
  color: var(--fg-faint);
  font-size: 0.85rem;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  padding-top: 0.1em;
}
.exp .what strong { color: var(--fg); font-weight: 600; }
.exp .what {
  color: var(--fg-muted);
  font-size: 0.93rem;
}
.exp .what .where { color: var(--fg-faint); font-size: 0.88rem; }

/* ---------- Footer ---------- */
.footer {
  margin-top: 5rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--border);
  color: var(--fg-faint);
  font-size: 0.82rem;
  text-align: center;
}
.footer a { color: var(--fg-faint); }

/* ---------- Mobile ---------- */
@media (max-width: 680px) {
  .hero {
    grid-template-columns: 1fr;
    gap: 1.25rem;
    text-align: center;
  }
  .hero .avatar {
    width: 130px;
    margin: 0 auto;
  }
  .hero .bio { text-align: left; }
  .contact { justify-content: center; }
  .pub {
    grid-template-columns: 1fr;
    gap: 0.75rem;
  }
  .pub .media { aspect-ratio: 16 / 9; }
  .pub:first-child { padding-top: 1.5rem; }
  .pubs-grid { grid-template-columns: 1fr; }
  .pubs-grid .pub:first-child { padding-top: 0; }
  .pubs-grid .pub .title { min-height: 0; }
  .news li,
  .exp li {
    grid-template-columns: 1fr;
    gap: 0.1rem;
  }
  .news time { font-size: 0.8rem; }
  .controls { flex-direction: column; align-items: stretch; }
  .nav { flex-direction: column; align-items: flex-start; gap: 0.4rem; padding-bottom: 1.5rem; }
  .nav-links { gap: 1.25rem; }
}

/* ---------- Motion preference ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation: none !important;
    transition: none !important;
  }
  html { scroll-behavior: auto; }
}
