/* ------------------------------------------------------------------
   Xingguo Wang — personal academic site
   Plain CSS, no build step. Palette and type are defined once on :root.
   ------------------------------------------------------------------ */

:root {
  --accent: #0f6e73;
  --accent-dark: #0a5257;
  --accent-soft: #e3f0f0;
  --ink: #17212b;
  --text: #26303a;
  --muted: #5d6874;
  --bg: #faf9f6;
  --surface: #ffffff;
  --border: #e4e0d8;
  --focus: #8fc7ca;

  --serif: "Newsreader", Georgia, "Times New Roman", serif;
  --sans: Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;

  --wrap: 1000px;
  --pad: 24px;
  --section-gap: 56px;
  --header-h: 64px;
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 17px;
  line-height: 1.6;
  font-optical-sizing: auto;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 {
  font-family: var(--serif);
  color: var(--ink);
  letter-spacing: -0.01em;
  line-height: 1.2;
  margin: 0 0 0.5em;
  font-optical-sizing: auto;
}
h1 { font-size: 40px; font-weight: 600; }
h2 { font-size: 26px; font-weight: 500; }
h3 { font-size: 20px; font-weight: 500; }

p { margin: 0 0 1em; }
p:last-child { margin-bottom: 0; }

a {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-thickness: 1px;
  transition: color 0.15s ease;
}
a:hover { color: var(--accent-dark); }

:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

img { max-width: 100%; height: auto; }

strong { font-weight: 600; color: var(--ink); }

.edu-note { color: var(--muted); font-size: 15px; }
address { font-style: normal; }
.addresses { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 20px 32px; }
.addresses strong { color: var(--ink); font-weight: 600; }

ul.plain { list-style: none; padding: 0; margin: 0; }
ul.plain li { margin: 0 0 6px; }

.wrap {
  max-width: var(--wrap);
  margin: 0 auto;
  padding: 0 var(--pad);
}

.lede {
  font-size: 18px;
  color: var(--muted);
  max-width: 60ch;
  margin-bottom: 0;
}

.note {
  font-size: 14px;
  color: var(--muted);
  margin-bottom: 18px;
}

/* ---------- Skip link ---------- */
.skip-link {
  position: absolute;
  left: -9999px;
  top: 8px;
  z-index: 200;
  background: var(--accent);
  color: #fff;
  padding: 10px 16px;
  border-radius: 999px;
  text-decoration: none;
  font-weight: 500;
}
.skip-link:focus { left: 16px; }

/* ---------- Header / navigation ---------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.nav-wrap {
  height: var(--header-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.wordmark {
  font-family: var(--serif);
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--ink);
  text-decoration: none;
  white-space: nowrap;
}
.wordmark:hover { color: var(--accent-dark); }

.nav-tabs {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  gap: 4px;
  height: 100%;
}

.tab {
  display: flex;
  align-items: center;
  gap: 8px;
  height: var(--header-h);
  padding: 0 12px;
  color: var(--text);
  text-decoration: none;
  font-size: 15px;
  font-weight: 500;
  border-bottom: 2px solid transparent;
  transition: color 0.15s ease, border-color 0.15s ease;
}
.tab svg { width: 24px; height: 24px; flex: none; }
.tab:hover { color: var(--accent-dark); }
.tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}
.tab:focus-visible { outline-offset: -3px; }

/* ---------- Main / sections ---------- */
main.wrap {
  padding: 48px var(--pad) 24px;
}

main > section + section { margin-top: var(--section-gap); }

section > h2 { margin-bottom: 18px; }

/* ---------- Hero ---------- */
.hero {
  display: grid;
  grid-template-columns: 240px 1fr;
  gap: 40px;
  align-items: center;
}

.headshot {
  width: 240px;
  height: 240px;
  border-radius: 18px;
  object-fit: cover;
  display: block;
  background: var(--accent-soft);
}

.hero h1 { margin-bottom: 4px; }
.pronounce {
  margin: 0 0 10px;
  font-size: 14px;
  font-style: italic;
  color: var(--muted);
  letter-spacing: 0.01em;
}
.name-zh {
  font-size: 0.8em;
  font-weight: 500;
  color: var(--muted);
  letter-spacing: 0.06em;
  white-space: nowrap;
  font-family: "Songti SC", "SimSun", "Noto Serif CJK SC", "Source Han Serif SC", Georgia, serif;
}

.hero-role {
  font-size: 19px;
  font-weight: 500;
  color: var(--ink);
  margin: 0 0 6px;
}

.hero-affil {
  color: var(--muted);
  margin: 0 0 4px;
}

/* ---------- Buttons ---------- */
.btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 22px;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  border-radius: 999px;
  background: var(--accent);
  border: 1px solid var(--accent);
  color: #fff;
  text-decoration: none;
  font-size: 15px;
  font-weight: 500;
  line-height: 1.2;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}
