/* ==========================================================================
   Ziming Zang — Academic Homepage
   Visual language inspired by the al-folio Jekyll theme (MIT License)
   Pure static CSS: no build step required.
   ========================================================================== */

:root {
  --accent: #0b6e5f;
  --accent-strong: #07564a;
  --accent-soft: rgba(11, 110, 95, 0.09);
  --gold: #c9a227;

  --bg: #f4f6f6;
  --surface: #ffffff;
  --surface-alt: #fafbfb;
  --text: #1e2426;
  --text-soft: #4a5559;
  --muted: #76838a;
  --border: #e3e8e9;
  --border-strong: #cfd7d9;
  --shadow-sm: 0 1px 2px rgba(16, 24, 32, 0.05);
  --shadow: 0 1px 2px rgba(16, 24, 32, 0.06), 0 10px 28px rgba(16, 24, 32, 0.07);

  --radius: 10px;
  --radius-lg: 14px;
  --nav-h: 58px;
  --maxw: 1180px;

  --font-body: "Inter", "Roboto", -apple-system, BlinkMacSystemFont, "Segoe UI",
    "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", sans-serif;
  --font-head: "Roboto Slab", Georgia, "Songti SC", "Noto Serif SC", serif;
}

html[data-theme="dark"] {
  --accent: #4ec9a8;
  --accent-strong: #79dcc2;
  --accent-soft: rgba(78, 201, 168, 0.12);
  --gold: #e0c05a;

  --bg: #141617;
  --surface: #1c1f20;
  --surface-alt: #212425;
  --text: #e7eaeb;
  --text-soft: #c2c9cb;
  --muted: #909a9d;
  --border: #2d3133;
  --border-strong: #3b4042;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 10px 28px rgba(0, 0, 0, 0.35);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 16.5px;
  line-height: 1.75;
  text-rendering: optimizeLegibility;
  transition: background-color 0.25s ease, color 0.25s ease;
}

img {
  max-width: 100%;
  display: block;
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  color: var(--accent-strong);
  text-decoration: underline;
  text-underline-offset: 3px;
}

h1,
h2,
h3,
h4 {
  font-family: var(--font-head);
  font-weight: 700;
  line-height: 1.3;
  color: var(--text);
}

/* --------------------------------------------------------------- navbar --- */

.navbar {
  position: sticky;
  top: 0;
  z-index: 50;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: saturate(180%) blur(10px);
  border-bottom: 1px solid var(--border);
}

.navbar__inner {
  max-width: var(--maxw);
  margin: 0 auto;
  min-height: var(--nav-h);
  padding: 0 22px;
  display: flex;
  align-items: center;
  gap: 18px;
}

.brand {
  font-family: var(--font-head);
  font-weight: 700;
  font-size: 17px;
  letter-spacing: 0.01em;
  color: var(--text);
  white-space: nowrap;
  margin-right: auto;
}

.brand:hover {
  text-decoration: none;
  color: var(--accent);
}

.brand small {
  display: block;
  font-family: var(--font-body);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
  line-height: 1.4;
}

.navlinks {
  display: flex;
  align-items: center;
  gap: 4px;
}

.navlinks a {
  position: relative;
  padding: 7px 11px;
  border-radius: 7px;
  font-size: 14.5px;
  font-weight: 500;
  color: var(--text-soft);
  transition: background-color 0.18s ease, color 0.18s ease;
}

.navlinks a:hover {
  background: var(--accent-soft);
  color: var(--accent);
  text-decoration: none;
}

.navlinks a.is-active {
  color: var(--accent);
}

.navlinks a.is-active::after {
  content: "";
  position: absolute;
  left: 11px;
  right: 11px;
  bottom: 2px;
  height: 2px;
  border-radius: 2px;
  background: var(--accent);
}

.icon-btn {
  flex: none;
  width: 36px;
  height: 36px;
  display: inline-grid;
  place-items: center;
  border: 1px solid var(--border-strong);
  border-radius: 9px;
  background: var(--surface);
  color: var(--text-soft);
  cursor: pointer;
  transition: border-color 0.18s ease, color 0.18s ease, background-color 0.18s ease;
}

.icon-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.icon-btn svg {
  width: 17px;
  height: 17px;
}

.navtoggle {
  display: none;
}

/* Both icons ship in the DOM; the inactive one is hidden per theme. */
html[data-theme="light"] .theme-icon--sun,
html[data-theme="dark"] .theme-icon--moon {
  display: none;
}

