@import url('https://fonts.googleapis.com/css2?family=Source+Serif+4:ital,opsz,wght@0,8..60,400;0,8..60,600;1,8..60,400&family=Source+Sans+3:wght@400;600&display=swap');

:root {
  --accent: #2a6f6b;
  --accent-hover: #1f5552;
  --ink: #2c2c2c;
  --muted: #5a5a5a;
  --light: #7a7a7a;
  --rule: #e2e0dc;
  --paper: #f7f5f1;
  --surface: #ffffff;
  --link: #1a5f7a;
}

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

html {
  overflow-x: hidden;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  padding: 0;
  font-family: 'Source Sans 3', Helvetica, sans-serif;
  color: var(--ink);
  background-color: var(--paper);
  line-height: 1.45;
}

a {
  color: var(--link);
  text-decoration: none;
  border-bottom: 1px dotted var(--link);
}

a:hover {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

/* Background + portrait */
.background-row {
  display: flex;
  flex-direction: row-reverse;
  align-items: flex-start;
  gap: 1.25em;
  margin-top: 0.5em;
}

.background-text {
  flex: 1;
  min-width: 0;
}

.background-text p:first-child {
  margin-top: 0;
}

.portrait {
  flex: 0 0 auto;
  line-height: 0;
}

.portrait img {
  display: block;
  width: auto;
  height: auto;
  max-width: 90vw;
  border: 1px solid #e5e5e5;
}

@media (max-width: 768px) {
  .background-row {
    flex-direction: column;
    align-items: center;
  }

  .portrait {
    order: -1;
    display: block;
    width: 90%;
    max-width: 90vw;
    margin: 0 auto 0.85em;
    align-self: center;
  }

  .portrait img {
    width: 100% !important;
    height: auto !important;
    max-width: 100%;
    margin: 0 auto;
  }

  .background-text {
    width: 100%;
  }
}

/* Header */
header {
  background-color: var(--surface);
  padding: 2.25em 1.5em 1.25em;
  text-align: center;
}

header h1 {
  margin: 0;
  font-family: 'Source Serif 4', Georgia, Times, serif;
  font-size: clamp(2rem, 5vw, 2.75rem);
  font-weight: 400;
  letter-spacing: 0.04em;
  color: var(--ink);
}

header h1 a {
  color: inherit;
  border-bottom: none;
}

header h1 a:hover {
  color: var(--accent);
}

header .chinese-name {
  display: block;
  margin-top: 0.35em;
  font-family: 'Source Serif 4', Georgia, serif;
  font-size: 0.45em;
  letter-spacing: 0.2em;
  color: var(--light);
}

/* Navigation */
nav {
  background-color: var(--surface);
  border-bottom: 1px solid var(--rule);
  position: sticky;
  top: 0;
  z-index: 50;
}

.nav-container {
  max-width: 45em;
  margin: 0 auto;
  padding: 0.9rem 1rem;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.15em 0.1em;
}

.nav-link {
  color: var(--ink);
  border-bottom: none;
  padding: 0.35em 0.85em;
  letter-spacing: 0.08em;
  font-size: 0.9em;
  text-transform: lowercase;
  transition: color 0.15s ease;
}

.nav-link:visited {
  color: var(--ink);
}

.nav-link:hover,
.nav-link[aria-current="page"] {
  color: var(--accent);
  border-bottom: 1px solid var(--accent);
}

/* Main layout */
.page {
  max-width: 45em;
  margin: 0 auto;
  padding: 2rem 1.5rem 3rem;
}

.page p,
.page li,
.page td {
  font-family: 'Source Serif 4', Georgia, Cambria, 'Times New Roman', Times, serif;
  font-size: 1.08em;
  line-height: 1.55;
  color: var(--ink);
}

.page p {
  margin: 0.85em 0 0;
}

.page ul {
  margin: 0.6em 0 0;
  padding-left: 1.25em;
}

.page li {
  margin-top: 0.35em;
}

.page h2 {
  font-family: 'Source Serif 4', Georgia, Times, serif;
  font-size: 1.65em;
  font-weight: 400;
  color: var(--muted);
  margin: 2.25em 0 0.4em;
  padding-bottom: 0.25em;
  border-bottom: 2px solid var(--accent);
  display: inline-block;
  line-height: 1.2;
  clear: both;
}

.page h2:first-child {
  margin-top: 0.5em;
}

.page h3 {
  font-family: 'Source Sans 3', Helvetica, sans-serif;
  font-size: 1.15em;
  font-weight: 600;
  color: var(--ink);
  margin: 1.75em 0 0.4em;
}

.more-link {
  display: inline-block;
  margin-top: 1em;
}

/* Publications */
.papers {
  list-style: disc;
  padding-left: 1.25em;
  margin: 0.75em 0 0;
}

.papers li {
  margin-bottom: 1.1em;
}

.papers .venue {
  font-style: italic;
}

.papers .links {
  font-family: 'Source Sans 3', Helvetica, sans-serif;
  font-size: 0.92em;
  letter-spacing: 0.02em;
}

.papers .links a {
  margin-right: 0.65em;
}

/* Projects */
.project {
  margin-top: 1.75em;
}

.project h3 {
  margin-bottom: 0.2em;
}

.project .meta {
  font-family: 'Source Sans 3', Helvetica, sans-serif;
  font-size: 0.9em;
  color: var(--light);
  margin: 0 0 0.35em;
}

/* Contact table */
.contact-table {
  width: 100%;
  margin: 1.25em 0 0;
  border-collapse: collapse;
}

.contact-table td {
  padding: 0.4em 1em 0.4em 0;
  vertical-align: top;
}

.contact-table td:first-child {
  font-family: 'Source Sans 3', Helvetica, sans-serif;
  font-size: 0.9em;
  letter-spacing: 0.04em;
  color: var(--muted);
  width: 7.5em;
  white-space: nowrap;
}

.elsewhere {
  margin-top: 1.25em;
}

/* Teaching schedule (Kirlin-style semester lists) */
.semester {
  margin-top: 1.35em;
}

.semester h3 {
  font-family: 'Source Sans 3', Helvetica, sans-serif;
  font-size: 1.1em;
  font-weight: 600;
  color: var(--ink);
  margin: 0 0 0.35em;
}

.course-list {
  list-style: none;
  padding: 0;
  margin: 0 0 0.25em;
}

.course-list li {
  margin: 0.2em 0;
  padding-left: 0.15em;
}

/* Teaching materials */
.resource-list {
  list-style: none;
  padding: 0;
  margin: 1em 0 0;
}

.resource-list li {
  font-family: 'Source Sans 3', Helvetica, sans-serif;
  margin: 0.5em 0;
}

.resource-list a {
  border-bottom: 1px solid transparent;
}

.resource-list a:hover {
  border-bottom-color: var(--accent);
}

/* Footer */
footer {
  background-color: var(--surface);
  border-top: 1px solid var(--rule);
  padding: 2.5em 1.5em;
  margin-top: 2em;
  text-align: center;
}

.footer-mark {
  display: inline-block;
  margin-bottom: 1.25em;
  opacity: 0.45;
}

.footer-links {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.5em 1.5em;
}

.footer-links a {
  font-family: 'Source Sans 3', Helvetica, sans-serif;
  font-size: 0.8em;
  letter-spacing: 0.18em;
  text-transform: lowercase;
  color: var(--muted);
  border-bottom: none;
}

.footer-links a:hover {
  color: var(--accent);
}

.footer-note {
  margin-top: 1.25em;
  font-family: 'Source Sans 3', Helvetica, sans-serif;
  font-size: 0.75em;
  letter-spacing: 0.12em;
  text-transform: lowercase;
  color: var(--light);
}

#last-updated {
  margin-top: 1.25em;
  font-family: 'Source Sans 3', Helvetica, sans-serif;
  font-size: 0.8em;
  letter-spacing: 0.04em;
  color: var(--light);
  min-height: 1.2em;
}

/* Responsive */
@media (max-width: 600px) {
  header {
    padding: 1.5em 1em 1em;
  }

  .page {
    padding: 1.5rem 1rem 2.5rem;
  }

  .page p,
  .page li,
  .page td {
    font-size: 1em;
  }

  .nav-link {
    padding: 0.3em 0.45em;
    font-size: 0.8em;
  }

  .contact-table td:first-child {
    display: block;
    width: auto;
    padding-bottom: 0;
  }

  .contact-table td {
    display: block;
    padding: 0.15em 0 0.55em;
  }
}

@media print {
  nav,
  footer {
    display: none;
  }

  body {
    background: #fff;
  }

  a {
    border-bottom: none;
    color: #000;
  }
}
