/* ------------------------------------------------------------------
   Xin (Henry) Zhang — personal site stylesheet
   Classic academic: white page (always, no dark mode), serif headings, garnet accent.
   No frameworks, no JavaScript, no web fonts — system fonts only.
   Hosted on Cloudflare Pages at https://xinhenryzhang.org (see README next to this folder).
   ------------------------------------------------------------------ */

:root {
  --bg: #fffdf9;
  --surface: #f6f2eb;
  --text: #1f1c19;
  --muted: #6b655c;
  --rule: #e6e0d5;
  --accent: #782f40;          /* garnet */
  --accent-strong: #5a2230;
  --accent-underline: rgba(120, 47, 64, 0.38);
  --chip-bg: #f8f4ee;
  --shadow: 0 1px 2px rgba(31, 28, 25, 0.10), 0 6px 18px rgba(31, 28, 25, 0.06);

  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, "Times New Roman", serif;
  --body: Charter, "Bitstream Charter", "Iowan Old Style", Georgia, "Times New Roman", serif;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --maxw: 820px;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--body);
  font-size: 17px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body::before {                      /* thin garnet band across the top */
  content: "";
  display: block;
  height: 4px;
  background: var(--accent);
}

a {
  color: var(--accent);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
  text-decoration-color: var(--accent-underline);
}
a:hover { color: var(--accent-strong); text-decoration-color: currentColor; }
a:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 2px; }

b, strong { font-weight: 650; }

/* superscripts and subscripts (2<sup>14</sup>, p<sup>2</sup>H) without stretching the line spacing */
sup, sub { font-size: 75%; line-height: 0; position: relative; vertical-align: baseline; }
sup { top: -0.5em; }
sub { bottom: -0.25em; }

.skip {
  position: absolute; left: -999px; top: 0;
  background: var(--accent); color: #fff; padding: .5rem .8rem; z-index: 10;
}
.skip:focus { left: .5rem; top: .5rem; }

/* ---------- header / nav ---------- */

.site-header {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 1.5rem 1.25rem 1rem;
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: .35rem 1.5rem;
  border-bottom: 1px solid var(--rule);
}

.brand a {
  font-family: var(--serif);
  font-size: 1.5rem;
  line-height: 1.2;
  color: var(--text);
  text-decoration: none;
  letter-spacing: .005em;
}
.brand a:hover { color: var(--accent); }
.brand .tag {
  display: block;
  font-family: var(--sans);
  font-size: .8rem;
  letter-spacing: .02em;
  color: var(--muted);
  margin-top: .2rem;
}

.site-nav { flex-basis: 100%; }      /* nav always sits on its own row under the name */
.site-nav ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: .2rem 1.15rem;
}
.site-nav a {
  display: inline-block;
  font-family: var(--sans);
  font-size: .8rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: var(--muted);
  text-decoration: none;
  padding: .4rem 0 .35rem;
  border-bottom: 2px solid transparent;
}
.site-nav a:hover { color: var(--accent); }
.site-nav a[aria-current="page"] { color: var(--accent); border-bottom-color: var(--accent); }

/* ---------- page body ---------- */

main {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 1.75rem 1.25rem 3.5rem;
}

h1, h2 { font-family: var(--serif); font-weight: 500; letter-spacing: .005em; }

h1 {
  font-size: 2.1rem;
  line-height: 1.15;
  margin: 0 0 .4rem;
}
.page-intro { margin: 0 0 1.25rem; color: var(--muted); }

h2 {
  font-size: 1.5rem;
  line-height: 1.25;
  margin: 2.4rem 0 .9rem;
  padding-bottom: .35rem;
  border-bottom: 1px solid var(--rule);
}
h2:first-child { margin-top: .5rem; }

h3 {                                   /* small-caps eyebrow for sub-sections */
  font-family: var(--sans);
  font-size: .78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .12em;
  color: var(--muted);
  margin: 1.9rem 0 .5rem;
}
h2 + h3 { margin-top: 1rem; }

p { margin: 0 0 1rem; }

.note { font-size: .95rem; color: var(--muted); }

/* in-page table of contents (Research page) */
.toc {
  list-style: none;
  margin: .3rem 0 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: .3rem 1.3rem;
  font-family: var(--sans);
  font-size: .85rem;
}
.toc a { color: var(--muted); text-decoration: none; }
.toc a:hover { color: var(--accent); }
.toc a::before { content: "\2193\00a0"; opacity: .6; }   /* ↓ */

