/* ============================================================
   Zhe Xie — Academic Homepage
   Design: Neo-Swiss Editorial
   Fonts: Playfair Display · Source Serif 4 · JetBrains Mono
   Palette: Warm white · Deep charcoal · Steel blue accent
   ============================================================ */

/* ── Reset & Base ─────────────────────────────────────────── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --bg:           #FAFAF8;
  --surface:      #FFFFFF;
  --fg:           #1A1A18;
  --fg-secondary: #3D3D38;
  --fg-muted:     #6B6B62;
  --accent:       #1D4ED8;
  --accent-light: #DBEAFE;
  --accent-muted: #93C5FD;
  --border:       #E4E4DC;
  --border-light: #EFEFEA;

  --font-display: 'Playfair Display', Georgia, 'Times New Roman', serif;
  --font-body:    'Source Serif 4', Georgia, 'Times New Roman', serif;
  --font-mono:    'JetBrains Mono', 'Courier New', Courier, monospace;

  --sidebar-width: 220px;
  --gap:           5rem;
  --content-max:   850px;
}

html {
  scroll-behavior: smooth;
  font-size: 17px; /* Base size increased from 16px */
}

body {
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font-body);
  font-size: 1rem;
  line-height: 1.78;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

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

/* ── Top accent bar ───────────────────────────────────────── */
.top-bar {
  height: 3px;
  background: var(--accent);
  width: 100%;
  position: fixed;
  top: 0;
  left: 0;
  z-index: 100;
}

/* ── Mobile nav ───────────────────────────────────────────── */
.mobile-nav {
  display: none;
  position: sticky;
  top: 3px;
  z-index: 90;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  padding: 0.7rem 1.25rem;
  gap: 1.5rem;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

/* ── Page layout ──────────────────────────────────────────── */
.page-wrapper {
  max-width: calc(var(--sidebar-width) + var(--gap) + var(--content-max) + 4rem);
  margin: 0 auto;
  padding: 3.5rem 2rem 2rem;
  display: flex;
  gap: var(--gap);
  align-items: flex-start;
}

/* ── Sidebar ──────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-width);
  min-width: var(--sidebar-width);
  position: sticky;
  top: 3.5rem;
  height: fit-content;
  display: flex;
  flex-direction: column;
  gap: 0;
}

.sidebar-name {
  margin-bottom: 2rem;
}

.name {
  font-family: var(--font-display);
  font-size: 1.45rem;
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: -0.01em;
  color: var(--fg);
}

.title-line {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--fg-muted);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  margin-top: 0.3rem;
  line-height: 1.5;
}

/* Sidebar nav */
.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  margin-bottom: 2rem;
}

.nav-link {
  font-family: var(--font-mono);
  font-size: 0.73rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--fg-muted);
  padding: 0.3rem 0;
  display: block;
  transition: color 0.15s ease;
  text-decoration: none;
}
.nav-link:hover {
  color: var(--accent);
  text-decoration: none;
}
.nav-link.active {
  color: var(--accent);
  font-weight: 500;
}

/* Sidebar contact */
.sidebar-contact {
  border-top: 1px solid var(--border);
  padding-top: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.contact-label {
  font-family: var(--font-mono);
  font-size: 0.67rem;
  color: var(--fg-muted);
  letter-spacing: 0.07em;
  text-transform: uppercase;
  margin-bottom: 0.1rem;
}

.contact-link {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--accent);
  word-break: break-all;
  line-height: 1.5;
  text-decoration: none;
  transition: opacity 0.15s;
}
.contact-link:hover {
  opacity: 0.75;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.cv-link {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  background: var(--accent);
  color: #fff !important;
  padding: 0.32rem 0.7rem;
  border-radius: 3px;
  font-size: 0.7rem;
  margin-top: 0.4rem;
  transition: background 0.15s, opacity 0.15s;
  width: fit-content;
}
.cv-link:hover {
  background: #1e40af;
  text-decoration: none;
  opacity: 1;
}

/* ── Main content ─────────────────────────────────────────── */
.main-content {
  flex: 1;
  min-width: 0;
  max-width: var(--content-max);
}

/* Mobile header (hidden on desktop) */
.mobile-header {
  display: none;
  margin-bottom: 2rem;
}
.mobile-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 0.75rem;
}

/* ── Sections ─────────────────────────────────────────────── */
.section {
  margin-bottom: 3.5rem;
  scroll-margin-top: 4rem;
}

.section-header {
  position: relative;
  margin-bottom: 1.75rem;
  padding-top: 0.5rem;
}

