/* Haipeng Li — site styles. Fonts: Source Serif 4 (text, headings) + Inter (labels, UI), loaded in each page's <head>. */
:root {
  --text: #1d1d1f;
  --text-2: #3a3a3f;
  --muted: #57575c;
  --accent: #8c1515;          /* Stanford cardinal */
  --accent-soft: #f6eded;
  --bg: #fcfbf9;              /* warm paper white */
  --card: #ffffff;
  --rule: #e8e5e0;
  --serif: "Source Serif 4", Georgia, "Times New Roman", serif;
  --sans: "Inter", -apple-system, "Segoe UI", Helvetica, Arial, sans-serif;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(29,29,31,.04), 0 8px 24px rgba(29,29,31,.06);
  --shadow-hover: 0 2px 4px rgba(29,29,31,.05), 0 16px 36px rgba(29,29,31,.11);
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 88px; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 400 18px/1.7 var(--serif);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  font-feature-settings: "kern", "liga";
}
::selection { background: var(--accent-soft); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 4px; }

.wrap { max-width: 1200px; margin: 0 auto; padding: 0 32px 80px; }

/* ---------- Header / nav ---------- */
header {
  position: sticky; top: 0; z-index: 20;
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 24px;
  margin: 0 -32px 56px; padding: 18px 32px;
  background: rgba(252, 251, 249, .86);
  -webkit-backdrop-filter: saturate(180%) blur(14px); backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid var(--rule);
}
.site-name { font: 600 1.2rem/1.2 var(--serif); letter-spacing: -.01em; color: var(--text); text-decoration: none; }
.site-name::before { content: ""; display: inline-block; width: 10px; height: 10px; margin-right: 10px; border-radius: 2px;
  background: var(--accent); vertical-align: 1px; }
nav { font: 500 15px/1.4 var(--sans); display: flex; flex-wrap: wrap; gap: 4px 26px; }
nav a { color: var(--muted); text-decoration: none; padding: 4px 0; border-bottom: 1.5px solid transparent; transition: color .2s, border-color .2s; }
nav a:hover { color: var(--text); }
nav a.active { color: var(--accent); border-bottom-color: var(--accent); }
@media (max-width: 560px) {
  .wrap { padding: 0 20px 56px; }
  header { position: static; margin: 0 -20px 36px; padding: 14px 20px; }
  nav { gap: 4px 16px; font-size: 14.5px; }
}

