/* ==========================================================================
   Jiaping Wang — personal academic homepage
   Warm editorial system. Cream paper, terracotta accent, flat surfaces,
   typographic depth. No external font dependencies; works offline.
   ========================================================================== */

:root {
  /* palette */
  --bg-primary:    #f4f3ee;
  --bg-secondary:  #eeede6;
  --bg-inverse:    #191817;
  --text-primary:  #191817;
  --text-secondary:#5a554e;
  --text-muted:    #8a847a;
  --accent:        #c96442;
  --accent-hover:  #b55738;
  --accent-soft:   #e89268;
  --border:        #d8d3c8;
  --border-strong: #c7c1b4;
  --danger:        #a53e2a;

  /* type */
  --serif: "Tiempos Headline", "Iowan Old Style", Georgia, "Songti SC", "STSong", serif;
  --sans:  "Styrene A", "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "PingFang SC", "Microsoft YaHei", sans-serif;
  --mono:  "GT America Mono", "JetBrains Mono", "SF Mono", "Cascadia Code", Consolas, "Liberation Mono", monospace;

  /* modular scale (1.25), 16px root */
  --t-13: 0.8125rem;
  --t-15: 0.9375rem;
  --t-17: 1.0625rem;
  --t-21: 1.3125rem;
  --t-26: 1.625rem;
  --t-32: 2rem;
  --t-40: 2.5rem;
  --t-50: 3.125rem;
  --t-62: 3.875rem;

  /* layout */
  --shell: 1180px;
  --measure: 680px;
  --gutter: 24px;
  --section-gap: 96px;
}

/* ----- reset ----- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }
body {
  margin: 0;
  background: var(--bg-primary);
  color: var(--text-primary);
  font-family: var(--sans);
  font-size: var(--t-17);
  font-weight: 400;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  font-feature-settings: "kern" 1, "liga" 1;
}
img { max-width: 100%; display: block; }

h1, h2, h3, h4 {
  font-family: var(--serif);
  font-weight: 500;
  line-height: 1.12;
  letter-spacing: -0.015em;
  text-wrap: balance;
  margin: 0;
  color: var(--text-primary);
}
p { text-wrap: pretty; margin: 0 0 1rem; }

a { color: inherit; text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 2.5px; text-decoration-color: var(--border-strong); transition: color .15s, text-decoration-color .15s; }
a:hover { color: var(--accent); text-decoration-color: var(--accent); }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 3px; }

/* ----- layout helpers ----- */
.shell { width: 100%; max-width: var(--shell); margin: 0 auto; padding: 0 var(--gutter); }
.measure { max-width: var(--measure); }

.eyebrow {
  font-family: var(--sans);
  font-size: var(--t-13);
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent);
  margin: 0 0 14px;
}

/* ==========================================================================
   Top bar
   ========================================================================== */
.topbar {
  position: sticky; top: 0; z-index: 50;
  background: var(--bg-primary);
  border-bottom: 1px solid var(--border);
}
.topbar__inner { display: flex; align-items: center; justify-content: space-between; height: 64px; }
.brand { font-family: var(--serif); font-weight: 500; font-size: var(--t-21); color: var(--text-primary); text-decoration: none; }
.brand:hover { color: var(--text-primary); }
.brand__cn { color: var(--text-muted); margin-left: .4em; font-size: .85em; }

.nav { display: flex; align-items: center; gap: 28px; }
.nav a {
  font-family: var(--sans); font-size: var(--t-15); font-weight: 500;
  color: var(--text-secondary); text-decoration: none; position: relative; padding: 4px 0;
}
.nav a::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: -1px; height: 1.5px;
  background: currentColor; transform: scaleX(0); transform-origin: left; transition: transform .2s ease;
}
.nav a:hover { color: var(--text-primary); }
.nav a:hover::after { transform: scaleX(1); }
.nav a.is-active { color: var(--text-primary); }
.nav a.is-active::after { background: var(--accent); transform: scaleX(1); }
.nav-icon { display: inline-flex; align-items: center; padding: 4px 2px; color: var(--text-secondary); }
.nav-icon::after { display: none; }
.nav-icon:hover { color: var(--accent); }
.nav-icon svg { width: 18px; height: 18px; }

/* ==========================================================================
   Buttons
   ========================================================================== */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  font-family: var(--sans); font-size: var(--t-15); font-weight: 500; line-height: 1;
  padding: 10px 18px; border-radius: 6px; cursor: pointer; text-decoration: none;
  border: 1px solid var(--border); background: transparent; color: var(--text-primary);
  transition: background .15s, border-color .15s, color .15s;
}
.btn:hover { background: var(--bg-secondary); border-color: var(--border-strong); color: var(--text-primary); text-decoration: none; }
.btn svg { width: 16px; height: 16px; }
.btn--primary { background: var(--accent); border-color: var(--accent); color: var(--bg-primary); }
.btn--primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: var(--bg-primary); }
.btn--sm { padding: 7px 13px; font-size: var(--t-13); }