.section-num {
  font-family: var(--font-display);
  font-size: 4.5rem;
  font-weight: 700;
  color: var(--border-light);
  line-height: 1;
  position: absolute;
  top: -1.25rem;
  left: -0.5rem;
  z-index: 0;
  user-select: none;
  pointer-events: none;
}

.section-title {
  font-family: var(--font-display);
  font-size: 1.6rem;
  font-weight: 600;
  color: var(--fg);
  position: relative;
  z-index: 1;
  letter-spacing: -0.01em;
}

.section-rule-short {
  width: 2.5rem;
  height: 2px;
  background: var(--accent);
  margin-top: 0.5rem;
}

.divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 0 0 1.5rem;
}

/* ── Prose ────────────────────────────────────────────────── */
.prose p {
  font-family: var(--font-body);
  font-size: 1rem;
  line-height: 1.82;
  color: var(--fg-secondary);
  margin-bottom: 1.05rem;
}
.prose p:last-child { margin-bottom: 0; }
.prose strong { color: var(--fg); font-weight: 600; }
.prose a { color: var(--accent); }

/* ── Tags ─────────────────────────────────────────────────── */
.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 1.25rem;
}

.tag {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  background: #F1F1EE;
  border: 1px solid var(--border);
  color: var(--fg-secondary);
  padding: 0.22rem 0.65rem;
  border-radius: 3px;
  letter-spacing: 0.02em;
}

/* ── News ─────────────────────────────────────────────────── */
.news-list {
  display: flex;
  flex-direction: column;
}

.news-item {
  display: flex;
  gap: 1.5rem;
  padding: 0.9rem 0;
  border-bottom: 1px solid var(--border-light);
}
.news-item:first-child { border-top: 1px solid var(--border-light); }

.news-date {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--fg-muted);
  min-width: 76px;
  padding-top: 0.15rem;
  letter-spacing: 0.02em;
  flex-shrink: 0;
}

.news-text {
  font-family: var(--font-body);
  font-size: 0.95rem;
  line-height: 1.68;
  color: var(--fg-secondary);
}
.news-text strong { color: var(--fg); }

/* ── Publications ─────────────────────────────────────────── */
.pub-note {
  font-family: var(--font-body);
  font-size: 0.88rem;
  color: var(--fg-muted);
  font-style: italic;
  margin-bottom: 1.35rem;
  line-height: 1.65;
}
.pub-note a {
  color: var(--accent);
  font-style: normal;
}

.pub-list {
  display: flex;
  flex-direction: column;
}

.pub-entry {
  padding: 1.2rem 0 1.2rem 1rem;
  border-bottom: 1px solid var(--border-light);
  border-left: 3px solid transparent;
  transition: border-left-color 0.2s ease, background 0.2s ease;
}
.pub-entry:first-child { border-top: 1px solid var(--border-light); }
.pub-entry:hover {
  border-left-color: var(--accent);
  background: #F7F7F4;
}

.pub-title {
  font-family: var(--font-body);
  font-size: 1rem;
  font-weight: 500;
  line-height: 1.58;
  color: var(--fg);
  margin-bottom: 0.35rem;
}

.pub-authors {
  font-family: var(--font-body);
  font-size: 0.88rem;
  color: var(--fg-muted);
  line-height: 1.55;
  margin-bottom: 0.5rem;
}
.pub-authors strong {
  color: var(--fg-secondary);
  font-weight: 600;
}

.pub-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.45rem;
}

.venue {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--fg-muted);
  letter-spacing: 0.02em;
}

.ccf-badge {
  font-family: var(--font-mono);
  font-size: 0.67rem;
  background: var(--accent);
  color: #fff;
  padding: 0.1rem 0.45rem;
  border-radius: 2px;
  letter-spacing: 0.03em;
  white-space: nowrap;
}

.pub-highlight {
  font-family: var(--font-body);
  font-size: 0.86rem;
  color: var(--accent);
  font-style: italic;
  line-height: 1.58;
  padding-left: 0.75rem;
  border-left: 2px solid var(--accent-muted);
  margin-top: 0.5rem;
  margin-bottom: 0.55rem;
}

/* Publication link buttons */
.pub-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin-top: 0.65rem;
}

.pub-link-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-family: var(--font-mono);
  font-size: 0.68rem;
  letter-spacing: 0.03em;
  color: var(--fg-secondary);
  background: #F1F1EE;
  border: 1px solid var(--border);
  padding: 0.22rem 0.6rem;
  border-radius: 3px;
  text-decoration: none;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.pub-link-btn:hover {
  background: var(--accent-light);
  border-color: var(--accent-muted);
  color: var(--accent);
  text-decoration: none;
}

