/* Leyang Hu — personal site */

:root {
  --bg:        #ffffff;
  --fg:        #1a1d21;
  --muted:     #656d76;
  --faint:     #8b939c;
  --rule:      #e3e6ea;
  --accent:    #2f5d8a;
  --accent-bg: #eef3f8;
  --tag-bg:    #f0f2f4;

  /* Layout. Every section shares --maxw, so all content lines up on the same
     left and right edges. Wide enough for three publication cards per row. */
  --maxw:      72rem;
  --gutter:    clamp(1.15rem, 4vw, 3rem);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg:        #14171a;
    --fg:        #e6e9ec;
    --muted:     #9aa3ad;
    --faint:     #6f7883;
    --rule:      #272c32;
    --accent:    #7fb2e0;
    --accent-bg: #1b2530;
    --tag-bg:    #21262c;
  }
}

/* Explicit overrides win in both directions */
:root[data-theme="light"] {
  --bg: #ffffff; --fg: #1a1d21; --muted: #656d76; --faint: #8b939c;
  --rule: #e3e6ea; --accent: #2f5d8a; --accent-bg: #eef3f8; --tag-bg: #f0f2f4;
}
:root[data-theme="dark"] {
  --bg: #14171a; --fg: #e6e9ec; --muted: #9aa3ad; --faint: #6f7883;
  --rule: #272c32; --accent: #7fb2e0; --accent-bg: #1b2530; --tag-bg: #21262c;
}

*, *::before, *::after { box-sizing: border-box; }

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  font-size: 16px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}

main {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 2.75rem var(--gutter) 5rem;
}

a {
  color: var(--accent);
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: border-color .12s ease;
}
a:hover { border-bottom-color: currentColor; }

p { margin: 0 0 1rem; }

/* ---------- sticky section nav ---------- */

html { scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

main section { scroll-margin-top: 4.5rem; }

.sitenav {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--bg);
  background: color-mix(in srgb, var(--bg) 85%, transparent);
  backdrop-filter: saturate(180%) blur(12px);
  -webkit-backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--rule);
}

.sitenav .wrap {
  /* Full-bleed, unlike the content column — the tabs sit at the page edge. */
  padding: .5rem var(--gutter);
  display: flex;
  align-items: center;
  gap: .75rem;
}

.sitenav a { border-bottom: none; }

.sitenav ul {
  list-style: none;
  margin: 0 0 0 auto;
  padding: 0;
  display: flex;
  align-items: center;
  gap: .1rem;
  /* Scroll the tabs inside the bar on narrow screens rather than wrapping. */
  overflow-x: auto;
  scrollbar-width: none;
}
.sitenav ul::-webkit-scrollbar { display: none; }

.sitenav ul a {
  display: block;
  padding: .35rem .5rem;
  font-size: .9rem;
  color: var(--muted);
  white-space: nowrap;
  border-bottom: 2px solid transparent;
  transition: color .12s ease, border-color .12s ease;
}
.sitenav ul a:hover { color: var(--fg); }
.sitenav ul a[aria-current] {
  color: var(--fg);
  border-bottom-color: var(--accent);
}

/* ---------- masthead ---------- */

.masthead {
  display: flex;
  align-items: center;
  gap: clamp(1.1rem, 3vw, 2.25rem);
  margin-bottom: 2.5rem;
}

.portrait {
  flex: 0 0 auto;
  width: clamp(92px, 5vw + 68px, 140px);
  height: clamp(92px, 5vw + 68px, 140px);
  border-radius: 50%;
  background-color: var(--tag-bg);
  background-image: url("profile.jpg");
  background-size: cover;
  background-position: center 20%;
  border: 1px solid var(--rule);
}

.intro { min-width: 0; }

h1 {
  margin: 0 0 .25rem;
  font-size: clamp(1.7rem, 1.15rem + 2.2vw, 2.4rem);
  font-weight: 600;
  letter-spacing: -.02em;
  line-height: 1.15;
}

h1 .cn {
  font-size: 1.15rem;
  font-weight: 400;
  color: var(--faint);
  margin-left: .4rem;
  letter-spacing: 0;
}

.tagline {
  margin: 0 0 .75rem;
  color: var(--muted);
  font-size: 1.02rem;
}

.links {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: .4rem .5rem;
  margin: 0;
  padding: 0;
  font-size: .88rem;
}

.links a {
  display: inline-block;
  padding: .18rem .6rem;
  border: 1px solid var(--rule);
  border-radius: 999px;
  color: var(--muted);
}
.links a:hover {
  color: var(--accent);
  border-color: var(--accent);
  background: var(--accent-bg);
}

/* Icon links: same pill treatment, squared to a circle around the glyph. */
.links a.icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.05rem;
  height: 2.05rem;
  padding: 0;
  border-radius: 50%;
}
.links a.icon svg {
  width: 1.05rem;
  height: 1.05rem;
  display: block;
}

/* ---------- bio ---------- */

.bio p { color: var(--fg); }

.bio strong { font-weight: 600; }

/* The two research directions, side by side on wide screens. Splitting them
   keeps the line length readable at the full container width. */
.directions {
  list-style: none;
  margin: 1.1rem 0 0;
  padding: 0;
  display: grid;
  gap: 1rem 1.6rem;
  grid-template-columns: repeat(auto-fit, minmax(17rem, 1fr));
}