/* ==========================================================================
   Hero
   ========================================================================== */
.hero { display: grid; grid-template-columns: 232px 1fr; gap: 56px; padding: 80px 0 48px; align-items: start; }
#publications { padding-top: 48px; }
.hero__media { position: sticky; top: 96px; }
.portrait {
  width: 100%; height: auto; display: block;
  border-radius: 8px; border: 1px solid var(--border); background: var(--bg-secondary);
}
.hero__name { font-size: clamp(1.3rem, 3.5vw, 2.25rem); margin: 0 0 4px; }
.hero__cn-img { display: inline-block; height: 1.05em; width: auto; margin-left: .5em; vertical-align: baseline; position: relative; top: 5px; }
.hero__tagline {
  font-family: var(--serif); font-style: italic; font-weight: 400;
  font-size: var(--t-21); color: var(--text-secondary); line-height: 1.4;
  margin: 0 0 32px; max-width: 30ch;
}
.hero__bio { font-size: var(--t-17); color: var(--text-secondary); max-width: var(--measure); }
.hero__bio p { margin: 0 0 1.1rem; }
.hero__bio strong { color: var(--text-primary); font-weight: 600; }

.facts { list-style: none; margin: 36px 0 0; padding: 0; max-width: var(--measure); }
.facts li { display: grid; grid-template-columns: 168px 1fr; gap: 20px; padding: 14px 0; border-top: 1px solid var(--border); }
.facts li:last-child { border-bottom: 1px solid var(--border); }
.facts .k { font-family: var(--sans); font-size: var(--t-13); font-weight: 500; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-muted); padding-top: 2px; }
.facts .v { font-size: var(--t-15); color: var(--text-primary); }
.facts .v small { color: var(--text-muted); font-size: 1em; }

.award-banner {
  display: inline-flex; align-items: center; gap: 10px; flex-wrap: wrap;
  margin-top: 28px; padding: 9px 15px;
  background: var(--bg-secondary); border-left: 3px solid var(--accent); border-radius: 0 6px 6px 0;
  font-size: var(--t-13); line-height: 1.3;
}
.award-banner svg { width: 17px; height: 17px; color: var(--accent); flex: none; }
.award-banner__text { color: var(--text-primary); font-weight: 500; }
.award-banner__text .meta { color: var(--text-muted); font-weight: 400; }
.award-banner a { color: inherit; text-decoration: none; border-bottom: 1px solid var(--border-strong); }
.award-banner a:hover { color: var(--accent); border-bottom-color: var(--accent); }
.award-banner__pdf { color: var(--text-secondary); }

.hero__links { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 36px; }
.hero__links svg { width: 17px; height: 17px; }

/* ==========================================================================
   Sections
   ========================================================================== */
.section { padding: var(--section-gap) 0; scroll-margin-top: 72px; }
.section--alt { background: var(--bg-secondary); }
.section__title { font-size: var(--t-32); margin: 0 0 18px; }
.section__dek { font-family: var(--serif); font-size: var(--t-21); line-height: 1.45; color: var(--text-secondary); max-width: 34ch; margin: 0 0 44px; }

/* ----- research ----- */
.tags { display: flex; flex-wrap: wrap; gap: 10px; margin: 0 0 56px; max-width: var(--measure); }
.tag {
  font-family: var(--sans); font-size: var(--t-15); font-weight: 500; color: var(--text-secondary);
  padding: 7px 14px; border: 1px solid var(--border); border-radius: 6px; background: transparent;
}

.callout {
  display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 24px;
  background: var(--bg-primary); border: 1px solid var(--border); border-radius: 8px; padding: 28px 30px;
  max-width: 860px;
}
.section--alt .callout { background: var(--bg-primary); }
.callout .award-kicker { font-family: var(--sans); font-size: var(--t-13); font-weight: 500; letter-spacing: 0.1em; text-transform: uppercase; color: var(--accent); margin: 0 0 8px; }
.callout h3 { font-size: var(--t-21); margin: 0 0 6px; }
.callout p { margin: 0; color: var(--text-secondary); font-size: var(--t-15); }

/* ==========================================================================
   Publications — flat editorial list, year as a margin sidenote
   ========================================================================== */
.pub-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; flex-wrap: wrap; }
.filter { display: inline-flex; gap: 20px; align-items: center; padding-bottom: 6px; }
.filter button {
  font-family: var(--sans); font-size: var(--t-15); font-weight: 500; color: var(--text-muted);
  background: none; border: 0; padding: 2px 0; cursor: pointer; position: relative;
}
.filter button::after { content: ""; position: absolute; left: 0; right: 0; bottom: -3px; height: 1.5px; background: var(--accent); transform: scaleX(0); transform-origin: left; transition: transform .2s; }
.filter button:hover { color: var(--text-primary); }
.filter button.is-active { color: var(--text-primary); }
.filter button.is-active::after { transform: scaleX(1); }