/* ------------------------------------------------------------- structure --- */

main {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 40px 22px 72px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}

/* ------------------------------------------------------------ about head --- */

.intro {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  gap: 38px;
  align-items: start;
  padding: 36px 38px;
  margin-bottom: 34px;
}

.intro__photo {
  position: relative;
}

.intro__photo img {
  width: 100%;
  height: auto; /* neutralise the width/height attributes so aspect-ratio wins */
  aspect-ratio: 1 / 1;
  object-fit: cover;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}

.intro__name {
  margin: 0 0 2px;
  font-size: clamp(30px, 4vw, 40px);
  letter-spacing: -0.01em;
}

/* Sub-line of the name; a dedicated class (not a bare `span` selector) so that
   the [data-lang-block] wrappers inside .intro__name are not affected. */
.intro__sub {
  font-size: 0.52em;
  font-weight: 400;
  color: var(--muted);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  display: block;
  margin-top: 6px;
}

.intro__title {
  margin: 10px 0 2px;
  font-size: 17px;
  font-weight: 600;
  color: var(--text-soft);
}

.intro__areas {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 9px;
  margin: 13px 0 0;
  font-size: 15px;
  color: var(--muted);
}

/* The headline research directions, rendered as highlighted chips. */
.intro__chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.intro__chips li {
  padding: 4px 13px;
  border: 1px solid transparent;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 14.5px;
  font-weight: 600;
  line-height: 1.5;
  white-space: nowrap;
}

.intro__affil {
  margin: 12px 0 0;
  font-size: 15.5px;
  line-height: 1.65;
  color: var(--text-soft);
}

.intro__bio {
  margin: 16px 0 0;
  font-size: 16px;
  color: var(--text-soft);
}

/* -------------------------------------------------------------- socials --- */

.socials {
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
  margin: 22px 0 0;
  padding: 0;
  list-style: none;
}

.socials a {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 6px 13px;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-soft);
  background: var(--surface-alt);
  transition: all 0.18s ease;
}

.socials a:hover {
  text-decoration: none;
  color: #fff;
  background: var(--accent);
  border-color: var(--accent);
  transform: translateY(-1px);
}

html[data-theme="dark"] .socials a:hover {
  color: #10201c;
}

.socials svg {
  width: 15px;
  height: 15px;
  flex: none;
}

/* -------------------------------------------------------------- sections --- */

section {
  margin-bottom: 34px;
  scroll-margin-top: 78px;
}

.section__head {
  display: flex;
  align-items: baseline;
  gap: 12px;
  margin: 0 0 18px;
  padding-bottom: 10px;
  border-bottom: 2px solid var(--border);
}

.section__head h2 {
  margin: 0;
  font-size: 22px;
}

.section__head .en {
  font-family: var(--font-body);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
}

.panel {
  padding: 26px 28px;
}

/* ---------------------------------------------------------------- news --- */

.news {
  margin: 0;
  padding: 0;
  list-style: none;
}

.news li {
  display: grid;
  grid-template-columns: 92px minmax(0, 1fr);
  gap: 14px;
  padding: 9px 0;
  border-bottom: 1px dashed var(--border);
  font-size: 15.5px;
}

.news li:last-child {
  border-bottom: 0;
}

.news .date {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13.5px;
  color: var(--accent);
  font-weight: 600;
  padding-top: 2px;
}

/* ------------------------------------------------------------- research --- */

.grid-2 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 18px;
}

/* When the cards leave a single item on the last row, let it span the full
   width instead of sitting half-empty next to a gap. */
.grid-2 > :last-child:nth-child(odd) {
  grid-column: 1 / -1;
}

.topic {
  padding: 20px 22px;
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius);
  background: var(--surface-alt);
}

.topic h3 {
  margin: 0 0 6px;
  font-size: 17.5px;
}

.topic p {
  margin: 0;
  font-size: 15px;
  color: var(--text-soft);
}

.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin: 12px 0 0;
  padding: 0;
  list-style: none;
}

.tags li {
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: 0.02em;
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
}

/* ---------------------------------------------------------- publications --- */

.pub-list {
  margin: 0;
  padding: 0;
  list-style: none;
  counter-reset: pub;
}

.pub {
  position: relative;
  padding: 22px 0 22px 46px;
  border-bottom: 1px solid var(--border);
  counter-increment: pub;
}

