/* ============================================================
   Thomas C. P. Chau — Minimalist Academic Stylesheet
   Modern responsive HTML5 & CSS3 for GitHub Pages
   ============================================================ */
:root {
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-serif: 'Newsreader', Georgia, 'Times New Roman', serif;
  --font-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;

  --bg-page: #faf8f4;
  --bg-surface: #ffffff;
  --bg-subtle: #f3efe7;
  --bg-nav: rgba(250, 248, 244, 0.94);
  --border: #e5dfd3;
  --border-strong: #cfc6b4;
  --text-primary: #1a2332;
  --text-secondary: #4a5568;
  --text-muted: #6b7280;
  --accent: #1e3a5f;
  --accent-soft: #eaf0f7;
  --accent-text: #1e3a5f;
  --accent-2: #9a3412;
  --accent-2-soft: #fdf2ee;

  --card-shadow: 0 1px 2px rgba(26, 35, 50, 0.04);
  --card-radius: 10px;
}

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

html {
  scroll-behavior: smooth;
}

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

body.drawer-open {
  overflow: hidden;
}

img {
  max-width: 100%;
  height: auto;
  display: block;
}

a {
  color: var(--accent-text);
  text-decoration: none;
  transition: color 150ms ease, opacity 150ms ease;
}

a:hover {
  text-decoration: underline;
}

button {
  font-family: inherit;
  cursor: pointer;
}

/* Header */
.site-header {
  position: sticky;
  top: 0;
  z-index: 40;
  background: var(--bg-nav);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}

.site-header-inner {
  max-width: 1060px;
  margin: 0 auto;
  padding: 14px 20px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.brand {
  display: flex;
  align-items: baseline;
  gap: 10px;
  color: var(--text-primary);
}

.brand:hover {
  text-decoration: none;
}

.brand-name {
  font-family: var(--font-serif);
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.brand-cn {
  font-size: 14px;
  color: var(--text-muted);
  font-weight: 500;
}

.nav-group {
  display: flex;
  align-items: center;
  gap: 6px;
}

.nav-tab {
  display: inline-block;
  color: var(--text-secondary);
  padding: 7px 14px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 500;
  transition: all 150ms ease;
}

.nav-tab:hover {
  color: var(--text-primary);
  background: var(--bg-subtle);
  text-decoration: none;
}

.nav-tab.active {
  background: var(--accent-soft);
  color: var(--accent-text);
  font-weight: 600;
}

.header-socials {
  display: flex;
  align-items: center;
  gap: 8px;
}

.icon-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg-surface);
  color: var(--text-secondary);
  transition: all 150ms ease;
}

.icon-link:hover {
  color: var(--accent-text);
  border-color: var(--accent);
  text-decoration: none;
  transform: translateY(-1px);
}

/* Main */
.container {
  max-width: 1060px;
  margin: 0 auto;
  padding: 28px 20px 64px;
}

/* Hero */
.hero-card {
  position: relative;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--card-radius);
  box-shadow: var(--card-shadow);
  overflow: hidden;
  margin-bottom: 26px;
}

.hero-banner-wrap {
  position: relative;
  width: 100%;
  height: 210px;
  overflow: hidden;
  background: #f5f2ea;
  border-bottom: 1px solid var(--border);
}

@media (min-width: 768px) {
  .hero-banner-wrap {
    height: 260px;
  }
}

.hero-banner-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center 54%;
}

.hero-banner-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(250, 248, 244, 0) 65%, rgba(250, 248, 244, 0.55) 100%);
  pointer-events: none;
}

.skyline-caption {
  position: absolute;
  top: 14px;
  right: 16px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 5px 12px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.04em;
  background: rgba(26, 35, 50, 0.78);
  color: #faf8f4;
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.16);
}

