/* ===================================================================
   Jiawei Xiong — academic site
   Design: clean, scholarly, responsive, light + dark themes
   =================================================================== */

:root {
  --bg: #ffffff;
  --bg-alt: #f6f7f9;
  --surface: #ffffff;
  --text: #1c2530;
  --text-soft: #55606d;
  --text-faint: #626d7b;
  --border: #e4e8ee;
  --accent: #1a4f8b;          /* scholarly navy */
  --accent-soft: #e8f0fa;
  --accent-hover: #123a68;
  --shadow: 0 1px 3px rgba(20, 40, 70, 0.06), 0 8px 24px rgba(20, 40, 70, 0.05);
  --maxw: 860px;
  --nav-h: 60px;
  --serif: Georgia, "Times New Roman", "Songti SC", serif;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

:root[data-theme="dark"] {
  --bg: #0f141a;
  --bg-alt: #151c24;
  --surface: #161d26;
  --text: #e6ebf1;
  --text-soft: #a9b4c0;
  --text-faint: #7e8a97;
  --border: #26313d;
  --accent: #6ea8e0;
  --accent-soft: #16283d;
  --accent-hover: #9ec4ec;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.4), 0 8px 24px rgba(0, 0, 0, 0.3);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f141a;
    --bg-alt: #151c24;
    --surface: #161d26;
    --text: #e6ebf1;
    --text-soft: #a9b4c0;
    --text-faint: #7e8a97;
    --border: #26313d;
    --accent: #6ea8e0;
    --accent-soft: #16283d;
    --accent-hover: #9ec4ec;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.4), 0 8px 24px rgba(0, 0, 0, 0.3);
  }
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; scroll-padding-top: calc(var(--nav-h) + 12px); }

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

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

.skip-link {
  position: absolute; left: -999px; top: 0;
  background: var(--accent); color: #fff; padding: 10px 16px; z-index: 200; border-radius: 0 0 6px 0;
}
.skip-link:focus { left: 0; }

/* ---------------- Navigation ---------------- */
.site-nav {
  position: sticky; top: 0; z-index: 100;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(180%) blur(10px);
  border-bottom: 1px solid var(--border);
}
.nav-inner {
  max-width: var(--maxw); margin: 0 auto; height: var(--nav-h);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 20px; gap: 12px;
}
.nav-brand {
  font-family: var(--serif); font-weight: 700; font-size: 1.2rem;
  color: var(--text); letter-spacing: .2px;
}
.nav-brand:hover { color: var(--accent); text-decoration: none; }
.nav-links { display: flex; align-items: center; gap: 2px; }
.nav-links a {
  color: var(--text-soft); font-size: .9rem; padding: 6px 8px; border-radius: 6px;
  font-weight: 500; white-space: nowrap;
}
.nav-links a:hover { color: var(--accent); background: var(--accent-soft); text-decoration: none; }
.nav-links a.active { color: var(--accent); background: var(--accent-soft); }

.theme-toggle, .nav-toggle {
  background: none; border: 1px solid var(--border); color: var(--text-soft);
  cursor: pointer; border-radius: 8px; padding: 6px; display: inline-flex;
  align-items: center; justify-content: center;
}
.nav-actions { display: flex; align-items: center; gap: 8px; }
.theme-toggle { width: 34px; height: 34px; }
.theme-toggle:hover { color: var(--accent); border-color: var(--accent); }
.icon-moon { display: none; }
:root[data-theme="dark"] .icon-sun { display: none; }
:root[data-theme="dark"] .icon-moon { display: inline; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .icon-sun { display: none; }
  :root:not([data-theme="light"]) .icon-moon { display: inline; }
}

.nav-toggle { display: none; flex-direction: column; gap: 4px; width: 38px; height: 34px; }
.nav-toggle span { display: block; width: 18px; height: 2px; background: currentColor; border-radius: 2px; transition: .2s; }

