/* ==========================================================================
   style.css — Yajuan Si academic website
   Design goals: professional, clear, accessible (WCAG AA), responsive,
   fast (no frameworks), with automatic light/dark support.
   Palette inspired by University of Michigan (Maize & Blue).
   ========================================================================== */

:root {
  /* Brand palette */
  --maize: #ffcb05;
  --blue: #00274c;      /* Michigan blue */
  --blue-600: #0b3a6f;
  --blue-500: #1a5aa0;
  --accent: #1a5aa0;    /* links */
  --accent-hover: #00274c;

  /* Neutrals (light) */
  --bg: #ffffff;
  --bg-soft: #f5f7fa;
  --bg-card: #ffffff;
  --border: #e2e8f0;
  --text: #1a202c;
  --text-soft: #45505f;
  --text-muted: #5b6675;   /* AA contrast on white (~5.5:1) */

  /* Layout */
  --maxw: 1400px;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(0,0,0,.08), 0 6px 20px rgba(0,0,0,.05);
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-serif: Georgia, "Times New Roman", serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1621;
    --bg-soft: #151f2e;
    --bg-card: #172233;
    --border: #263449;
    --text: #e8edf4;
    --text-soft: #b3c0d1;
    --text-muted: #8798ad;
    --accent: #7db3ec;
    --accent-hover: #a9cef5;
    --shadow: 0 1px 3px rgba(0,0,0,.4), 0 6px 20px rgba(0,0,0,.35);
  }
}

/* ----- Reset & base ----- */
*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }

/* Respect users who prefer reduced motion */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: 18px;         /* comfortable, accessible base size */
  line-height: 1.7;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4 { font-family: var(--font-serif); line-height: 1.25; color: var(--text); font-weight: 700; }
h1 { font-size: clamp(1.9rem, 4vw, 2.6rem); margin: 0 0 .3em; }
h2 { font-size: clamp(1.4rem, 3vw, 1.8rem); margin: 2.2rem 0 1rem; }
h3 { font-size: 1.2rem; margin: 1.5rem 0 .5rem; }
p { margin: 0 0 1rem; }
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); text-decoration: underline; }
img { max-width: 100%; height: auto; }
ul { padding-left: 1.2rem; }

/* Accessible focus ring */
a:focus-visible, button:focus-visible, input:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}

/* Skip link for keyboard/screen-reader users */
.skip-link {
  position: absolute; left: -999px; top: 0; z-index: 999;
  background: var(--blue); color: #fff; padding: .6rem 1rem; border-radius: 0 0 8px 0;
}
.skip-link:focus { left: 0; }

.container { max-width: var(--maxw); margin: 0 auto; padding: 0 1.25rem; }
.visually-hidden {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}

