/* ============================================================
   Yiming Gan — personal site
   Layout inspired by jemdoc / baichen318.github.io:
   quiet serif typography, fixed left menu, one section at a time.
   ============================================================ */

:root {
  --ink: #232323;
  --ink-soft: #3c3c3c;
  --muted: #6d7681;
  --faint: #78808a;
  --accent: #527bbd;
  --accent-deep: #2b4d7d;
  --link: #224b8d;
  --rule: #d5d5d2;
  --rule-soft: #ececea;
  --side-bg: #f7f7f4;
  --side-line: #e3e3df;
  --sidebar-w: 254px;
  --content-max: 810px;
  --serif: Georgia, "Iowan Old Style", "Palatino Linotype", "Songti SC",
           "Noto Serif CJK SC", "Source Han Serif SC", "Times New Roman", serif;
}

* { box-sizing: border-box; }

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: #fff;
  color: var(--ink);
  font-family: var(--serif);
  font-size: 1.05rem;
  line-height: 1.66;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

::selection { background: #dde7f5; }

img { max-width: 100%; height: auto; }

a {
  color: var(--link);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
  text-underline-offset: 2px;
}

a:focus-visible,
.tab:focus-visible {
  outline: 2px solid #7ba0d4;
  outline-offset: 3px;
  border-radius: 2px;
}

.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  z-index: 100;
  background: #fff;
  color: var(--link);
  padding: .6rem 1rem;
  border: 1px solid var(--rule);
}
.skip-link:focus { left: .75rem; top: .75rem; }

/* ---------------- layout ---------------- */

.layout {
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  align-self: start;
  height: 100vh;
  height: 100dvh;
  padding: 2.5rem 1.15rem 1.6rem;
  background: var(--side-bg);
  border-right: 1px solid var(--side-line);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}

.brand {
  padding-left: .95rem;
  margin-bottom: 1.65rem;
  line-height: 1.3;
}

.brand-name {
  display: block;
  font-size: 1.06rem;
  font-weight: 700;
  letter-spacing: .01em;
  color: #182634;
}

.brand-cn {
  display: block;
  margin-top: .28rem;
  font-size: .78rem;
  letter-spacing: .32em;
  color: #7c8590;
}

.tabs {
  display: flex;
  flex-direction: column;
}

.tab {
  display: block;
  margin-left: -.15rem;
  padding: .34rem .55rem .34rem .8rem;
  border-left: 2px solid transparent;
  color: var(--accent);
  font-size: .97rem;
  line-height: 1.45;
}

.tab:hover {
  color: var(--accent-deep);
  background: rgba(82, 123, 189, .06);
  text-decoration: none;
}

.tab[aria-selected="true"] {
  color: #17335c;
  font-weight: 600;
  border-left-color: var(--accent);
  background: linear-gradient(90deg, rgba(82, 123, 189, .12), rgba(82, 123, 189, 0) 88%);
}

.side-note {
  margin-top: 1.9rem;
  padding-top: 1.1rem;
  border-top: 1px solid var(--side-line);
}

.side-note-title {
  margin: 0 0 .35rem;
  font-size: .66rem;
  font-weight: 700;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: #8a919b;
}

.side-note p:last-child {
  margin: 0;
  font-size: .76rem;
  line-height: 1.75;
  color: #5f6772;
}

.sidebar-foot {
  margin-top: auto;
  padding-top: 1.4rem;
  border-top: 1px solid var(--side-line);
  color: #7b838c;
  font-size: .7rem;
  letter-spacing: .015em;
  line-height: 1.55;
}

.sidebar-foot p { margin: 0; }

.chip-icon {
  display: block;
  width: 22px;
  height: 22px;
  margin-bottom: .55rem;
  fill: none;
  stroke: #9aa3ad;
  stroke-width: 1.3;
  stroke-linecap: round;
}

/* ---------------- content ---------------- */

.content {
  padding: 2.7rem clamp(1.5rem, 4.5vw, 3.6rem) 2.4rem;
}

.content-inner {
  max-width: var(--content-max);
  margin: 0 auto;
}

.section {
  scroll-margin-top: 40px;
}

.section:focus { outline: none; }

.section[hidden] { display: none; }

.section.is-active { animation: section-in .22s ease-out both; }

@keyframes section-in {
  from { opacity: 0; transform: translateY(3px); }
  to   { opacity: 1; transform: none; }
}

/* ---------------- hero ---------------- */

.hero {
  display: grid;
  grid-template-columns: 232px minmax(0, 1fr);
  gap: 2.3rem;
  align-items: start;
  margin-bottom: .4rem;
}

.portrait img {
  display: block;
  width: 100%;
  border: 1px solid #e0e0dc;
  border-radius: 2px;
  box-shadow: 0 2px 8px rgba(28, 38, 52, .06);
  background: #f0f0ec;
}

.hero-body { padding-top: .2rem; }

