/* ==========================================================================
   Jiayi Hong — site styles
   Colors are defined once as variables; dark mode follows the OS setting.
   ========================================================================== */

:root {
  --bg: #ffffff;
  --bg-soft: #f6f7f9;
  --surface: #ffffff;
  --text: #1f2328;
  --text-soft: #57606a;
  --muted: #8b949e;
  --border: #e4e7eb;
  --accent: #1d4f91;          /* ULaval-ish deep blue */
  --accent-soft: #e8f0fb;
  --accent-text: #174178;
  --highlight: #b4232a;       /* ULaval red, used sparingly */
  --highlight-soft: #fdf0f0;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 1px 3px rgba(16, 24, 40, .06);
  --shadow-hover: 0 6px 20px rgba(16, 24, 40, .10);
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "PingFang SC", "Microsoft YaHei", sans-serif;
  --serif: "Source Serif 4", Georgia, "Times New Roman", "Songti SC", serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1216;
    --bg-soft: #161b22;
    --surface: #161b22;
    --text: #e6edf3;
    --text-soft: #b1bac4;
    --muted: #7d8590;
    --border: #2a313a;
    --accent: #7cacf8;
    --accent-soft: #1b2a40;
    --accent-text: #a5c8ff;
    --highlight: #ff7b72;
    --highlight-soft: #2d1a1c;
    --shadow: none;
    --shadow-hover: 0 6px 20px rgba(0, 0, 0, .4);
  }
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 80px; -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}
img { max-width: 100%; height: auto; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 2px; }
h1, h2, h3 { font-family: var(--serif); font-weight: 600; line-height: 1.25; color: var(--text); }
h1 { font-size: 2rem; margin: 0 0 1rem; letter-spacing: -.01em; }
h2 { font-size: 1.45rem; margin: 2.5rem 0 1rem; }
h3 { font-size: 1.15rem; margin: 1.75rem 0 .5rem; }
p { margin: 0 0 1rem; }
pre, code { font-family: var(--mono); font-size: .875em; }
pre { background: var(--bg-soft); border: 1px solid var(--border); border-radius: 8px; padding: .75rem 1rem; overflow-x: auto; }
.muted { color: var(--muted); font-size: .9rem; }
[hidden] { display: none !important; }

/* ---------- Top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 50;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(180%) blur(10px);
  -webkit-backdrop-filter: saturate(180%) blur(10px);
  border-bottom: 1px solid var(--border);
}
.topbar-inner {
  max-width: 1120px; margin: 0 auto; padding: 0 24px;
  height: 60px; display: flex; align-items: center; justify-content: space-between;
}
.brand { font-family: var(--serif); font-weight: 600; font-size: 1.2rem; color: var(--text); }
.brand:hover { text-decoration: none; color: var(--accent); }
.nav-links { list-style: none; display: flex; gap: 4px; margin: 0; padding: 0; }
.nav-links a {
  display: block; padding: 6px 12px; border-radius: 6px;
  color: var(--text-soft); font-weight: 500; font-size: .95rem;
}
.nav-links a:hover { background: var(--bg-soft); color: var(--text); text-decoration: none; }
.nav-links a.active { color: var(--accent); background: var(--accent-soft); }
.nav-links .ext { font-size: .65em; opacity: .6; margin-left: 2px; vertical-align: 1px; }
.nav-toggle { display: none; background: none; border: 0; color: var(--text); font-size: 1.25rem; padding: 8px; cursor: pointer; }

/* ---------- Layout ---------- */
.shell {
  max-width: 1120px; margin: 0 auto; padding: 40px 24px 24px;
  display: grid; grid-template-columns: 250px minmax(0, 1fr); gap: 56px;
}
.content { min-width: 0; }
.content > section:first-child > h1:first-child,
.content > h1:first-child, .content > .section-head:first-child { margin-top: 0; }

/* ---------- Sidebar ---------- */
.sidebar { position: sticky; top: 92px; align-self: start; font-size: .92rem; }
.avatar { width: 100%; max-width: 250px; aspect-ratio: 1; object-fit: cover; border-radius: 14px; display: block; box-shadow: var(--shadow); }
.sidebar-name { font-family: var(--serif); font-size: 1.3rem; font-weight: 600; margin-top: 18px; }
.native { font-weight: 500; color: var(--text-soft); }
.sidebar-role { color: var(--text-soft); margin-top: 4px; line-height: 1.5; }
.social { display: flex; gap: 6px; margin: 14px 0 18px; }
.social a {
  width: 36px; height: 36px; display: inline-grid; place-items: center;
  border-radius: 8px; border: 1px solid var(--border); color: var(--text-soft); font-size: 1.05rem;
  transition: all .15s ease;
}
.social a:hover { color: var(--accent); border-color: var(--accent); background: var(--accent-soft); text-decoration: none; }
.contact { margin: 0; }
.contact dt { font-size: .75rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 600; margin-top: 12px; }
.contact dt i { width: 14px; }
.contact dd { margin: 2px 0 0; color: var(--text-soft); word-break: break-word; }