/* ----- Header / navigation ----- */
.site-header {
  position: sticky; top: 0; z-index: 100;
  background: var(--blue);
  border-bottom: 3px solid var(--maize);
}
.nav {
  display: flex; align-items: center; justify-content: space-between;
  max-width: var(--maxw); margin: 0 auto; padding: .6rem 1.25rem;
  gap: 1rem;
}
.nav-brand { font-family: var(--font-serif); font-weight: 700; font-size: 1.15rem; color: #fff; white-space: nowrap; }
.nav-brand:hover { color: var(--maize); text-decoration: none; }
.nav-links { display: flex; align-items: center; gap: .25rem; list-style: none; margin: 0; padding: 0; flex-wrap: wrap; }
.nav-links a {
  color: #e8edf4; padding: .45rem .7rem; border-radius: 8px; font-size: .95rem; display: block;
}
.nav-links a:hover, .nav-links a[aria-current="page"] {
  background: rgba(255,255,255,.12); color: #fff; text-decoration: none;
}
.nav-links a[aria-current="page"] { color: var(--maize); }
.nav-toggle {
  display: none; background: none; border: 1px solid rgba(255,255,255,.4);
  color: #fff; border-radius: 8px; padding: .4rem .6rem; cursor: pointer; font-size: 1.2rem;
}

@media (max-width: 760px) {
  .nav-toggle { display: block; }
  .nav-links {
    display: none; position: absolute; top: 100%; left: 0; right: 0;
    flex-direction: column; background: var(--blue); padding: .5rem 1rem 1rem; gap: .1rem;
    border-bottom: 3px solid var(--maize);
  }
  .nav-links.open { display: flex; }
  .nav-links a { padding: .6rem .5rem; }
}

/* ----- Hero (homepage) ----- */
.hero { background: var(--bg-soft); padding: 3rem 0 2.5rem; border-bottom: 1px solid var(--border); }
.hero-grid {
  display: grid; grid-template-columns: 220px 1fr; gap: 2.5rem; align-items: start;
}
.hero-photo {
  width: 220px; height: 220px; border-radius: 50%; object-fit: cover;
  /* Bias the crop toward the top of the source image so the head is not cut off.
     Increase the percentage (e.g. 30%) to show more of the head/less of the chin. */
  object-position: center 20%;
  border: 4px solid var(--maize); box-shadow: var(--shadow); background: var(--bg-card);
}
.hero h1 { margin-bottom: .15em; }
.hero .role { font-size: 1.15rem; color: var(--text-soft); margin: 0 0 .5rem; }
.hero .tagline { font-size: 1.05rem; color: var(--text-soft); }
@media (max-width: 680px) {
  .hero-grid { grid-template-columns: 1fr; gap: 1.5rem; justify-items: center; text-align: center; }
  .hero-photo { width: 160px; height: 160px; }
  .hero .tagline { text-align: left; }
}

/* ----- Buttons ----- */
.btn {
  display: inline-flex; align-items: center; gap: .4rem;
  background: var(--blue); color: #fff; padding: .6rem 1.1rem; border-radius: 999px;
  font-weight: 600; font-size: .95rem; border: 2px solid var(--blue); cursor: pointer;
}
.btn:hover { background: var(--blue-600); border-color: var(--blue-600); color: #fff; text-decoration: none; }
.btn.secondary { background: transparent; color: var(--accent); border-color: var(--accent); }
.btn.secondary:hover { background: var(--accent); color: #fff; }
.btn-row { display: flex; flex-wrap: wrap; gap: .7rem; margin-top: 1.2rem; }

/* ----- Social icons ----- */
.social { display: flex; gap: .6rem; margin-top: 1.1rem; flex-wrap: wrap; }
.social a {
  display: inline-flex; align-items: center; gap: .35rem;
  font-size: .9rem; color: var(--text-soft);
  border: 1px solid var(--border); border-radius: 999px; padding: .3rem .75rem; background: var(--bg-card);
}
.social a:hover { border-color: var(--accent); color: var(--accent); text-decoration: none; }

/* ----- Main layout ----- */
main { padding: 2.5rem 0 3rem; }
.section { margin-bottom: 2.5rem; }
.lead { font-size: 1.12rem; color: var(--text-soft); }

/* Consistent section headings in the main content column: a maize underline
   gives each chunk (About, Education, Experience, Awards…) a clear anchor. */
main .section > h2 {
  border-bottom: 2px solid var(--maize);
  padding-bottom: .35rem;
  margin-bottom: 1rem;
}
/* Keep anchored headings clear of the sticky header when linked to. */
:target { scroll-margin-top: 5rem; }

/* Two-column layout (content + sidebar) */
.layout { display: grid; grid-template-columns: 1fr 300px; gap: 2.5rem; align-items: start; }
@media (max-width: 900px) { .layout { grid-template-columns: 1fr; } }

/* ----- Cards ----- */
.card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1.3rem 1.4rem; box-shadow: var(--shadow);
}
.card h3 { margin-top: 0; }
.sidebar .card { margin-bottom: 1.25rem; }
.sidebar h3 { font-size: 1.05rem; color: var(--text); border-bottom: 2px solid var(--maize); padding-bottom: .3rem; }

.chip-list { list-style: none; padding: 0; margin: .5rem 0 0; display: flex; flex-wrap: wrap; gap: .4rem; }
.chip {
  background: var(--bg-soft); border: 1px solid var(--border); color: var(--text-soft);
  padding: .3rem .75rem; border-radius: 999px; font-size: .95rem;
}
/* Emphasize research-interest topics */
#interests-mount .chip { font-weight: 700; color: var(--text); }

/* Highlight/feature grid */
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 1.2rem; }

/* ----- Research theme cards (research page) ----- */
.theme-card { display: flex; flex-direction: column; padding: 0; overflow: hidden; }
/* The illustration sits in a tinted banner so the whole grid reads as a set. */
.theme-art {
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, var(--bg-soft), var(--bg-card));
  border-bottom: 1px solid var(--border);
  padding: 1.1rem 1rem;
}
.theme-art svg { width: 100%; max-width: 190px; height: auto; display: block; }
/* The MRP US-map carries more detail, so give it more room and less padding. */
.theme-art:has(.us-map) { padding: 0.7rem 0.5rem; }
.theme-art .us-map { max-width: 250px; }
/* SVG palette helpers — driven by CSS vars so the art follows light/dark mode.
   (CSS custom properties are not valid inside SVG presentation attributes, so
   the colors are applied via these classes rather than fill="var(--…)".) */
.theme-svg .fill-blue   { fill: var(--blue-500); }
.theme-svg .fill-maize  { fill: var(--maize); }
.theme-svg .stroke-blue { stroke: var(--blue-500); }
.theme-svg .stroke-maize{ stroke: var(--maize); }
.theme-svg .stroke-muted{ stroke: var(--text-muted); }
/* Choropleth region borders: hairline in the card color separates small areas. */
.theme-svg .map-regions { stroke: var(--bg-card); }
/* In dark mode the deep Michigan blue is too dark on the card; lift it. */
@media (prefers-color-scheme: dark) {
  .theme-svg .fill-blue   { fill: var(--accent); }
  .theme-svg .stroke-blue { stroke: var(--accent); }
}
.theme-body { padding: 1.1rem 1.4rem 1.3rem; }
.theme-body h3 { margin-top: 0; }
.theme-body p { margin-bottom: 0; color: var(--text-soft); font-size: .98rem; }
/* A subtle lift on hover ties the cards to the site's interactive feel. */
@media (hover: hover) {
  .theme-card { transition: transform .18s ease, box-shadow .18s ease; }
  .theme-card:hover { transform: translateY(-3px); box-shadow: 0 4px 10px rgba(0,0,0,.12), 0 12px 28px rgba(0,0,0,.10); }
}