h1 {
  margin: 0 0 .4rem;
  font-size: 2.3rem;
  line-height: 1.14;
  font-weight: 700;
  letter-spacing: -.008em;
  color: #2c5185;
}

h1 .cn {
  margin-left: .3rem;
  font-size: .56em;
  font-weight: 400;
  letter-spacing: .12em;
  color: #71809a;
}

.role {
  margin: 0 0 .4rem;
  font-size: 1.02rem;
  font-weight: 600;
  color: #2a2a2a;
}

.affil {
  margin: 0 0 1.05rem;
  font-size: .96rem;
  line-height: 1.55;
  color: var(--ink-soft);
}

.links {
  display: flex;
  flex-wrap: wrap;
  gap: .35rem 1.05rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.links a {
  display: inline-flex;
  align-items: center;
  gap: .32rem;
  font-size: .9rem;
  color: var(--link);
}

.links svg {
  width: 14px;
  height: 14px;
  fill: currentColor;
  opacity: .85;
  flex: none;
}

.hero-note {
  margin: .9rem 0 .1rem;
  text-align: right;
}

.motto {
  margin: 0 0 .1rem;
  font-size: .96rem;
  font-style: italic;
  color: #5a6b82;
}

.updated {
  margin: 0;
  font-size: .76rem;
  font-style: italic;
  color: var(--faint);
}

/* ---------------- headings & text ---------------- */

h2 {
  margin: 2.35rem 0 .85rem;
  padding-bottom: .28rem;
  border-bottom: 1px solid var(--rule);
  font-size: 1.32rem;
  line-height: 1.25;
  font-weight: 700;
  color: var(--accent);
}

.section > h2:first-child { margin-top: 0; }

h3 {
  margin: 1.9rem 0 .55rem;
  font-size: 1.05rem;
  line-height: 1.35;
  font-weight: 700;
  color: #3d639b;
}

p {
  margin: 0 0 .85rem;
  line-height: 1.68;
}

ul, ol {
  margin: 0 0 .95rem;
  padding-left: 1.35rem;
}

li {
  margin: .28rem 0;
  padding-left: .15rem;
}

li::marker { color: #8fa3bf; }

ul.plain,
ul.news,
ul.timeline,
ul.funding,
ul.pub-list {
  list-style: none;
  padding-left: 0;
}

ul.plain li {
  margin: .3rem 0;
  padding-left: 0;
}

.muted { color: var(--muted); font-size: .93em; }

.legend {
  font-size: .82rem;
  color: var(--muted);
  margin: -.35rem 0 1.2rem;
}

sup { line-height: 0; font-size: .7em; }

.more {
  margin: 1.1rem 0 0;
  font-size: .93rem;
}

/* ---------------- news timeline ---------------- */

.news li {
  display: grid;
  grid-template-columns: 86px minmax(0, 1fr);
  gap: 1rem;
  margin: 0;
  padding: .4rem 0;
  border-bottom: 1px dotted #e6e6e2;
  font-size: .97rem;
  line-height: 1.58;
}

.news li:last-child { border-bottom: none; }

.news time {
  color: var(--muted);
  font-size: .8rem;
  letter-spacing: .02em;
  padding-top: .14rem;
  white-space: nowrap;
}

/* ---------------- education timeline ---------------- */

.timeline li {
  display: grid;
  grid-template-columns: 108px minmax(0, 1fr);
  gap: 1rem;
  margin: 0;
  padding: .38rem 0;
  font-size: .97rem;
}

.timeline .when {
  color: var(--muted);
  font-size: .82rem;
  padding-top: .14rem;
  white-space: nowrap;
}

.timeline .what b { color: #1f2c3c; }

/* ---------------- funding ---------------- */

.funding li {
  margin: 0 0 .8rem;
  font-size: .96rem;
  line-height: 1.6;
}

.fund-meta {
  font-size: .86em;
  color: var(--muted);
}

/* ---------------- publications ---------------- */

.pub-list { margin: 0; }

.pub {
  margin: 0;
  padding: .85rem 0 .9rem;
  border-bottom: 1px solid var(--rule-soft);
}

.pub:last-child { border-bottom: none; }

.pub-title {
  margin: 0 0 .25rem;
  font-size: 1rem;
  font-weight: 600;
  line-height: 1.48;
  color: #1e2b3a;
}

.pub-title a { color: var(--link); }
.pub-title a:hover { color: var(--accent-deep); }

.pub-authors {
  margin: 0 0 .16rem;
  font-size: .92rem;
  line-height: 1.55;
  color: #3d3d3d;
}

.pub-authors b { color: #172435; white-space: nowrap; }

.pub-venue {
  margin: 0;
  font-size: .89rem;
  line-height: 1.55;
  color: #5f6975;
}

.pub-venue b { color: #2f4d78; font-weight: 600; }

.compact .pub { padding: .7rem 0 .75rem; }
.compact .pub:last-child { border-bottom: none; }

.badge {
  display: inline-block;
  margin-left: .3rem;
  padding: .01rem .38rem .04rem;
  border: 1px solid #eed6ce;
  border-radius: 3px;
  background: #fbf0ec;
  color: #9c3f24;
  font-size: .7rem;
  font-style: normal;
  font-weight: 600;
  letter-spacing: .04em;
  text-transform: uppercase;
  vertical-align: 1px;
  white-space: nowrap;
}

.badge-hiring {
  margin-left: .2rem;
  border-color: #cddcef;
  background: #eef4fc;
  color: #2b5387;
}

/* ---------------- team ---------------- */

.team-plain {
  margin: 0 0 1rem;
  padding-left: 0;
  list-style: none;
}

.team-plain li {
  margin: .3rem 0;
  padding-left: 0;
  font-size: .97rem;
  line-height: 1.6;
}

/* ---------------- callout ---------------- */

.callout {
  margin: 1.5rem 0 .5rem;
  padding: .95rem 1.15rem .95rem;
  border-left: 3px solid var(--accent);
  background: #f6f8fc;
}

.callout p:last-child { margin-bottom: 0; }


/* ---------------- footer ---------------- */

.site-footer {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 3.2rem;
  padding-top: 1rem;
  border-top: 1px solid #e6e6e2;
  font-size: .79rem;
  color: var(--faint);
  line-height: 1.5;
}

.site-footer a { color: #7b8ca3; }

/* ---------------- responsive ---------------- */

@media (max-width: 1000px) {
  :root { --sidebar-w: 232px; }
  .content { padding-top: 2.2rem; }
  .hero { grid-template-columns: 205px minmax(0, 1fr); gap: 1.8rem; }
  h1 { font-size: 2.05rem; }
}

@media (max-width: 860px) {
  .layout { display: block; }

  .sidebar {
    position: sticky;
    top: 0;
    z-index: 20;
    height: auto;
    padding: .7rem 1rem .5rem;
    border-right: none;
    border-bottom: 1px solid var(--side-line);
    background: rgba(247, 247, 244, .97);
    -webkit-backdrop-filter: blur(8px);
    backdrop-filter: blur(8px);
    overflow: visible;
  }

  .brand {
    display: flex;
    align-items: baseline;
    gap: .5rem;
    margin: 0 0 .35rem;
    padding-left: .1rem;
  }

  .brand-name { font-size: .98rem; }
  .brand-cn { margin-top: 0; font-size: .72rem; }

  .tabs {
    flex-direction: row;
    gap: .05rem;
    overflow-x: auto;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
  }

  .tabs::-webkit-scrollbar { display: none; }

  .tab {
    margin: 0;
    padding: .36rem .55rem;
    border-left: none;
    border-bottom: 2px solid transparent;
    font-size: .88rem;
    white-space: nowrap;
  }

  .tab[aria-selected="true"] {
    border-left: none;
    border-bottom-color: var(--accent);
    background: none;
  }

  .tabs.is-overflowing {
    -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 26px), transparent);
    mask-image: linear-gradient(to right, #000 calc(100% - 26px), transparent);
  }

  .side-note { display: none; }

  .sidebar-foot { display: none; }

  .section { scroll-margin-top: 96px; }

  .content { padding: 1.7rem 1.25rem 2rem; }
  .content-inner { max-width: 700px; }

  .hero {
    grid-template-columns: 178px minmax(0, 1fr);
    gap: 1.6rem;
  }

  h1 { font-size: 1.95rem; }
  .hero-note { margin-top: .7rem; }

  .news li,
  .timeline li {
    grid-template-columns: 92px minmax(0, 1fr);
  }

  h2 { margin-top: 2rem; font-size: 1.22rem; }
}

@media (max-width: 620px) {
  .hero {
    grid-template-columns: 1fr;
    gap: 1.25rem;
  }

  .portrait { max-width: 180px; }

  .hero-note { text-align: left; }

  .news li,
  .timeline li {
    grid-template-columns: 1fr;
    gap: .05rem;
  }

  .site-footer { flex-direction: column; gap: .35rem; }

  .content { padding: 1.4rem 1.15rem 1.8rem; }

  h1 { font-size: 1.8rem; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    transition-duration: .001ms !important;
    scroll-behavior: auto !important;
  }
}

/* ---------------- no javascript ---------------- */

html:not(.js) .tabs { display: none; }

html:not(.js) .section {
  display: block !important;
  margin-bottom: 3rem;
}

html:not(.js) .section + .section {
  padding-top: 1rem;
  border-top: 1px solid var(--rule);
}

/* ---------------- print ---------------- */

@media print {
  .sidebar, .skip-link, .site-footer a { display: none; }
  .layout { display: block; }
  .content { padding: 0; }
  .section[hidden] { display: none !important; }
  a { color: #000; text-decoration: underline; }
  body { font-size: 10.5pt; }
}