.year-group { display: grid; grid-template-columns: 88px 1fr; gap: 0 32px; }
.year-label {
  grid-column: 1; font-family: var(--serif); font-size: var(--t-26); font-weight: 500; color: var(--text-muted);
  padding-top: 22px;
}
.year-group:first-of-type .year-label { padding-top: 4px; }
.year-group .pubs-col { grid-column: 2; }

.pub {
  display: grid; grid-template-columns: 128px 1fr; gap: 26px;
  padding: 22px 0;
  content-visibility: auto; contain-intrinsic-size: auto 232px;
}
.year-group:first-of-type .pubs-col .pub:first-child { padding-top: 4px; }

.pub__media { position: relative; }
.pub__thumb { width: 128px; height: 128px; object-fit: cover; border-radius: 8px; border: 1px solid var(--border); background: var(--bg-secondary); }

.pub__body { max-width: var(--measure); }
.pub__venue { font-family: var(--mono); font-size: var(--t-13); font-weight: 500; letter-spacing: 0.06em; text-transform: uppercase; color: var(--text-muted); margin: 0 0 10px; }
.pub__title { font-size: var(--t-21); line-height: 1.2; margin: 0 0 8px; }
.pub__authors { font-size: var(--t-15); color: var(--text-secondary); margin: 0 0 6px; }
.pub__authors a { color: var(--text-secondary); text-decoration: none; border-bottom: 1px solid transparent; }
.pub__authors a:hover { color: var(--accent); border-bottom-color: var(--accent); }
.pub__authors .self { color: var(--text-primary); font-weight: 600; }
.pub__cite { font-size: var(--t-15); color: var(--text-muted); margin: 0 0 18px; }
.award { display: inline; font-family: var(--sans); font-weight: 600; color: var(--accent); }
.award a { color: var(--accent); text-decoration: none; border-bottom: 1px solid var(--accent); }

.pub__actions { display: flex; flex-wrap: wrap; gap: 10px; }