.pub-link-btn.code-btn {
  color: #166534;
  background: #F0FDF4;
  border-color: #BBF7D0;
}
.pub-link-btn.code-btn:hover {
  background: #DCFCE7;
  border-color: #86EFAC;
  color: #15803D;
}

.pub-link-btn.demo-btn {
  color: #966315;
  background: #fdfdf0;
  border-color: #f7edbb;
}
.pub-link-btn.demo-btn:hover {
  background: #fafcdc;
  border-color: #c9b36c;
  color: #71450d;
}

/* Google Scholar CTA */
.scholar-cta {
  margin-top: 1.75rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--border-light);
}

.scholar-link {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--accent);
  letter-spacing: 0.02em;
  text-decoration: none;
  transition: opacity 0.15s;
}
.scholar-link:hover {
  opacity: 0.75;
  text-decoration: underline;
  text-underline-offset: 3px;
}

/* ── Experience ───────────────────────────────────────────── */
.subsection-title {
  font-family: var(--font-display);
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--fg);
  margin-bottom: 0.9rem;
  letter-spacing: -0.01em;
}

.exp-list {
  display: flex;
  flex-direction: column;
}

.exp-entry {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  padding: 1.05rem 0;
  border-bottom: 1px solid var(--border-light);
}
.exp-entry:first-child { border-top: 1px solid var(--border-light); }

.exp-main {
  flex: 1;
  min-width: 0;
}

.exp-org {
  font-family: var(--font-display);
  font-size: 1.02rem;
  font-weight: 600;
  color: var(--fg);
  display: block;
  margin-bottom: 0.1rem;
}

.exp-role {
  font-family: var(--font-body);
  font-size: 0.9rem;
  color: var(--fg-muted);
  font-style: italic;
  margin-left: 0.5rem;
}

.exp-topic {
  font-family: var(--font-body);
  font-size: 0.9rem;
  color: var(--fg-secondary);
  margin-top: 0.2rem;
  line-height: 1.55;
}

.exp-note {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--accent);
  margin-top: 0.25rem;
  letter-spacing: 0.01em;
}

.exp-period {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--fg-muted);
  white-space: nowrap;
  padding-top: 0.2rem;
  flex-shrink: 0;
  text-align: right;
}

/* ── Honors ───────────────────────────────────────────────── */
.honors-list {
  display: flex;
  flex-direction: column;
}

.honor-entry {
  display: grid;
  grid-template-columns: 90px 1fr;
  gap: 0 1.5rem;
  padding: 0.85rem 0;
  border-bottom: 1px solid var(--border-light);
  align-items: baseline;
}
.honor-entry:first-child { border-top: 1px solid var(--border-light); }

.honor-year {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--fg-muted);
  letter-spacing: 0.02em;
}

.honor-name {
  font-family: var(--font-body);
  font-size: 0.97rem;
  color: var(--fg-secondary);
}

.honor-org {
  font-family: var(--font-body);
  font-size: 0.88rem;
  color: var(--fg-muted);
  margin-left: 0.4rem;
  font-style: italic;
}

/* ── Footer ───────────────────────────────────────────────── */
.footer {
  padding-top: 2rem;
  border-top: 1px solid var(--border);
  margin-top: 1rem;
}

.footer p {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--fg-muted);
  letter-spacing: 0.03em;
}

/* ── Animations ───────────────────────────────────────────── */
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

.fade-in-up {
  animation: fadeInUp 0.5s ease forwards;
}

/* ── Responsive ───────────────────────────────────────────── */
@media (max-width: 920px) {
  .page-wrapper {
    flex-direction: column;
    padding: 1rem 1.25rem 2rem;
    gap: 0;
  }

  .sidebar {
    display: none;
  }

  .mobile-nav {
    display: flex;
  }

  .mobile-header {
    display: block;
    padding-top: 1.5rem;
  }

  .main-content {
    max-width: 100%;
    padding-top: 1.5rem;
  }

  .section-num {
    font-size: 3.5rem;
  }

  .exp-entry {
    flex-direction: column;
    gap: 0.25rem;
  }

  .exp-period {
    text-align: left;
  }
}

@media (max-width: 480px) {
  html { font-size: 16px; }

  .news-item {
    flex-direction: column;
    gap: 0.25rem;
  }

  .honor-entry {
    grid-template-columns: 70px 1fr;
    gap: 0 0.75rem;
  }

  .pub-links {
    gap: 0.35rem;
  }
}
