/* ==========================================================================
   Jiaru Li — personal site
   Clean academic light theme. No framework, no build step.
   ========================================================================== */

:root {
  --bg:          #ffffff;
  --surface:     #f7f8fa;
  --surface-2:   #eef1f5;
  --ink:         #14171c;
  --text:        #2f3640;
  --muted:       #697180;
  --rule:        #e2e6eb;
  --accent:      #1d4e89;
  --accent-ink:  #163c6b;
  --accent-soft: #e9f0f8;
  --focus:       #1d4e89;

  --serif: "Source Serif 4", Charter, "Iowan Old Style", Georgia, "Times New Roman", serif;
  --sans:  "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --mono:  ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;

  --container: 1060px;
  --prose: 70ch;
  --radius: 6px;
}

/* --- reset ---------------------------------------------------------------- */
*, *::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.65;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
img, video { max-width: 100%; height: auto; display: block; }
h1, h2, h3, h4 { color: var(--ink); font-family: var(--serif); font-weight: 600; line-height: 1.2; margin: 0 0 .5em; }
h1 { font-size: clamp(2rem, 1.4rem + 2.2vw, 2.85rem); letter-spacing: -.015em; }
h2 { font-size: clamp(1.4rem, 1.15rem + .9vw, 1.75rem); letter-spacing: -.01em; }
h3 { font-size: 1.16rem; }
h4 { font-size: 1rem; font-family: var(--sans); font-weight: 600; }
p  { margin: 0 0 1.1em; }
ul, ol { margin: 0 0 1.1em; padding-left: 1.25em; }
li { margin-bottom: .35em; }
a { color: var(--accent); text-decoration: none; text-underline-offset: 2px; }
a:hover { text-decoration: underline; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 2px; }
hr { border: 0; border-top: 1px solid var(--rule); margin: 2.5rem 0; }
code { font-family: var(--mono); font-size: .9em; background: var(--surface-2); padding: .1em .35em; border-radius: 3px; }

/* --- layout --------------------------------------------------------------- */
.container { width: 100%; max-width: var(--container); margin-inline: auto; padding-inline: 1.5rem; }
.prose { max-width: var(--prose); }
.section { padding: 3.25rem 0; }
.section + .section { border-top: 1px solid var(--rule); }
.skip-link {
  position: absolute; left: -9999px; top: 0; background: var(--accent); color: #fff;
  padding: .6rem 1rem; z-index: 100; border-radius: 0 0 var(--radius) 0;
}
.skip-link:focus { left: 0; }

/* --- header / nav --------------------------------------------------------- */
.site-header {
  position: sticky; top: 0; z-index: 50;
  background: rgba(255,255,255,.92);
  backdrop-filter: saturate(180%) blur(8px);
  border-bottom: 1px solid var(--rule);
}
.header-inner { display: flex; align-items: center; justify-content: space-between; gap: 1rem; min-height: 60px; }
.brand {
  font-family: var(--serif); font-size: 1.12rem; font-weight: 600;
  color: var(--ink); letter-spacing: -.01em; white-space: nowrap;
}
.brand:hover { text-decoration: none; color: var(--accent); }
.site-nav { display: flex; gap: 1.45rem; align-items: center; }
.site-nav a {
  color: var(--text); font-size: .935rem; font-weight: 500;
  padding: .35rem 0; border-bottom: 2px solid transparent; white-space: nowrap;
}
.site-nav a:hover { color: var(--accent); text-decoration: none; border-bottom-color: var(--surface-2); }
.site-nav a[aria-current="page"] { color: var(--accent-ink); border-bottom-color: var(--accent); }
.nav-toggle {
  display: none; background: none; border: 1px solid var(--rule); border-radius: var(--radius);
  color: var(--text); font: inherit; font-size: .9rem; padding: .35rem .7rem; cursor: pointer;
}