/* ---------------- Hero ---------------- */
.hero {
  background: linear-gradient(180deg, var(--accent-soft), var(--bg) 70%);
  border-bottom: 1px solid var(--border);
}
.hero-inner {
  max-width: var(--maxw); margin: 0 auto; padding: 56px 20px 44px;
  display: flex; gap: 36px; align-items: center; flex-wrap: wrap;
}
.hero-photo { flex: 0 0 auto; }
.hero-photo img {
  width: 180px; height: 180px; border-radius: 50%; object-fit: cover;
  border: 4px solid var(--surface); box-shadow: var(--shadow);
}
.hero-monogram {
  width: 180px; height: 180px; border-radius: 50%;
  align-items: center; justify-content: center;
  font-family: var(--serif); font-size: 4rem; font-weight: 700; color: #fff;
  background: linear-gradient(135deg, var(--accent), var(--accent-hover));
  box-shadow: var(--shadow);
}
.hero-text { flex: 1 1 320px; min-width: 0; }
.hero-text h1 {
  font-family: var(--serif); font-size: 2.6rem; line-height: 1.1; margin: 0 0 8px;
  color: var(--text); letter-spacing: .3px;
}
.hero-subtitle { font-size: 1.15rem; color: var(--accent); font-weight: 600; margin: 0 0 6px; }
.hero-areas { color: var(--text-soft); margin: 0 0 18px; font-size: .98rem; }

.hero-links {
  list-style: none; display: flex; flex-wrap: wrap; gap: 8px; padding: 0; margin: 0 0 22px;
}
.hero-links a {
  display: inline-block; padding: 6px 14px; border: 1px solid var(--border);
  border-radius: 20px; font-size: .9rem; font-weight: 500; background: var(--surface);
  color: var(--text-soft);
}
.hero-links a:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); text-decoration: none; }

.hero-stats { list-style: none; display: flex; flex-wrap: wrap; gap: 26px; padding: 0; margin: 0; }
.hero-stats li { display: flex; flex-direction: column; }
.stat-num { font-family: var(--serif); font-size: 1.7rem; font-weight: 700; color: var(--text); line-height: 1; }
.stat-label { font-size: .8rem; color: var(--text-faint); text-transform: uppercase; letter-spacing: .5px; margin-top: 4px; }

/* ---------------- Sections ---------------- */
.section { max-width: var(--maxw); margin: 0 auto; padding: 48px 20px 8px; }
.section:last-of-type { padding-bottom: 40px; }
.section-title {
  font-family: var(--serif); font-size: 1.7rem; margin: 0 0 22px; color: var(--text);
  padding-bottom: 10px; border-bottom: 2px solid var(--border); position: relative;
}
.section-title::after {
  content: ""; position: absolute; left: 0; bottom: -2px; width: 54px; height: 2px; background: var(--accent);
}
.subsection-title {
  font-size: 1.05rem; color: var(--accent); margin: 28px 0 12px; font-weight: 600;
  text-transform: uppercase; letter-spacing: .6px;
}
.section-note { color: var(--text-faint); font-size: .9rem; margin: -6px 0 18px; }
.corr { color: var(--accent); font-weight: 700; }

/* ---------------- Education timeline ---------------- */
.timeline { list-style: none; padding: 0; margin: 0; }
.timeline li {
  padding: 16px 0 16px 22px; border-left: 2px solid var(--border); position: relative;
  margin-left: 4px;
}
.timeline li::before {
  content: ""; position: absolute; left: -7px; top: 22px; width: 12px; height: 12px;
  background: var(--accent); border-radius: 50%; border: 3px solid var(--bg);
}
.tl-head { display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; align-items: baseline; }
.tl-title { font-weight: 700; font-size: 1.05rem; color: var(--text); }
.tl-date { color: var(--text-faint); font-size: .88rem; white-space: nowrap; }
.tl-org { color: var(--accent); font-weight: 500; margin-top: 2px; }
.tl-detail { color: var(--text-soft); font-size: .93rem; margin-top: 2px; }

/* ---------------- Award / list rows ---------------- */
.award-list { list-style: none; padding: 0; margin: 0; }
.award-list li {
  display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap;
  padding: 11px 0; border-bottom: 1px solid var(--border); align-items: baseline;
}
.award-list li:last-child { border-bottom: none; }
.award-name { color: var(--text); }
.award-date { color: var(--text-faint); font-size: .88rem; white-space: nowrap; }
.service-group { margin-bottom: 8px; }

/* ---------------- Publications / talks ---------------- */
.pub-list { margin: 0; padding-left: 2.2em; }
.pub-list li {
  padding: 12px 0; border-bottom: 1px solid var(--border); line-height: 1.6;
  color: var(--text-soft);
}
.pub-list li:last-child { border-bottom: none; }
.pub-list li::marker { color: var(--text-faint); font-size: .85em; }
.pub-list strong { color: var(--text); font-weight: 700; }
.pub-list em { color: var(--text); }
.pub-list a { word-break: break-word; }

