/* Homepage of Yuzhuo Li.
   Two schemes: light (white/black) and dark (#1c1c1d/#e8e8e8). The accent is University of Auckland blue.
   The theme is set on <html data-theme> by the inline script in each page's <head>. */

:root {
  --bg: #fff;
  --text: #000;
  --text-muted: #666;
  --accent: #0a5ea8;
  --accent-hover: #00467f;
  --tag-bg: #00467f;
  --divider: rgba(0, 0, 0, 0.1);
  --box-border: #ddd;
  --code-bg: #f5f7fa;
  --figure-bg: #fff;
  --footer-bg: #1c1c1d;
  --footer-text: #e8e8e8;
  --shadow: 0 2px 5px 0 rgba(0, 0, 0, 0.16), 0 2px 10px 0 rgba(0, 0, 0, 0.12);
  --scroll-thumb: #c1c1c1;
  --scroll-track: #f3f3f3;
  --nav-h: 56px;
  --footer-h: 35px;
  color-scheme: light;
}

html[data-theme="dark"] {
  --bg: #1c1c1d;
  --text: #e8e8e8;
  --text-muted: #a3a3a3;
  --accent: #6cb4ee;
  --accent-hover: #9ccdf5;
  --tag-bg: #1d5f99;
  --divider: #424246;
  --box-border: #424246;
  --code-bg: #26292d;
  --figure-bg: #f2f2f2;
  --footer-bg: #e8e8e8;
  --footer-text: #1c1c1d;
  --scroll-thumb: #55555a;
  --scroll-track: #26262a;
  color-scheme: dark;
}

/* Without JavaScript there is no data-theme attribute, so fall back to the system setting. */
@media (prefers-color-scheme: dark) {
  html:not([data-theme]) {
    --bg: #1c1c1d;
    --text: #e8e8e8;
    --text-muted: #a3a3a3;
    --accent: #6cb4ee;
    --accent-hover: #9ccdf5;
    --tag-bg: #1d5f99;
    --divider: #424246;
    --box-border: #424246;
    --code-bg: #26292d;
    --figure-bg: #f2f2f2;
    --footer-bg: #e8e8e8;
    --footer-text: #1c1c1d;
    --scroll-thumb: #55555a;
    --scroll-track: #26262a;
    color-scheme: dark;
  }
}

/* ---------- Base ---------- */

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

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

body {
  margin: 0;
  padding: calc(var(--nav-h) + 40px) 0 calc(var(--footer-h) + 48px);
  background: var(--bg);
  color: var(--text);
  font-family: "Roboto", -apple-system, "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  font-size: 16px;
  font-weight: 300;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  transition: background-color 0.2s, color 0.2s;
}

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

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

b, strong { font-weight: 500; }

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

.container {
  width: 100%;
  max-width: 1080px;
  margin: 0 auto;
  padding: 0 15px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.icon {
  width: 1em;
  height: 1em;
  fill: currentColor;
  vertical-align: -0.125em;
}

/* ---------- Navigation bar ---------- */

.navbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  height: var(--nav-h);
  border-bottom: 1px solid var(--divider);
  background: var(--bg);
  transition: background-color 0.2s;
}

.navbar .container {
  display: flex;
  align-items: center;
  height: 100%;
}

.brand {
  margin-right: auto;
  font-size: 1.25rem;
  font-weight: 400;
  color: var(--text);
  white-space: nowrap;
}

.brand:hover {
  color: var(--text);
  text-decoration: none;
}

.nav-links {
  display: flex;
  align-items: center;
  margin-left: auto;
}

.nav-links a {
  padding: 8px 10px;
  font-weight: 400;
  color: var(--text);
}

.nav-links a:hover,
.nav-links a[aria-current="page"] {
  color: var(--accent);
  text-decoration: none;
}

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 0;
  border-radius: 4px;
  background: none;
  color: var(--text);
  font-size: 18px;
  cursor: pointer;
}

.icon-btn:hover { color: var(--accent); }

.theme-toggle { margin-left: 6px; }

.theme-toggle .icon-sun { display: none; }
html[data-theme="dark"] .theme-toggle .icon-sun { display: inline; }
html[data-theme="dark"] .theme-toggle .icon-moon { display: none; }

