/* ==========================================================================
   Haolan Xu — personal homepage
   Single light theme. Full-width alternating section bands (tianxingchen
   style) with a floating "Contents" sidebar in the left gutter (chen-geng
   style). Content column centered inside each band.
   ========================================================================== */

:root {
  --ink: #1d2433;
  --ink-strong: #141a26;
  --muted: #5c6577;
  --faint: #8b93a5;
  --border: #e3e8f2;
  --border-soft: #e9edf4;
  --band-alt: #f5f7fa;
  --accent: #2f55d4;
  --accent-strong: #2343b8;
  --accent-tint: #edf2fe;
  --accent-tint-border: #d8e2fb;
  --navy: #1e2c50;
  --amber-bg: #fff7e0;
  --amber-border: #f3e2ab;
  --amber-ink: #7c5c10;
  --font-serif: "Source Serif 4", Georgia, "Times New Roman", serif;
  --font-serif-zh: "Noto Serif SC", "Songti SC", "SimSun", var(--font-serif);
  --font-sans: "Source Sans 3", -apple-system, BlinkMacSystemFont, "Segoe UI", "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

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

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }
a:focus-visible,
button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}

/* --------------------------------------------------------------------------
   Full-width bands + centered content column
   -------------------------------------------------------------------------- */

.band { padding: 58px 0; }
.band-alt {
  background: var(--band-alt);
  border-top: 1px solid var(--border-soft);
  border-bottom: 1px solid var(--border-soft);
}

.container {
  max-width: 920px;
  margin: 0 auto;
  padding: 0 30px;
}

section { scroll-margin-top: 70px; }

/* --------------------------------------------------------------------------
   Floating table-of-contents sidebar (desktop only)
   -------------------------------------------------------------------------- */

#toc-nav {
  position: fixed;
  top: 50%;
  left: calc(50% - 460px - 158px);
  transform: translateY(-50%);
  width: 138px;
  z-index: 100;
  padding-left: 15px;
  border-left: 1px solid var(--border);
}
#toc-nav .toc-title {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--faint);
  margin-bottom: 10px;
}
#toc-nav a {
  display: block;
  position: relative;
  color: var(--muted);
  font-size: 15px;
  font-weight: 500;
  line-height: 1.35;
  padding: 5px 0;
  transition: color 0.18s ease, padding-left 0.18s ease;
}
#toc-nav a::before {
  content: "";
  position: absolute;
  left: -16px;
  top: 50%;
  transform: translateY(-50%);
  width: 2px;
  height: 0;
  background: var(--accent);
  transition: height 0.18s ease;
}
#toc-nav a:hover { color: var(--accent); text-decoration: none; }
#toc-nav a.active {
  color: var(--accent-strong);
  font-weight: 700;
  padding-left: 6px;
}
#toc-nav a.active::before { height: 100%; }

/* --------------------------------------------------------------------------
   Mobile top bar (replaces the sidebar on narrow screens)
   -------------------------------------------------------------------------- */

.topbar {
  display: none;
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
  padding: 11px 20px;
}
.topbar .topbar-inner {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  max-width: 860px;
  margin: 0 auto;
}
.topbar .top-name {
  font-family: var(--font-serif);
  font-size: 18px;
  font-weight: 700;
  color: var(--ink-strong);
  white-space: nowrap;
}
.topbar .top-name:hover { text-decoration: none; color: var(--accent); }
.topbar nav { display: flex; gap: 18px; }
.topbar nav a {
  font-size: 14.5px;
  font-weight: 600;
  color: var(--muted);
  white-space: nowrap;
}
.topbar nav a:hover { color: var(--accent); text-decoration: none; }

/* --------------------------------------------------------------------------
   Section headers
   -------------------------------------------------------------------------- */

.section-head {
  display: flex;
  align-items: center;
  gap: 18px;
  margin-bottom: 26px;
  flex-wrap: wrap;
}
.section-head h2 {
  font-family: var(--font-serif);
  font-size: 29px;
  font-weight: 700;
  color: var(--ink-strong);
  margin: 0;
  line-height: 1.25;
}

/* --------------------------------------------------------------------------
   Hero / About
   -------------------------------------------------------------------------- */

#about.band { padding-top: 64px; }

.hero-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 264px;
  gap: 48px;
  align-items: start;
}

.name-row {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  margin: 0 0 20px;
}
.name-row h1 {
  font-family: var(--font-serif);
  font-size: 42px;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--ink-strong);
  margin: 0;
  line-height: 1;
}
.name-zh {
  font-family: var(--font-serif-zh);
  font-size: 27px;
  font-weight: 600;
  color: var(--muted);
  letter-spacing: 0.06em;
  line-height: 1;
  transform: translateY(2px);
}

.hero-text p { margin: 0 0 13px; }
.hero-text p:last-child { margin-bottom: 0; }

.portrait-col {
  display: flex;
  flex-direction: column;
}
.portrait {
  width: 100%;
  height: auto;
  display: block;
  border-radius: 14px;
  box-shadow: 0 0 0 1px var(--border), 0 12px 30px -16px rgba(30, 45, 90, 0.35);
}


/* Social / contact buttons (incl. CV) */
.contact-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 26px;
}
.contact-row a {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 15px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: #fbfcfe;
  font-size: 14.5px;
  font-weight: 600;
  color: var(--ink);
  transition: border-color 0.15s ease, color 0.15s ease, background 0.15s ease;
}
.contact-row a:hover {
  text-decoration: none;
  border-color: var(--accent);
  color: var(--accent-strong);
  background: var(--accent-tint);
}
.contact-row .icon { color: var(--accent); }