.btn svg { width: 16px; height: 16px; flex: none; }
.btn:hover {
  background: var(--accent-dark);
  border-color: var(--accent-dark);
  color: #fff;
}

.btn-secondary {
  background: var(--surface);
  border-color: var(--border);
  color: var(--ink);
}
.btn-secondary:hover {
  background: var(--accent-soft);
  border-color: var(--border);
  color: var(--accent-dark);
}

/* ---------- Chips ---------- */
.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  list-style: none;
  padding: 0;
  margin: 18px 0 0;
}
.chip {
  background: var(--accent-soft);
  color: var(--accent-dark);
  border-radius: 999px;
  font-size: 13px;
  font-weight: 500;
  padding: 4px 12px;
  line-height: 1.5;
}

/* ---------- Research areas ---------- */
.area { margin-bottom: 28px; }
.area:last-child { margin-bottom: 0; }
.area h3 { margin-bottom: 6px; }
.area p { max-width: 72ch; }
.area-refs {
  color: var(--muted);
  font-size: 15px;
  margin-top: 6px;
}
.area-refs a { margin-right: 4px; font-variant-numeric: tabular-nums; }

/* ---------- Publications ---------- */
.pub-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.pub {
  display: grid;
  grid-template-columns: 3.4em 1fr;
  gap: 10px;
  padding: 14px 0;
  border-top: 1px solid var(--border);
  scroll-margin-top: calc(var(--header-h) + 16px);
  transition: background 0.3s ease;
}
.pub:last-child { border-bottom: 1px solid var(--border); }
.pub:target { background: var(--accent-soft); }

.pub-num {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-variant-numeric: tabular-nums;
  font-size: 14px;
  color: var(--muted);
  padding-top: 4px;
  white-space: nowrap;
}

.pub-cite { margin: 0; }

.pub-links {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  margin: 6px 0 0;
  font-size: 14px;
}


/* ---------- Tables (projects, courses, service) ---------- */
.table-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
  overflow: hidden;
}

table.proj {
  width: 100%;
  border-collapse: collapse;
  font-size: 15px;
}

.proj th,
.proj td {
  text-align: left;
  vertical-align: top;
  padding: 12px 14px;
  border-top: 1px solid var(--border);
}

.proj thead th {
  border-top: 0;
  background: var(--bg);
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.proj .num {
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.proj .nowrap { white-space: nowrap; }
.proj .code { white-space: nowrap; font-weight: 500; color: var(--ink); }

/* ---------- Student feedback (teaching) ---------- */
.quotes { list-style: none; padding: 0; margin: 0; display: grid; gap: 14px; }
.quotes blockquote { margin: 0; padding: 12px 16px; border-left: 3px solid var(--accent); background: var(--surface); border: 1px solid var(--border); border-left-width: 3px; border-left-color: var(--accent); border-radius: 8px; color: var(--text); font-size: 16px; }

/* ---------- Gallery ---------- */
.gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 14px;
}

.tile {
  margin: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.tile-media {
  display: block;
  aspect-ratio: 4 / 3;
  overflow: hidden;
}
.tile-media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
a.tile-media:focus-visible { outline-offset: -3px; }

.tile-ph {
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--accent-soft) 0%, #cfe3e4 100%);
  color: var(--accent-dark);
  font-size: 14px;
  font-weight: 500;
}

.tile figcaption {
  padding: 10px 12px;
  font-size: 14px;
  color: var(--muted);
}

/* ---------- Lightbox ---------- */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 300;
  background: rgba(23, 33, 43, 0.92);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 72px;
}
.lightbox[hidden] { display: none; }

