/* ============================================================
   ACADEMIC HOMEPAGE — style.css
   Black-and-white minimalist design
   ============================================================ */

/* ── Design Tokens ── */
:root {
  --color-sidebar-bg:   #1a1a1a;
  --color-sidebar-text: #e8e8e0;
  --color-sidebar-muted: #a0a09a;
  --color-sidebar-hover: #ffffff;
  --color-sidebar-border: rgba(255,255,255,0.12);

  --color-accent:   #1a1a1a;
  --color-bg:       #ffffff;
  --color-text:     #1a1a1a;
  --color-muted:    #6b7280;
  --color-border:   #e5e7eb;
  --color-bg-alt:   #f9fafb;

  /* Paper status badge colors */
  --badge-jmp-bg:   #1a1a1a;
  --badge-jmp-text: #ffffff;
  --badge-wp-bg:    #ffffff;
  --badge-wp-text:  #4b5563;
  --badge-wp-border: #d1d5db;
  --badge-pub-bg:   #374151;
  --badge-pub-text: #ffffff;

  --sidebar-width: 260px;
  --content-max:   760px;

  --font-serif: 'Noto Serif SC', 'Georgia', serif;
  --font-sans:  'Inter', system-ui, -apple-system, sans-serif;

  --radius-sm: 3px;
  --radius-md: 6px;

  --transition: 0.18s ease;
}

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

html {
  scroll-behavior: smooth;
  font-size: 16px;
}

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

/* ── Layout ── */
.layout {
  display: flex;
  min-height: 100vh;
}

/* ── Sidebar ── */
.sidebar {
  width: var(--sidebar-width);
  min-width: var(--sidebar-width);
  background: var(--color-sidebar-bg);
  color: var(--color-sidebar-text);
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
}

/* Custom scrollbar for sidebar */
.sidebar::-webkit-scrollbar { width: 4px; }
.sidebar::-webkit-scrollbar-track { background: transparent; }
.sidebar::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.15); border-radius: 2px; }

.sidebar-inner {
  display: flex;
  flex-direction: column;
  gap: 0;
  padding: 36px 24px 32px;
  min-height: 100%;
}

/* Photo */
.photo-wrap {
  display: flex;
  justify-content: center;
  margin-bottom: 20px;
}

.profile-photo {
  width: 110px;
  height: 110px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid rgba(255,255,255,0.18);
  background: #333;
  display: block;
}

/* Name / Title block */
.sidebar-name-block {
  text-align: center;
  margin-bottom: 24px;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--color-sidebar-border);
}

.sidebar-name {
  font-family: var(--font-serif);
  font-size: 1.2rem;
  font-weight: 600;
  color: var(--color-sidebar-hover);
  line-height: 1.3;
  margin-bottom: 6px;
}

.sidebar-title {
  font-size: 0.78rem;
  color: var(--color-sidebar-muted);
  font-weight: 400;
  line-height: 1.4;
  margin-bottom: 2px;
}

.sidebar-dept {
  font-size: 0.78rem;
  color: var(--color-sidebar-muted);
  font-weight: 400;
  line-height: 1.4;
}

.sidebar-institution {
  font-size: 0.78rem;
  color: var(--color-sidebar-muted);
  font-weight: 400;
  margin-top: 2px;
}

/* Navigation */
.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-bottom: 24px;
}

.nav-link {
  display: block;
  padding: 7px 10px;
  color: var(--color-sidebar-text);
  text-decoration: none;
  font-size: 0.85rem;
  font-weight: 400;
  border-radius: var(--radius-sm);
  letter-spacing: 0.04em;
  transition: background var(--transition), color var(--transition);
}

.nav-link:hover,
.nav-link.active {
  background: rgba(255,255,255,0.08);
  color: var(--color-sidebar-hover);
}

/* Contact links */
.sidebar-contact {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--color-sidebar-border);
  margin-bottom: 16px;
}

.contact-link {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--color-sidebar-muted);
  text-decoration: none;
  font-size: 0.8rem;
  transition: color var(--transition);
}

.contact-link:hover { color: var(--color-sidebar-hover); }

.contact-link svg {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
  opacity: 0.75;
}

/* External links (Scholar, SSRN, Twitter) */
.sidebar-links {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 20px;
}

.ext-link {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--color-sidebar-muted);
  text-decoration: none;
  font-size: 0.8rem;
  transition: color var(--transition);
}

.ext-link:hover { color: var(--color-sidebar-hover); }

.ext-link svg {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
  opacity: 0.7;
}

/* Language toggle */
.lang-toggle-wrap {
  margin-top: auto;
  padding-top: 20px;
  display: flex;
  justify-content: center;
}

