/* ============================================
   Jiehan Liu — Academic site (al-folio inspired)
   ============================================ */

:root {
  --bg: #ffffff;
  --text: #212529;
  --muted: #6c757d;
  --accent: #5b8fb9; /* soft sky/ocean blue — matches profile photo */
  --accent-hover: #3d6e96;
  --border: #e9ecef;
  --card-bg: #fafafa;
  --code-bg: #f5f5f5;
  --max-width: 920px;
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-serif: "Charter", "Georgia", "Times New Roman", serif;
  --font-mono: "SFMono-Regular", Menlo, Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1c1c1c;
    --text: #e9ecef;
    --muted: #adb5bd;
    --accent: #8ab4d4; /* lighter sky-blue for dark mode */
    --accent-hover: #a8c4d8;
    --border: #2c2c2c;
    --card-bg: #242424;
    --code-bg: #2a2a2a;
  }
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

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

/* ---------- Navigation ---------- */
.navbar {
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  position: sticky;
  top: 0;
  z-index: 100;
}

.nav-inner {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 1rem 1.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
}

.nav-brand {
  font-weight: 600;
  font-size: 1.05rem;
  color: var(--text);
  text-decoration: none;
  letter-spacing: -0.01em;
}

.nav-brand:hover { color: var(--accent); }

.nav-links {
  display: flex;
  gap: 1.5rem;
  list-style: none;
  margin: 0;
  padding: 0;
  flex-wrap: wrap;
}

.nav-links a {
  color: var(--text);
  text-decoration: none;
  font-size: 0.95rem;
  transition: color 0.15s ease;
}

.nav-links a:hover,
.nav-links a.active {
  color: var(--accent);
}

/* ---------- Layout ---------- */
.container {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 2.5rem 1.5rem 4rem;
}

h1, h2, h3, h4 {
  font-weight: 600;
  line-height: 1.3;
  letter-spacing: -0.015em;
}

h1 {
  font-size: 2.25rem;
  margin: 0 0 0.25rem;
}

h1 .subtle {
  font-weight: 400;
  color: var(--muted);
  font-size: 1.5rem;
}

/* ----- Chinese name in Kaiti style ----- */
/* Primary: LXGW WenKai Screen webfont (loaded via CDN in the HTML head).
   Fallbacks: local Kaiti variants for visitors who have them installed. */
.zh-name {
  font-family: "LXGW WenKai Screen",
               "STKaiti", "STKaiti SC", "Kaiti SC", "Kaiti",
               "KaiTi", "BiauKai",
               serif !important;
  font-weight: 400 !important;
  font-style: normal !important;
  font-size: 0.95em;
  margin-left: 0.5rem;
  letter-spacing: 0.02em;
}

h2 {
  font-size: 1.5rem;
  margin: 2.5rem 0 1rem;
  border-bottom: 1px solid var(--border);
  padding-bottom: 0.4rem;
}

h3 {
  font-size: 1.15rem;
  margin: 1.5rem 0 0.5rem;
}

p { margin: 0.75rem 0; }

a {
  color: var(--accent);
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: border-color 0.15s ease;
}

a:hover {
  border-bottom-color: var(--accent);
}

/* ---------- Home / About hero ---------- */
.hero {
  display: grid;
  grid-template-columns: 1fr 220px;
  gap: 2.5rem;
  align-items: start;
  margin-bottom: 1rem;
}

@media (max-width: 640px) {
  .hero {
    grid-template-columns: 1fr;
  }
  .hero-photo {
    order: -1;
    margin: 0 auto;
  }
}