/* ----- Lists: news, timeline ----- */
.news-list { list-style: none; padding: 0; margin: 0; }
.news-list li { display: flex; gap: 1rem; padding: .7rem 0; border-bottom: 1px solid var(--border); }
.news-list li:last-child { border-bottom: none; }
.news-date { flex: 0 0 3.2rem; font-weight: 700; color: var(--accent); font-variant-numeric: tabular-nums; }

.timeline { list-style: none; padding: 0; margin: 0; }
.timeline li { padding: .8rem 0; border-bottom: 1px solid var(--border); }
.timeline li:last-child { border-bottom: none; }
.timeline .role { font-weight: 700; }
.timeline .org { color: var(--text-soft); }
.timeline .years { color: var(--text-muted); font-size: .9rem; font-variant-numeric: tabular-nums; }

/* Awards list on the homepage — match the timeline's clean, borderless rows */
#awards-mount { list-style: none; padding: 0; margin: 0; }
#awards-mount li { padding: .8rem 0; border-bottom: 1px solid var(--border); }
#awards-mount li:last-child { border-bottom: none; }
#awards-mount strong { color: var(--accent); font-variant-numeric: tabular-nums; margin-right: .4rem; }

/* ----- Publications ----- */
.pub-controls { display: flex; flex-wrap: wrap; gap: .7rem; align-items: center; margin: 1rem 0 1.5rem; }
.pub-search {
  flex: 1 1 240px; padding: .55rem .9rem; font-size: 1rem;
  border: 1px solid var(--border); border-radius: 999px; background: var(--bg-card); color: var(--text);
}
.pub-filter {
  padding: .55rem .9rem; border: 1px solid var(--border); border-radius: 999px;
  background: var(--bg-card); color: var(--text); font-size: .95rem;
}
.pub-count { color: var(--text-muted); font-size: .9rem; }

.pub-list { list-style: none; padding: 0; margin: 0; counter-reset: pub; }
.pub-list li {
  padding: 1rem 0 1rem 0; border-bottom: 1px solid var(--border);
}
.pub-list li:last-child { border-bottom: none; }
.pub-title { font-weight: 600; color: var(--text); }
.pub-authors { color: var(--text-soft); font-size: .95rem; }
.pub-venue { color: var(--text-muted); font-style: italic; font-size: .95rem; }
.pub-year-tag {
  display: inline-block; font-size: .85rem; font-weight: 700; color: var(--blue);
  background: var(--maize); padding: .05rem .5rem; border-radius: 6px; margin-right: .5rem;
  vertical-align: middle;
}
@media (prefers-color-scheme: dark) { .pub-year-tag { color: #1a202c; } }
.pub-link { font-size: .85rem; margin-left: .4rem; }
.corr { color: var(--accent); font-weight: 700; } /* corresponding-author star */

.year-heading {
  font-family: var(--font-serif); font-size: 1.25rem; margin: 1.8rem 0 .4rem;
  color: var(--text); border-bottom: 2px solid var(--maize); padding-bottom: .25rem;
}

/* Table (grants, teaching) */
.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: .95rem; }
table.data th, table.data td { text-align: left; padding: .7rem .6rem; border-bottom: 1px solid var(--border); vertical-align: top; }
table.data th { color: var(--text-soft); font-size: .9rem; text-transform: uppercase; letter-spacing: .04em; }
table.data tr:hover td { background: var(--bg-soft); }
.tag {
  display: inline-block; font-size: .85rem; font-weight: 600; padding: .12rem .55rem;
  border-radius: 6px; background: var(--bg-soft); border: 1px solid var(--border); color: var(--text-soft);
}
.tag.pi { background: var(--blue); color: #fff; border-color: var(--blue); }

/* ----- Footer ----- */
.site-footer {
  background: var(--blue); color: #cbd5e0; padding: 2rem 0; margin-top: 2rem;
  border-top: 3px solid var(--maize); font-size: .92rem;
}
.site-footer a { color: #fff; }
.site-footer .foot-grid { display: flex; flex-wrap: wrap; gap: 1.5rem; justify-content: space-between; }
.site-footer h4 { color: var(--maize); font-family: var(--font-sans); font-size: .85rem; text-transform: uppercase; letter-spacing: .05em; margin: 0 0 .5rem; }
.site-footer .muted { color: #aebdd2; font-size: .9rem; margin-top: 1.2rem; }

/* Utilities */
.mt-0 { margin-top: 0; }
.center { text-align: center; }
.small { font-size: .95rem; color: var(--text-muted); }
