/* ============================================================
   Yicheng Leng — personal site
   Tokens first, then layout, then components.
   Selectors target classes, never href fragments.
   ============================================================ */

:root {
  --bg: #fbfaf7;
  --bg-alt: #f3f0ea;
  --surface: #ffffff;
  --surface-sunk: #f7f5f1;
  --ink: #18191b;
  --ink-soft: #30363d;
  --muted: #5e6673;
  --line: #e7e2da;
  --line-strong: #d8d1c7;
  --accent: #990000;
  --accent-dark: #6f0000;
  --accent-wash: rgba(153, 0, 0, 0.07);
  --link: #123d6a;
  --shadow-sm: 0 1px 2px rgba(27, 31, 35, 0.04), 0 6px 16px rgba(27, 31, 35, 0.045);
  --shadow-md: 0 2px 4px rgba(27, 31, 35, 0.04), 0 18px 44px rgba(27, 31, 35, 0.075);

  --measure: 68ch;
  --radius: 8px;
  --radius-sm: 6px;

  --ease: cubic-bezier(0.2, 0.7, 0.3, 1);
}

* {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 16px;
  font-variant-numeric: tabular-nums;
  line-height: 1.68;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

main {
  flex: 1 0 auto;
}

img {
  max-width: 100%;
}

/* ---------- links ---------- */

a {
  color: var(--link);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.18em;
  text-decoration-color: color-mix(in srgb, currentColor 30%, transparent);
  transition: color 160ms var(--ease), text-decoration-color 160ms var(--ease);
}

a:hover {
  color: var(--accent);
  text-decoration-color: currentColor;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 3px;
}

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  z-index: 100;
  padding: 0.7rem 1rem;
  background: var(--ink);
  color: var(--bg);
  border-radius: 0 0 var(--radius-sm) 0;
  text-decoration: none;
}

.skip-link:focus {
  left: 0;
}

/* ---------- header ---------- */

.site-header {
  position: sticky;
  top: 0;
  z-index: 10;
  padding: 0.85rem 2rem;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(16px) saturate(1.4);
  -webkit-backdrop-filter: blur(16px) saturate(1.4);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
  width: min(1080px, 100%);
  margin: 0 auto;
}

.brand {
  display: flex;
  align-items: center;
  flex: 0 0 auto;
  text-decoration: none;
  opacity: 0.9;
  transition: opacity 160ms var(--ease);
}

.brand:hover {
  opacity: 1;
}

.brand img {
  display: block;
  height: 46px;
  width: auto;
}

.site-nav {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 0.15rem;
}

.site-nav a {
  padding: 0.46rem 0.62rem;
  border-radius: var(--radius-sm);
  color: var(--ink-soft);
  font-size: 0.92rem;
  font-weight: 500;
  line-height: 1;
  text-decoration: none;
  transition: color 160ms var(--ease), background-color 160ms var(--ease);
}

.site-nav a:hover {
  background: var(--accent-wash);
  color: var(--accent);
}

.site-nav a.is-active {
  background: var(--accent-wash);
  color: var(--accent);
  font-weight: 600;
}

/* ---------- shared section chrome ---------- */

section {
  width: min(920px, calc(100% - 40px));
  margin: 0 auto;
  padding: 4.2rem 0;
}

h2 {
  margin: 0 0 1.5rem;
  padding-bottom: 0.7rem;
  border-bottom: 1px solid var(--line);
  color: var(--ink);
  font-size: clamp(1.4rem, 1.9vw, 1.75rem);
  font-weight: 650;
  letter-spacing: -0.015em;
  line-height: 1.2;
}

h2 .heading-note {
  margin-left: 0.6rem;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  vertical-align: 0.18em;
}

p {
  margin: 0 0 1rem;
}

ul {
  padding-left: 1.15rem;
}

strong {
  color: var(--ink);
  font-weight: 650;
}

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

.hero {
  display: grid;
  grid-template-columns: minmax(160px, 0.22fr) minmax(0, 1fr);
  align-items: start;
  gap: clamp(1.8rem, 4vw, 3.2rem);
  width: min(1120px, calc(100% - 40px));
  margin: 3rem auto 1rem;
  padding: 2.8rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
}

.hero-portrait {
  position: sticky;
  top: 6.2rem;
  max-width: 210px;
}

.hero-portrait img {
  display: block;
  width: 100%;
  aspect-ratio: 4 / 5;
  object-fit: cover;
  border-radius: var(--radius);
  border: 1px solid var(--line-strong);
  box-shadow: var(--shadow-sm);
}

.hero-caption {
  width: 100%;
  margin: 0.7rem 0 0;
  color: var(--muted);
  font-size: 0.72rem;
  line-height: 1.5;
}

.hero-facts {
  margin: 1.1rem 0 0;
  padding: 0.95rem 0 0;
  list-style: none;
  border-top: 1px solid var(--line);
  display: grid;
  gap: 0.5rem;
}

