/* ============================================================
   Guangyu Zhao — academic homepage
   Clean, neutral, content-first.
   ============================================================ */

:root {
  --bg:        #fbfaf7;
  --surface:   #ffffff;
  --text:      #1f2328;
  --muted:     #5b6470;
  --subtle:    #8a93a0;
  --line:      #e6e3dc;
  --accent:    #a23a2a;          /* PKU-ish red, but desaturated */
  --accent-50: #fcefec;
  --link:      #2e5fa1;
  --link-hov:  #1c3f72;

  --radius-sm: 6px;
  --radius:    10px;
  --radius-lg: 14px;

  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --font-serif: 'Newsreader', 'Source Serif 4', 'Iowan Old Style', 'Apple Garamond', Georgia, serif;
}

/* Dark palette — applied either via system preference (when no explicit
   override) or via [data-theme="dark"] override on <html>. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg:        #14161a;
    --surface:   #1b1e23;
    --text:      #e8eaed;
    --muted:     #a4abb6;
    --subtle:    #707683;
    --line:      #2a2e35;
    --accent:    #d77163;
    --accent-50: #2d1d1a;
    --link:      #8ab4f8;
    --link-hov:  #b9d0ff;
  }
}

:root[data-theme="dark"] {
  --bg:        #14161a;
  --surface:   #1b1e23;
  --text:      #e8eaed;
  --muted:     #a4abb6;
  --subtle:    #707683;
  --line:      #2a2e35;
  --accent:    #d77163;
  --accent-50: #2d1d1a;
  --link:      #8ab4f8;
  --link-hov:  #b9d0ff;
}

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

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a {
  color: var(--link);
  text-decoration: none;
  transition: color .15s ease;
}
a:hover { color: var(--link-hov); text-decoration: underline; }

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

/* ---------- layout ---------- */
.container {
  max-width: 920px;
  margin: 0 auto;
  padding: 56px 28px 80px;
}

.section { margin-top: 56px; }

.section h2 {
  font-family: var(--font-serif);
  font-weight: 600;
  font-size: 1.6rem;
  letter-spacing: -0.01em;
  margin: 0 0 20px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--line);
}

.section__hint {
  margin: -10px 0 18px;
  color: var(--subtle);
  font-size: 0.85rem;
}

.nowrap { white-space: nowrap; }

/* ---------- hero ---------- */
.hero {
  display: grid;
  grid-template-columns: 200px 1fr;
  gap: 36px;
  align-items: start;
}

.hero__photo img {
  width: 200px;
  height: 200px;
  object-fit: cover;
  border-radius: 50%;
  border: 3px solid var(--surface);
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.08), 0 0 0 1px var(--line);
}

.hero__text h1 {
  font-family: var(--font-serif);
  font-weight: 600;
  font-size: 2.4rem;
  letter-spacing: -0.02em;
  margin: 0 0 6px;
  line-height: 1.15;
}

.hero__cn {
  font-weight: 400;
  color: var(--muted);
  margin-left: 8px;
  font-size: 0.7em;
}

.hero__role {
  margin: 0 0 16px;
  color: var(--muted);
  font-size: 1rem;
  line-height: 1.55;
}

.hero__bio {
  margin: 0 0 18px;
  font-size: 1rem;
  line-height: 1.75;
  color: var(--text);
}

.hero__bio strong {
  font-weight: 600;
  color: var(--text);
}

.hero__links {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.hero__links a {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--text);
  font-size: 0.875rem;
  font-weight: 500;
  transition: transform .12s ease, border-color .12s ease, background .12s ease;
}

.hero__links a:hover {
  transform: translateY(-1px);
  border-color: var(--accent);
  background: var(--accent-50);
  color: var(--accent);
  text-decoration: none;
}

.hero__links svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

/* ---------- news ---------- */
.news {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 10px;
}

.news li {
  display: grid;
  grid-template-columns: 96px 1fr;
  gap: 16px;
  align-items: baseline;
  font-size: 0.95rem;
}