.hero-photo {
  width: 220px;
  height: 220px;
  border-radius: 50%;
  overflow: hidden;
  border: 1px solid var(--border);
  background: var(--card-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  font-size: 0.85rem;
  text-align: center;
}

.hero-photo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.hero-text .affiliation {
  color: var(--muted);
  margin-top: 0.25rem;
  font-size: 1rem;
}

.hero-text .bio {
  margin-top: 1.25rem;
}

/* ---------- Social icons ---------- */
.socials {
  display: flex;
  gap: 1rem;
  margin-top: 1.5rem;
  flex-wrap: wrap;
  font-size: 0.95rem;
}

.socials a {
  color: var(--muted);
  border-bottom: none;
}

.socials a:hover { color: var(--accent); }

/* ---------- News list ---------- */
.news-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.news-list li {
  display: grid;
  grid-template-columns: 110px 1fr;
  gap: 1rem;
  padding: 0.6rem 0;
  border-bottom: 1px dashed var(--border);
  font-size: 0.95rem;
}

.news-list li:last-child { border-bottom: none; }

.news-date {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  font-size: 0.9rem;
}

/* ---------- Publications ---------- */
.pub-year {
  font-size: 1.4rem;
  font-weight: 600;
  margin: 2rem 0 0.75rem;
  color: var(--muted);
}

.pub {
  padding: 1rem 0;
  border-bottom: 1px solid var(--border);
}

.pub:last-child { border-bottom: none; }

.pub-title {
  font-weight: 600;
  margin: 0 0 0.25rem;
  font-size: 1.05rem;
  line-height: 1.4;
}

.pub-authors {
  color: var(--text);
  font-size: 0.95rem;
  margin: 0.15rem 0;
}

.pub-authors .me { font-weight: 600; }

.pub-venue {
  color: var(--muted);
  font-style: italic;
  font-size: 0.9rem;
  margin: 0.15rem 0;
}

.pub-links {
  margin-top: 0.6rem;
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
  align-items: center;
}

/* Unified pill button: link version */
.pub-link,
details.pub-toggle > summary {
  display: inline-block;
  box-sizing: border-box;
  font-family: var(--font-sans);
  font-size: 0.75rem;
  line-height: 1;
  padding: 0.35rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--muted);
  background: transparent;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  cursor: pointer;
  text-decoration: none;
  transition: border-color 0.15s ease, color 0.15s ease;
  list-style: none;
}

.pub-link:hover,
details.pub-toggle > summary:hover,
details.pub-toggle[open] > summary {
  border-color: var(--accent);
  color: var(--accent);
}

/* Hide default disclosure triangle */
details.pub-toggle > summary::-webkit-details-marker { display: none; }
details.pub-toggle > summary::marker { content: ""; }

details.pub-toggle {
  display: inline-block;
}

/* When a pub-toggle is open, its content drops below all pill buttons */
.pub-toggle-content {
  width: 100%;
  margin-top: 0.6rem;
}

.pub-toggle-content pre {
  background: var(--code-bg);
  padding: 0.85rem 1rem;
  border-radius: 6px;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  line-height: 1.5;
  overflow-x: auto;
  margin: 0;
  border: 1px solid var(--border);
  white-space: pre-wrap;
  word-wrap: break-word;
}

.pub-toggle-content p {
  margin: 0;
  padding: 0.85rem 1rem;
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.92rem;
  line-height: 1.6;
  color: var(--text);
}

/* Section subheaders for "Working Papers" / "Peer Reviewed Articles" */
.pub-section-title {
  font-size: 1.25rem;
  font-weight: 600;
  margin: 2.5rem 0 0.5rem;
  padding-bottom: 0.4rem;
  border-bottom: 2px solid var(--accent);
  display: inline-block;
}

/* ---------- Project cards ---------- */
.project-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 1.25rem;
  margin-top: 1.5rem;
}

.project-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1.25rem;
  transition: transform 0.18s ease, box-shadow 0.18s ease;
  text-decoration: none;
  color: inherit;
  display: block;
  border-bottom: 1px solid var(--border);
}

.project-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(0,0,0,0.06);
  border-color: var(--accent);
}

.project-card h3 {
  margin: 0 0 0.4rem;
  font-size: 1.1rem;
  color: var(--text);
}

.project-card p {
  margin: 0;
  font-size: 0.92rem;
  color: var(--muted);
  line-height: 1.55;
}

.project-tag {
  display: inline-block;
  font-size: 0.72rem;
  padding: 0.1rem 0.5rem;
  border-radius: 3px;
  background: var(--border);
  color: var(--muted);
  margin-right: 0.3rem;
  margin-top: 0.6rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* ---------- CV table ---------- */
.cv-section {
  margin-bottom: 1rem;
}

.cv-entry {
  display: grid;
  grid-template-columns: 130px 1fr;
  gap: 1.25rem;
  padding: 0.7rem 0;
  border-bottom: 1px dashed var(--border);
}

.cv-entry:last-child { border-bottom: none; }

.cv-date {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  font-size: 0.9rem;
}

.cv-title { font-weight: 600; }
.cv-detail { color: var(--muted); font-size: 0.93rem; }

@media (max-width: 520px) {
  .cv-entry { grid-template-columns: 1fr; }
}

/* ---------- Footer ---------- */
footer {
  border-top: 1px solid var(--border);
  padding: 1.5rem 1.5rem;
  text-align: center;
  color: var(--muted);
  font-size: 0.85rem;
  max-width: var(--max-width);
  margin: 0 auto;
}