.hero-facts li {
  display: grid;
  grid-template-columns: 14px auto minmax(0, 1fr);
  align-items: start;
  gap: 0.28rem;
  margin: 0;
  color: var(--ink-soft);
  font-size: 0.78rem;
  line-height: 1.55;
}

.fact-icon {
  width: 14px;
  height: 14px;
  margin-top: 0.16rem;
  color: var(--accent);
  flex: 0 0 auto;
}

.fact-colon {
  color: var(--muted);
}

.fact-value {
  min-width: 0;
  overflow-wrap: anywhere;
}

.hero-text {
  max-width: 100%;
}

.hero-text p {
  margin: 0;
  color: var(--ink-soft);
  font-size: clamp(1rem, 1.2vw, 1.08rem);
  line-height: 1.82;
}

.hero-text strong a {
  color: var(--ink);
  font-weight: 650;
}

.hero-text strong a:hover {
  color: var(--accent);
}

.personal-links {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.6rem;
  margin-top: 1.6rem;
  padding-top: 1.2rem;
  border-top: 1px solid var(--line);
}

.personal-links span {
  margin-right: 0.3rem;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.personal-links a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  text-decoration: none;
  transition: border-color 160ms var(--ease), background-color 160ms var(--ease), transform 160ms var(--ease);
}

.personal-links a:hover {
  border-color: color-mix(in srgb, var(--accent) 40%, var(--line-strong));
  background: var(--accent-wash);
  transform: translateY(-1px);
}

.personal-links svg {
  width: 18px;
  height: 18px;
  display: block;
}

/* Brand colours, applied only on hover; the resting state stays neutral so
   the row reads as one set rather than four competing logos. */
.personal-links a:hover svg {
  color: var(--brand);
}

.brand-icon--scholar {
  --brand: #4285f4;
}

.brand-icon--linkedin {
  --brand: #0a66c2;
}

.brand-icon--github {
  --brand: #181717;
}

.brand-icon--orcid {
  --brand: #a6ce39;
}

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

.news-section {
  padding-top: 2.6rem;
}

.news-list {
  margin: 0;
  padding: 0;
  list-style: none;
  border-top: 1px solid var(--line);
}

.news-list li {
  display: grid;
  grid-template-columns: 7.5rem minmax(0, 1fr);
  gap: 1rem;
  margin: 0;
  padding: 0.72rem 0;
  border-bottom: 1px solid var(--line);
  color: var(--ink-soft);
  font-size: 0.96rem;
}

.news-date {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  font-variant-numeric: tabular-nums;
  padding-top: 0.14rem;
}

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

.publications-section {
  width: min(980px, calc(100% - 40px));
}

.pub-block {
  margin: 0 0 1.4rem;
  padding: 1.1rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  scroll-margin-top: 6rem;
  transition: border-color 200ms var(--ease), box-shadow 200ms var(--ease);
}

/* Landing from a news link: make the target card obvious without a flash. */
.pub-block:target {
  border-color: color-mix(in srgb, var(--accent) 45%, var(--line-strong));
  box-shadow: 0 0 0 3px var(--accent-wash), var(--shadow-sm);
}

.pub-block:hover {
  border-color: var(--line-strong);
  box-shadow: var(--shadow-md);
}

.pub-figure {
  margin: 0 0 1.1rem;
  padding: 0.55rem;
  background: var(--surface-sunk);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
}

.pub-figure img {
  display: block;
  width: 100%;
  max-height: 340px;
  object-fit: contain;
  border-radius: 3px;
}

.pub-venue {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin: 0 0 0.6rem;
}

.chip {
  display: inline-block;
  padding: 0.16rem 0.5rem;
  border: 1px solid color-mix(in srgb, var(--accent) 26%, transparent);
  border-radius: 999px;
  background: var(--accent-wash);
  color: var(--accent);
  font-size: 0.7rem;
  font-weight: 650;
  letter-spacing: 0.07em;
  line-height: 1.5;
  text-transform: uppercase;
}

.chip--quiet {
  border-color: var(--line-strong);
  background: transparent;
  color: var(--muted);
}

.pub-title {
  margin: 0 0 0.45rem;
  font-size: 1.08rem;
  font-weight: 620;
  letter-spacing: -0.008em;
  line-height: 1.42;
}

.pub-title a {
  color: var(--ink);
  text-decoration: none;
  background-image: linear-gradient(currentColor, currentColor);
  background-repeat: no-repeat;
  background-position: 0 100%;
  background-size: 0% 1px;
  transition: background-size 260ms var(--ease), color 160ms var(--ease);
  padding-bottom: 1px;
}

.pub-title a:hover {
  color: var(--accent);
  background-size: 100% 1px;
}

.pub-authors {
  margin: 0 0 0.6rem;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.55;
}

.pub-authors strong {
  color: var(--ink-soft);
  font-weight: 650;
}

.pub-tldr {
  margin: 0 0 0.75rem;
  color: var(--ink-soft);
  font-size: 0.95rem;
  line-height: 1.65;
}