.pub:last-child {
  border-bottom: 0;
  padding-bottom: 6px;
}

.pub::before {
  content: "[" counter(pub) "]";
  position: absolute;
  left: 0;
  top: 22px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 14px;
  color: var(--muted);
}

.pub__title {
  margin: 0 0 5px;
  font-family: var(--font-head);
  font-size: 17.5px;
  font-weight: 700;
  line-height: 1.45;
}

.pub__authors {
  margin: 0;
  font-size: 15px;
  color: var(--text-soft);
}

.pub__authors strong {
  color: var(--text);
  font-weight: 700;
}

.pub__venue {
  margin: 3px 0 0;
  font-size: 15px;
  color: var(--muted);
}

.pub__venue em {
  color: var(--text-soft);
  font-style: italic;
}

.badges {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin: 11px 0 0;
  padding: 0;
  list-style: none;
}

.badge {
  display: inline-block;
  padding: 2px 10px;
  border: 1px solid var(--border-strong);
  border-radius: 5px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-soft);
  background: var(--surface-alt);
}

.badge--accent {
  border-color: transparent;
  background: var(--accent);
  color: #fff;
}

html[data-theme="dark"] .badge--accent {
  color: #10201c;
}

.badge--ghost {
  border-style: dashed;
  background: transparent;
}

a.badge:hover {
  text-decoration: none;
  border-color: var(--accent);
  color: var(--accent);
}

/* Action buttons under a publication entry: Abs / DOI / PDF */

.pub-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 16px 0 0;
}

.pub-action {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 15px;
  border: 1px solid var(--accent);
  border-radius: 8px;
  font-size: 13.5px;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--accent);
  background: transparent;
  transition: color 0.18s ease, background-color 0.18s ease, transform 0.18s ease;
}

.pub-action:hover {
  text-decoration: none;
  color: #fff;
  background: var(--accent);
  transform: translateY(-1px);
}

html[data-theme="dark"] .pub-action:hover {
  color: #10201c;
}

.pub-action svg {
  width: 14px;
  height: 14px;
  flex: none;
}

/* ------------------------------------------------------------- timeline --- */

.entry {
  position: relative;
  padding: 0 0 24px 26px;
  border-left: 2px solid var(--border);
}

.entry:last-child {
  padding-bottom: 0;
  border-left-color: transparent;
}

.entry::before {
  content: "";
  position: absolute;
  left: -7px;
  top: 8px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--surface);
  border: 2.5px solid var(--accent);
}

.entry__top {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}

.entry__title {
  margin: 0;
  font-size: 17.5px;
}

.entry__when {
  flex: none;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--muted);
  white-space: nowrap;
}

.entry__meta {
  margin: 4px 0 0;
  font-size: 14.5px;
  color: var(--muted);
}

.entry__meta a {
  color: var(--accent);
}

.entry ul {
  margin: 10px 0 0;
  padding-left: 20px;
}

.entry li {
  margin: 5px 0;
  font-size: 15.5px;
  color: var(--text-soft);
}

.entry li::marker {
  color: var(--accent);
}

.entry li strong {
  color: var(--text);
}

/* -------------------------------------------------------------- keyvals --- */

.keyvals {
  margin: 0;
  padding: 0;
  list-style: none;
}

.keyvals li {
  display: grid;
  grid-template-columns: 108px minmax(0, 1fr);
  gap: 14px;
  padding: 8px 0;
  border-bottom: 1px dashed var(--border);
  font-size: 15.5px;
  color: var(--text-soft);
}

.keyvals li:last-child {
  border-bottom: 0;
}

.keyvals .k {
  font-weight: 600;
  color: var(--text);
}

/* ----------------------------------------------------------- score chips --- */

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 10px 0 0;
  padding: 0;
  list-style: none;
}

.chips li {
  display: flex;
  align-items: baseline;
  gap: 7px;
  padding: 5px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-alt);
  font-size: 14px;
  color: var(--text-soft);
}

.chips b {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 14px;
  color: var(--accent);
}

/* -------------------------------------------------------------- sidebar --- */

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 30px;
  align-items: start;
}

.side {
  position: sticky;
  top: calc(var(--nav-h) + 18px);
}

.side .panel {
  padding: 22px 24px;
}

.side .panel + .panel {
  margin-top: 20px;
}

.side h3 {
  margin: 0 0 12px;
  font-size: 16px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}