/* small pill links (supplement, code, download, …) */
.chip, .chips a {
  display: inline-block;
  font-family: var(--sans);
  font-size: .74rem;
  font-weight: 500;
  letter-spacing: .02em;
  line-height: 1.5;
  color: var(--accent);
  background: var(--chip-bg);
  border: 1px solid var(--rule);
  border-radius: 999px;
  padding: .1rem .6rem;
  text-decoration: none;
  white-space: nowrap;
  vertical-align: 1px;
}
.chip:hover, .chips a:hover { border-color: var(--accent); color: var(--accent-strong); }
.chips { display: flex; flex-wrap: wrap; gap: .4rem; margin-top: .45rem; }
.chips a { white-space: normal; border-radius: 8px; }
.extra { display: inline; }
.extra a { margin-left: .3rem; }

.button {
  display: inline-block;
  font-family: var(--sans);
  font-size: .92rem;
  font-weight: 500;
  color: #fff;
  background: var(--accent);
  padding: .6rem 1rem;
  border-radius: 6px;
  text-decoration: none;
}
.button:hover { background: var(--accent-strong); color: #fff; }

/* ---------- home ---------- */

.hero {
  display: grid;
  grid-template-columns: 210px 1fr;
  gap: 1.8rem;
  align-items: start;
  margin-top: .75rem;
}
.hero img {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 8px;
  box-shadow: var(--shadow);
}
.hero h1 { margin-top: -.25rem; }
.hero .role {
  font-family: var(--sans);
  font-size: .95rem;
  color: var(--muted);
  margin: 0 0 1.1rem;
}
.lead { font-size: 1.04rem; }

.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li {
  display: grid;
  grid-template-columns: 165px 1fr;
  gap: 1rem;
  padding: .65rem 0;
  border-top: 1px solid var(--rule);
}
.timeline li:first-child { border-top: 0; }
.timeline .when {
  font-family: var(--sans);
  font-size: .85rem;
  color: var(--muted);
  padding-top: .22rem;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.timeline .what { margin: 0; }

.contact-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem 2.5rem;
}
address { font-style: normal; }
.contact-grid h3 { margin-top: 0; }
.contact-grid ul { list-style: none; margin: 0; padding: 0; }
.contact-grid li { padding: .15rem 0; }

/* ---------- research topics ---------- */

.topic { margin-bottom: 1rem; }
.topic p { max-width: 72ch; }
figure.fig {
  margin: 1.5rem 0 2rem;
  max-width: 680px;
}
figure.fig.narrow { max-width: 420px; }
figure.fig.wide { max-width: none; }          /* detailed figures use the full text width */
figure.fig a.fig-link { display: block; text-decoration: none; }   /* click a figure to open it full size */
figure.fig img {
  display: block;
  width: 100%;
  height: auto;
  background: #fff;
  border: 1px solid var(--rule);
  border-radius: 6px;
  padding: 8px;
}
figure.fig figcaption {
  font-family: var(--sans);
  font-size: .8rem;
  line-height: 1.55;
  color: var(--muted);
  margin: .6rem .25rem 0;
}
figure.fig figcaption a { color: var(--muted); }
figure.fig figcaption a:hover { color: var(--accent); }

/* ---------- publications ---------- */

.pubs { list-style: none; margin: 0; padding: 0; }
.pubs li {
  padding: .7rem 0;
  border-top: 1px solid var(--rule);
}
.pubs li:first-child { border-top: 0; }
.pubs u {                              /* FSU Ph.D. student coauthors */
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
  text-decoration-color: var(--text);
}
.pubs .venue { font-style: italic; }       /* journal names spelled out, italic as in a reference list */
.pubs .journal { font-style: italic; }
.pubs .year { color: var(--muted); }

/* ---------- software ---------- */

.pkg { padding: 1rem 0; border-top: 1px solid var(--rule); }
h2 + .pkg { border-top: 0; }
.pkg h3 {
  font-family: var(--serif);
  font-size: 1.15rem;
  font-weight: 500;
  text-transform: none;
  letter-spacing: 0;
  color: var(--text);
  margin: 0 0 .2rem;
}
.pkg p { margin: 0; }
.pkg .lang { font-family: var(--sans); font-size: .8rem; color: var(--muted); }

/* ---------- teaching ---------- */

.people { list-style: none; margin: 0; padding: 0; }
.people li { padding: .8rem 0; border-top: 1px solid var(--rule); }
.people li:first-child { border-top: 0; }
.people .who { font-weight: 650; }
.people .meta { font-family: var(--sans); font-size: .85rem; color: var(--muted); margin-left: .35rem; }
.people .thesis { display: block; margin-top: .1rem; }
.people .award { display: block; font-size: .93rem; color: var(--accent); margin-top: .1rem; }

.courses { list-style: none; margin: 0; padding: 0; }
.courses li {
  display: grid;
  grid-template-columns: 150px 1fr;
  gap: 1rem;
  padding: .45rem 0;
  border-top: 1px solid var(--rule);
}
.courses li:first-child { border-top: 0; }
.courses + .note { margin-top: 1rem; }
.courses .code {
  font-family: var(--sans);
  font-size: .82rem;
  letter-spacing: .04em;
  color: var(--muted);
  padding-top: .2rem;
  white-space: nowrap;
}

/* ---------- CV ---------- */

.cv-actions { display: flex; flex-wrap: wrap; gap: .8rem 1.2rem; align-items: center; margin: 1rem 0 1.4rem; }
.cv-frame {
  display: block;
  width: 100%;
  height: 82vh;
  min-height: 520px;
  border: 1px solid var(--rule);
  border-radius: 6px;
  background: var(--surface);
}
.cv-frame .fallback { padding: 2rem 1.5rem; text-align: center; }

/* ---------- page photos (Research intro, Teaching classes) ---------- */

/* Research: photo to the right of the title and intro (floats beside them on phones) */
.page-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 150px;
  grid-template-rows: auto 1fr;
  grid-template-areas: "title pic" "intro pic";
  column-gap: 2.25rem;
}
.page-head h1 { grid-area: title; }
.page-head .page-intro { grid-area: intro; }
.page-head .side-pic { grid-area: pic; }