.hero-body {
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

@media (min-width: 768px) {
  .hero-body {
    padding: 26px 34px 30px;
    flex-direction: row;
    align-items: flex-end;
    justify-content: space-between;
  }
}

.hero-profile {
  display: flex;
  align-items: flex-start;
  gap: 20px;
  flex: 1;
}

.avatar-wrap {
  width: 86px;
  height: 86px;
  border-radius: 999px;
  overflow: hidden;
  border: 3px solid var(--bg-surface);
  box-shadow: 0 6px 18px rgba(26, 35, 50, 0.12);
  background: var(--accent);
  color: #ffffff;
  flex-shrink: 0;
  margin-top: -54px;
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
}

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

.avatar-fallback {
  display: none;
  width: 100%;
  height: 100%;
  align-items: center;
  justify-content: center;
  font-family: var(--font-serif);
  font-size: 28px;
  font-weight: 700;
}

.hero-text h1 {
  margin: 0;
  font-family: var(--font-serif);
  font-size: clamp(1.7rem, 3vw, 2.35rem);
  line-height: 1.15;
  letter-spacing: -0.02em;
  color: var(--text-primary);
}

.hero-role {
  margin: 6px 0 12px;
  font-size: 16px;
  font-weight: 500;
  color: var(--text-secondary);
}

.hero-role strong {
  color: var(--accent-text);
  font-weight: 600;
}

.hero-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 500;
  background: var(--bg-subtle);
  color: var(--text-secondary);
  border: 1px solid var(--border);
}

.badge-accent {
  background: var(--accent-soft);
  color: var(--accent-text);
  border-color: transparent;
  font-weight: 600;
}

.badge-warm {
  background: var(--accent-2-soft);
  color: var(--accent-2);
  border-color: transparent;
  font-weight: 600;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  flex-shrink: 0;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 9px 16px;
  border-radius: 8px;
  font-size: 13.5px;
  font-weight: 600;
  border: 1px solid var(--border);
  background: var(--bg-surface);
  color: var(--text-primary);
  transition: all 150ms ease;
}

.btn:hover {
  border-color: var(--accent);
  color: var(--accent-text);
  text-decoration: none;
}

.btn-primary {
  background: var(--accent);
  color: #ffffff;
  border-color: var(--accent);
}

.btn-primary:hover {
  opacity: 0.92;
  color: #ffffff;
}

.btn-sm {
  padding: 5px 11px;
  font-size: 12.5px;
  border-radius: 7px;
}

.btn-pdf {
  background: var(--accent-2-soft);
  color: var(--accent-2);
  border-color: rgba(154, 52, 18, 0.22);
}

.btn-pdf:hover {
  background: var(--accent-2);
  color: #ffffff;
  border-color: var(--accent-2);
}

/* City Strip */
.city-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
  margin-bottom: 26px;
}

@media (min-width: 768px) {
  .city-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

.city-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--card-radius);
  padding: 18px 20px;
  box-shadow: var(--card-shadow);
  transition: border-color 180ms ease;
}

.city-card:hover {
  border-color: var(--border-strong);
}

.city-kicker {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent-text);
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.city-title {
  margin: 0 0 6px;
  font-family: var(--font-serif);
  font-size: 19px;
  font-weight: 700;
  color: var(--text-primary);
}

.city-desc {
  margin: 0;
  font-size: 13.5px;
  color: var(--text-secondary);
  line-height: 1.55;
}

/* Two-Column Content */
.content-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 24px;
}

@media (min-width: 860px) {
  .content-grid {
    grid-template-columns: minmax(0, 1.65fr) minmax(0, 1fr);
    align-items: start;
  }
}

.card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--card-radius);
  padding: 24px;
  box-shadow: var(--card-shadow);
  margin-bottom: 20px;
}

.card:last-child {
  margin-bottom: 0;
}

.section-kicker {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--accent-text);
  margin: 0 0 5px;
}

.section-title {
  margin: 0 0 14px;
  font-family: var(--font-serif);
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.015em;
  color: var(--text-primary);
}

.prose p {
  margin: 0 0 14px;
  font-size: 15px;
  color: var(--text-secondary);
}

.prose p:last-child {
  margin-bottom: 0;
}

.prose strong {
  color: var(--text-primary);
  font-weight: 600;
}

/* Specialties */
.specialty-list {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}

.specialty-item {
  padding: 15px 16px;
  border-radius: 8px;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
}

.specialty-item h3 {
  margin: 0 0 4px;
  font-size: 15px;
  font-weight: 650;
  color: var(--text-primary);
}

.specialty-item p {
  margin: 0;
  font-size: 13.5px;
  color: var(--text-secondary);
}