/* --- hero (home) ---------------------------------------------------------- */
.hero { padding: 3.5rem 0 2.75rem; }
.hero-grid { display: grid; grid-template-columns: 220px 1fr; gap: 2.75rem; align-items: start; }
.hero-photo {
  width: 100%; aspect-ratio: 3 / 4; object-fit: cover; object-position: center 18%;
  border-radius: var(--radius); box-shadow: 0 1px 3px rgba(20,23,28,.1), 0 8px 24px rgba(20,23,28,.07);
}
.hero h1 { margin-bottom: .15em; }
.hero .role { font-size: 1.06rem; color: var(--text); margin-bottom: .1em; }
.hero .affil { color: var(--muted); margin-bottom: 1.5rem; }
.hero .affil a { color: var(--muted); text-decoration: underline; text-decoration-color: var(--rule); }
.hero .affil a:hover { color: var(--accent); }

/* --- link row ------------------------------------------------------------- */
.linkrow { display: flex; flex-wrap: wrap; gap: .5rem; margin: 1.5rem 0 0; padding: 0; list-style: none; }
.linkrow li { margin: 0; }
.linkrow a {
  display: inline-block; font-size: .88rem; font-weight: 500;
  padding: .4rem .85rem; border: 1px solid var(--rule); border-radius: 999px;
  color: var(--text); background: var(--bg); transition: background .15s, border-color .15s, color .15s;
}
.linkrow a:hover { text-decoration: none; background: var(--accent-soft); border-color: #c8d9ec; color: var(--accent-ink); }

/* --- generic bits --------------------------------------------------------- */
.eyebrow {
  font-family: var(--sans); font-size: .76rem; font-weight: 600; letter-spacing: .09em;
  text-transform: uppercase; color: var(--muted); margin-bottom: .75rem;
}
.lede { font-size: 1.08rem; color: var(--text); }
.muted { color: var(--muted); }
.small { font-size: .9rem; }

.note {
  background: var(--surface); border: 1px solid var(--rule); border-left: 3px solid var(--accent);
  border-radius: 0 var(--radius) var(--radius) 0; padding: 1rem 1.25rem; margin: 1.5rem 0;
}
.note p:last-child { margin-bottom: 0; }

/* --- news ----------------------------------------------------------------- */
.news { list-style: none; padding: 0; margin: 0; }
.news li { display: grid; grid-template-columns: 6.5rem 1fr; gap: 1rem; padding: .7rem 0; border-top: 1px solid var(--rule); margin: 0; }
.news li:first-child { border-top: 0; }
.news time { color: var(--muted); font-size: .88rem; font-variant-numeric: tabular-nums; padding-top: .12em; }

/* --- research themes ------------------------------------------------------ */
.theme { padding: 2.75rem 0; border-top: 1px solid var(--rule); }
.section + .container .theme:first-of-type { margin-top: -1rem; }
.theme:first-of-type { border-top: 0; padding-top: 0; }
.theme > h2 { margin-bottom: .35em; }
.theme .prose { margin-bottom: 1.75rem; }
.theme-papers { font-size: .92rem; color: var(--muted); }
.theme-papers a { color: var(--accent); }

.figure-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(290px, 1fr)); gap: 1.75rem; }
figure.sim { margin: 0; }
figure.sim video {
  width: 100%; background: #0e1116; border: 1px solid var(--rule); border-radius: var(--radius);
}
figure.sim figcaption { font-size: .88rem; color: var(--muted); margin-top: .6rem; line-height: 1.5; }
figure.sim figcaption b { color: var(--text); font-weight: 600; }

/* research page: section tabs, stuck just under the site header; pills like .linkrow (Notes page) */
.theme-tabs {
  position: sticky; top: 61px; z-index: 40; margin: -3.4rem 0 2.5rem;   /* pulled up into the intro's bottom padding */
  background: rgba(255,255,255,.94); backdrop-filter: saturate(180%) blur(8px);
}
.theme-tabs .tabs-row {
  display: flex; gap: .5rem; padding-block: .6rem .75rem; overflow-x: auto; scrollbar-width: none;
  border-bottom: 1px solid var(--rule);   /* same rule as between sections, content width */
}
.theme-tabs .tabs-row::-webkit-scrollbar { display: none; }
@media (max-width: 680px) { .theme-tabs { margin-top: -2.6rem; } }   /* section padding shrinks to 2.5rem there */
.theme-tabs a {
  flex: none; display: inline-block; font-size: .88rem; font-weight: 500; white-space: nowrap;
  padding: .4rem .85rem; border: 1px solid var(--rule); border-radius: 999px;
  color: var(--text); background: var(--bg); transition: background .15s, border-color .15s, color .15s;
}
.theme-tabs a:hover,
.theme-tabs a[aria-current="true"] {
  text-decoration: none; background: var(--accent-soft); border-color: #c8d9ec; color: var(--accent-ink);
}
.theme { scroll-margin-top: 120px; }   /* header + tabs */