/* Teaching: photo to the right of the class list */
.with-pic {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 150px;
  gap: 1rem 2.25rem;
  align-items: start;
}
.side-pic { margin: .45rem 0 0; }
.side-pic img {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 8px;
  box-shadow: var(--shadow);
}
.with-pic + .note { margin-top: 1rem; }

/* ---------- 404 page ---------- */

.plain-list { list-style: none; margin: 0; padding: 0; }
.plain-list li { padding: .3rem 0; }

/* ---------- footer ---------- */

.site-footer {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 1.2rem 1.25rem 2.5rem;
  border-top: 1px solid var(--rule);
  font-family: var(--sans);
  font-size: .8rem;
  color: var(--muted);
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: .4rem 1.5rem;
}
.site-footer a { color: inherit; text-decoration-color: transparent; }
.site-footer a:hover { color: var(--accent); }

/* ---------- small screens ---------- */

@media (max-width: 640px) {
  body { font-size: 16.5px; }
  .site-header { padding-top: 1.2rem; }
  .site-nav ul { gap: .1rem .95rem; }
  .site-nav a { font-size: .76rem; }
  h1 { font-size: 1.75rem; }
  h2 { font-size: 1.32rem; }
  .hero { grid-template-columns: 1fr; gap: 1.1rem; }
  .hero img { width: 170px; }
  .timeline li, .courses li { grid-template-columns: 1fr; gap: .1rem; }
  .timeline .when, .courses .code { padding-top: 0; }
  .contact-grid { grid-template-columns: 1fr; }
  .cv-frame { display: none; }      /* phones: the PDF opens in its own viewer */
  .with-pic { grid-template-columns: 1fr; }
  .side-pic { width: 132px; margin-top: .25rem; }
  .page-head { display: flow-root; }
  .page-head .side-pic { float: right; width: 104px; margin: .35rem 0 .6rem 1rem; }
}

/* ---------- print ---------- */

@media print {
  body::before, .site-nav, .skip, .toc, .cv-frame, .side-pic { display: none; }
  .with-pic, .page-head { display: block; }
  body { background: #fff; color: #000; font-size: 11pt; }
  a { color: #000; text-decoration: none; }
  .chip, .chips a { border-color: #999; color: #000; background: none; }
  h2 { break-after: avoid; }
  .pubs li, .people li, .pkg { break-inside: avoid; }
}