/* Timeline */
.timeline {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.timeline-item {
  position: relative;
  padding-left: 15px;
  border-left: 2px solid var(--border);
}

.timeline-item.current {
  border-left-color: var(--accent);
}

.timeline-org {
  font-size: 14px;
  font-weight: 650;
  color: var(--text-primary);
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
}

.timeline-loc {
  font-size: 11.5px;
  color: var(--text-muted);
  font-weight: 500;
  flex-shrink: 0;
}

.timeline-role {
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: 2px;
}

/* Service Tag Cloud */
.service-desc {
  margin: 0 0 12px;
  font-size: 13px;
  color: var(--text-secondary);
}

.tag-cloud {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.mini-tag {
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 500;
  background: var(--bg-subtle);
  color: var(--text-secondary);
  border: 1px solid var(--border);
}

.mini-tag-highlight {
  background: var(--accent-2-soft);
  color: var(--accent-2);
  border-color: rgba(154, 52, 18, 0.22);
  font-weight: 600;
}

/* Chinese Name & Audio */
.cn-name-display {
  padding: 14px 16px;
  border-radius: 8px;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  margin-bottom: 12px;
}

.cn-chars {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: 0.14em;
  color: var(--text-primary);
  line-height: 1.2;
}

.cn-note {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 4px;
}

.audio-row {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.audio-btn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 10px 13px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg-surface);
  color: var(--text-primary);
  font-size: 13px;
  text-align: left;
  transition: all 150ms ease;
}

.audio-btn:hover,
.audio-btn.playing {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent-text);
}

.audio-lang {
  font-weight: 600;
  display: block;
}

.audio-roman {
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--text-muted);
}

/* Publications */
.pub-header {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-bottom: 22px;
}

@media (min-width: 720px) {
  .pub-header {
    flex-direction: row;
    align-items: flex-end;
    justify-content: space-between;
  }
}

.pub-header h1 {
  margin: 0 0 6px;
  font-family: var(--font-serif);
  font-size: clamp(1.65rem, 3vw, 2.2rem);
  letter-spacing: -0.02em;
}

.pub-header p {
  margin: 0;
  font-size: 14.5px;
  color: var(--text-secondary);
}

.pub-stats {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-bottom: 20px;
}

@media (min-width: 640px) {
  .pub-stats {
    grid-template-columns: repeat(4, 1fr);
  }
}

.stat-box {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--card-radius);
  padding: 14px 16px;
  box-shadow: var(--card-shadow);
}

.stat-num {
  font-family: var(--font-serif);
  font-size: 24px;
  font-weight: 700;
  color: var(--accent-text);
  line-height: 1.15;
}

.stat-label {
  font-size: 12.5px;
  color: var(--text-muted);
  margin-top: 3px;
}

.pub-controls {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 20px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--card-radius);
  padding: 16px;
  box-shadow: var(--card-shadow);
}

.pub-search-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.search-input-wrap {
  position: relative;
  flex: 1;
  min-width: 220px;
}

.search-input {
  width: 100%;
  padding: 9px 14px 9px 36px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg-subtle);
  color: var(--text-primary);
  font-size: 14px;
  outline: none;
  transition: border-color 150ms ease;
}

.search-input:focus {
  border-color: var(--accent);
  background: var(--bg-surface);
}

.search-icon {
  position: absolute;
  left: 11px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
}

.match-count {
  font-size: 12.5px;
  color: var(--text-muted);
  white-space: nowrap;
}

.filter-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.filter-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.filter-pill {
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg-subtle);
  color: var(--text-secondary);
  font-size: 12.5px;
  font-weight: 500;
  transition: all 140ms ease;
}

.filter-pill:hover {
  border-color: var(--accent);
  color: var(--text-primary);
}

.filter-pill.active {
  background: var(--accent);
  color: #ffffff;
  border-color: var(--accent);
  font-weight: 600;
}

.pdf-toggle-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid rgba(154, 52, 18, 0.28);
  background: var(--accent-2-soft);
  color: var(--accent-2);
  font-size: 12.5px;
  font-weight: 600;
  transition: all 140ms ease;
}

.pdf-toggle-pill:hover {
  border-color: var(--accent-2);
}

.pdf-toggle-pill.active {
  background: var(--accent-2);
  color: #ffffff;
  border-color: var(--accent-2);
}

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

