/* ==========================================================================
   Academic Personal Website — Zihan Zhao (University of Virginia)
   ========================================================================== */

:root {
  --bg: #ffffff;
  --bg-page: #fafbfc;
  --bg-subtle: #f5f7fa;
  --bg-hover: #f7f9fc;
  --bg-code: #f5f7fa;
  --text: #1a2028;
  --text-muted: #576270;
  --border: #e5e9ef;
  --border-strong: #cdd5df;

  /* Restrained UVA-inspired academic palette */
  --uva-navy: #232d4b;
  --uva-navy-soft: rgba(35, 45, 75, 0.08);
  --link: #224b82;
  --link-underline: rgba(34, 75, 130, 0.28);
  --accent-warm: #cc5d14;
  --accent-warm-soft: rgba(204, 93, 20, 0.1);

  --venue-bg: #eef2f8;
  --venue-text: #232d4b;
  --preprint-bg: #f3f4f6;
  --preprint-text: #4b5563;

  --shadow-photo: 0 10px 26px rgba(35, 45, 75, 0.09);

  --font-serif: "Newsreader", Georgia, "Times New Roman", serif;
  --font-sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

  --max-width: 960px;
  --radius: 7px;
}

[data-theme="dark"] {
  --bg: #10141a;
  --bg-page: #10141a;
  --bg-subtle: #171c24;
  --bg-hover: #161b23;
  --bg-code: #151a22;
  --text: #e7ecf2;
  --text-muted: #98a3b3;
  --border: #242b36;
  --border-strong: #374152;

  --uva-navy: #e8edf5;
  --uva-navy-soft: rgba(124, 176, 236, 0.14);
  --link: #7db2ef;
  --link-underline: rgba(125, 178, 239, 0.34);
  --accent-warm: #f0954f;
  --accent-warm-soft: rgba(240, 149, 79, 0.15);

  --venue-bg: rgba(125, 178, 239, 0.14);
  --venue-text: #a5ccf6;
  --preprint-bg: rgba(152, 163, 179, 0.14);
  --preprint-text: #b7c0ce;

  --shadow-photo: 0 10px 28px rgba(0, 0, 0, 0.38);
}

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

html {
  scroll-behavior: smooth;
  scroll-padding-top: 4.75rem;
}

body {
  margin: 0;
  background-color: var(--bg);
  background-image: radial-gradient(
    ellipse 90% 420px at 50% -140px,
    var(--uva-navy-soft),
    transparent 70%
  );
  background-repeat: no-repeat;
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 15.5px;
  line-height: 1.66;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a {
  color: var(--link);
  text-decoration: underline;
  text-decoration-color: var(--link-underline);
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
  transition: color 0.15s ease, text-decoration-color 0.15s ease, border-color 0.15s ease, background-color 0.15s ease;
}

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

a:focus-visible,
button:focus-visible {
  outline: 2px solid var(--link);
  outline-offset: 2px;
  border-radius: 4px;
}

code {
  font-family: var(--font-mono);
  font-size: 0.86em;
}

/* Layout container */
.container {
  width: 100%;
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 2rem;
}

/* Header & Navigation */
.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  background-color: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}

.header-accent-bar {
  height: 3px;
  width: 100%;
  background: linear-gradient(90deg, #232d4b 0%, #232d4b 76%, #d96b27 100%);
}

[data-theme="dark"] .header-accent-bar {
  background: linear-gradient(90deg, #3c5385 0%, #3c5385 74%, #e58844 100%);
}

.header-inner {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  min-height: 3.6rem;
}

.site-brand {
  margin-right: auto;
  font-family: var(--font-serif);
  font-size: 1.18rem;
  font-weight: 500;
  letter-spacing: -0.01em;
  color: var(--uva-navy);
  text-decoration: none;
  white-space: nowrap;
}

.site-brand:hover {
  color: var(--accent-warm);
}

.site-nav {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  flex-wrap: wrap;
}

.site-nav a {
  position: relative;
  padding: 0.2rem 0;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-muted);
  text-decoration: none;
}

.site-nav a::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: -2px;
  height: 2px;
  border-radius: 2px;
  background-color: var(--accent-warm);
  transform: scaleX(0);
  transform-origin: center;
  transition: transform 0.18s ease;
}

.site-nav a:hover,
.site-nav a.is-active {
  color: var(--text);
}

.site-nav a.is-active::after {
  transform: scaleX(1);
}

.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--text-muted);
  cursor: pointer;
  transition: border-color 0.15s ease, color 0.15s ease, background-color 0.15s ease;
}

.theme-toggle:hover {
  color: var(--text);
  border-color: var(--border-strong);
  background-color: var(--bg-subtle);
}

.theme-toggle .icon-sun {
  display: none;
}

[data-theme="dark"] .theme-toggle .icon-sun {
  display: block;
}

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

/* Hero / About */
.hero {
  padding: 2.5rem 0 1.65rem;
}

.hero-top {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 216px;
  gap: 2.75rem;
  align-items: start;
}

