/* ═══════════════════════════════════════════════════════
   Jiawen Chen — site styles (layout: academic)
   ═══════════════════════════════════════════════════════ */

*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --c-bg: #ffffff;
  --c-panel: #f8f8f5;
  --c-hover: #f2f2ee;
  --c-text: #1b1b1b;
  --c-text-2: #555;
  --c-text-3: #8a8a8a;
  --c-accent: #1f4f8a;
  --c-accent-dark: #143866;
  --c-accent-bg: #e6eef8;
  --c-border: #e3e2dc;
  --c-border-light: #efeee9;

  --c-star: #a67c1a;
  --c-star-bg: #fdf4d8;
  --c-star-border: #ecd78f;

  /* topic tags */
  --t-spatial-c: #0c6e85;   --t-spatial-bg: #dcedf2;
  --t-agentic-c: #9a4a15;   --t-agentic-bg: #fae6d6;
  --t-gp-c: #1f4a85;        --t-gp-bg: #e2e9f5;
  --t-dr-c: #6a3f8a;        --t-dr-bg: #eee5f4;
  --t-ml-c: #a63d5a;        --t-ml-bg: #f7e3e9;
  --t-genomics-c: #2e6b3a;  --t-genomics-bg: #e3f0e6;

  --font-serif: 'Source Serif 4', Charter, Georgia, serif;
  --font-sans: 'Instrument Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono: 'IBM Plex Mono', ui-monospace, Menlo, monospace;

  --topbar-h: 60px;
}

html { scroll-behavior: smooth; }

body {
  font-family: var(--font-sans);
  background: var(--c-bg);
  color: var(--c-text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a { color: var(--c-accent); text-decoration: none; transition: color .2s, background .2s, text-decoration-color .2s; }
a:hover { color: var(--c-accent-dark); }
b, strong { font-weight: 600; }

.page { display: flex; min-height: calc(100vh - var(--topbar-h)); }

/* ── TOP BAR ── */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding: 0 32px;
  background: rgba(255,255,255,.92);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--c-border);
}
.topnav { display: flex; gap: 4px; }
.topnav a {
  font-size: .93rem;
  font-weight: 500;
  color: var(--c-text-2);
  padding: 6px 14px;
  border-radius: 7px;
  white-space: nowrap;
}
.topnav a:hover { background: var(--c-hover); color: var(--c-text); }
.topnav a.active { color: var(--c-accent); background: var(--c-accent-bg); font-weight: 600; }

/* ── SIDEBAR ── */
.sidebar {
  width: 300px;
  flex-shrink: 0;
  position: sticky;
  top: var(--topbar-h);
  height: calc(100vh - var(--topbar-h));
  padding: 44px 32px 32px;
  border-right: 1px solid var(--c-border);
  background: var(--c-panel);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}

.sidebar-photo {
  display: block;
  width: 124px;
  height: 124px;
  border-radius: 50%;
  object-fit: cover;
  margin-bottom: 22px;
  border: 3px solid #fff;
  box-shadow: 0 1px 4px rgba(0,0,0,.08);
}

.sidebar-name {
  font-family: var(--font-serif);
  font-size: 1.55rem;
  font-weight: 600;
  letter-spacing: -.02em;
  line-height: 1.25;
}
.sidebar-role { font-size: .9rem; font-weight: 500; margin-top: 6px; }
.sidebar-aff { font-size: .84rem; color: var(--c-text-2); line-height: 1.5; margin-top: 2px; }
.sidebar-email {
  display: inline-block;
  margin-top: 8px;
  font-family: var(--font-mono);
  font-size: .76rem;
  color: var(--c-text-3);
  word-break: break-all;
}
.sidebar-email:hover { color: var(--c-accent); }

.sidebar-links { margin-top: 24px; display: flex; flex-wrap: wrap; gap: 6px; }
.sidebar-links a {
  font-family: var(--font-mono);
  font-size: .72rem;
  color: var(--c-text-2);
  padding: 3px 9px;
  border: 1px solid var(--c-border);
  border-radius: 5px;
  background: #fff;
}
.sidebar-links a:hover { color: var(--c-accent); border-color: var(--c-accent); }

/* ── MAIN ── */
.main {
  flex: 1;
  min-width: 0;
  max-width: 860px;
  padding: 44px 64px 28px;
  display: flex;
  flex-direction: column;
}
.main-content { flex: 1 0 auto; }