/* ---------- Type ---------- */
h1 { font: 600 clamp(2.3rem, 4.4vw, 2.8rem)/1.1 var(--serif); letter-spacing: -.022em; margin: 0 0 12px; text-wrap: balance; }
.subtitle { font: 400 1.14rem/1.65 var(--serif); color: var(--text-2); margin: 0 0 8px; }
.role { font: 500 16.5px/1.6 var(--sans); color: var(--accent); margin: 0 0 24px; text-wrap: balance; }
h2 {
  position: relative;
  font: 600 clamp(1.55rem, 2.6vw, 1.875rem)/1.25 var(--serif); letter-spacing: -.015em; color: var(--text);
  margin: 72px 0 24px; padding-top: 18px; border-top: 1px solid var(--rule); text-wrap: balance;
}
h2::before { content: ""; position: absolute; top: -1px; left: 0; width: 44px; height: 2px; background: var(--accent); }
h3 { font: 600 1.35rem/1.35 var(--serif); letter-spacing: -.01em; margin: 0 0 8px; text-wrap: balance; }
p { margin: 0 0 1em; text-wrap: pretty; }
a { color: var(--accent); text-decoration-thickness: 1px; text-underline-offset: 3px; }
a:hover { text-decoration-thickness: 2px; }
ul { padding-left: 20px; }
li { margin-bottom: 8px; text-wrap: pretty; }
li::marker { color: var(--accent); }
.muted { color: var(--muted); }
code { font: .86em/1 "SF Mono", Menlo, Consolas, monospace; background: #f1efeb; padding: 2px 5px; border-radius: 4px; }

/* ---------- Link buttons ---------- */
.links { display: flex; flex-wrap: wrap; gap: 10px; margin: 0; font: 500 15px/1 var(--sans); }
.links a {
  display: inline-flex; align-items: center; gap: 8px; padding: 10px 16px;
  color: var(--text-2); text-decoration: none; background: var(--card);
  border: 1px solid var(--rule); border-radius: 999px;
  transition: border-color .2s, color .2s, box-shadow .2s, transform .2s;
}
.links a:hover { color: var(--accent); border-color: var(--accent); box-shadow: var(--shadow); transform: translateY(-1px); }
.links svg { width: 16px; height: 16px; flex: none; }

/* ---------- Home intro ---------- */
.intro { display: grid; grid-template-columns: minmax(0, 1fr) 260px; gap: 56px; align-items: center; }
.intro h1 { font-size: clamp(2.6rem, 5.4vw, 3.5rem); }
.intro img { width: 260px; height: auto; border-radius: 14px; box-shadow: var(--shadow);
  outline: 1px solid rgba(0,0,0,.04); }
.intro p.lead { font-size: 1.2rem; line-height: 1.7; color: var(--text); margin-bottom: 28px; }
@media (max-width: 760px) {
  .intro { grid-template-columns: 1fr; gap: 24px; }
  .intro img { width: 180px; order: -1; }
}

/* Research interests: four labeled cards */
ul.interests { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; }
ul.interests li { margin: 0; display: flex; background: var(--card); border: 1px solid var(--rule); border-radius: var(--radius);
  font-size: 16px; line-height: 1.6; color: var(--text-2); transition: border-color .25s, box-shadow .25s, transform .25s; }
ul.interests li a { display: flex; flex-direction: column; flex: 1; padding: 20px 20px 18px; color: inherit; text-decoration: none; border-radius: inherit; }
ul.interests .more { margin-top: auto; padding-top: 14px; font: 500 13.5px/1 var(--sans); color: var(--muted); transition: color .2s; }
ul.interests li:hover .more { color: var(--accent); }
ul.interests li:hover strong { color: var(--accent); }
ul.interests li:hover { border-color: #d9c9c9; box-shadow: var(--shadow); transform: translateY(-2px); }
ul.interests li strong { display: block; font: 600 1.2rem/1.3 var(--serif); color: var(--text); margin-bottom: 8px; transition: color .2s; }
ul.interests li strong::before { content: ""; display: block; width: 22px; height: 2px; background: var(--accent); margin-bottom: 12px; }
@media (max-width: 560px) { ul.interests { grid-template-columns: 1fr; } }

/* Highlights timeline */
ul.timeline { list-style: none; padding: 0; margin: 0; border-left: 1px solid var(--rule); }
ul.timeline li { position: relative; display: grid; grid-template-columns: 84px 1fr; gap: 18px; padding: 0 0 18px 24px; margin: 0; }
ul.timeline li:last-child { padding-bottom: 0; }
ul.timeline li::before { content: ""; position: absolute; left: -5px; top: 11px; width: 9px; height: 9px; border-radius: 50%;
  background: var(--bg); border: 1.5px solid var(--accent); }
ul.timeline li:first-child::before { background: var(--accent); }
ul.timeline .date { font: 500 14px/30px var(--sans); color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
@media (max-width: 560px) { ul.timeline li { grid-template-columns: 1fr; gap: 0; } }

/* Contact */
.contact { display: flex; flex-wrap: wrap; gap: 20px 64px; }
.contact .label { display: block; font: 600 12px/1.4 var(--sans); letter-spacing: .1em; text-transform: uppercase; color: var(--muted); margin-bottom: 4px; }

/* ---------- Research cards ---------- */
.project { margin-bottom: 40px; }
.project img { width: 100%; border: 1px solid var(--rule); border-radius: var(--radius); margin: 8px 0; }

/* ---------- Code cards ---------- */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 18px; margin-top: 36px; }
.card { display: flex; flex-direction: column; padding: 22px 22px 20px; background: var(--card); border: 1px solid var(--rule);
  border-radius: var(--radius); color: var(--text-2); text-decoration: none; transition: border-color .25s, box-shadow .25s, transform .25s; }
.card:hover { border-color: #d9c9c9; box-shadow: var(--shadow-hover); transform: translateY(-2px); }
.card h3 { display: flex; align-items: center; gap: 10px; color: var(--text); margin-bottom: 8px; }
.card h3 svg { width: 20px; height: 20px; color: var(--muted); flex: none; }
.card:hover h3 { color: var(--accent); }
.card p { font-size: 16px; line-height: 1.6; flex: 1; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; }
.tags span { font: 500 12px/1 var(--sans); color: var(--muted); background: #f3f1ed; padding: 6px 9px; border-radius: 999px; }

/* ---------- Field photo gallery ---------- */
.gallery { display: grid; grid-template-columns: repeat(4, 1fr); gap: 20px; }
@media (max-width: 900px) { .gallery { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 480px) { .gallery { grid-template-columns: 1fr; } }
.gallery figure { margin: 0; }
.gallery img { width: 100%; aspect-ratio: 1 / 1; object-fit: cover; display: block; border-radius: var(--radius); box-shadow: var(--shadow);
  transition: transform .5s ease, box-shadow .5s ease; }
.gallery figure:hover img { transform: translateY(-3px); box-shadow: var(--shadow-hover); }
.gallery figcaption { color: var(--muted); font: 14px/1.5 var(--sans); margin-top: 10px; }

/* ---------- Publications ---------- */
ol.pubs { padding-left: 30px; }
ol.pubs li { margin-bottom: 20px; padding-left: 6px; line-height: 1.65; }
ol.pubs li::marker { font: 500 13px var(--sans); color: var(--muted); }
.pub-title { font-weight: 600; color: var(--text); text-decoration: none; }
a.pub-title:hover { color: var(--accent); text-decoration: underline; }
.me { font-weight: 600; text-decoration: underline; text-decoration-color: var(--accent); text-underline-offset: 3px; }
.venue { font-style: italic; }

/* ---------- CV rows ---------- */
.row { display: grid; grid-template-columns: 1fr auto; gap: 24px; padding: 12px 0; border-bottom: 1px solid var(--rule); }
.row:last-of-type { border-bottom: 0; }
.row .when { color: var(--muted); font: 500 14.5px/1.8 var(--sans); white-space: nowrap; font-variant-numeric: tabular-nums; }
.row .muted { font-size: 16px; }
@media (max-width: 560px) { .row { grid-template-columns: 1fr; gap: 0; } }

/* ---------- Footer ---------- */
footer { margin-top: 88px; padding-top: 22px; border-top: 1px solid var(--rule);
  color: var(--muted); font: 14px/1.5 var(--sans); display: flex; justify-content: space-between; flex-wrap: wrap; gap: 8px; }
footer a { color: var(--muted); text-decoration: none; }
footer a:hover { color: var(--accent); }

/* Small note under a section heading (e.g., corresponding-author key) */
.note { font: 400 14px/1.4 var(--sans); color: var(--muted); margin: -12px 0 18px; }
.intro p.lead + p.lead { margin-top: -14px; }
.role:has(+ .advisors) { margin-bottom: 2px; }
.advisors { font: 400 16px/1.6 var(--sans); color: var(--text); margin: 0 0 24px; }
/* Research Directions: step label above each title, matching the Research page */
ul.interests li strong::before { content: none; }
ul.interests .step { display: block; font: 600 12.5px/1 var(--sans); letter-spacing: .1em; text-transform: uppercase;
  color: var(--accent); margin-bottom: 12px; }
/* title block under the name: quiet links, underline only on hover */
.advisors { color: var(--text-2, var(--text)); }
.role a, .advisors a { color: inherit; text-decoration: none; transition: color .2s; }
.role a:hover, .advisors a:hover { color: var(--accent); }
.advisors .sep { margin: 0 .55em; color: var(--muted); }
/* intro: name block across the top, photo beside the paragraph with matching top edge */
.intro { grid-template-areas: "head head" "body photo"; row-gap: 0; align-items: start; }
.intro-head { grid-area: head; }
.intro-body { grid-area: body; }
.intro > img { grid-area: photo; margin-top: 8px; }
@media (max-width: 760px) {
  .intro { grid-template-areas: "photo" "head" "body"; }
  .intro > img { margin-top: 0; margin-bottom: 20px; }
}
/* intro paragraph: justified so its right edge lines up like the photo beside it */
.intro p.lead { text-align: justify; hyphens: manual; -webkit-hyphens: manual; text-wrap: pretty; }
@media (max-width: 560px) { .intro p.lead { text-align: left; hyphens: manual; } }
/* keep hyphenated compounds (fiber-optic, physical-process, ...) on one line */
.nw { white-space: nowrap; }