.lang-btn {
  background: none;
  border: 1px solid var(--color-sidebar-border);
  color: var(--color-sidebar-muted);
  font-family: var(--font-sans);
  font-size: 0.75rem;
  letter-spacing: 0.08em;
  padding: 6px 14px;
  border-radius: 20px;
  cursor: pointer;
  transition: border-color var(--transition), color var(--transition);
  display: flex;
  align-items: center;
  gap: 4px;
}

.lang-btn:hover {
  border-color: rgba(255,255,255,0.35);
  color: var(--color-sidebar-hover);
}

.lang-opt { transition: opacity var(--transition); }
.lang-sep { opacity: 0.4; }

/* Active language label highlight */
body[data-lang="en"] #lang-en-label { color: #fff; font-weight: 500; }
body[data-lang="zh"] #lang-zh-label { color: #fff; font-weight: 500; }

/* ── Main content ── */
.main-content {
  flex: 1;
  min-width: 0;
  padding: 60px 64px 80px;
  max-width: calc(var(--content-max) + 128px);
}

/* ── Section ── */
.section {
  margin-bottom: 72px;
}

.section-heading {
  font-family: var(--font-serif);
  font-size: 1.55rem;
  font-weight: 600;
  color: var(--color-text);
  padding-bottom: 12px;
  border-bottom: 1.5px solid var(--color-border);
  margin-bottom: 32px;
  letter-spacing: -0.01em;
}

/* ── About section ── */
.about-grid {
  display: block;
}

.bio-paragraph {
  font-size: 0.95rem;
  line-height: 1.8;
  color: var(--color-text);
  margin-bottom: 20px;
  white-space: pre-line;
}

.fields-wrap {
  font-size: 0.875rem;
  color: var(--color-muted);
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  align-items: baseline;
}

.fields-label {
  font-weight: 500;
  color: var(--color-text);
  margin-right: 4px;
}

.fields-list {
  color: var(--color-muted);
}

/* ── Papers section ── */
.papers-subheading {
  font-family: var(--font-sans);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--color-muted);
  margin-top: 40px;
  margin-bottom: 0;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--color-border);
}

.papers-subheading:first-child {
  margin-top: 0;
}

.papers-list {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.paper-item {
  padding: 24px 0;
  border-bottom: 1px solid var(--color-border);
}

.paper-item:last-child {
  border-bottom: none;
}

.paper-header {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 6px;
  flex-wrap: wrap;
}

.paper-title {
  font-family: var(--font-serif);
  font-size: 1.02rem;
  font-weight: 600;
  color: var(--color-text);
  line-height: 1.4;
  flex: 1;
  min-width: 0;
}

/* Status badges */
.status-badge {
  display: inline-flex;
  align-items: center;
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 2px 8px;
  border-radius: var(--radius-sm);
  white-space: nowrap;
  flex-shrink: 0;
  align-self: flex-start;
  margin-top: 3px;
}

.badge-jmp {
  background: var(--badge-jmp-bg);
  color: var(--badge-jmp-text);
}

.badge-wp {
  background: var(--badge-wp-bg);
  color: var(--badge-wp-text);
  border: 1px solid var(--badge-wp-border);
}

.badge-pub {
  background: var(--badge-pub-bg);
  color: var(--badge-pub-text);
}

.paper-meta {
  font-size: 0.82rem;
  color: var(--color-muted);
  margin-bottom: 8px;
  line-height: 1.5;
}

.paper-meta .coauthors::before { content: "With "; }

.paper-journal {
  font-style: italic;
  color: var(--color-muted);
}

.paper-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 8px;
  flex-wrap: wrap;
}