.news__date {
  color: var(--accent);
  font-weight: 600;
  font-size: 0.85rem;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.news__body em { font-style: italic; color: var(--text); }
.news__body strong { font-weight: 600; }

/* ---------- publications ---------- */
.pubs {
  list-style: none;
  margin: 0;
  padding: 0;
  counter-reset: pub;
  display: grid;
  gap: 24px;
}

.pub {
  display: grid;
  grid-template-columns: 260px 1fr;
  gap: 24px;
  padding: 18px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  align-items: stretch;
  transition: border-color .15s ease, transform .15s ease, box-shadow .15s ease;
}

.pub:hover {
  border-color: var(--accent);
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.05);
}

.pub__thumb {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  overflow: hidden;
  /* Belt-and-suspenders: enforces rounded clipping even on transformed
     children (Safari/WebKit overflow:hidden + border-radius edge case). */
  clip-path: inset(0 round var(--radius-sm));
  background: var(--surface);
  border: none;
  /* Height tracks the publication entry: top of image aligns with the
     title's top; bottom aligns with the bottom of the links row. */
  height: 100%;
  min-height: 100%;
}

/* Image always fills container width (no horizontal crop). Vertically:
   - if the scaled image is taller than the box, the middle slice is shown
     (flex align-items:center overflows top and bottom equally);
   - if shorter, it's centered vertically inside the box. */
.pub__thumb img {
  width: 100%;
  height: auto;
  flex-shrink: 0;
  /* Rounds the image itself — important for short images that don't fill the
     container vertically, where the container's clip mask wouldn't show. */
  border-radius: var(--radius-sm);
  transition: transform .25s ease;
}

.pub__thumb:hover img {
  transform: scale(1.03);
}

.pub__body { min-width: 0; }

.pub__title {
  margin: 0 0 8px;
  font-family: var(--font-serif);
  font-size: 1.12rem;
  font-weight: 600;
  line-height: 1.35;
  letter-spacing: -0.005em;
}

.pub__title a {
  color: var(--text);
}

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

.pub__authors {
  margin: 0 0 10px;
  font-size: 0.92rem;
  color: var(--muted);
  line-height: 1.55;
}

.pub__authors strong {
  color: var(--text);
  font-weight: 600;
}

.pub__venue {
  margin: 0 0 10px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.venue {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  border: 1px solid transparent;
}

.venue--accepted {
  background: var(--accent-50);
  color: var(--accent);
  border-color: var(--accent);
}

.venue--review {
  background: transparent;
  color: var(--muted);
  border-color: var(--line);
}

.venue--award {
  background: #fff8e1;
  color: #8a6d2a;
  border-color: #f0e2b4;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .venue--award {
    background: #2d2616;
    color: #e8c980;
    border-color: #4a3e22;
  }
}

:root[data-theme="dark"] .venue--award {
  background: #2d2616;
  color: #e8c980;
  border-color: #4a3e22;
}

.pub__links {
  margin: 0;
  font-size: 0.88rem;
  color: var(--muted);
}

.pub__links a {
  color: var(--link);
  font-weight: 500;
}

.pub__links .dot {
  margin: 0 4px;
  color: var(--subtle);
}

/* ---------- entry cards (experience / education) ---------- */
.entry-cards {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 16px;
}

.entry-card {
  display: grid;
  grid-template-columns: 140px 1fr;
  gap: 22px;
  padding: 16px 18px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  align-items: stretch;
  transition: border-color .15s ease, box-shadow .15s ease;
}

.entry-card:hover {
  border-color: var(--accent);
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.05);
}

.entry-card__logo {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  background: var(--surface);
  height: 100%;
  min-height: 0;
}

/* Image fills width and is vertically centered (same behavior as paper
   thumbnails, but no rounded corners). */
.entry-card__logo img {
  width: 100%;
  height: auto;
  flex-shrink: 0;
  display: block;
}

