/* ==========================================================================
   Xinyu Tang — Personal Homepage
   Clean academic homepage, adapted from an academic-homepage layout.
   ========================================================================== */

:root {
  --accent: #4f46e5;
  --accent-soft: #eef0fe;
  --accent-dark: #4338ca;
  --text: #1f2933;
  --text-soft: #4b5563;
  --muted: #7b8794;
  --border: #e6e8f0;
  --bg: #ffffff;
  --bg-soft: #f7f8fc;
  --badge-bg: #eef2ff;
  --badge-text: #3730a3;
  --radius: 14px;
  --shadow: 0 1px 3px rgba(16, 24, 40, 0.06), 0 6px 24px rgba(16, 24, 40, 0.06);
  --maxw: 900px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --accent: #8b8cf6;
    --accent-soft: #1e2033;
    --accent-dark: #a5b4fc;
    --text: #e5e9f0;
    --text-soft: #b8c1cc;
    --muted: #8a95a3;
    --border: #2a3143;
    --bg: #0f131c;
    --bg-soft: #161c28;
    --badge-bg: #232a49;
    --badge-text: #c7d2fe;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.4), 0 6px 24px rgba(0, 0, 0, 0.35);
  }
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Helvetica Neue",
    "PingFang SC", "Microsoft YaHei", Roboto, Arial, sans-serif;
  color: var(--text);
  background: var(--bg);
  line-height: 1.65;
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
}

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

.wrap {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 0 22px 80px;
}

/* ------------------------------------------------------------------ Nav */
.topnav {
  position: sticky;
  top: 0;
  z-index: 50;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(150%) blur(10px);
  border-bottom: 1px solid var(--border);
}
.topnav .wrap {
  padding: 12px 22px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.topnav .brand { font-weight: 700; letter-spacing: -0.01em; }
.topnav nav a {
  color: var(--text-soft);
  margin-left: 18px;
  font-size: 0.93rem;
  font-weight: 500;
}
.topnav nav a:hover { color: var(--accent); text-decoration: none; }
@media (max-width: 640px) {
  .topnav nav a { margin-left: 12px; font-size: 0.82rem; }
  .topnav .brand { font-size: 0.95rem; }
}

/* -------------------------------------------------------------- Profile */
.profile {
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 38px;
  align-items: start;
  padding: 48px 0 8px;
}
@media (max-width: 640px) {
  .profile { grid-template-columns: 1fr; gap: 22px; text-align: center; padding-top: 34px; }
}

.avatar-col { display: flex; flex-direction: column; align-items: center; gap: 16px; }
.avatar {
  width: 200px;
  height: 200px;
  border-radius: 50%;
  object-fit: cover;
  border: 4px solid var(--bg);
  box-shadow: var(--shadow);
  background: var(--bg-soft);
}

.social {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  max-width: 230px;
}
.social a {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 11px;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-soft);
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 999px;
  transition: all 0.15s ease;
}
.social a:hover {
  color: #fff;
  background: var(--accent);
  border-color: var(--accent);
  text-decoration: none;
  transform: translateY(-1px);
}
.social a i { font-size: 0.92rem; }

.intro h1 {
  margin: 0 0 2px;
  font-size: 2.15rem;
  letter-spacing: -0.02em;
  line-height: 1.15;
}
.intro .zh { color: var(--muted); font-weight: 500; font-size: 1.15rem; margin-left: 8px; }
.intro .role { margin: 6px 0 2px; color: var(--text-soft); font-weight: 600; }
.intro .affil { margin: 0 0 14px; color: var(--muted); }
.intro .affil a { font-weight: 600; }
.bio { margin: 0 0 12px; color: var(--text-soft); }
.bio strong { color: var(--text); }

/* -------------------------------------------------------------- Section */
section { padding-top: 42px; scroll-margin-top: 72px; }
.section-title {
  font-size: 1.4rem;
  margin: 0 0 18px;
  letter-spacing: -0.01em;
  display: flex;
  align-items: center;
  gap: 9px;
}
.section-title::after {
  content: "";
  flex: 1;
  height: 1px;
  background: linear-gradient(to right, var(--border), transparent);
  margin-left: 6px;
}

/* Research interests chips */
.interests { display: flex; flex-wrap: wrap; gap: 9px; }
.interests span {
  background: var(--accent-soft);
  color: var(--accent-dark);
  padding: 6px 14px;
  border-radius: 999px;
  font-size: 0.88rem;
  font-weight: 600;
}