/* Abstract toggle button */
.abstract-toggle {
  background: none;
  border: none;
  padding: 0;
  font-family: var(--font-sans);
  font-size: 0.8rem;
  color: var(--color-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 4px;
  transition: color var(--transition);
}

.abstract-toggle:hover { color: var(--color-text); }

.abstract-toggle .toggle-arrow {
  display: inline-block;
  transition: transform var(--transition);
  font-size: 0.65rem;
  margin-top: 1px;
}

.abstract-toggle[aria-expanded="true"] .toggle-arrow {
  transform: rotate(90deg);
}

/* PDF link */
.pdf-link {
  font-size: 0.8rem;
  color: var(--color-text);
  text-decoration: none;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  border-bottom: 1px solid currentColor;
  transition: opacity var(--transition);
}

.pdf-link:hover { opacity: 0.65; }

.pdf-link svg {
  width: 13px;
  height: 13px;
  flex-shrink: 0;
}

/* DOI link */
.doi-link {
  font-size: 0.78rem;
  color: var(--color-muted);
  text-decoration: none;
  transition: color var(--transition);
}

.doi-link:hover { color: var(--color-text); }

/* Abstract panel */
.abstract-body {
  overflow: hidden;
  max-height: 0;
  transition: max-height 0.28s ease, opacity 0.28s ease;
  opacity: 0;
}

.abstract-body.open {
  max-height: 600px;
  opacity: 1;
}

.abstract-inner {
  margin-top: 12px;
  padding: 14px 16px;
  background: var(--color-bg-alt);
  border-left: 3px solid var(--color-border);
  font-size: 0.875rem;
  line-height: 1.75;
  color: var(--color-text);
}

/* ── Lectures section ── */
.lectures-list {
  display: flex;
  flex-direction: column;
  gap: 36px;
}

.course-block {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.course-header {
  padding: 16px 20px;
  background: var(--color-bg-alt);
  border-bottom: 1px solid var(--color-border);
}

.course-name {
  font-family: var(--font-serif);
  font-size: 0.98rem;
  font-weight: 600;
  color: var(--color-text);
  margin-bottom: 4px;
  line-height: 1.35;
}

.course-meta {
  font-size: 0.8rem;
  color: var(--color-muted);
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.course-meta .sep { opacity: 0.4; }

.course-notes {
  list-style: none;
}

.note-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 11px 20px;
  border-bottom: 1px solid var(--color-border);
  gap: 12px;
}

.note-item:last-child { border-bottom: none; }

.note-title {
  font-size: 0.875rem;
  color: var(--color-text);
  line-height: 1.4;
}

.note-pdf-link {
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--color-muted);
  text-decoration: none;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: color var(--transition);
  flex-shrink: 0;
}

.note-pdf-link:hover { color: var(--color-text); }

.note-pdf-link svg {
  width: 12px;
  height: 12px;
}

/* ── Loading ── */
.loading-indicator {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  min-height: 50vh;
  color: var(--color-muted);
  font-size: 0.875rem;
}

.loading-spinner {
  width: 28px;
  height: 28px;
  border: 2px solid var(--color-border);
  border-top-color: var(--color-text);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ── Error banner ── */
.error-banner {
  margin: 32px 0 24px;
  padding: 16px 20px;
  background: #fef2f2;
  border: 1px solid #fecaca;
  border-radius: var(--radius-md);
  color: #991b1b;
  font-size: 0.875rem;
  line-height: 1.6;
}

.error-banner strong { display: block; margin-bottom: 4px; }

/* ── Mobile header (hidden on desktop) ── */
.mobile-header { display: none; }

/* ── Responsive ── */
@media (max-width: 800px) {
  .sidebar { display: none; }

  .mobile-header {
    display: block;
    position: sticky;
    top: 0;
    z-index: 100;
    background: var(--color-sidebar-bg);
    color: var(--color-sidebar-text);
    padding: 0 16px;
  }

  .mobile-header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 56px;
    gap: 12px;
  }

  .mobile-name {
    display: block;
    font-family: var(--font-serif);
    font-size: 0.95rem;
    font-weight: 600;
    color: #fff;
    line-height: 1.2;
  }

  .mobile-title {
    display: block;
    font-size: 0.7rem;
    color: var(--color-sidebar-muted);
    line-height: 1.3;
  }

  .mobile-controls {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
  }

  .mobile-menu-btn {
    background: none;
    border: none;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    gap: 5px;
    padding: 4px;
  }

  .mobile-menu-btn span {
    display: block;
    width: 20px;
    height: 1.5px;
    background: var(--color-sidebar-text);
    border-radius: 1px;
    transition: transform 0.2s, opacity 0.2s;
  }

  .mobile-menu-btn[aria-expanded="true"] span:nth-child(1) {
    transform: translateY(6.5px) rotate(45deg);
  }

  .mobile-menu-btn[aria-expanded="true"] span:nth-child(2) {
    opacity: 0;
  }

  .mobile-menu-btn[aria-expanded="true"] span:nth-child(3) {
    transform: translateY(-6.5px) rotate(-45deg);
  }

  .mobile-nav {
    display: none;
    flex-direction: column;
    padding: 8px 0 12px;
    border-top: 1px solid var(--color-sidebar-border);
  }

  .mobile-nav.open {
    display: flex;
  }

  .mobile-nav .nav-link {
    padding: 10px 4px;
    font-size: 0.9rem;
  }

  .layout { display: block; }

  .main-content {
    padding: 32px 20px 60px;
  }

  .section-heading { font-size: 1.3rem; }
  .paper-title { font-size: 0.97rem; }
}

@media (min-width: 801px) and (max-width: 1100px) {
  .main-content { padding: 48px 40px 72px; }
}

/* ── Print ── */
@media print {
  .sidebar, .mobile-header, .lang-toggle-wrap,
  .abstract-toggle, .paper-actions { display: none !important; }

  .layout { display: block; }
  .main-content { padding: 0; }

  .abstract-body { max-height: none !important; opacity: 1 !important; }

  .section { page-break-inside: avoid; margin-bottom: 32px; }
  .paper-item { page-break-inside: avoid; }

  a[href]::after { content: " (" attr(href) ")"; font-size: 0.75em; color: #555; }
  a[href^="mailto"]::after { content: none; }
}