.entry-card__body {
  min-width: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.entry-card__date {
  margin: 0 0 4px;
  font-size: 0.82rem;
  font-weight: 500;
  letter-spacing: 0.02em;
  color: var(--muted);
}

.entry-card__title {
  margin: 0 0 4px;
  font-family: var(--font-serif);
  font-size: 1.08rem;
  font-weight: 600;
  line-height: 1.35;
  letter-spacing: -0.005em;
  color: var(--text);
}

.entry-card__where {
  margin: 0;
  font-size: 0.92rem;
  color: var(--muted);
}

/* ---------- timeline (talks/experience/awards/education) ---------- */
.timeline {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 14px;
}

.timeline li {
  display: grid;
  grid-template-columns: 200px 1fr;
  gap: 20px;
  align-items: baseline;
  padding-bottom: 14px;
  border-bottom: 1px dashed var(--line);
  font-size: 0.96rem;
}

.timeline li:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.timeline__date {
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 500;
  letter-spacing: 0.02em;
}

.timeline__body strong {
  color: var(--text);
  font-weight: 600;
}

.timeline__where {
  color: var(--muted);
}

/* ---------- footer ---------- */
.footer {
  margin-top: 72px;
  padding-top: 24px;
  border-top: 1px solid var(--line);
  font-size: 0.82rem;
  color: var(--subtle);
  text-align: center;
}

/* ---------- theme toggle (sliding pill switch) ---------- */
.theme-toggle {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 50;
  width: 60px;
  height: 30px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  cursor: pointer;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.06);
  transition: border-color .15s ease, background .15s ease;
  -webkit-tap-highlight-color: transparent;
}

.theme-toggle:hover { border-color: var(--accent); }

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

.theme-toggle__knob {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: linear-gradient(135deg, #ffd86b 0%, #ff9d3a 100%);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.18);
  transition: left .28s cubic-bezier(.4, .2, .2, 1), background .25s ease;
  z-index: 1;
}

.theme-toggle__icon {
  position: absolute;
  top: 50%;
  width: 14px;
  height: 14px;
  transform: translateY(-50%);
  pointer-events: none;
  z-index: 2;
  transition: color .2s ease, opacity .2s ease;
}

.theme-toggle__icon--sun  { left: 8px; }
.theme-toggle__icon--moon { right: 8px; }

/* Default (light) — knob on the left, sun bright, moon dim */
.theme-toggle__icon--sun  { color: #6b3f12; opacity: 1; }
.theme-toggle__icon--moon { color: var(--subtle); opacity: .55; }

/* Explicit dark — knob slides right, moon bright, sun dim */
:root[data-theme="dark"] .theme-toggle__knob {
  left: calc(100% - 26px);
  background: linear-gradient(135deg, #d3d8e5 0%, #6a7186 100%);
}
:root[data-theme="dark"] .theme-toggle__icon--sun  { color: var(--subtle); opacity: .55; }
:root[data-theme="dark"] .theme-toggle__icon--moon { color: #1e2230; opacity: 1; }

/* OS dark with no explicit override */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-toggle__knob {
    left: calc(100% - 26px);
    background: linear-gradient(135deg, #d3d8e5 0%, #6a7186 100%);
  }
  :root:not([data-theme="light"]) .theme-toggle__icon--sun  { color: var(--subtle); opacity: .55; }
  :root:not([data-theme="light"]) .theme-toggle__icon--moon { color: #1e2230; opacity: 1; }
}

/* ---------- responsive ---------- */
@media (max-width: 760px) {
  .container { padding: 36px 20px 60px; }

  .hero {
    grid-template-columns: 1fr;
    gap: 24px;
    text-align: center;
  }

  .hero__photo { justify-self: center; }
  .hero__photo img { width: 160px; height: 160px; }

  .hero__text h1 { font-size: 2rem; }

  .hero__bio { text-align: left; }

  .hero__links { justify-content: center; }

  .pub {
    grid-template-columns: 1fr;
    gap: 14px;
    padding: 16px;
  }
  .pub__thumb { aspect-ratio: 16 / 9; }

  .entry-card {
    grid-template-columns: 100px 1fr;
    gap: 16px;
    padding: 14px;
  }

  .news li,
  .timeline li {
    grid-template-columns: 1fr;
    gap: 4px;
  }
  .news__date,
  .timeline__date { font-size: 0.78rem; }

  .section h2 { font-size: 1.4rem; }
}

@media (max-width: 420px) {
  .hero__text h1 { font-size: 1.7rem; }
  .hero__cn { display: block; margin-left: 0; margin-top: 4px; font-size: 1rem; }
}