.side p {
  margin: 0 0 8px;
  font-size: 14.5px;
  color: var(--text-soft);
}

.side dl {
  margin: 0;
  font-size: 14.5px;
}

.side dt {
  font-weight: 600;
  color: var(--muted);
  font-size: 12px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  margin-top: 10px;
}

.side dd {
  margin: 2px 0 0;
  color: var(--text-soft);
  word-break: break-word;
}

/* --------------------------------------------------------------- footer --- */

.site-footer {
  border-top: 1px solid var(--border);
  background: var(--surface);
}

.site-footer__inner {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 22px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: space-between;
  font-size: 14px;
  color: var(--muted);
}

/* ------------------------------------------------------------ to the top --- */

.totop {
  position: fixed;
  right: 22px;
  bottom: 24px;
  z-index: 40;
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text-soft);
  box-shadow: var(--shadow);
  cursor: pointer;
  opacity: 0;
  visibility: hidden;
  transform: translateY(8px);
  transition: all 0.22s ease;
}

.totop.is-visible {
  opacity: 1;
  visibility: visible;
  transform: none;
}

.totop:hover {
  color: #fff;
  background: var(--accent);
  border-color: var(--accent);
}

.totop svg {
  width: 17px;
  height: 17px;
}

/* -------------------------------------------------------------- print cv --- */

@media print {
  .navbar,
  .totop,
  .site-footer,
  .no-print {
    display: none !important;
  }

  body {
    background: #fff;
    font-size: 11pt;
  }

  main {
    max-width: none;
    padding: 0;
  }

  .card,
  .panel {
    border: 0;
    box-shadow: none;
    padding: 0;
  }

  .layout {
    display: block;
  }

  .side {
    position: static;
  }

  section {
    break-inside: avoid;
  }

  .intro {
    grid-template-columns: 120px minmax(0, 1fr);
    gap: 20px;
    padding: 0 0 16px;
  }
}

/* ------------------------------------------------------------ responsive --- */

@media (max-width: 900px) {
  .layout {
    grid-template-columns: minmax(0, 1fr);
  }

  .side {
    position: static;
    order: -1;
  }

  .intro {
    grid-template-columns: 160px minmax(0, 1fr);
    gap: 26px;
    padding: 26px 24px;
  }
}

@media (max-width: 720px) {
  body {
    font-size: 16px;
  }

  .navbar__inner {
    padding: 10px 18px;
    flex-wrap: wrap;
    row-gap: 10px;
  }

  .brand {
    margin-right: 0;
    flex: 1 1 auto;
  }

  .navtoggle {
    display: inline-grid;
  }

  .navlinks {
    display: none;
    flex: 1 1 100%;
    flex-direction: column;
    align-items: stretch;
    gap: 2px;
    padding-bottom: 8px;
  }

  .navlinks.is-open {
    display: flex;
  }

  .navlinks a {
    padding: 10px 12px;
    border-radius: 8px;
  }

  .navlinks a.is-active::after {
    display: none;
  }

  .navlinks a.is-active {
    background: var(--accent-soft);
  }

  main {
    padding: 24px 16px 56px;
  }

  .intro {
    grid-template-columns: minmax(0, 1fr);
    gap: 20px;
    padding: 24px 20px;
  }

  .intro__photo {
    max-width: 190px;
  }

  .panel,
  .side .panel {
    padding: 20px 18px;
  }

  .news li {
    grid-template-columns: minmax(0, 1fr);
    gap: 2px;
  }

  .entry {
    padding-left: 20px;
  }

  .keyvals li {
    grid-template-columns: minmax(0, 1fr);
    gap: 2px;
  }

  .pub {
    padding-left: 0;
  }

  .pub::before {
    position: static;
    display: block;
    margin-bottom: 4px;
  }
}

@media (max-width: 420px) {
  .intro__name {
    font-size: 26px;
  }
}

/* ============================================================== language ===
   Every translatable unit ships both variants in the DOM and the inactive one
   is hidden by CSS. `data-lang` is set on <html> in the static markup and by an
   inline bootstrap script, so the default language renders correctly with or
   without JavaScript.
   ======================================================================== */

html[data-lang="en"] [data-lang-block="zh"],
html[data-lang="zh"] [data-lang-block="en"] {
  display: none;
}

.lang-btn {
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.02em;
  line-height: 1;
}

@media print {
  [data-lang-toggle] {
    display: none !important;
  }
}