/* ---------- Section headers ---------- */
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; border-bottom: 1px solid var(--border); padding-bottom: 8px; margin: 3rem 0 1.25rem; }
.section-head h1, .section-head h2 { margin: 0; }
.more { font-size: .9rem; font-weight: 500; white-space: nowrap; }
.more i { font-size: .75em; margin-left: 2px; }

/* ---------- Intro ---------- */
.intro h1 { font-size: 2rem; margin-bottom: 1rem; }
.prose { color: var(--text); }
.prose p { margin-bottom: 1rem; }
.prose ol, .prose ul { padding-left: 1.4rem; margin: 0 0 1rem; }
.interests { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 1.25rem 0; }
.interests-label { font-size: .8rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 600; margin-right: 4px; }
.pill { background: var(--accent-soft); color: var(--accent-text); padding: 3px 12px; border-radius: 999px; font-size: .88rem; font-weight: 500; }
.callout {
  display: flex; gap: 14px; align-items: flex-start;
  background: var(--highlight-soft); border-left: 3px solid var(--highlight);
  border-radius: 0 var(--radius) var(--radius) 0; padding: 14px 18px; margin: 1.5rem 0 0;
}
.callout > i { color: var(--highlight); margin-top: 5px; }
.callout p { margin: 0; }

/* ---------- News ---------- */
.news { list-style: none; margin: 0; padding: 0; }
.news-item { display: grid; grid-template-columns: 84px minmax(0, 1fr); gap: 16px; padding: 8px 0; border-bottom: 1px dashed var(--border); font-size: .94rem; line-height: 1.4; }
.news-item:last-child { border-bottom: 0; }
.news-item time { color: var(--muted); font-size: .70rem; font-weight: 600; font-variant-numeric: tabular-nums; padding-top: 2px; white-space: nowrap; }
.news-icon { color: var(--accent); }

/* Justified text: bio, news items, publication entries, projects, team page.
   Hyphenation keeps word spacing even; the last line stays left-aligned. */
.intro .prose, .news-text, .pub-title, .pub-authors, .pub-venue,
.project .prose, .project .lead, .project-meta p,
.page-team .content > p, .page-team .content li {
  text-align: justify;
  -webkit-hyphens: auto;
  hyphens: auto;
}