.directions li {
  padding-left: .9rem;
  border-left: 2px solid var(--rule);
}

.directions .dir-label {
  margin: 0 0 .15rem;
  font-size: .95rem;
  font-weight: 600;
  color: var(--fg);
}

.directions p {
  margin: 0;
  font-size: .92rem;
  line-height: 1.6;
  color: var(--muted);
}

/* ---------- sections ---------- */

section { margin-top: 3rem; }

h2 {
  font-size: .78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .12em;
  color: var(--faint);
  margin: 0 0 1.25rem;
  padding-bottom: .5rem;
  border-bottom: 1px solid var(--rule);
}

.note {
  font-size: .82rem;
  color: var(--faint);
  margin-bottom: 1.25rem;
}

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

.news {
  list-style: none;
  margin: 0;
  padding: 0;
  font-size: .93rem;
}

.news li {
  display: flex;
  gap: 1rem;
  padding: .45rem 0;
  border-bottom: 1px solid var(--rule);
}
.news li:last-child { border-bottom: 0; }

.news .when {
  flex: 0 0 5.5rem;
  color: var(--faint);
  font-variant-numeric: tabular-nums;
  font-size: .85rem;
  padding-top: .1rem;
}
.news .what { color: var(--muted); }
.news .what strong { color: var(--fg); font-weight: 600; }

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

.pubs {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(18.5rem, 1fr));
  gap: 1.4rem;
}

.pub {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--rule);
  border-radius: 10px;
  overflow: hidden;
  transition: border-color .15s ease;
}
.pub:hover { border-color: var(--accent); }

.teaser {
  position: relative;
  aspect-ratio: 16 / 10;
  overflow: hidden;
  border-bottom: 1px solid var(--rule);
  background: var(--tag-bg);
}

.teaser-media {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
  transition: transform .4s ease;
}
.pub:hover .teaser-media { transform: scale(1.06); }
@media (prefers-reduced-motion: reduce) {
  .pub:hover .teaser-media { transform: none; }
}

/* Placeholder while a paper has no teaser figure: a faint grid rather than
   an empty box, so the card does not read as a broken image. */
div.teaser-media {
  background-image:
    linear-gradient(var(--rule) 1px, transparent 1px),
    linear-gradient(90deg, var(--rule) 1px, transparent 1px);
  background-size: 24px 24px;
}

.badges {
  position: absolute;
  top: .6rem;
  left: .6rem;
  display: flex;
  flex-wrap: wrap;
  gap: .3rem;
}

.badge {
  font-size: .67rem;
  font-weight: 500;
  letter-spacing: .07em;
  text-transform: uppercase;
  padding: .18rem .5rem;
  border-radius: 999px;
  background: var(--bg);
  border: 1px solid var(--rule);
  color: var(--accent);
  white-space: nowrap;
}
.badge.muted { color: var(--faint); }

.pub-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: .4rem;
  padding: .95rem 1.05rem 1.05rem;
}

.pubs .title {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
  line-height: 1.35;
  color: var(--fg);
  letter-spacing: -.005em;
}

.pubs .authors {
  margin: 0;
  font-size: .8rem;
  line-height: 1.5;
  color: var(--faint);
}
.pubs .authors strong { color: var(--muted); font-weight: 600; }

.pubs .summary {
  margin: 0;
  font-size: .875rem;
  line-height: 1.55;
  color: var(--muted);
}

/* Multi-column only: reserve the tallest observed title and author block so the
   summaries start on the same line across a row. The summary itself needs no
   reservation — .pub-links is bottom-pinned, so its slack collects there.
   Author lists longer than two lines use the head-and-tail form instead. */
@media (min-width: 40rem) {
  .pubs .title   { min-height: calc(1.35em * 3); }
  .pubs .authors { min-height: calc(1.5em * 2); }
}

.pub-links {
  margin: auto 0 0;
  padding-top: .55rem;
  display: flex;
  flex-wrap: wrap;
  gap: .4rem;
}
.pub-links a {
  font-size: .78rem;
  padding: .1rem .5rem;
  border: 1px solid var(--rule);
  border-radius: 3px;
  color: var(--muted);
}
.pub-links a:hover {
  color: var(--accent);
  border-color: var(--accent);
  background: var(--accent-bg);
}


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

footer {
  margin-top: 3.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--rule);
  font-size: .87rem;
  color: var(--muted);
}
footer p { margin: 0 0 .3rem; }
.colophon { color: var(--faint); font-size: .8rem; }

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

@media (max-width: 34rem) {
  /* Horizontal padding and type scale are fluid — only the vertical rhythm
     and the stacking behaviour need a breakpoint. */
  main { padding-top: 2rem; padding-bottom: 3.5rem; }

  .sitenav .wrap { padding-top: .35rem; padding-bottom: .35rem; }

  .masthead {
    flex-direction: column;
    align-items: flex-start;
    gap: 1.1rem;
  }
  h1 .cn { display: block; margin-left: 0; font-size: 1rem; }

  .news li { flex-direction: column; gap: .1rem; }
  .news .when { flex: none; }
}

@media print {
  :root { --bg: #fff; --fg: #000; --muted: #333; --faint: #666; --rule: #ccc; --accent: #000; }
  main { max-width: none; padding: 0; }
  a { color: #000; }
  .links, .portrait, .sitenav { display: none; }
}