/* Collaboration callout */
.callout {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-top: 22px;
  background: var(--amber-bg);
  border: 1px solid var(--amber-border);
  color: var(--amber-ink);
  border-radius: 12px;
  padding: 13px 18px;
  font-size: 15.5px;
  font-weight: 500;
  line-height: 1.55;
}
.callout .icon { font-size: 18px; margin-top: 4px; color: #d99e0b; }
.callout a { color: inherit; font-weight: 700; text-decoration: underline; text-underline-offset: 3px; }

/* --------------------------------------------------------------------------
   Publications
   -------------------------------------------------------------------------- */

/* Selected / All segmented control */
.pub-toggle {
  display: inline-flex;
  background: #e7ebf2;
  border-radius: 999px;
  padding: 3px;
  margin-left: auto;
}
.pub-toggle button {
  appearance: none;
  border: 0;
  background: transparent;
  font-family: var(--font-sans);
  font-size: 14px;
  font-weight: 600;
  color: var(--muted);
  padding: 5px 18px;
  border-radius: 999px;
  cursor: pointer;
  transition: color 0.15s ease, background 0.15s ease, box-shadow 0.15s ease;
}
.pub-toggle button.active {
  background: #ffffff;
  color: var(--accent-strong);
  box-shadow: 0 1px 3px rgba(30, 45, 90, 0.16);
}

.pub-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin: 0 -20px;
  padding: 0;
  list-style: none;
}
.pub-item {
  display: grid;
  grid-template-columns: 252px minmax(0, 1fr);
  gap: 28px;
  align-items: center;
  padding: 20px;
  border-radius: 14px;
}
.pub-item.hidden { display: none; }

/* In the "All" view, selected papers are highlighted (chen-geng.com style) */
.pub-list.show-all .pub-item[data-selected="true"] {
  background: #ffffff;
  border: 1px solid var(--border);
  box-shadow: inset 3px 0 0 0 var(--accent), 0 2px 10px -6px rgba(30, 45, 90, 0.12);
}

.pub-thumb {
  display: block;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--border);
  background: #ffffff;
  transition: box-shadow 0.2s ease, transform 0.2s ease;
}
.pub-thumb img {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 10;
  height: auto;
  object-fit: contain;
}
/* For teasers on a dark ground, letterbox in the same color */
.pub-thumb.thumb-dark { background: #000000; border-color: #000000; }
.pub-thumb:hover {
  box-shadow: 0 8px 22px -10px rgba(30, 45, 90, 0.35);
  transform: translateY(-2px);
}

.pub-venue {
  display: inline-block;
  background: var(--navy);
  color: #ffffff;
  font-size: 12.5px;
  font-weight: 700;
  letter-spacing: 0.05em;
  padding: 3px 11px;
  border-radius: 6px;
  margin-bottom: 8px;
}

.pub-title {
  font-family: var(--font-serif);
  font-size: 19.5px;
  font-weight: 700;
  line-height: 1.4;
  margin: 0 0 6px;
}
.pub-title a { color: var(--ink-strong); }
.pub-title a:hover { color: var(--accent); text-decoration: none; }

.pub-authors {
  font-size: 15.5px;
  color: var(--muted);
  margin: 0 0 12px;
  line-height: 1.55;
}
.pub-authors .me { color: var(--ink); font-weight: 700; }

.pub-links {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.pub-links a {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--accent-strong);
  background: var(--accent-tint);
  border: 1px solid var(--accent-tint-border);
  border-radius: 999px;
  padding: 4px 13px;
  transition: background 0.15s ease, border-color 0.15s ease;
}
.pub-links a:hover {
  text-decoration: none;
  background: #e0e9fd;
  border-color: var(--accent);
}

/* Legend line directly under the Publications title */
.pub-desc {
  margin: -12px 0 24px;
  font-size: 14px;
  color: var(--faint);
}
.pub-desc .legend-swatch {
  background: #ffffff;
  border: 1px solid var(--border);
  box-shadow: inset 3px 0 0 0 var(--accent);
  padding: 1px 7px;
  color: var(--muted);
}

/* --------------------------------------------------------------------------
   Footer
   -------------------------------------------------------------------------- */

.footer {
  padding: 34px 0;
  text-align: center;
  font-size: 13.5px;
  color: var(--faint);
  line-height: 1.7;
}
.footer .motto {
  font-family: var(--font-serif);
  font-style: italic;
  color: var(--muted);
}

/* --------------------------------------------------------------------------
   Icons
   -------------------------------------------------------------------------- */

.icon {
  width: 1em;
  height: 1em;
  font-size: 16px;
  flex-shrink: 0;
  fill: currentColor;
}

/* --------------------------------------------------------------------------
   Responsive
   -------------------------------------------------------------------------- */

/* Below this width the left gutter can no longer hold the sidebar */
@media (max-width: 1270px) {
  #toc-nav { display: none; }
  .topbar { display: block; }
}

@media (max-width: 760px) {
  .band { padding: 40px 0; }
  #about.band { padding-top: 34px; }
  .container { padding: 0 20px; }
  section { scroll-margin-top: 64px; }

  .hero-grid {
    grid-template-columns: minmax(0, 1fr);
    gap: 24px;
  }
  .portrait-col {
    order: -1;
    max-width: 210px;
    padding-top: 0;
  }
  .name-row h1 { font-size: 34px; }
  .name-zh { font-size: 22px; }

  .pub-list { margin: 0 -12px; }
  .pub-item {
    grid-template-columns: minmax(0, 1fr);
    gap: 14px;
    padding: 14px 12px;
  }
  .pub-thumb { max-width: 360px; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  * { transition: none !important; }
}