.pub-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin: 0;
}

.tag {
  display: inline-block;
  padding: 0.2rem 0.55rem;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--ink-soft);
  font-size: 0.76rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  line-height: 1.5;
  text-decoration: none;
  transition: border-color 160ms var(--ease), background-color 160ms var(--ease), color 160ms var(--ease);
}

.tag:hover {
  border-color: color-mix(in srgb, var(--accent) 45%, var(--line-strong));
  background: var(--accent-wash);
  color: var(--accent);
}

.tag--code::before {
  content: "{ }";
  margin-right: 0.36rem;
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  font-size: 0.72em;
  opacity: 0.7;
}

.coauthor-pub {
  padding: 1.05rem 1.25rem;
  border-left: 3px solid color-mix(in srgb, var(--accent) 70%, transparent);
}

.subsection-heading {
  margin-top: 3rem;
}

/* ---------- research ---------- */

.research-item {
  padding: 1.5rem 0;
  border-bottom: 1px solid var(--line);
}

.research-item:first-of-type {
  padding-top: 0.5rem;
}

.research-item:last-of-type {
  border-bottom: 0;
  padding-bottom: 0;
}

.research-item h3 {
  margin: 0 0 1.1rem;
  color: var(--ink);
  font-size: 1.18rem;
  font-weight: 620;
  letter-spacing: -0.01em;
  line-height: 1.35;
}

.research-meta {
  margin: 0;
  display: grid;
  grid-template-columns: 6.2rem minmax(0, 1fr);
  gap: 0.7rem 1.4rem;
}

.research-meta dt {
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 650;
  letter-spacing: 0.12em;
  line-height: 1.9;
  text-transform: uppercase;
}

.research-meta dd {
  margin: 0;
  color: var(--ink-soft);
  font-size: 0.98rem;
  line-height: 1.72;
}

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

  .research-meta dd {
    margin-bottom: 0.7rem;
  }
}

/* ---------- subpages ---------- */

.page-section {
  margin-top: 2.2rem;
  padding: 3rem;
  width: min(920px, calc(100% - 40px));
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  font-size: 1.01rem;
}

.detail-list {
  margin: 1.2rem 0 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 0.7rem;
}

.detail-list li {
  position: relative;
  margin: 0;
  padding: 0.95rem 1.05rem 0.95rem 2.3rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface-sunk);
  color: var(--ink-soft);
}

.detail-list li::before {
  content: "";
  position: absolute;
  left: 1rem;
  top: 1.5rem;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-wash);
}

.back-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  margin-top: 2rem;
  padding: 0.6rem 1rem;
  background: var(--ink);
  border: 1px solid var(--ink);
  border-radius: var(--radius-sm);
  color: var(--bg);
  font-size: 0.9rem;
  font-weight: 600;
  line-height: 1;
  text-decoration: none;
  transition: background-color 180ms var(--ease), border-color 180ms var(--ease), transform 180ms var(--ease);
}

.back-link:hover {
  background: var(--accent-dark);
  border-color: var(--accent-dark);
  color: #fff;
  transform: translateY(-1px);
}

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

.site-footer {
  margin-top: 3rem;
  padding: 2.4rem 2rem;
  background: var(--bg-alt);
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.86rem;
  text-align: center;
}

.footer-inner {
  width: min(920px, 100%);
  margin: 0 auto;
}

.site-footer p {
  margin: 0 0 1.2rem;
}

.visit-map__label {
  display: block;
  margin-bottom: 0.5rem;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.visit-map {
  width: 12.5%;
  min-width: 140px;
  margin: 0 auto;
}

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

@media (max-width: 860px) {
  .site-header {
    position: static;
    padding: 1rem 1.1rem;
  }

  .header-inner {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.7rem;
  }

  .site-nav {
    justify-content: flex-start;
    width: 100%;
  }

  .site-nav a {
    margin: 0 0.1rem 0.2rem 0;
    padding: 0.44rem 0.5rem;
    font-size: 0.89rem;
  }

  .hero {
    grid-template-columns: 1fr;
    gap: 1.4rem;
    margin-top: 1.4rem;
    padding: 1.4rem;
  }

  .hero-portrait {
    position: static;
    max-width: 180px;
  }

  .hero-portrait img,
  .hero-caption {
    width: 100%;
  }

  section {
    width: min(100% - 28px, 720px);
    padding: 3rem 0;
  }

  .page-section {
    width: min(100% - 28px, 720px);
    margin-top: 1.4rem;
    padding: 1.4rem;
  }

  .news-list li {
    grid-template-columns: 1fr;
    gap: 0.1rem;
  }

  .pub-block {
    padding: 0.9rem;
  }
}

@media (max-width: 520px) {
  body {
    font-size: 15px;
  }

  .brand img {
    height: 38px;
  }

  .personal-links span {
    width: 100%;
  }
}

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

  *,
  *::before,
  *::after {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
  }
}
