/* ============================================================
   Ma Liang — Academic Homepage
   Design system: editorial serif display + clean sans body,
   muted blue-purple palette on warm off-white.
   ============================================================ */

:root {
  --bg: #f4f5f2;
  --ink: #292456;
  --ink-soft: rgba(41, 36, 86, .68);
  --ink-faint: rgba(41, 36, 86, .46);
  --accent: #1818c4;
  --accent-soft: rgba(24, 24, 196, .08);
  --tint: #e9ecf7;
  --line: rgba(41, 36, 86, .14);
  --card: #fbfbf8;
  --serif: "Source Serif 4", "Noto Serif SC", "Songti SC", "SimSun", serif;
  --sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  --sidebar-w: 264px;
  --ease: cubic-bezier(.22, .68, .31, 1);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.72;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

::selection { background: rgba(24, 24, 196, .22); }

/* Custom scrollbar */
::-webkit-scrollbar { width: 9px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: #7d93ed; border-radius: 6px; border: 2px solid var(--bg); }

a { color: var(--accent); text-decoration-color: rgba(24, 24, 196, .38); text-underline-offset: 3px; transition: color .25s var(--ease), text-decoration-color .25s var(--ease); }
a:hover { color: var(--ink); text-decoration-color: var(--ink); }

/* ---------------- Sidebar ---------------- */

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: var(--sidebar-w);
  padding: 44px 32px 32px;
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--line);
  background: var(--bg);
  z-index: 60;
}

.monogram {
  font-family: var(--serif);
  font-size: 46px;
  font-weight: 600;
  line-height: 1;
  letter-spacing: -.01em;
  color: var(--ink);
  text-decoration: none;
}
.monogram span { color: var(--accent); }

.side-name { margin-top: 22px; }
.side-name .zh { font-family: var(--serif); font-size: 22px; font-weight: 600; display: block; }
.side-name .en { font-size: 12px; letter-spacing: .22em; text-transform: uppercase; color: var(--ink-faint); display: block; margin-top: 4px; }

.side-role { margin-top: 14px; font-size: 12.5px; line-height: 1.7; color: var(--ink-soft); }

.side-nav { margin-top: 36px; list-style: none; }
.side-nav li { border-top: 1px solid var(--line); }
.side-nav li:last-child { border-bottom: 1px solid var(--line); }
.side-nav a {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding: 11px 2px;
  color: var(--ink);
  text-decoration: none;
  font-size: 13.5px;
  transition: padding-left .3s var(--ease), color .25s var(--ease);
}
.side-nav a .tick { color: var(--accent); opacity: 0; transition: opacity .25s var(--ease); font-size: 12px; }
.side-nav a:hover { padding-left: 8px; color: var(--accent); }
.side-nav li.active a { color: var(--accent); font-weight: 600; }
.side-nav li.active a .tick { opacity: 1; }
.side-nav a small { display: block; font-size: 10.5px; letter-spacing: .14em; text-transform: uppercase; color: var(--ink-faint); margin-top: 1px; }