.main-title {
  font-family: var(--font-serif);
  font-size: 2.1rem;
  font-weight: 600;
  letter-spacing: -.03em;
  line-height: 1.2;
  margin-bottom: 10px;
}
.main-subtitle {
  font-size: .9rem;
  color: var(--c-text-2);
  margin-bottom: 32px;
}

.section-heading {
  font-family: var(--font-serif);
  font-size: 1.25rem;
  font-weight: 600;
  letter-spacing: -.02em;
  margin: 44px 0 16px;
  scroll-margin-top: calc(var(--topbar-h) + 20px);
}
.section-heading:first-child { margin-top: 0; }

/* underlined links inside running text */
.bio a, .news a, .project-desc a, .prose a, .main-subtitle a, .cv-what a {
  text-decoration-line: underline;
  text-decoration-color: var(--c-accent-bg);
  text-decoration-thickness: 2px;
  text-underline-offset: 2px;
}
.bio a:hover, .news a:hover, .project-desc a:hover, .prose a:hover, .main-subtitle a:hover, .cv-what a:hover {
  text-decoration-color: var(--c-accent);
}

/* ═══ HOME ═══ */
.page--centered .main { margin: 0 auto; }
.home-hero { text-align: center; padding: 16px 0 36px; animation: fadeIn .5s ease both; }
.home-avatar {
  display: block;
  width: 50%;
  max-width: 220px;
  aspect-ratio: 1;
  object-fit: cover;
  border-radius: 50%;
  margin: 0 auto 22px;
  border: 4px solid #fff;
  box-shadow: 0 2px 10px rgba(0,0,0,.08);
}
.home-links { font-size: .95rem; color: var(--c-text-3); word-spacing: 2px; }
.home-links a { color: var(--c-accent); font-weight: 500; margin: 0 2px; white-space: nowrap; }
.home-links a:hover { color: var(--c-accent-dark); text-decoration: underline; text-underline-offset: 3px; }
.bio { font-size: .97rem; line-height: 1.75; max-width: 680px; animation: fadeIn .5s ease both; }
.bio p { margin-bottom: 16px; }

.keywords { list-style: none; display: flex; flex-wrap: wrap; gap: 8px; max-width: 680px; }
.keywords li {
  font-size: .9rem;
  font-weight: 500;
  padding: 6px 14px;
  border-radius: 999px;
  border: 1px solid var(--c-border);
  background: var(--c-panel);
}

.news { list-style: none; font-size: .9rem; }
.news li {
  display: grid;
  grid-template-columns: 82px 1fr;
  gap: 14px;
  padding: 8px 0;
  border-bottom: 1px solid var(--c-border-light);
  line-height: 1.55;
}
.news li:last-child { border-bottom: none; }
.news-date {
  font-family: var(--font-mono);
  font-size: .74rem;
  color: var(--c-text-3);
  padding-top: 2px;
  white-space: nowrap;
}
.news-more summary {
  cursor: pointer;
  list-style: none;
  font-family: var(--font-mono);
  font-size: .76rem;
  color: var(--c-accent);
  padding: 8px 0;
}
.news-more summary::-webkit-details-marker { display: none; }
.news-more summary::before { content: '+ '; }
.news-more[open] summary::before { content: '− '; }
.news-more[open] summary .more-label::after { content: ' (hide)'; }

/* ═══ RESEARCH ═══ */
.project {
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 22px;
  padding: 18px;
  margin-bottom: 12px;
  border-radius: 10px;
  border: 1px solid var(--c-border-light);
  background: #fff;
  transition: border-color .2s, box-shadow .25s;
  animation: slideUp .45s ease both;
}
.project:hover { border-color: var(--c-border); box-shadow: 0 3px 12px rgba(0,0,0,.05); }
.project-image {
  border-radius: 6px;
  overflow: hidden;
  background: var(--c-panel);
  border: 1px solid var(--c-border-light);
  align-self: start;
}
.project-image img { display: block; width: 100%; height: auto; }
.project-title {
  font-family: var(--font-serif);
  font-size: 1.15rem;
  font-weight: 600;
  letter-spacing: -.01em;
  line-height: 1.35;
}
.project-venue { font-family: var(--font-serif); font-style: italic; font-size: .85rem; color: var(--c-text-3); margin-top: 2px; }
.project-desc { font-size: .87rem; color: var(--c-text-2); line-height: 1.65; margin-top: 8px; }
.project-stat {
  display: inline-block;
  margin-top: 10px;
  font-family: var(--font-mono);
  font-size: .72rem;
  font-weight: 500;
  color: var(--c-star);
  background: var(--c-star-bg);
  border: 1px solid var(--c-star-border);
  padding: 2px 9px;
  border-radius: 4px;
}