.nav-toggle { display: none; }

@media (max-width: 575.98px) {
  .nav-toggle {
    display: inline-grid;
    margin-left: 4px;
  }

  .nav-links {
    display: none;
    position: absolute;
    top: var(--nav-h);
    left: 0;
    right: 0;
    flex-direction: column;
    align-items: stretch;
    padding: 6px 15px 12px;
    border-bottom: 1px solid var(--divider);
    background: var(--bg);
  }

  .navbar.nav-open .nav-links { display: flex; }

  .nav-links a { padding: 10px 0; }

  .theme-toggle { margin: 4px 0 0 -8px; }
}

/* ---------- Page headers ---------- */

.post-header { margin-bottom: 24px; }

.post-title {
  margin: 0;
  font-size: 2.5rem;
  font-weight: 300;
  line-height: 1.2;
}

.post-description {
  margin: 4px 0 0;
  font-size: 0.875rem;
}

.desc { margin: 8px 0 0; }

h2 {
  margin: 40px 0 16px;
  font-size: 2rem;
  font-weight: 300;
  line-height: 1.2;
}

h2 a,
h2 a:hover { color: inherit; }

h2 .full-list {
  margin-left: 8px;
  font-size: 0.6em;
  color: var(--accent);
}

h2 .full-list:hover { color: var(--accent-hover); }

/* ---------- About ---------- */

.profile {
  float: right;
  width: 22%;
  max-width: 225px;
  margin: 4px 0 16px 32px;
}

.profile img {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 50%;
  box-shadow: var(--shadow);
}

.bio p { margin: 0 0 16px; }

.bio ul {
  margin: 0 0 16px;
  padding-left: 1.4em;
}

.bio li { margin-bottom: 2px; }

.clearfix::after {
  content: "";
  display: table;
  clear: both;
}

.social {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px 28px;
  margin: 28px 0 0;
  padding: 0;
  list-style: none;
  font-size: 2.1rem;
}

.social a {
  display: block;
  color: var(--text);
  line-height: 1;
}

.social a:hover { color: var(--accent); }

/* ---------- Scrolling boxes (News, Papers) ---------- */

.scroll-box {
  overflow-y: auto;
  scrollbar-gutter: stable;
}

.scroll-box::-webkit-scrollbar { width: 10px; }
.scroll-box::-webkit-scrollbar-track { background: var(--scroll-track); }

.scroll-box::-webkit-scrollbar-thumb {
  border: 2px solid var(--scroll-track);
  border-radius: 6px;
  background: var(--scroll-thumb);
}

/* Firefox has no ::-webkit-scrollbar; give it the standard properties instead. */
@supports not selector(::-webkit-scrollbar) {
  .scroll-box { scrollbar-color: var(--scroll-thumb) var(--scroll-track); }
}

.news-box { max-height: 300px; }

.news table {
  width: 100%;
  border-collapse: collapse;
}

.news th,
.news td {
  padding: 9px 5px;
  vertical-align: top;
  text-align: left;
}

.news th {
  width: 12%;
  min-width: 92px;
  font-weight: 300;
  white-space: nowrap;
}

/* Short enough that the list scrolls (with its bar on the right) even while there are only a few papers. */
.papers-box {
  max-height: 420px;
  margin-top: 15px;
  padding: 14px 14px 0;
  border: 1px solid var(--box-border);
}

/* ---------- Publication entries ---------- */

.pubs {
  margin: 0;
  padding: 0;
  list-style: none;
}

.pub {
  display: flex;
  align-items: flex-start;
  gap: 24px;
  margin-bottom: 22px;
}

.pub-fig {
  flex: none;
  display: grid;
  place-items: center;
  width: 180px;
  height: 100px;
  padding: 6px;
  border: 1px solid var(--box-border);
  border-radius: 4px;
  background: var(--figure-bg);
  cursor: zoom-in;
}

.pub-fig img {
  display: block;
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
}

.pub-body {
  flex: 1;
  min-width: 0;
}

.pub-title { font-weight: 500; }