.lightbox-fig {
  margin: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  max-width: 100%;
}
.lightbox-fig img {
  max-width: 100%;
  max-height: 78vh;
  border-radius: 10px;
  display: block;
}
.lightbox-cap {
  color: #fff;
  margin-top: 12px;
  font-size: 15px;
  text-align: center;
}

.lightbox-btn {
  position: absolute;
  width: 44px;
  height: 44px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.35);
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  font: inherit;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s ease;
}
.lightbox-btn:hover { background: rgba(255, 255, 255, 0.25); }
.lightbox-btn:focus-visible { outline-color: #fff; }
.lightbox-close { top: 16px; right: 16px; }
.lightbox-prev { left: 16px; top: 50%; transform: translateY(-50%); }
.lightbox-next { right: 16px; top: 50%; transform: translateY(-50%); }

body.lightbox-open { overflow: hidden; }

/* ---------- 404 ---------- */
.notfound p { max-width: 50ch; }

/* ---------- Footer ---------- */
.site-footer {
  margin-top: 72px;
  border-top: 1px solid var(--border);
  padding: 24px 0 40px;
  font-size: 14px;
  color: var(--muted);
}
.footer-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 10px;
}
.footer-row .sep { color: var(--border); }
.motto {
  margin: 0 0 14px;
  font-style: italic;
  color: var(--muted);
  max-width: 70ch;
}
.motto-by { font-style: normal; white-space: nowrap; }
.motto-zh {
  font-style: normal;
  margin-left: 0.3em;
  letter-spacing: 0.08em;
  font-family: "Songti SC", "SimSun", "Noto Serif CJK SC", "Source Han Serif SC", Georgia, serif;
}

/* ---------- Responsive ---------- */
/* Narrow desktops / tablets: keep the horizontal nav but tighten it so it never overflows. */
@media (min-width: 720px) and (max-width: 899px) {
  .nav-wrap { gap: 12px; }
  .wordmark { font-size: 20px; }
  .nav-tabs { gap: 0; }
  .tab { padding: 0 8px; gap: 6px; }
}

@media (max-width: 767px) {
  .hero {
    grid-template-columns: 1fr;
    gap: 24px;
  }
}

@media (max-width: 719px) {
  body { font-size: 16px; }
  h1 { font-size: 32px; }
  main.wrap { padding-top: 32px; }

  .nav-wrap {
    height: auto;
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    padding: 0;
  }
  .wordmark {
    display: block;
    text-align: center;
    font-size: 19px;
    padding: 10px 16px 6px;
  }
  .nav-tabs {
    gap: 0;
    justify-content: space-around;
    height: auto;
  }
  .tab {
    flex-direction: column;
    justify-content: center;
    gap: 3px;
    height: auto;
    padding: 6px 4px 8px;
    font-size: 11px;
    line-height: 1.2;
    min-width: 56px;
  }

  .pub { grid-template-columns: 2.8em 1fr; gap: 8px; }

  /* Tables become stacked cards */
  .proj thead {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
  }
  .proj,
  .proj tbody,
  .proj tr { display: block; }
  .proj tr {
    padding: 10px 14px 12px;
    border-top: 1px solid var(--border);
  }
  .proj tr:first-child { border-top: 0; }
  .proj td {
    border: 0;
    padding: 4px 0;
    display: grid;
    grid-template-columns: 96px 1fr;
    gap: 10px;
  }
  .proj td::before {
    content: attr(data-label);
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--muted);
    padding-top: 3px;
  }
  .proj td.num,
  .proj td.nowrap,
  .proj td.code { text-align: left; white-space: normal; }

  .lightbox { padding: 64px 16px; }
  .lightbox-prev { left: 8px; top: auto; bottom: 12px; transform: none; }
  .lightbox-next { right: 8px; top: auto; bottom: 12px; transform: none; }
}

/* ---------- Motion / print ---------- */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    transition: none !important;
    animation: none !important;
  }
}

@media print {
  .site-header,
  .skip-link,
  .btn-row,
  .btn,
  .lightbox,
  .site-footer a { display: none !important; }
  body { background: #fff; color: #000; font-size: 12pt; }
  a { color: #000; text-decoration: none; }
  .pub-links a::after { content: " (" attr(href) ")"; font-size: 10pt; }
  .table-card, .tile { box-shadow: none; }
}