.side-links { margin-top: auto; padding-top: 26px; display: flex; gap: 14px; }
.side-links a {
  width: 36px; height: 36px;
  display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--line); border-radius: 50%;
  color: var(--ink-soft); text-decoration: none;
  transition: all .3s var(--ease);
}
.side-links a:hover { background: var(--accent); border-color: var(--accent); color: #fff; transform: translateY(-2px); }
.side-links svg { width: 16px; height: 16px; fill: currentColor; }

.side-copy { margin-top: 18px; font-size: 10.5px; color: var(--ink-faint); letter-spacing: .04em; }

/* Mobile top bar */
.topbar {
  display: none;
  position: fixed;
  inset: 0 0 auto 0;
  z-index: 70;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
  padding: 14px 20px;
  align-items: center;
  justify-content: space-between;
}
.topbar .tb-name { font-family: var(--serif); font-weight: 600; font-size: 18px; }
.topbar .tb-name span { color: var(--accent); }
.burger {
  width: 40px; height: 40px;
  border: 1px solid var(--line); border-radius: 50%;
  background: transparent; cursor: pointer;
  display: inline-flex; flex-direction: column; align-items: center; justify-content: center; gap: 5px;
}
.burger i { display: block; width: 16px; height: 1.6px; background: var(--ink); transition: transform .3s var(--ease), opacity .3s; }
body.nav-open .burger i:nth-child(1) { transform: translateY(6.6px) rotate(45deg); }
body.nav-open .burger i:nth-child(2) { opacity: 0; }
body.nav-open .burger i:nth-child(3) { transform: translateY(-6.6px) rotate(-45deg); }

.nav-scrim { display: none; }

/* ---------------- Main ---------------- */

.main { margin-left: var(--sidebar-w); min-height: 100vh; }
.wrap { max-width: 880px; padding: 64px 56px 120px; }

.page-head { margin-bottom: 52px; }
.kicker {
  font-size: 11px; letter-spacing: .24em; text-transform: uppercase;
  color: var(--accent); font-weight: 600;
  display: flex; align-items: center; gap: 12px;
}
.kicker::after { content: ""; height: 1px; flex: 0 0 56px; background: var(--accent); opacity: .5; }
.page-title {
  font-family: var(--serif);
  font-size: clamp(34px, 4.4vw, 52px);
  font-weight: 600;
  line-height: 1.14;
  letter-spacing: -.015em;
  margin-top: 14px;
}
.page-title .zh-sub { font-size: .5em; font-weight: 500; color: var(--ink-soft); margin-left: 12px; letter-spacing: .02em; }
.page-lede { margin-top: 18px; max-width: 62ch; color: var(--ink-soft); font-size: 15.5px; }

/* Sections */
section.block { margin-top: 58px; }
.sec-label {
  font-size: 11px; letter-spacing: .22em; text-transform: uppercase;
  color: var(--accent); font-weight: 600; margin-bottom: 6px;
}
.sec-title {
  font-family: var(--serif);
  font-size: 24px; font-weight: 600; letter-spacing: -.01em;
  padding-bottom: 14px; margin-bottom: 26px;
  border-bottom: 1px solid var(--line);
}
.sec-title .zh-sub { font-size: .72em; color: var(--ink-soft); font-weight: 500; margin-left: 10px; }
.sub-title {
  font-size: 12px; letter-spacing: .16em; text-transform: uppercase;
  color: var(--ink-faint); font-weight: 600;
  margin: 30px 0 14px;
}

/* Bracket metadata */
.bk { color: var(--ink); font-weight: 500; }
.bk b { color: var(--accent); font-weight: 600; }

/* ---------------- Hero (index) ---------------- */

.hero { position: relative; padding: 28px 0 10px; }
.hero-name {
  font-family: var(--serif);
  font-size: clamp(56px, 8vw, 96px);
  font-weight: 600;
  line-height: 1.02;
  letter-spacing: -.02em;
}
.hero-name .en { display: block; font-size: .32em; letter-spacing: .3em; text-transform: uppercase; color: var(--ink-faint); font-weight: 500; margin-top: 14px; }
.hero-title-line { margin-top: 26px; font-size: 16.5px; color: var(--ink); max-width: 60ch; }
.hero-title-line strong { color: var(--accent); font-weight: 600; }

.hero-stats { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 30px; }
.stat-chip {
  font-size: 12.5px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 7px 16px;
  background: var(--card);
  color: var(--ink-soft);
}
.stat-chip b { color: var(--accent); font-family: var(--serif); font-size: 15px; margin-right: 4px; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
.chip {
  font-size: 12.5px;
  background: var(--tint);
  color: var(--ink);
  border-radius: 999px;
  padding: 6px 14px;
  transition: background .25s var(--ease), color .25s var(--ease);
  cursor: default;
}
.chip:hover { background: var(--accent); color: #fff; }

/* Bio */
.bio p { margin-bottom: 16px; max-width: 68ch; color: var(--ink); }
.bio p .en { display: block; color: var(--ink-soft); font-size: 13.5px; margin-top: 4px; }

/* Timeline */
.tl { list-style: none; }
.tl li {
  display: grid;
  grid-template-columns: 148px 1fr;
  gap: 20px;
  padding: 16px 0;
  border-bottom: 1px solid var(--line);
}
.tl .when { font-size: 12px; color: var(--accent); font-weight: 600; letter-spacing: .06em; padding-top: 3px; white-space: nowrap; }
.tl .what .t { font-weight: 600; font-size: 14.5px; }
.tl .what .d { color: var(--ink-soft); font-size: 13px; margin-top: 2px; }
.tl .what .en { color: var(--ink-faint); font-size: 12.5px; }

/* Plain list rows */
.rows { list-style: none; }
.rows li {
  padding: 12px 0 12px 20px;
  border-bottom: 1px solid var(--line);
  position: relative;
  font-size: 14px;
}
.rows li::before {
  content: "—";
  position: absolute; left: 0; top: 12px;
  color: var(--accent);
}
.rows li .en { display: block; color: var(--ink-faint); font-size: 12.5px; }
.rows li ul { list-style: none; margin-top: 6px; }
.rows li ul li { border: 0; padding: 4px 0 4px 20px; font-size: 13px; color: var(--ink-soft); }

/* Year group heading inside rows */
.yr {
  font-family: var(--serif);
  font-size: 30px; font-weight: 600;
  color: var(--ink);
  margin: 34px 0 6px;
  display: flex; align-items: baseline; gap: 14px;
}
.yr::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.yr small { font-family: var(--sans); font-size: 11px; letter-spacing: .18em; color: var(--ink-faint); text-transform: uppercase; }

/* ---------------- Publications ---------------- */

.filterbar {
  position: sticky;
  top: 0;
  z-index: 40;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
  padding: 14px 0;
  margin: -8px 0 30px;
  display: flex; flex-wrap: wrap; gap: 10px; align-items: center;
}
.pill {
  border: 1px solid var(--line);
  background: transparent;
  color: var(--ink-soft);
  border-radius: 999px;
  padding: 7px 16px;
  font-size: 12.5px;
  font-family: var(--sans);
  cursor: pointer;
  transition: all .3s var(--ease);
}
.pill:hover { border-color: var(--accent); color: var(--accent); }
.pill.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.search {
  margin-left: auto;
  border: 1px solid var(--line);
  background: var(--card);
  border-radius: 999px;
  padding: 8px 18px;
  font-size: 13px;
  font-family: var(--sans);
  color: var(--ink);
  width: 220px;
  outline: none;
  transition: border-color .25s var(--ease), width .3s var(--ease);
}
.search:focus { border-color: var(--accent); width: 260px; }
.search::placeholder { color: var(--ink-faint); }

.pubs { list-style: none; counter-reset: pub; }
.pub {
  display: grid;
  grid-template-columns: 86px 1fr;
  gap: 18px;
  padding: 17px 0;
  border-bottom: 1px solid var(--line);
}
.pub .meta {
  font-size: 11.5px;
  line-height: 1.6;
  color: var(--ink-faint);
  padding-top: 4px;
  word-break: break-word;
}
.pub .meta .venue { display: block; color: var(--accent); font-weight: 600; }
.pub .body .authors { font-size: 12.5px; color: var(--ink-faint); margin-top: 4px; }
.pub .body .title {
  font-family: var(--serif);
  font-size: 16.5px;
  font-weight: 600;
  line-height: 1.45;
  transition: color .25s var(--ease);
}
.pub:hover .body .title { color: var(--accent); }
.pub .body .title a { color: inherit; text-decoration: none; }
.pub .body .title a:hover { color: var(--accent); }
.pub .body .ext { font-size: 11px; color: var(--ink-faint); margin-left: 6px; letter-spacing: .06em; }
.pub .body .note { font-size: 12px; color: var(--ink-soft); margin-top: 3px; }
mark.hl { background: var(--tint); color: var(--accent); padding: 0 1px; }

.hidden-by-filter { display: none !important; }
.no-result { padding: 40px 0; color: var(--ink-faint); font-size: 14px; display: none; }

/* ---------------- Projects ---------------- */

.proj-group { margin-top: 34px; }
.proj-group h4 {
  font-family: var(--serif);
  font-size: 18px; font-weight: 600;
  margin-bottom: 4px;
}
.proj-group .g-sub { font-size: 12px; color: var(--ink-faint); margin-bottom: 14px; }
.proj { list-style: none; }
.proj li {
  padding: 14px 0;
  border-bottom: 1px solid var(--line);
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 16px;
  align-items: baseline;
}
.proj li .p-t { font-size: 14.5px; font-weight: 600; }
.proj li .p-en { font-size: 12.5px; color: var(--ink-soft); margin-top: 2px; }
.proj li .p-when { font-size: 11.5px; color: var(--accent); font-weight: 600; white-space: nowrap; letter-spacing: .04em; }
.proj li .p-grant { font-size: 11px; color: var(--ink-faint); }
.tag-role {
  display: inline-block; font-size: 10.5px; letter-spacing: .1em;
  border: 1px solid var(--accent); color: var(--accent);
  border-radius: 4px; padding: 1px 7px; margin-right: 8px;
  vertical-align: 1px; font-weight: 600;
}
.proj-cat { margin-top: 26px; font-size: 13px; font-weight: 600; color: var(--ink); }

/* ---------------- Courses ---------------- */

.course-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 44px; }
.course { padding: 18px 0; border-bottom: 1px solid var(--line); }
.course .c-zh { font-family: var(--serif); font-size: 17px; font-weight: 600; }
.course .c-en { font-size: 12.5px; color: var(--ink-soft); }
.course .c-terms { font-size: 11.5px; color: var(--ink-faint); margin-top: 6px; line-height: 1.7; }
.course .c-level { font-size: 10.5px; letter-spacing: .12em; text-transform: uppercase; color: var(--accent); font-weight: 600; display: block; margin-bottom: 4px; }

/* ---------------- Students ---------------- */

.alumni { display: grid; grid-template-columns: 1fr 1fr; gap: 0 44px; list-style: none; }
.alumni li { padding: 12px 0; border-bottom: 1px solid var(--line); font-size: 13.5px; }
.alumni li b { font-family: var(--serif); font-size: 15px; }
.alumni li span { display: block; color: var(--ink-soft); font-size: 12.5px; }
.current-list { list-style: none; display: grid; grid-template-columns: 1fr 1fr; gap: 0 44px; }
.current-list li {
  padding: 11px 0; border-bottom: 1px solid var(--line);
  display: flex; justify-content: space-between; align-items: baseline; gap: 12px;
  font-size: 13.5px;
}
.current-list li b { font-family: var(--serif); font-size: 15px; font-weight: 600; }
.current-list li em { font-style: normal; color: var(--ink-faint); font-size: 11.5px; white-space: nowrap; }
.thesis { list-style: none; }
.thesis li { padding: 13px 0; border-bottom: 1px solid var(--line); font-size: 13.5px; }
.thesis li b { font-family: var(--serif); font-size: 14.5px; font-weight: 600; }
.thesis li .tt { display: block; margin-top: 2px; }
.thesis li .zh { display: block; color: var(--ink-soft); font-size: 12.5px; }
.thesis li .yr-tag { color: var(--accent); font-size: 11.5px; font-weight: 600; margin-right: 8px; }

/* ---------------- Contact ---------------- */

.contact-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 44px; }
.c-item { padding: 20px 0; border-bottom: 1px solid var(--line); }
.c-item .c-k { font-size: 11px; letter-spacing: .18em; text-transform: uppercase; color: var(--accent); font-weight: 600; }
.c-item .c-v { margin-top: 6px; font-size: 15px; }
.c-item .c-v small { display: block; color: var(--ink-soft); font-size: 12.5px; }

/* ---------------- Footer ---------------- */

.foot {
  margin-top: 90px;
  padding-top: 22px;
  border-top: 1px solid var(--line);
  font-size: 11.5px;
  color: var(--ink-faint);
  display: flex; justify-content: space-between; flex-wrap: wrap; gap: 10px;
}
.foot a { color: var(--ink-soft); }

/* ---------------- Motion ---------------- */

.rise { opacity: 0; transform: translateY(22px); transition: opacity .9s var(--ease), transform .9s var(--ease); }
.rise.in { opacity: 1; transform: none; }

@media (prefers-reduced-motion: reduce) {
  .rise { opacity: 1; transform: none; transition: none; }
  html { scroll-behavior: auto; }
}

/* ---------------- Responsive ---------------- */

@media (max-width: 1020px) {
  .wrap { padding: 56px 40px 100px; }
}

@media (max-width: 860px) {
  .topbar { display: flex; }
  .sidebar {
    transform: translateX(-100%);
    transition: transform .45s var(--ease);
    width: min(320px, 84vw);
    box-shadow: 0 0 60px rgba(41,36,86,.18);
    padding-top: 88px;
  }
  body.nav-open .sidebar { transform: none; }
  .nav-scrim {
    display: block; position: fixed; inset: 0; z-index: 55;
    background: rgba(41,36,86,.32); opacity: 0; pointer-events: none;
    transition: opacity .4s var(--ease);
  }
  body.nav-open .nav-scrim { opacity: 1; pointer-events: auto; }
  .main { margin-left: 0; padding-top: 68px; }
  .wrap { padding: 40px 24px 90px; }
  .pub { grid-template-columns: 1fr; gap: 4px; }
  .pub .meta { display: flex; gap: 10px; padding-top: 0; }
  .tl li { grid-template-columns: 1fr; gap: 2px; }
  .course-grid, .alumni, .current-list, .contact-grid { grid-template-columns: 1fr; }
  .search { width: 100%; margin-left: 0; }
  .search:focus { width: 100%; }
}