.hero-name {
  margin: 0 0 0.4rem;
  font-family: var(--font-serif);
  font-size: clamp(2.2rem, 4vw, 2.75rem);
  font-weight: 500;
  line-height: 1.12;
  letter-spacing: -0.02em;
  color: var(--uva-navy);
}

.hero-affiliation {
  margin: 0 0 1.15rem;
  font-size: 0.96rem;
  color: var(--text-muted);
  line-height: 1.5;
}

.affiliation-sep {
  margin: 0 0.35rem;
  opacity: 0.65;
}

.hero-bio p {
  margin: 0 0 0.85rem;
}

.hero-bio p:last-child {
  margin-bottom: 0;
}

.hero-aside {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-top: 0.3rem;
}

.hero-photo {
  margin: 0;
}

.hero-photo img {
  display: block;
  width: 216px;
  height: 216px;
  object-fit: cover;
  border-radius: 12px;
  border: 1px solid var(--border);
  background-color: var(--bg-subtle);
  box-shadow: var(--shadow-photo);
}

/* Personal link pills (2x2 grid under portrait) */
.profile-links {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.45rem;
  list-style: none;
  margin: 0;
  padding: 0;
}

.profile-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.36rem;
  width: 100%;
  padding: 0.34rem 0.5rem;
  font-size: 0.81rem;
  font-weight: 500;
  color: var(--text);
  background-color: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: 7px;
  text-decoration: none;
  white-space: nowrap;
  transition: color 0.15s ease, border-color 0.15s ease, background-color 0.15s ease, transform 0.15s ease;
}

.profile-pill svg {
  color: var(--text-muted);
  flex-shrink: 0;
  transition: color 0.15s ease;
}

.profile-pill:hover {
  color: var(--accent-warm);
  border-color: color-mix(in srgb, var(--accent-warm) 45%, var(--border));
  background-color: var(--bg);
  transform: translateY(-1px);
}

.profile-pill:hover svg {
  color: var(--accent-warm);
}

/* Education panel inside About */
.hero-education {
  margin-top: 1.55rem;
  padding: 1.15rem 1.4rem;
  background-color: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: 10px;
}

.timeline-compact {
  gap: 0.75rem;
}

/* Sections */
.section {
  padding: 1.7rem 0;
  border-top: 1px solid var(--border);
}

.section-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.05rem;
  flex-wrap: wrap;
}

.section-title {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  margin: 0 0 0.95rem;
  font-family: var(--font-serif);
  font-size: 1.55rem;
  font-weight: 500;
  letter-spacing: -0.012em;
  color: var(--uva-navy);
}

.section-title::before {
  content: "";
  display: inline-block;
  width: 3px;
  height: 1.05em;
  border-radius: 2px;
  background-color: var(--accent-warm);
}

@keyframes sectionHeadingPulse {
  0% {
    background-color: var(--accent-warm-soft);
  }
  100% {
    background-color: transparent;
  }
}

.section-flash .section-title {
  border-radius: 6px;
  padding-right: 0.45rem;
  animation: sectionHeadingPulse 0.9s ease-out;
}

.section-header .section-title {
  margin-bottom: 0.22rem;
}

.section-note {
  margin: 0;
  font-size: 0.875rem;
  color: var(--text-muted);
}

/* News list (retained for when re-enabled) */
.news-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.news-list li {
  display: grid;
  grid-template-columns: 88px minmax(0, 1fr);
  gap: 1rem;
  align-items: baseline;
}

.news-date {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.news-text {
  font-size: 0.94rem;
}

/* Publication filters */
.pub-filters {
  display: inline-flex;
  padding: 2px;
  background-color: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.filter-btn {
  padding: 0.25rem 0.78rem;
  border: 0;
  border-radius: 5px;
  background: transparent;
  color: var(--text-muted);
  font-family: var(--font-sans);
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
}

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

.filter-btn.is-active {
  background-color: var(--bg);
  color: var(--text);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
}

/* Publications */
.pub-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.pub-item {
  scroll-margin-top: 5rem;
  padding: 0.9rem 1.15rem;
  border-left: 2.5px solid var(--border);
  border-radius: 0 8px 8px 0;
  transition: background-color 0.16s ease, border-left-color 0.16s ease;
}

.pub-item:hover {
  background-color: var(--bg-hover);
  border-left-color: var(--accent-warm);
}

.pub-item[hidden] {
  display: none;
}

.pub-title {
  font-weight: 600;
  font-size: 1.02rem;
  line-height: 1.42;
  margin-bottom: 0.28rem;
}

.pub-title a {
  color: var(--text);
  text-decoration: none;
}

.pub-title a:hover {
  color: var(--accent-warm);
  text-decoration: underline;
  text-decoration-color: var(--accent-warm);
}

.pub-authors {
  font-size: 0.91rem;
  line-height: 1.55;
  color: var(--text-muted);
  margin-bottom: 0.35rem;
}

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

.pub-venue {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.55rem;
  font-size: 0.89rem;
  color: var(--text-muted);
  font-style: italic;
  margin-bottom: 0.6rem;
}

.venue-badge {
  font-style: normal;
  font-family: var(--font-mono);
  font-size: 0.73rem;
  font-weight: 500;
  letter-spacing: 0.01em;
  padding: 0.14rem 0.52rem;
  border-radius: 5px;
  background-color: var(--venue-bg);
  color: var(--venue-text);
}

.venue-badge-preprint {
  background-color: var(--preprint-bg);
  color: var(--preprint-text);
}

.pub-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  align-items: center;
}

.pub-actions a,
.bib-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.32rem;
  padding: 0.2rem 0.6rem;
  font-family: var(--font-mono);
  font-size: 0.76rem;
  line-height: 1.4;
  color: var(--text-muted);
  background-color: var(--bg);
  border: 1px solid var(--border);
  border-radius: 5px;
  text-decoration: none;
  cursor: pointer;
  transition: color 0.15s ease, border-color 0.15s ease, background-color 0.15s ease;
}