.pub-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--card-radius);
  padding: 18px 20px;
  box-shadow: var(--card-shadow);
  transition: border-color 150ms ease;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

@media (min-width: 720px) {
  .pub-card {
    flex-direction: row;
    align-items: flex-start;
    justify-content: space-between;
    gap: 20px;
  }
}

.pub-card:hover {
  border-color: var(--border-strong);
}

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

.pub-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}

.pub-year {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 600;
  color: var(--accent-text);
  background: var(--accent-soft);
  padding: 2px 8px;
  border-radius: 6px;
}

.pub-type {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}

.pub-award {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--accent-2);
  background: var(--accent-2-soft);
  padding: 2px 8px;
  border-radius: 6px;
}

.pub-title {
  margin: 0 0 6px;
  font-family: var(--font-serif);
  font-size: 17.5px;
  font-weight: 600;
  line-height: 1.35;
  color: var(--text-primary);
}

.pub-authors {
  margin: 0 0 5px;
  font-size: 13.5px;
  color: var(--text-secondary);
  line-height: 1.5;
}

.pub-authors strong {
  color: var(--text-primary);
  font-weight: 650;
}

.pub-venue {
  margin: 0;
  font-size: 13px;
  color: var(--text-muted);
  font-style: italic;
}

.pub-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.empty-state {
  text-align: center;
  padding: 40px 20px;
  background: var(--bg-surface);
  border: 1px dashed var(--border-strong);
  border-radius: var(--card-radius);
  color: var(--text-secondary);
}

/* PDF Reader Drawer */
.drawer-backdrop {
  position: fixed;
  inset: 0;
  z-index: 90;
  background: rgba(26, 35, 50, 0.55);
  backdrop-filter: blur(3px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 200ms ease;
}

.drawer-backdrop.open {
  opacity: 1;
  pointer-events: auto;
}

.pdf-drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  z-index: 100;
  width: min(760px, 100vw);
  background: var(--bg-surface);
  border-left: 1px solid var(--border);
  box-shadow: -12px 0 36px rgba(26, 35, 50, 0.22);
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 240ms cubic-bezier(0.22, 1, 0.36, 1);
}

.pdf-drawer.open {
  transform: translateX(0);
}

.drawer-header {
  padding: 18px 22px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-page);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.drawer-kicker {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent-2);
  margin-bottom: 4px;
}

.drawer-title {
  margin: 0 0 4px;
  font-family: var(--font-serif);
  font-size: 19px;
  font-weight: 700;
  line-height: 1.3;
  color: var(--text-primary);
}

.drawer-sub {
  margin: 0;
  font-size: 13px;
  color: var(--text-secondary);
}

.drawer-close {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  width: 34px;
  height: 34px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.drawer-close:hover {
  border-color: var(--accent);
  color: var(--text-primary);
}

.drawer-toolbar {
  padding: 12px 22px;
  border-bottom: 1px solid var(--border);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background: var(--bg-surface);
}

.drawer-body {
  flex: 1;
  overflow-y: auto;
  background: var(--bg-subtle);
  display: flex;
  flex-direction: column;
}

.pdf-frame {
  width: 100%;
  flex: 1;
  min-height: 460px;
  border: none;
  background: #ffffff;
}

.pdf-fallback-card {
  margin: 24px;
  padding: 24px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--card-radius);
  box-shadow: var(--card-shadow);
}

.pdf-fallback-card h3 {
  margin: 0 0 8px;
  font-family: var(--font-serif);
  font-size: 19px;
  color: var(--text-primary);
}

.pdf-fallback-card p {
  margin: 0 0 14px;
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.6;
}

.citation-box {
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 14px;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-primary);
  line-height: 1.55;
  margin-bottom: 16px;
  word-break: break-word;
}

/* Footer & Toast */
.site-footer {
  border-top: 1px solid var(--border);
  padding: 24px 20px;
  text-align: center;
  font-size: 13px;
  color: var(--text-muted);
}

.toast {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 120;
  background: #1a2332;
  color: #faf8f4;
  padding: 10px 16px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  box-shadow: 0 12px 28px rgba(26, 35, 50, 0.25);
  opacity: 0;
  transform: translateY(10px);
  pointer-events: none;
  transition: opacity 180ms ease, transform 180ms ease;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}