/* ----------------------------------------------------------------- News */
.news-box {
  max-height: 240px;
  overflow-y: auto;
  padding: 4px 18px;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.news-box::-webkit-scrollbar { width: 8px; }
.news-box::-webkit-scrollbar-thumb { background: var(--border); border-radius: 8px; }
.news-list { list-style: none; margin: 0; padding: 10px 0; }
.news-list li { padding: 7px 0; border-bottom: 1px dashed var(--border); font-size: 0.94rem; }
.news-list li:last-child { border-bottom: none; }
.news-date {
  display: inline-block;
  min-width: 84px;
  font-weight: 700;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
  margin-right: 6px;
}

/* --------------------------------------------------------- Publications */
.pub-note {
  font-size: 0.88rem;
  color: var(--muted);
  margin: -6px 0 6px;
}
.pub-group-title {
  font-size: 1.02rem;
  font-weight: 700;
  color: var(--text-soft);
  margin: 26px 0 4px;
  letter-spacing: 0.01em;
}
.pub-list { list-style: none; margin: 0; padding: 0; }
.pub {
  display: grid;
  grid-template-columns: 240px 1fr;
  gap: 20px;
  padding: 18px 0;
  border-bottom: 1px solid var(--border);
  align-items: center;
}
.pub:last-child { border-bottom: none; }
@media (max-width: 640px) {
  .pub { grid-template-columns: 1fr; gap: 12px; }
}
.pub-thumb {
  width: 100%;
  height: auto;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: #fff;
  padding: 4px;
  box-shadow: var(--shadow);
}
.pub-venue {
  display: inline-block;
  background: var(--badge-bg);
  color: var(--badge-text);
  font-weight: 700;
  font-size: 0.76rem;
  text-align: center;
  letter-spacing: 0.02em;
  padding: 3px 10px;
  border-radius: 6px;
  margin-bottom: 6px;
}
.pub-venue.report { background: #fff1e6; color: #b45309; }
.pub-venue.preprint { background: var(--bg-soft); color: var(--muted); border: 1px solid var(--border); }
@media (prefers-color-scheme: dark) {
  .pub-venue.report { background: #3a2a14; color: #fcd9a5; }
  .pub-thumb { background: var(--bg-soft); }
}
.ccf-tag {
  display: inline-block;
  font-size: 0.68rem;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 4px;
  margin-left: 6px;
  vertical-align: middle;
}
.ccf-tag.ccf-a { background: #dcfce7; color: #166534; }
.ccf-tag.ccf-b { background: #fef3c7; color: #92400e; }
.ccf-tag.survey { background: #e0e7ff; color: #3730a3; }
@media (prefers-color-scheme: dark) {
  .ccf-tag.ccf-a { background: #14532d; color: #86efac; }
  .ccf-tag.ccf-b { background: #451a03; color: #fcd34d; }
  .ccf-tag.survey { background: #312e81; color: #c7d2fe; }
}
.pub-title { font-weight: 700; font-size: 1.03rem; margin: 2px 0 3px; color: var(--text); line-height: 1.4; }
.pub-authors { color: var(--text-soft); font-size: 0.92rem; margin: 0 0 5px; }
.pub-authors .me { color: var(--accent-dark); font-weight: 700; }
.pub-links { display: flex; flex-wrap: wrap; gap: 7px; }
.pub-links a {
  font-size: 0.78rem;
  font-weight: 600;
  padding: 2px 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--text-soft);
  background: var(--bg);
  transition: all 0.15s ease;
}
.pub-links a:hover { background: var(--accent); color: #fff; border-color: var(--accent); text-decoration: none; }

/* ------------------------------------------------------------ Timeline */
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li {
  display: grid;
  grid-template-columns: 170px 1fr;
  gap: 18px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}
.timeline li:last-child { border-bottom: none; }
@media (max-width: 560px) {
  .timeline li { grid-template-columns: 1fr; gap: 2px; }
}
.timeline .when { color: var(--muted); font-weight: 600; font-size: 0.9rem; padding-top: 1px; }
.timeline .what strong { display: block; color: var(--text); }
.timeline .what span { display: block; color: var(--text-soft); font-size: 0.93rem; }

/* -------------------------------------------------------------- Contact */
.bio code {
  background: var(--bg-soft);
  padding: 1px 7px;
  border-radius: 6px;
  border: 1px solid var(--border);
  font-size: 0.9rem;
}

/* --------------------------------------------------------- Lang toggle */
.lang-toggle {
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 4px 12px;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-soft);
  cursor: pointer;
  margin-left: 14px;
  transition: all 0.15s ease;
}
.lang-toggle:hover {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.lang-zh { display: none !important; }
body.zh .lang-en { display: none !important; }
body.zh span.lang-zh { display: inline !important; }
body.zh p.lang-zh,
body.zh ul.lang-zh { display: block !important; }
body.zh div.interests.lang-zh { display: flex !important; }
body.zh .timeline li.lang-zh { display: grid !important; }

/* ------------------------------------------------- Collapsible details */
.collab-details summary {
  cursor: pointer;
  list-style: none;
}
.collab-details summary::-webkit-details-marker { display: none; }
.collab-details summary::after {
  content: "▸";
  margin-left: 8px;
  font-size: 0.85em;
  color: var(--muted);
  transition: transform 0.2s ease;
  display: inline-block;
}
.collab-details[open] summary::after {
  transform: rotate(90deg);
}

/* -------------------------------------------------------------- Footer */
footer {
  margin-top: 56px;
  padding-top: 22px;
  border-top: 1px solid var(--border);
  text-align: center;
  color: var(--muted);
  font-size: 0.85rem;
}
footer a { color: var(--muted); }