.pub-actions a:hover,
.bib-toggle:hover,
.bib-toggle[aria-expanded="true"] {
  color: var(--accent-warm);
  border-color: color-mix(in srgb, var(--accent-warm) 45%, var(--border));
  background-color: var(--bg-subtle);
}

/* BibTeX drawer */
.bibtex-box {
  position: relative;
  margin-top: 0.7rem;
  padding: 0.9rem 1.05rem;
  background-color: var(--bg-code);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.bibtex-box pre {
  margin: 0;
  overflow-x: auto;
  font-size: 0.8rem;
  line-height: 1.5;
  color: var(--text);
  padding-right: 3.5rem;
}

.copy-btn {
  position: absolute;
  top: 0.55rem;
  right: 0.55rem;
  padding: 0.2rem 0.56rem;
  font-family: var(--font-sans);
  font-size: 0.74rem;
  font-weight: 500;
  color: var(--text-muted);
  background-color: var(--bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  cursor: pointer;
  transition: color 0.15s ease, border-color 0.15s ease;
}

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

/* Education, Experience & Teaching Timelines */
.subsection-title {
  margin: 0 0 0.7rem;
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.timeline-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.95rem;
}

.timeline-rail {
  position: relative;
  padding-left: 1.25rem;
}

.timeline-rail .timeline-item {
  position: relative;
}

.timeline-rail .timeline-item:not(:last-child)::after {
  content: "";
  position: absolute;
  left: calc(-1.25rem + 3px);
  top: 0.95rem;
  bottom: calc(-0.95rem - 0.5rem);
  width: 1px;
  background-color: var(--border);
}

.timeline-rail .timeline-item::before {
  content: "";
  position: absolute;
  left: -1.25rem;
  top: 0.5rem;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background-color: var(--bg);
  border: 2px solid var(--uva-navy);
  z-index: 1;
}

.timeline-item {
  display: flex;
  flex-direction: column;
  gap: 0.14rem;
}

.timeline-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1.25rem;
  font-size: 0.95rem;
}

.timeline-org {
  min-width: 0;
}

.timeline-sub {
  font-size: 0.88rem;
  color: var(--text-muted);
}

.timeline-location {
  text-align: right;
  white-space: nowrap;
}

.timeline-date {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--text-muted);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

/* Footer */
.site-footer {
  margin-top: 0.75rem;
  border-top: 1px solid var(--border);
  padding: 1.45rem 0 2.25rem;
  font-size: 0.84rem;
  color: var(--text-muted);
}

.footer-inner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}

/* Responsive adjustments */
@media (max-width: 720px) {
  .container {
    padding: 0 1.25rem;
  }

  .header-inner {
    display: grid;
    grid-template-columns: 1fr auto;
    row-gap: 0.45rem;
    column-gap: 0.75rem;
    padding-top: 0.65rem;
    padding-bottom: 0.65rem;
  }

  .site-brand {
    grid-column: 1;
    grid-row: 1;
    margin-right: 0;
  }

  .theme-toggle {
    grid-column: 2;
    grid-row: 1;
  }

  .site-nav {
    grid-column: 1 / -1;
    grid-row: 2;
    gap: 0.45rem 1rem;
  }

  .site-nav a {
    font-size: 0.85rem;
  }

  .hero {
    padding: 2rem 0 1.5rem;
  }

  .hero-top {
    grid-template-columns: 1fr;
    gap: 1.5rem;
  }

  .hero-aside {
    order: -1;
    flex-direction: row;
    align-items: center;
    gap: 1.1rem;
    margin-top: 0;
  }

  .hero-photo img {
    width: 112px;
    height: 112px;
  }

  .profile-links {
    flex: 1;
    max-width: 230px;
  }

  .hero-education {
    padding: 1rem 1.1rem;
  }

  .pub-item {
    padding: 0.75rem 0.85rem;
  }

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

  .timeline-row {
    flex-direction: column;
    gap: 0.08rem;
  }

  .timeline-location {
    text-align: left;
  }
}

/* Print styles */
@media print {
  .site-header,
  .pub-filters,
  .pub-actions,
  .bibtex-box {
    display: none !important;
  }

  body {
    color: #000;
    background: #fff;
    font-size: 11pt;
  }

  .hero-education {
    background: #fff;
    border-color: #ccc;
  }

  a {
    color: #000;
    text-decoration: none;
  }
}