/* inline video */
.pub__video { margin-top: 24px; }
.pub__video[hidden] { display: none; }
.video-frame { position: relative; background: var(--bg-inverse); border-radius: 8px; overflow: hidden; border: 1px solid var(--border); }
.video-frame video { display: block; width: 100%; max-height: 72vh; background: var(--bg-inverse); }
.video-close { position: absolute; top: 10px; right: 10px; z-index: 2; width: 34px; height: 34px; border-radius: 6px; border: 0; cursor: pointer; background: rgba(25,24,23,.6); color: #f4f3ee; display: grid; place-items: center; }
.video-close:hover { background: rgba(25,24,23,.85); }
.video-close svg { width: 16px; height: 16px; }

/* abstract */
.pub__abstract { margin-top: 18px; }
.pub__abstract[hidden] { display: none; }
.pub__abstract .abstract-body { font-size: var(--t-17); color: var(--text-secondary); max-width: var(--measure); }
.pub__abstract .abstract-body p { margin: 0 0 12px; }
.pub__abstract .abstract-body p:last-child { margin: 0; }
.btn[data-abstract-trigger][aria-expanded="true"] { background: var(--bg-secondary); border-color: var(--border-strong); }

/* ==========================================================================
   Archive
   ========================================================================== */
.toys { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 16px; max-width: 920px; }
.toy { display: flex; align-items: center; gap: 16px; padding: 18px; background: var(--bg-primary); border: 1px solid transparent; border-radius: 8px; text-decoration: none; transition: border-color .15s; }
.section--alt .toy { background: var(--bg-primary); }
.toy:hover { border-color: var(--border); text-decoration: none; }
.toy img { width: 50px; height: 50px; border-radius: 6px; object-fit: cover; border: 1px solid var(--border); }
.toy .toy-name { font-family: var(--serif); font-size: var(--t-17); font-weight: 500; color: var(--text-primary); }
.toy .toy-sub { font-size: var(--t-13); color: var(--text-muted); }

/* ==========================================================================
   Footer — inverse section
   ========================================================================== */
.footer { background: var(--bg-inverse); color: #b7b1a6; padding: 72px 0; margin-top: 0; }
.footer__inner { display: flex; flex-wrap: wrap; gap: 24px 48px; justify-content: space-between; }
.footer strong { color: #f4f3ee; font-family: var(--serif); font-weight: 500; font-size: var(--t-21); }
.footer__cn { color: #8a847a; }
.footer .tagline { font-size: var(--t-15); color: #8a847a; margin-top: 6px; }
.footer a { color: #e8e3d8; text-decoration: none; border-bottom: 1px solid #3a3835; }
.footer a:hover { color: var(--accent-soft); border-bottom-color: var(--accent-soft); }
.footer .links { font-size: var(--t-15); display: flex; gap: 18px; align-items: center; flex-wrap: wrap; }

/* ==========================================================================
   BibTeX modal — the single allowed shadow
   ========================================================================== */
.bib-modal { border: 0; padding: 0; background: transparent; max-width: 760px; width: calc(100% - 32px); }
.bib-modal::backdrop { background: rgba(25,24,23,.35); }
.bib-card { background: var(--bg-primary); border: 1px solid var(--border); border-radius: 8px; box-shadow: 0 8px 24px rgba(25,24,23,.08); overflow: hidden; }
.bib-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 18px 22px; border-bottom: 1px solid var(--border); }
.bib-head h3 { font-size: var(--t-17); font-family: var(--serif); font-weight: 500; }
.bib-actions { display: flex; gap: 8px; }
.bib-body { margin: 0; padding: 22px; font-family: var(--mono); font-size: var(--t-13); line-height: 1.7; white-space: pre; overflow-x: auto; color: var(--text-primary); background: var(--bg-secondary); max-height: 60vh; }

/* ==========================================================================
   Responsive
   ========================================================================== */
@media (max-width: 900px) {
  .hero { grid-template-columns: 180px 1fr; gap: 40px; padding-top: 56px; }
  .hero__media { position: static; }
}
@media (max-width: 720px) {
  :root { --section-gap: 64px; }
  body { font-size: 18px; }
  .nav { gap: 20px; }
  .nav .nav-extra { display: none; }
  .brand__cn { display: none; }
  .hero { grid-template-columns: 1fr; gap: 28px; padding-top: 40px; }
  .hero__media { max-width: 156px; }
  .facts li { grid-template-columns: 132px 1fr; gap: 14px; }
  .year-group { grid-template-columns: 1fr; }
  .year-group .year-label, .year-group .pubs-col { grid-column: auto; }
  .year-label { position: static; top: auto; padding: 12px 0 4px; font-size: var(--t-21); color: var(--accent); }
  .year-group:first-of-type .pubs-col .pub:first-child { padding-top: 0; }
  .pub { grid-template-columns: 104px 1fr; gap: 16px; padding: 18px 0; }
  .pub__thumb { width: 104px; height: 104px; }
}
@media (max-width: 440px) {
  .pub { grid-template-columns: 1fr; gap: 16px; }
  .pub__media { max-width: 132px; }
}

/* ==========================================================================
   Archive subpages (old_site/*.htm)
   ========================================================================== */
.page { padding: 52px 0 76px; }
.page-hero { margin-bottom: 44px; }
.page-hero .eyebrow { margin-bottom: 10px; }
.page-title { font-size: var(--t-40); margin: 0 0 14px; }
.page-lead { font-family: var(--serif); font-size: var(--t-21); line-height: 1.45; color: var(--text-secondary); max-width: 42ch; margin: 0; }

.page-grid { display: grid; grid-template-columns: minmax(0, 1fr) 280px; gap: 52px; align-items: start; }
.page-body { font-size: var(--t-17); color: var(--text-secondary); }
.page-body > p { margin: 0 0 16px; max-width: var(--measure); }
.page-body strong { color: var(--text-primary); font-weight: 600; }
.page-h2 { font-family: var(--serif); font-weight: 500; font-size: var(--t-21); color: var(--text-primary); margin: 38px 0 14px; }

.doc-group { margin: 0 0 18px; }
.doc-group__label { font-family: var(--sans); font-weight: 600; color: var(--text-primary); font-size: var(--t-15); margin: 0 0 9px; }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; }

.kv-table { width: 100%; max-width: var(--measure); border-collapse: collapse; margin: 6px 0 8px; font-size: var(--t-15); }
.kv-table th { font-family: var(--mono); font-size: var(--t-13); text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-muted); text-align: left; font-weight: 500; padding: 9px 14px; border-bottom: 1px solid var(--border); }
.kv-table td { padding: 9px 14px; color: var(--text-secondary); }
.kv-table tbody tr:nth-child(odd) { background: var(--bg-secondary); }
.kv-table td:first-child { color: var(--text-primary); }

.figures { display: flex; flex-direction: column; gap: 24px; }
.figure { margin: 0; }
.figure a { display: block; border: 0; }
.figure a:hover { text-decoration: none; }
.figure img { width: 100%; height: auto; border-radius: 8px; border: 1px solid var(--border); background: var(--bg-secondary); display: block; }
.figure figcaption { font-size: var(--t-13); color: var(--text-muted); margin-top: 8px; }

@media (max-width: 760px) {
  .page-grid { grid-template-columns: 1fr; gap: 36px; }
  .figures { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 20px; }
}