/* plain-language opener for each research theme */
.theme-intro { font-size: 1.06rem; color: var(--text); border-left: 3px solid var(--accent); padding-left: 1rem; margin-bottom: 1.4rem; }

/* static figures on the research page (click to magnify, via site.js) */
.fig-row { display: grid; grid-template-columns: minmax(0, 1fr); gap: 1.75rem; margin-bottom: 1.75rem; max-width: 980px; }
.fig-row.pair { grid-template-columns: minmax(0, 1fr) minmax(0, 2fr); align-items: start; }  /* square + 2:1, equal heights */
@media (max-width: 760px) { .fig-row.pair { grid-template-columns: minmax(0, 1fr); } }
.fig-row.col { max-width: var(--prose); }  /* single figure, as wide as the text column */
.fig-row.col figcaption { max-width: none; }
.figure-grid.col { max-width: var(--prose); margin-bottom: 1.75rem; }  /* movies held to the text column too */
/* GW Ori: observation (1.13:1) beside the animation (1.79:1), equal heights */
.fig-row.gw { grid-template-columns: minmax(0, 1.13fr) minmax(0, 1.79fr); align-items: start; }
@media (max-width: 680px) { .fig-row.gw { grid-template-columns: minmax(0, 1fr); } }
figure.fig video { display: block; width: 100%; background: #0e1116; border: 1px solid var(--rule); border-radius: var(--radius); }
figure.fig { margin: 0; }
figure.fig img {
  display: block; width: 100%; height: auto; background: #fff;
  border: 1px solid var(--rule); border-radius: var(--radius);
}
figure.fig figcaption { font-size: .88rem; color: var(--muted); margin-top: .6rem; line-height: 1.5; max-width: var(--prose); }
figure.fig figcaption b { color: var(--text); font-weight: 600; }

/* --- home: one display per research topic ------------------------------ */
.topic-grid {
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 2rem; margin-top: 2.25rem; align-items: start;
}
/* each card spans four shared rows (title, summary, display, caption) so the
   displays line up across columns even when the summaries differ in length */
.topic { margin: 0; display: grid; grid-template-rows: subgrid; grid-row: span 4; row-gap: 0; align-content: start; }
.topic img, .topic video {
  width: 100%; aspect-ratio: 1 / 1; display: block; object-fit: cover;
  background: #2b2b44; border: 1px solid var(--rule); border-radius: var(--radius);
}
.topic video { cursor: pointer; }
.topic h3 { margin: 0 0 .3em; }
.topic > .small { margin-bottom: 1rem; }
.topic p { margin-bottom: 0; }
.topic-src { font-size: .82rem; color: var(--muted); line-height: 1.5; margin-top: .6rem; }
.topic-src-label { color: var(--text); font-weight: 600; }

/* --- notes: places map + photo galleries -------------------------------- */
.places-map { margin-top: 1.5rem; }
.places-map svg { display: block; width: 100%; height: auto; }
.pm-sea { fill: var(--surface); stroke: var(--rule); stroke-width: 1; }
.pm-grid { fill: none; stroke: var(--rule); stroke-width: .6; }
.pm-land { fill: #dfe4ea; }
.pm-border { fill: none; stroke: #fff; stroke-width: .8; }
.pm-route { fill: none; stroke: var(--accent); stroke-width: 1.5; stroke-dasharray: 4 6; opacity: .55; }
.pm-place circle { fill: var(--accent); stroke: #fff; stroke-width: 2.5; }
.pm-place text { font: 600 13px var(--sans); fill: var(--ink); paint-order: stroke; stroke: #fff; stroke-width: 4px; stroke-linejoin: round; }
.pm-place:focus { outline: none; }
.pm-place:focus circle, .pm-place:hover circle { fill: var(--accent-ink); r: 7; }
.places-list { margin-top: 1.25rem; font-size: .95rem; }
.photo-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 1.25rem; margin-top: 1.5rem;
}
.photo { margin: 0; }
.photo img, .photo-ph {
  width: 100%; aspect-ratio: 4 / 3; object-fit: cover; display: block;
  border-radius: var(--radius);
}
.photo-ph {
  display: grid; place-items: center; background: var(--surface-2);
  border: 1px dashed #c9cfd8; color: var(--muted); font-size: .85rem;
}
.photo figcaption { font-size: .85rem; color: var(--muted); margin-top: .5rem; line-height: 1.45; }

.zoomable { cursor: zoom-in; transition: opacity .15s; }
.zoomable:hover { opacity: .9; }
.photo-zoom {
  position: fixed; inset: 0; z-index: 1000; cursor: zoom-out;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: .9rem; padding: 2rem; background: rgba(12, 14, 18, .88);
}
.photo-zoom[hidden] { display: none; }
.photo-zoom img, .photo-zoom .photo-ph {
  max-width: min(92vw, 1400px); max-height: 82vh; width: auto; height: auto;
  border-radius: var(--radius); box-shadow: 0 10px 40px rgba(0, 0, 0, .45);
}
.photo-zoom .photo-ph { width: min(80vw, 1000px); aspect-ratio: 4 / 3; font-size: 1.1rem; }
.photo-zoom p { color: #e8eaee; font-size: .95rem; max-width: 70ch; text-align: center; margin: 0; }
html.zoom-open { overflow: hidden; }

/* --- publications --------------------------------------------------------- */
.filters { display: flex; flex-wrap: wrap; gap: .5rem; margin-bottom: 2rem; }
.filters button {
  font: inherit; font-size: .88rem; font-weight: 500; cursor: pointer;
  padding: .38rem .85rem; border: 1px solid var(--rule); border-radius: 999px;
  background: var(--bg); color: var(--text); transition: background .15s, border-color .15s, color .15s;
}
.filters button:hover { background: var(--surface); }
.filters button[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: #fff; }

.year-group { margin-bottom: 2.5rem; }
.year-group > h2 {
  font-family: var(--sans); font-size: .78rem; font-weight: 700; letter-spacing: .1em;
  text-transform: uppercase; color: var(--muted);
  padding-bottom: .5rem; border-bottom: 1px solid var(--rule); margin-bottom: 1.25rem;
}
.pub { padding: 1.15rem 0; border-bottom: 1px solid var(--rule); }
.pub:last-child { border-bottom: 0; }
.pub h3 { font-size: 1.08rem; line-height: 1.35; margin-bottom: .3em; }
.pub .authors { font-size: .94rem; margin-bottom: .2em; }
.pub .authors .me { font-weight: 600; color: var(--ink); border-bottom: 1.5px solid var(--accent); }
.pub .venue { font-size: .9rem; color: var(--muted); margin-bottom: .55em; }
.pub .venue em { font-style: italic; }
.pub-links { display: flex; flex-wrap: wrap; gap: .4rem; align-items: center; }
.pub-links a, .pub details > summary {
  font-size: .82rem; font-weight: 500; padding: .22rem .6rem;
  border: 1px solid var(--rule); border-radius: var(--radius);
  color: var(--text); background: var(--bg);
}
.pub-links a:hover { text-decoration: none; background: var(--accent-soft); border-color: #c8d9ec; color: var(--accent-ink); }
.pub details { margin-top: .55rem; }
.pub details > summary {
  display: inline-block; cursor: pointer; list-style: none; color: var(--accent); user-select: none;
}
.pub details > summary::-webkit-details-marker { display: none; }
.pub details > summary:hover { background: var(--accent-soft); border-color: #c8d9ec; }
.pub details[open] > summary { margin-bottom: .75rem; }
.pub details .abstract {
  font-size: .94rem; color: var(--text); background: var(--surface);
  border-radius: var(--radius); padding: 1rem 1.15rem; max-width: var(--prose);
}
.pub details .abstract p:last-child { margin-bottom: 0; }
.status {
  display: inline-block; font-size: .72rem; font-weight: 600; letter-spacing: .04em;
  text-transform: uppercase; color: var(--accent-ink); background: var(--accent-soft);
  padding: .12rem .45rem; border-radius: 3px; vertical-align: 2px; margin-left: .4rem;
}

/* --- talks ---------------------------------------------------------------- */
.talk { padding: 1.5rem 0; border-bottom: 1px solid var(--rule); }
.talk:last-child { border-bottom: 0; }
.talk h3 { margin-bottom: .6em; max-width: var(--prose); }
.talk-venues { list-style: none; padding: 0; margin: 0; }
.talk-venues li {
  display: grid; grid-template-columns: 1.9rem 1fr; gap: .5rem;
  font-size: .94rem; padding: .3rem 0; margin: 0;
}
.talk-venues .n { color: var(--muted); font-size: .82rem; font-weight: 600; padding-top: .18em; }
.talk-venues .where { color: var(--text); }
.talk-venues .place { color: var(--muted); font-size: .89rem; }

/* --- CV ------------------------------------------------------------------- */
.cv-entry { display: grid; grid-template-columns: 9.5rem 1fr; gap: 1.5rem; padding: 1rem 0; border-top: 1px solid var(--rule); }
.cv-entry:first-of-type { border-top: 0; }
.cv-entry .when { color: var(--muted); font-size: .9rem; font-variant-numeric: tabular-nums; padding-top: .15em; }
.cv-entry h3 { font-family: var(--sans); font-size: 1rem; font-weight: 600; margin-bottom: .15em; }
.cv-entry .org { color: var(--text); font-size: .95rem; margin-bottom: .25em; }
.cv-entry .detail { color: var(--muted); font-size: .9rem; margin: 0; }
.cv-entry .detail + .detail { margin-top: .1em; }

/* --- footer --------------------------------------------------------------- */
.site-footer { border-top: 1px solid var(--rule); margin-top: 3.5rem; padding: 2.25rem 0 3rem; background: var(--surface); }
.footer-inner { display: flex; flex-wrap: wrap; gap: 1rem 2rem; justify-content: space-between; align-items: baseline; }
.site-footer p { font-size: .88rem; color: var(--muted); margin: 0; }
.site-footer a { color: var(--muted); text-decoration: underline; text-decoration-color: var(--rule); }
.site-footer a:hover { color: var(--accent); }
.footer-links { display: flex; flex-wrap: wrap; gap: 1.1rem; font-size: .88rem; }

/* --- responsive ----------------------------------------------------------- */
@media (max-width: 860px) {
  .hero-grid { grid-template-columns: 160px 1fr; gap: 1.75rem; }
  .topic-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1.75rem; }
}
@media (max-width: 680px) {
  body { font-size: 16px; }
  .nav-toggle { display: block; }
  .site-nav {
    display: none; position: absolute; left: 0; right: 0; top: 100%;
    flex-direction: column; align-items: stretch; gap: 0;
    background: var(--bg); border-bottom: 1px solid var(--rule);
    padding: .5rem 1.5rem 1rem; box-shadow: 0 10px 24px rgba(20,23,28,.08);
  }
  .site-nav.open { display: flex; }
  .site-nav a { padding: .6rem 0; border-bottom: 1px solid var(--rule); }
  .site-nav a[aria-current="page"] { border-bottom-color: var(--accent); }
  .header-inner { position: relative; }
  .hero { padding: 2.25rem 0 1.75rem; }
  .hero-grid { grid-template-columns: 1fr; gap: 1.5rem; }
  .hero-photo { width: 150px; }
  .topic-grid { grid-template-columns: 1fr; gap: 2.25rem; }
  .topic img, .topic video { max-width: 320px; }
  .pm-place text { font-size: 22px; stroke-width: 5px; }
  .pm-place circle { r: 7; }
  .news li { grid-template-columns: 1fr; gap: .15rem; padding: .85rem 0; }
  .cv-entry { grid-template-columns: 1fr; gap: .25rem; }
  .section { padding: 2.5rem 0; }
}

/* --- print ---------------------------------------------------------------- */
@media print {
  .site-header, .site-footer, .filters, .linkrow, .nav-toggle, video { display: none !important; }
  body { font-size: 11pt; }
  .pub details[open] .abstract { background: none; padding: 0; }
  a { color: inherit; text-decoration: none; }
}

/* Readers who ask for reduced motion get a still frame (JS pauses the video). */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
}
