/* ==========================================================================
   Xinrun Wang — personal site
   Academic layout: masthead nav + sticky author sidebar + content column
   ========================================================================== */

:root {
  --bg: #ffffff;
  --bg-soft: #f7f8fa;
  --bg-sidebar: #ffffff;
  --text: #1f2328;
  --text-muted: #5c6570;
  --text-faint: #8a929c;
  --border: #e3e6ea;
  --link: #1b6ac9;
  --link-hover: #0d4f9e;
  --accent: #1b6ac9;
  --accent-soft: #eaf2fc;
  --highlight: #c62828;
  --highlight-soft: #fdecec;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 4px 16px rgba(16, 24, 40, .04);
  --radius: 10px;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "Helvetica Neue",
          "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", Arial, sans-serif;
}

html[data-theme="dark"] {
  --bg: #14171a;
  --bg-soft: #1b1f23;
  --bg-sidebar: #1b1f23;
  --text: #e6e9ec;
  --text-muted: #a4adb7;
  --text-faint: #7d8792;
  --border: #2b3138;
  --link: #6aaef5;
  --link-hover: #97c8fb;
  --accent: #6aaef5;
  --accent-soft: #1d2a38;
  --highlight: #ff7b72;
  --highlight-soft: #33201f;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 4px 16px rgba(0, 0, 0, .25);
}

* { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  scroll-padding-top: 70px;
}

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

a { color: var(--link); text-decoration: none; }
a:hover { color: var(--link-hover); text-decoration: underline; }

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

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

/* --------------------------------------------------------------- masthead */

.masthead {
  position: sticky;
  top: 0;
  z-index: 100;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--border);
}

.masthead__inner {
  max-width: 1180px;
  margin: 0 auto;
  padding: 0 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  min-height: 56px;
}

.site-title {
  font-weight: 700;
  font-size: .98rem;
  letter-spacing: .01em;
  color: var(--text);
  white-space: nowrap;
}
.site-title:hover { color: var(--accent); text-decoration: none; }

.nav-links {
  list-style: none;
  display: flex;
  align-items: center;
  gap: .25rem;
  margin: 0;
  padding: 0;
}

.nav-links a {
  display: block;
  padding: .4rem .7rem;
  border-radius: 6px;
  font-size: .9rem;
  font-weight: 500;
  color: var(--text-muted);
}
.nav-links a:hover { background: var(--bg-soft); color: var(--text); text-decoration: none; }
.nav-links a.is-active { color: var(--accent); background: var(--accent-soft); }

.theme-toggle {
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-muted);
  border-radius: 6px;
  width: 32px;
  height: 32px;
  font-size: .95rem;
  cursor: pointer;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.theme-toggle:hover { color: var(--text); border-color: var(--text-faint); }

.nav-toggle {
  display: none;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  border-radius: 6px;
  width: 34px;
  height: 32px;
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
}

/* ------------------------------------------------------------------ layout */

.layout {
  max-width: 1180px;
  margin: 0 auto;
  padding: 2.5rem 1.5rem 3rem;
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  gap: 3rem;
  align-items: start;
}

.layout--wide { grid-template-columns: minmax(0, 1fr); }

/* ----------------------------------------------------------------- sidebar */

.sidebar {
  position: sticky;
  top: 84px;
  text-align: center;
}

.sidebar__avatar {
  width: 190px;
  height: 190px;
  object-fit: cover;
  border-radius: 50%;
  border: 3px solid var(--bg);
  box-shadow: var(--shadow);
  margin-bottom: 1rem;
}

.sidebar__name {
  margin: 0 0 .15rem;
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: -.01em;
}

.sidebar__bio {
  margin: 0 0 1rem;
  font-size: .88rem;
  color: var(--text-muted);
  line-height: 1.5;
}
.sidebar__bio strong { color: var(--text); font-weight: 600; }

.sidebar__meta {
  list-style: none;
  margin: 0 0 1rem;
  padding: 1rem 0 0;
  border-top: 1px solid var(--border);
  text-align: left;
  font-size: .86rem;
  color: var(--text-muted);
}
.sidebar__meta li { margin-bottom: .45rem; display: flex; gap: .55rem; align-items: baseline; }
.sidebar__meta .ico { flex: none; text-align: center; color: var(--text-faint); font-size: .92em; }

.sidebar__links {
  list-style: none;
  margin: 0;
  padding: 1rem 0 0;
  border-top: 1px solid var(--border);
  text-align: left;
  font-size: .86rem;
}
.sidebar__links li { margin-bottom: .45rem; display: flex; gap: .55rem; align-items: baseline; }
.sidebar__links .ico { flex: none; text-align: center; color: var(--text-faint); font-size: .92em; }