/* ---------------- Assessments tags ---------------- */
.tag-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 8px; }
.tag-list li {
  background: var(--bg-alt); border: 1px solid var(--border); border-radius: 8px;
  padding: 11px 16px; color: var(--text); font-size: .95rem;
}

/* ---------------- Media ---------------- */
.media-list { list-style: none; padding: 0; margin: 0; }
.media-list li { padding: 12px 0; border-bottom: 1px solid var(--border); }
.media-list li:last-child { border-bottom: none; }
.media-list a { font-weight: 600; }
.media-meta { color: var(--text-faint); font-size: .88rem; margin-top: 3px; }

/* ---------------- Home: research summary + explore ---------------- */
.lead { font-size: 1.05rem; color: var(--text-soft); max-width: 68ch; margin: 0 0 6px; }
.btn {
  display: inline-block; margin-top: 12px; padding: 10px 20px; border-radius: 8px;
  background: var(--accent); color: #fff; font-weight: 600; font-size: .95rem;
}
.btn:hover { background: var(--accent-hover); text-decoration: none; color: #fff; }
.explore-grid {
  list-style: none; padding: 0; margin: 6px 0 0;
  display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 14px;
}
.explore-grid a {
  display: block; padding: 16px 18px; border: 1px solid var(--border); border-radius: 10px;
  background: var(--surface); color: var(--text);
  transition: border-color .15s, transform .15s, box-shadow .15s;
}
.explore-grid a:hover { border-color: var(--accent); box-shadow: var(--shadow); text-decoration: none; transform: translateY(-2px); }
.explore-title { font-weight: 700; color: var(--text); display: block; }
.explore-desc { font-size: .85rem; color: var(--text-faint); margin-top: 3px; display: block; }

/* ---------------- Footer ---------------- */
.site-footer { border-top: 1px solid var(--border); background: var(--bg-alt); margin-top: 40px; }
.footer-inner {
  max-width: var(--maxw); margin: 0 auto; padding: 26px 20px;
  display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap;
}
.footer-inner p { margin: 0; color: var(--text-faint); font-size: .9rem; }
.footer-links { list-style: none; display: flex; gap: 16px; padding: 0; margin: 0; }
.footer-links a { color: var(--text-soft); font-size: .88rem; }

/* ---------------- Back to top ---------------- */
.to-top {
  position: fixed; bottom: 24px; right: 24px; width: 44px; height: 44px; border-radius: 50%;
  background: var(--accent); color: #fff; border: none; cursor: pointer; font-size: 1.2rem;
  box-shadow: var(--shadow); opacity: 0; pointer-events: none; transition: opacity .25s, transform .25s;
  transform: translateY(8px);
}
.to-top.show { opacity: 1; pointer-events: auto; transform: translateY(0); }
.to-top:hover { background: var(--accent-hover); }

/* ---------------- Responsive ---------------- */
@media (max-width: 860px) {
  body { font-size: 16px; }
  .nav-toggle { display: flex; }
  .nav-links {
    position: fixed; top: var(--nav-h); left: 0; right: 0;
    flex-direction: column; align-items: stretch; gap: 0;
    background: var(--bg); border-bottom: 1px solid var(--border);
    padding: 8px 12px 14px; box-shadow: var(--shadow);
    max-height: 0; overflow: hidden; transform: translateY(-8px); opacity: 0;
    transition: max-height .3s ease, opacity .2s, transform .2s, visibility .3s;
    pointer-events: none; visibility: hidden;
  }
  .nav-links.open { max-height: 520px; opacity: 1; transform: translateY(0); pointer-events: auto; visibility: visible; }
  .nav-links a { padding: 11px 10px; border-radius: 6px; font-size: 1rem; }

  .hero-inner { padding: 40px 20px 34px; gap: 24px; justify-content: center; text-align: center; }
  .hero-text { text-align: center; }
  .hero-text h1 { font-size: 2.1rem; }
  .hero-links, .hero-stats { justify-content: center; }
  .hero-photo img, .hero-monogram { width: 140px; height: 140px; }

  .tl-head { gap: 2px; }
}

@media print {
  .site-nav, .to-top, .theme-toggle, .nav-toggle { display: none !important; }
  body { font-size: 11pt; color: #000; background: #fff; }
  a { color: #000; text-decoration: none; }
  .hero { background: none; }
}