/* ---------- Publications ---------- */
.pub-list { display: flex; flex-direction: column; gap: 1px; }
.pub {
  display: grid; grid-template-columns: 180px minmax(0, 1fr); gap: 20px;
  padding: 10px; border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface); box-shadow: var(--shadow); transition: box-shadow .2s ease, border-color .2s ease;
}
.pub:hover { box-shadow: var(--shadow-hover); border-color: color-mix(in srgb, var(--accent) 30%, var(--border)); }
.pub-thumb img {
  width: 100%; aspect-ratio: 4 / 3; object-fit: contain; display: block;
  background: #fff; border-radius: 6px; border: 1px solid var(--border);
}
.pub-badges { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 6px; }
.badge { font-size: .72rem; font-weight: 600; padding: 2px 8px; border-radius: 5px; letter-spacing: .02em; }
.badge-venue { background: var(--accent); color: #fff; }
@media (prefers-color-scheme: dark) { .badge-venue { color: #0f1216; } }
.badge-type { background: var(--bg-soft); color: var(--text-soft); border: 1px solid var(--border); }
.badge-award { background: #fff4d6; color: #8a5a00; }
.pub-title { font-family: var(--font); font-size: .85rem; font-weight: 600; line-height: 1.4; margin: 0 0 4px; }
.pub-title a { color: var(--text); }
.pub-title a:hover { color: var(--accent); }
.pub-authors { font-size: .80rem; color: var(--text-soft); }
.pub-authors a { color: inherit; text-decoration: underline; text-decoration-color: var(--border); text-underline-offset: 2px; }
.pub-authors a:hover { color: var(--accent); text-decoration-color: currentColor; }
.me { font-weight: 600; color: var(--text); }
.pub-venue { font-size: .80rem; font-style: italic; color: var(--muted); margin-top: 2px; }
.pub-links { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.chip {
  display: inline-flex; align-items: center; gap: 5px;
  font: 500 .7rem/1 var(--font); color: var(--text-soft);
  padding: 5px 9px; border: 1px solid var(--border); border-radius: 6px; background: var(--surface);
  cursor: pointer; transition: all .15s ease;
}
.chip:hover { color: var(--accent); border-color: var(--accent); background: var(--accent-soft); text-decoration: none; }
.chip i { font-size: .95em; }
.doi-label { font-weight: 700; font-size: .7rem; color: var(--highlight); }
.bibtex { margin: 10px 0 0; font-size: .78rem; white-space: pre-wrap; }

.filters { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 8px; }
.filter {
  font: 500 .88rem var(--font); color: var(--text-soft); background: var(--surface);
  border: 1px solid var(--border); border-radius: 999px; padding: 5px 14px; cursor: pointer;
}
.filter:hover { border-color: var(--accent); color: var(--accent); }
.filter.active { background: var(--accent); border-color: var(--accent); color: #fff; }
@media (prefers-color-scheme: dark) { .filter.active { color: #0f1216; } }
.year-group .year {
  font-family: var(--font); font-size: 1rem; font-weight: 700; color: var(--muted);
  letter-spacing: .04em; margin: 2rem 0 .75rem; display: flex; align-items: center; gap: 12px;
}
.year-group .year::after { content: ""; flex: 1; height: 1px; background: var(--border); }

/* ---------- Projects ---------- */
.project-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 18px; margin-bottom: 1rem; }
.project-card {
  display: flex; flex-direction: column; border: 1px solid var(--border); border-radius: var(--radius);
  overflow: hidden; background: var(--surface); color: var(--text); box-shadow: var(--shadow);
  transition: transform .2s ease, box-shadow .2s ease;
}
.project-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-hover); text-decoration: none; }
.project-img { aspect-ratio: 16 / 10; background: #fff; border-bottom: 1px solid var(--border); display: grid; place-items: center; overflow: hidden; }
.project-img img { width: 100%; height: 100%; object-fit: cover; }
.project-meta { padding: 14px 16px 16px; }
.project-meta h3 { font-family: var(--font); font-size: 1.05rem; margin: 4px 0 6px; }
.project-meta p { font-size: .88rem; color: var(--text-soft); margin: 0; line-height: 1.5; }
.project-cat { font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: var(--highlight); }
.project { border-top: 1px solid var(--border); padding-top: 2.5rem; margin-top: 3rem; }
.project h2 { margin: .25rem 0 .75rem; }
.lead { font-size: 1.08rem; color: var(--text-soft); }
.project .sub { font-family: var(--font); font-size: .8rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin: 2rem 0 .75rem; }
.video { position: relative; aspect-ratio: 16 / 9; margin: 0 0 1.25rem; border-radius: var(--radius); overflow: hidden; background: #000; }
.video iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; margin: 1rem 0; }
.gallery img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 8px; border: 1px solid var(--border); display: block; transition: opacity .15s; }
.gallery a:hover img { opacity: .85; }
.back-top { display: inline-block; font-size: .85rem; margin-top: 1rem; }

/* ---------- Team ---------- */
.team-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; margin: 1rem 0 2rem; }
.member { display: flex; gap: 14px; align-items: flex-start; padding: 14px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); }
.member-photo { width: 56px; height: 56px; flex: none; border-radius: 50%; object-fit: cover; }
.initials { display: grid; place-items: center; background: var(--accent-soft); color: var(--accent-text); font-weight: 700; font-size: 1.05rem; }
.member-name { font-weight: 600; }
.member-role { color: var(--text-soft); font-size: .9rem; }
.member-note { color: var(--muted); font-size: .84rem; margin-top: 2px; }
.member-note a { color: inherit; text-decoration: underline; text-decoration-color: var(--border); }
.rounded-img { border-radius: var(--radius); margin-top: .5rem; }

/* ---------- Footer ---------- */
.footer { max-width: 1120px; margin: 3rem auto 0; padding: 24px; border-top: 1px solid var(--border); text-align: center; color: var(--muted); font-size: .8rem; }
.footer p { margin: 2px 0; }

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; gap: 32px; padding-top: 24px; }
  .sidebar { position: static; display: grid; grid-template-columns: 120px 1fr; gap: 20px; align-items: start; border-bottom: 1px solid var(--border); padding-bottom: 24px; }
  .sidebar-name { margin-top: 0; }
}
@media (max-width: 720px) {
  .topbar-inner { padding: 0 16px; }
  .nav-toggle { display: block; }
  .nav-links {
    display: none; position: absolute; top: 60px; left: 0; right: 0;
    flex-direction: column; background: var(--bg); border-bottom: 1px solid var(--border); padding: 8px 12px 12px;
  }
  .nav-links.open { display: flex; }
  .shell { padding: 20px 16px; }
  h1, .intro h1 { font-size: 1.7rem; }
  .sidebar { grid-template-columns: 96px 1fr; gap: 16px; }
  body:not(.is-home) .sidebar { display: none; }
  .pub { grid-template-columns: 1fr; gap: 12px; }
  .pub-thumb img { aspect-ratio: 16 / 9; max-height: 200px; }
  .news-item { grid-template-columns: 1fr; gap: 0; }
}