/* ----------------------------------------------------------------- content */

.content { min-width: 0; }

.content h1 {
  font-size: 1.9rem;
  font-weight: 700;
  letter-spacing: -.02em;
  margin: 0 0 .4rem;
}

.content h2 {
  font-size: 1.28rem;
  font-weight: 700;
  letter-spacing: -.01em;
  margin: 2.6rem 0 1rem;
  padding-bottom: .45rem;
  border-bottom: 1px solid var(--border);
}
.content h2:first-child { margin-top: 0; }

.content h3 {
  font-size: 1.02rem;
  font-weight: 650;
  margin: 1.8rem 0 .6rem;
}

.content p { margin: 0 0 1rem; }

.lede {
  font-size: 1.02rem;
  color: var(--text-muted);
}

.muted { color: var(--text-muted); }
.small { font-size: .85rem; }

/* ------------------------------------------------------------------- cards */

.callout {
  border: 1px solid var(--border);
  border-left: 3px solid var(--highlight);
  background: var(--bg-soft);
  border-radius: var(--radius);
  padding: 1.1rem 1.25rem;
  margin: 0 0 1.6rem;
  font-size: .94rem;
}
.callout__tag {
  display: inline-block;
  font-weight: 700;
  color: var(--highlight);
  background: var(--highlight-soft);
  border-radius: 5px;
  padding: 0 .45rem;
  margin-right: .4rem;
  font-size: .82rem;
  letter-spacing: .02em;
}
.callout p:last-child { margin-bottom: 0; }

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1rem;
  margin-bottom: 1rem;
}

.card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-soft);
  padding: 1rem 1.1rem;
}
.card h3 { margin: 0 0 .35rem; font-size: .98rem; }
.card p { margin: 0; font-size: .88rem; color: var(--text-muted); line-height: 1.55; }

a.card { color: inherit; display: block; transition: border-color .15s, transform .15s; }
a.card:hover { text-decoration: none; border-color: var(--accent); transform: translateY(-1px); }
a.card:hover h3 { color: var(--accent); }

/* -------------------------------------------------------------------- news */

.news {
  list-style: none;
  margin: 0;
  padding: 0;
}
.news > li {
  display: grid;
  grid-template-columns: 108px minmax(0, 1fr);
  gap: 1rem;
  padding: .7rem 0;
  border-bottom: 1px dashed var(--border);
  font-size: .94rem;
}
.news > li:last-child { border-bottom: 0; }
.news .date {
  color: var(--text-faint);
  font-size: .82rem;
  font-variant-numeric: tabular-nums;
  padding-top: .12rem;
  white-space: nowrap;
}

.news--collapsed > li:nth-child(n + 7) { display: none; }
.news--collapsed.is-open > li { display: grid; }

.more-btn {
  margin-top: 1rem;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-muted);
  border-radius: 6px;
  padding: .4rem .9rem;
  font: inherit;
  font-size: .86rem;
  cursor: pointer;
}
.more-btn:hover { color: var(--text); border-color: var(--text-faint); }

/* ------------------------------------------------------------ publications */

.pub-note {
  font-size: .86rem;
  color: var(--text-muted);
  margin-bottom: 1.4rem;
}

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

.pubs > li {
  position: relative;
  padding: .85rem 0 .85rem 1.6rem;
  border-bottom: 1px solid var(--border);
}
.pubs > li:last-child { border-bottom: 0; }
.pubs > li::before {
  content: "";
  position: absolute;
  left: .3rem;
  top: 1.5rem;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--border);
}
.pubs > li:hover::before { background: var(--accent); }

.pub-title {
  display: block;
  font-weight: 600;
  font-size: .98rem;
  line-height: 1.45;
  color: var(--text);
  margin-bottom: .25rem;
}
a.pub-title:hover { color: var(--accent); text-decoration: none; }

.pub-authors {
  display: block;
  font-size: .87rem;
  color: var(--text-muted);
  line-height: 1.5;
}
.pub-authors b { color: var(--text); }

.pub-venue {
  display: block;
  font-size: .85rem;
  color: var(--text-faint);
  font-style: italic;
  margin-top: .15rem;
}

.badge {
  display: inline-block;
  margin-top: .35rem;
  font-size: .76rem;
  font-weight: 700;
  letter-spacing: .02em;
  color: var(--highlight);
  background: var(--highlight-soft);
  border-radius: 5px;
  padding: .05rem .45rem;
}
.badge--neutral { color: var(--accent); background: var(--accent-soft); }