.theme-block { margin-bottom: 26px; }
.theme-label {
  font-family: var(--font-mono);
  font-size: .7rem;
  font-weight: 500;
  letter-spacing: .05em;
  text-transform: uppercase;
  color: var(--c-text-3);
  margin-bottom: 4px;
  padding: 0 20px;
}

/* ═══ PUBLICATIONS ═══ */
.filters {
  scroll-margin-top: calc(var(--topbar-h) + 16px);
  padding: 12px 14px;
  border-radius: 8px;
  background: var(--c-panel);
  border: 1px solid var(--c-border-light);
  margin-bottom: 30px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.filter-row { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.filter-label {
  font-family: var(--font-mono);
  font-size: .64rem;
  letter-spacing: .05em;
  text-transform: uppercase;
  color: var(--c-text-3);
  width: 52px;
  flex-shrink: 0;
}
.chip {
  font-family: var(--font-mono);
  font-size: .7rem;
  font-weight: 500;
  padding: 3px 10px;
  border-radius: 4px;
  border: 1px solid var(--c-border);
  background: #fff;
  color: var(--c-text-2);
  cursor: pointer;
  line-height: 1.5;
  transition: background .15s, color .15s, border-color .15s;
}
.chip:hover { border-color: var(--c-text-3); color: var(--c-text); }
.chip.is-active { background: var(--c-accent); border-color: var(--c-accent); color: #fff; }
.chip.topic.is-active { outline: 2px solid currentColor; outline-offset: 1px; border-color: transparent; }
.filter-empty { display: none; font-size: .9rem; color: var(--c-text-3); padding: 12px 20px; }

.legend { font-size: .78rem; color: var(--c-text-3); margin-top: 2px; }
.legend sup { font-size: .7em; }

.year-section { margin-bottom: 30px; animation: slideUp .45s ease both; }
.year-heading {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 8px;
  position: sticky;
  top: var(--topbar-h);
  z-index: 5;
  background: var(--c-bg);
  padding: 8px 0;
}
.year-num { font-family: var(--font-serif); font-weight: 600; font-size: 1.35rem; color: var(--c-accent); letter-spacing: -.02em; }
.year-rule { flex: 1; height: 1px; background: var(--c-border); }

.paper {
  position: relative;
  padding: 14px 20px;
  border-radius: 8px;
  margin-bottom: 2px;
  border: 1px solid transparent;
  transition: background .2s, border-color .2s, box-shadow .25s;
}
.paper:hover { background: var(--c-panel); border-color: var(--c-border); box-shadow: 0 2px 8px rgba(0,0,0,.04); }
.paper-title {
  font-family: var(--font-serif);
  font-weight: 500;
  font-size: 1.04rem;
  line-height: 1.45;
  letter-spacing: -.01em;
}
.paper-title .star { color: var(--c-star); font-size: .85em; margin-left: 4px; }
.paper-authors { font-size: .82rem; color: var(--c-text-2); line-height: 1.55; margin-top: 3px; }
.paper-authors b { color: var(--c-text); }
.paper-authors sup { font-size: .7em; }
.paper-venue { font-family: var(--font-serif); font-style: italic; font-size: .85rem; color: var(--c-text-3); margin-top: 2px; }
.paper-status {
  font-family: var(--font-mono);
  font-style: normal;
  font-size: .64rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--c-text-2);
  background: var(--c-hover);
  border: 1px solid var(--c-border);
  padding: 0 6px;
  border-radius: 3px;
  margin-right: 6px;
  vertical-align: 1px;
}
.paper-status--end { margin: 0 0 0 auto; line-height: 1.6; }
.paper-note {
  display: inline-block;
  margin-top: 6px;
  font-size: .78rem;
  font-weight: 600;
  color: var(--c-star);
}
.paper-meta { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 9px; align-items: center; }
.paper-meta .sep { width: 1px; height: 14px; background: var(--c-border); margin: 0 4px; }

.topic {
  font-family: var(--font-mono);
  font-size: .66rem;
  font-weight: 500;
  padding: 1px 8px;
  border-radius: 3px;
  letter-spacing: .02em;
  line-height: 1.6;
  white-space: nowrap;
}
.topic-spatial   { color: var(--t-spatial-c);   background: var(--t-spatial-bg); }
.topic-agentic   { color: var(--t-agentic-c);   background: var(--t-agentic-bg); }
.topic-gp        { color: var(--t-gp-c);        background: var(--t-gp-bg); }
.topic-dr        { color: var(--t-dr-c);        background: var(--t-dr-bg); }
.topic-ml        { color: var(--t-ml-c);        background: var(--t-ml-bg); }
.topic-genomics  { color: var(--t-genomics-c);  background: var(--t-genomics-bg); }
.chip.topic { border-color: transparent; }

.paper-link {
  font-family: var(--font-mono);
  font-size: .7rem;
  font-weight: 500;
  color: var(--c-accent);
  padding: 1px 9px;
  border-radius: 4px;
  background: var(--c-accent-bg);
  line-height: 1.6;
}
.paper-link:hover { background: var(--c-accent); color: #fff; }

/* ═══ CV ═══ */
.cv-row {
  display: grid;
  grid-template-columns: 112px 1fr;
  gap: 16px;
  padding: 12px 20px;
  border-radius: 8px;
  border: 1px solid transparent;
  transition: background .2s, border-color .2s;
}
.cv-row:hover { background: var(--c-panel); border-color: var(--c-border-light); }
.cv-when {
  font-family: var(--font-mono);
  font-size: .74rem;
  color: var(--c-text-3);
  padding-top: 3px;
  white-space: nowrap;
}
.cv-what { font-size: .9rem; line-height: 1.55; }
.cv-title { font-family: var(--font-serif); font-size: 1.02rem; font-weight: 600; letter-spacing: -.01em; }
.cv-sub { color: var(--c-text-2); font-size: .86rem; }
.cv-tags { margin-top: 4px; display: flex; flex-wrap: wrap; gap: 5px; }
.cv-venue {
  font-family: var(--font-mono);
  font-size: .68rem;
  color: var(--c-text-2);
  background: var(--c-hover);
  padding: 0 7px;
  border-radius: 3px;
}
.cv-subhead {
  font-family: var(--font-mono);
  font-size: .7rem;
  font-weight: 500;
  letter-spacing: .05em;
  text-transform: uppercase;
  color: var(--c-text-3);
  margin: 18px 0 2px;
  padding: 0 20px;
}

/* ── FOOTER ── */
.site-footer {
  flex-shrink: 0;
  margin-top: 64px;
  padding-top: 18px;
  border-top: 1px solid var(--c-border-light);
  font-size: .76rem;
  color: var(--c-text-3);
}

/* ═══ ANIMATIONS ═══ */
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes slideUp { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } html { scroll-behavior: auto; } }

/* ═══ RESPONSIVE ═══ */
.menu-toggle { display: none; }

@media (max-width: 960px) {
  /* profile sidebar hidden; menu collapses into a drop-down */
  .sidebar { display: none; }
  .page { display: block; }
  .topbar { padding: 0 16px; justify-content: flex-end; }
  .menu-toggle {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font: 500 .9rem var(--font-sans);
    color: var(--c-text);
    background: #fff;
    border: 1px solid var(--c-border);
    border-radius: 7px;
    padding: 6px 12px;
    cursor: pointer;
  }
  .menu-toggle:hover, .topbar.is-open .menu-toggle { background: var(--c-hover); }
  .topnav {
    display: none;
    position: absolute;
    top: calc(100% + 6px);
    right: 16px;
    min-width: 210px;
    flex-direction: column;
    gap: 2px;
    padding: 6px;
    background: #fff;
    border: 1px solid var(--c-border);
    border-radius: 10px;
    box-shadow: 0 8px 24px rgba(0,0,0,.08);
  }
  .topbar.is-open .topnav { display: flex; }
  .topnav a { padding: 9px 12px; }
  .main { padding: 32px 20px 24px; max-width: none; min-height: calc(100vh - var(--topbar-h)); }
  .main-title { font-size: 1.75rem; }
}

@media (max-width: 640px) {
  .project { grid-template-columns: 1fr; gap: 14px; }
  .project-image { max-width: 360px; }
  .paper, .cv-row { padding: 12px 10px; }
  .cv-row { grid-template-columns: 1fr; gap: 2px; }
  .news li { grid-template-columns: 1fr; gap: 0; }
  .cv-subhead { padding: 0 10px; }
  .filter-label { width: 100%; }
}