.venue-tag {
  display: inline-block;
  margin-right: 8px;
  padding: 0 6px;
  border-radius: 3px;
  background: var(--tag-bg);
  color: #fff;
  font-size: 12px;
  font-weight: 500;
  line-height: 20px;
  vertical-align: 1px;
  white-space: nowrap;
}

.pub-authors .me { font-weight: 500; }

.pub-venue { color: var(--text-muted); }

.pub-links {
  display: flex;
  flex-wrap: wrap;
  margin: 4px 0 0;
  padding: 0;
  list-style: none;
}

/* The separator trails each item, so a wrapped row never starts with a slash. */
.pub-links li:not(:last-child)::after {
  content: "/";
  margin: 0 0.5em;
  color: var(--text-muted);
}

.link-btn {
  padding: 0;
  border: 0;
  background: none;
  color: var(--accent);
  font: inherit;
  cursor: pointer;
}

.link-btn:hover,
.link-btn[aria-expanded="true"] {
  color: var(--accent-hover);
  text-decoration: underline;
}

.abstract,
.bibtex { margin-top: 10px; }

.abstract p {
  margin: 0;
  padding: 8px 12px;
  border-left: 3px solid var(--box-border);
  font-size: 0.95rem;
}

.bibtex { position: relative; }

.bibtex pre {
  margin: 0;
  padding: 10px 12px;
  overflow-x: auto;
  border-radius: 4px;
  background: var(--code-bg);
  font: 0.78rem/1.55 ui-monospace, "Cascadia Mono", SFMono-Regular, Menlo, Consolas, monospace;
  white-space: pre;
}

.copy {
  position: absolute;
  top: 6px;
  right: 6px;
  padding: 1px 8px;
  border: 1px solid var(--box-border);
  border-radius: 3px;
  background: var(--bg);
  color: var(--text-muted);
  font: 400 0.72rem "Roboto", sans-serif;
  cursor: pointer;
}

.copy:hover { color: var(--text); }

/* Year headings on the full list */
h2.year {
  margin: 36px 0 18px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--divider);
  font-size: 1.5rem;
  font-weight: 400;
}

.post-header + h2.year { margin-top: 8px; }

@media (max-width: 575.98px) {
  .pub {
    flex-direction: column;
    gap: 10px;
  }

  .pub-fig {
    width: 100%;
    max-width: 320px;
    height: 150px;
  }
}

/* ---------- Simple lists: Services, Teaching ---------- */

.plain-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.plain-list li { margin-bottom: 12px; }

.plain-list .when { font-weight: 400; }

/* ---------- CV ---------- */

.cv-item { margin-bottom: 20px; }

.cv-head {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0 16px;
}

.cv-title { font-weight: 500; }

.cv-date {
  color: var(--text-muted);
  white-space: nowrap;
}

.cv-sub { color: var(--text-muted); }

.cv-item ul {
  margin: 4px 0 0;
  padding-left: 1.3em;
}

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

.footer {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  height: var(--footer-h);
  background: var(--footer-bg);
  color: var(--footer-text);
  font-size: 12px;
  text-align: center;
}

.footer a { color: inherit; }

/* ---------- Figure zoom ---------- */

.zoom-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(0, 0, 0, 0.8);
  cursor: zoom-out;
}

.zoom-overlay[hidden] { display: none; }

.zoom-overlay img {
  max-width: min(1400px, 100%);
  max-height: 100%;
  border-radius: 4px;
  background: #fff;
}

/* ---------- Small screens ---------- */

@media (max-width: 767.98px) {
  body { padding-top: calc(var(--nav-h) + 24px); }

  .post-title { font-size: 2.1rem; }

  .profile {
    float: none;
    width: 160px;
    margin: 0 auto 24px;
  }

  h2 { font-size: 1.75rem; }

  .news th { width: auto; }
}

@media (prefers-reduced-motion: reduce) {
  body, .navbar { transition: none; }
}

@media print {
  .navbar, .footer, .pub-links, .theme-toggle, .zoom-overlay { display: none !important; }

  body { padding: 0; }

  .scroll-box {
    max-height: none;
    overflow: visible;
  }
}