.pub-remark {
  display: block;
  margin-top: .3rem;
  font-size: .82rem;
  color: var(--text-faint);
}
.pub-remark b { color: var(--text-muted); }

.year-head {
  display: flex;
  align-items: center;
  gap: .8rem;
  margin: 2.4rem 0 .4rem;
  font-size: 1.15rem;
  font-weight: 700;
}
.year-head::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border);
}
.year-head:first-child { margin-top: 0; }

.year-nav {
  display: flex;
  flex-wrap: wrap;
  gap: .4rem;
  margin: 0 0 2rem;
  padding: 0;
  list-style: none;
}
.year-nav a {
  display: block;
  padding: .2rem .6rem;
  font-size: .84rem;
  font-variant-numeric: tabular-nums;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--text-muted);
}
.year-nav a:hover { border-color: var(--accent); color: var(--accent); text-decoration: none; }

/* ------------------------------------------------------------------ people */

.lab-hero {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-soft);
  padding: 1.4rem 1.5rem;
  margin-bottom: 2rem;
}
.lab-hero img { width: 120px; flex: none; }
.lab-hero h1 { margin: 0 0 .3rem; font-size: 1.5rem; }
.lab-hero p { margin: 0; font-size: .93rem; color: var(--text-muted); }

.people {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 1rem;
  list-style: none;
  margin: 0 0 1rem;
  padding: 0;
}
.person {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .9rem 1rem;
  background: var(--bg-soft);
}
.person__name { font-weight: 650; font-size: .96rem; }
.person__role { font-size: .84rem; color: var(--text-muted); margin-top: .15rem; }
.person__when { font-size: .8rem; color: var(--text-faint); font-variant-numeric: tabular-nums; }

.plain-list { list-style: none; margin: 0 0 1rem; padding: 0; }
.plain-list > li {
  padding: .55rem 0;
  border-bottom: 1px dashed var(--border);
  font-size: .93rem;
}
.plain-list > li:last-child { border-bottom: 0; }

.speculations { counter-reset: spec; list-style: none; margin: 0; padding: 0; }
.speculations > li {
  counter-increment: spec;
  position: relative;
  padding: .2rem 0 1.1rem 2.4rem;
  font-size: .94rem;
  color: var(--text-muted);
}
.speculations > li::before {
  content: counter(spec, decimal-leading-zero);
  position: absolute;
  left: 0;
  top: .2rem;
  font-size: .78rem;
  font-weight: 700;
  color: var(--text-faint);
  font-variant-numeric: tabular-nums;
}
.speculations b { color: var(--text); }

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

.site-footer {
  border-top: 1px solid var(--border);
  margin-top: 2rem;
}
.site-footer__inner {
  max-width: 1180px;
  margin: 0 auto;
  padding: 1.4rem 1.5rem 2.2rem;
  font-size: .82rem;
  color: var(--text-faint);
  display: flex;
  flex-wrap: wrap;
  gap: .8rem;
  justify-content: space-between;
}

/* ------------------------------------------------------------- responsive */

@media (max-width: 900px) {
  .layout {
    grid-template-columns: minmax(0, 1fr);
    gap: 2rem;
    padding-top: 2rem;
  }
  .sidebar {
    position: static;
    display: grid;
    grid-template-columns: 150px minmax(0, 1fr);
    gap: 1.4rem;
    text-align: left;
    align-items: center;
    padding-bottom: 1.6rem;
    border-bottom: 1px solid var(--border);
  }
  .sidebar__avatar { width: 150px; height: 150px; margin: 0; }
  .sidebar__meta, .sidebar__links { border-top: 0; padding-top: 0; margin-bottom: .6rem; }
  .sidebar__links { display: flex; flex-wrap: wrap; gap: .3rem 1rem; }
  .sidebar__links li { margin-bottom: 0; }
}

@media (max-width: 680px) {
  body { font-size: 15.5px; }
  .nav-toggle { display: inline-flex; align-items: center; justify-content: center; }
  .masthead__inner { flex-wrap: wrap; padding: .5rem 1.1rem; }
  .nav-links {
    order: 3;
    flex-basis: 100%;
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    display: none;
    padding-bottom: .5rem;
  }
  .nav-links.is-open { display: flex; }
  .nav-links a { padding: .55rem .6rem; }
  .layout { padding: 1.6rem 1.1rem 2rem; }
  .sidebar { grid-template-columns: minmax(0, 1fr); justify-items: start; }
  .sidebar__avatar { width: 130px; height: 130px; }
  .news > li { grid-template-columns: minmax(0, 1fr); gap: .15rem; }
  .lab-hero { flex-direction: column; align-items: flex-start; text-align: left; }
  .content h1 { font-size: 1.55rem; }
}
