/* =============================================
   Haolin (Harry) Zhang — Academic Homepage
   Minimal & clean static site
   ============================================= */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

:root {
  --bg: #ffffff;
  --bg-alt: #f8f9fa;
  --text: #333333;
  --text-light: #666666;
  --text-lighter: #999999;
  --accent: #b8860b;
  --accent-light: #e8c547;
  --link: #1a6dcc;
  --link-hover: #b8860b;
  --border: #e5e5e5;
  --border-light: #f0f0f0;
  --shadow: 0 1px 3px rgba(0,0,0,0.06);
  --shadow-md: 0 2px 8px rgba(0,0,0,0.08);
  --max-width: 780px;
  --nav-height: 56px;
  --radius: 6px;
  --transition: 0.2s ease;
}

[data-theme="dark"] {
  --bg: #1a1a2e;
  --bg-alt: #16213e;
  --text: #e0e0e0;
  --text-light: #aaaaaa;
  --text-lighter: #777777;
  --link: #6db3f2;
  --link-hover: #e8c547;
  --border: #2a2a4a;
  --border-light: #333355;
  --shadow: 0 1px 3px rgba(0,0,0,0.3);
  --shadow-md: 0 2px 8px rgba(0,0,0,0.4);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; -webkit-text-size-adjust: none; text-size-adjust: none; }

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 15px;
  line-height: 1.7;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  transition: background var(--transition), color var(--transition);
}

/* =============================================
   NAVIGATION
   ============================================= */
nav {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(10px);
  height: var(--nav-height);
}
nav .nav-inner {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 1.2rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 100%;
}
nav .nav-brand {
  font-weight: 600;
  font-size: 1rem;
  color: var(--text);
  text-decoration: none;
  letter-spacing: -0.01em;
}
nav .nav-links { display: flex; gap: 0.3rem; align-items: center; }
nav .nav-links a {
  color: var(--text-light);
  text-decoration: none;
  font-size: 0.88rem;
  font-weight: 500;
  padding: 0.35rem 0.75rem;
  border-radius: 4px;
  transition: all var(--transition);
}
nav .nav-links a:hover,
nav .nav-links a.active { color: var(--accent); background: var(--bg-alt); }

/* Theme toggle */
#theme-toggle {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-light);
  cursor: pointer;
  width: 32px; height: 32px;
  border-radius: 50%;
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-left: 0.5rem;
  transition: all var(--transition);
}
#theme-toggle:hover { color: var(--accent); border-color: var(--accent); }

/* =============================================
   MAIN CONTENT
   ============================================= */
main {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 2rem 1.2rem 4rem;
}

/* =============================================
   PROFILE / HEADER
   ============================================= */
.profile {
  display: flex;
  align-items: flex-start;
  gap: 1.8rem;
  margin-bottom: 2.5rem;
  flex-wrap: wrap;
}
.profile-photo {
  flex-shrink: 0;
  width: 160px;
  height: 190px;
  border-radius: 4px;
  object-fit: cover;
  object-position: 43% center;
  box-shadow: var(--shadow-md);
}
.profile-info { flex: 1; min-width: 0; }
.lang-zh, .lang-en { display: block; }
.profile-info h1 .lang-zh, .profile-info h1 .lang-en, h2 .lang-zh, h2 .lang-en { display: inline; }
h2 .lang-en { margin-left: 0.4rem; font-size: 0.8em; font-weight: 500; color: var(--text-light); }
.translation { color: var(--text-light); font-size: 0.86rem; }
.profile-info h1 .lang-en { font-size: 1.2rem; font-weight: 500; }
.profile-info .affiliation .lang-zh { color: var(--text-light); margin-bottom: 0.2rem; }
.news-content { min-width: 0; }
.news-content .translation { font-size: 0.82rem; }
.profile-info h1 {
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.02em;
  margin-bottom: 0.2rem;
}
.profile-info .subtitle {
  font-size: 1rem;
  color: var(--text-light);
  font-weight: 400;
  margin-bottom: 0.4rem;
}
.profile-info .affiliation {
  font-size: 0.9rem;
  color: var(--text-lighter);
}

/* Social Icons */
.social-icons {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.6rem;
  flex-wrap: wrap;
}
.social-icons a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--bg-alt);
  color: var(--text-light);
  text-decoration: none;
  font-size: 0.85rem;
  transition: all var(--transition);
  border: 1px solid transparent;
}
.social-icons a:hover {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
  transform: translateY(-1px);
}

/* =============================================
   SECTIONS
   ============================================= */
section { margin-bottom: 2.5rem; padding-top: 0.5rem; }

h2 {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 2px solid var(--border-light);
  letter-spacing: -0.01em;
}
h3 {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 0.4rem;
}

p { margin-bottom: 0.8rem; color: var(--text-light); }

a { color: var(--link); text-decoration: none; transition: color var(--transition); }
a:hover { color: var(--link-hover); }

/* =============================================
   EDUCATION / TIMELINE ITEMS
   ============================================= */
.timeline-item {
  display: flex;
  gap: 1rem;
  margin-bottom: 1.2rem;
  padding-bottom: 1.2rem;
  border-bottom: 1px solid var(--border-light);
}
.timeline-item:last-child { border-bottom: none; padding-bottom: 0; }
.timeline-year {
  flex-shrink: 0;
  width: 90px;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--accent);
  padding-top: 0.15rem;
}
.timeline-year .translation { font-size: 0.72rem; white-space: nowrap; }
.timeline-content { flex: 1; }
.timeline-content h4 {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 0.15rem;
}
.timeline-content .meta {
  font-size: 0.85rem;
  color: var(--text-lighter);
  margin-bottom: 0.3rem;
}
.timeline-content p {
  font-size: 0.88rem;
  color: var(--text-light);
  line-height: 1.6;
}
.education-item { display: grid; grid-template-columns: 90px 200px minmax(0, 1fr); align-items: start; }
.education-logo {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 200px;
  max-width: 100%;
  min-height: 50px;
  padding: 8px;
  border: 0;
  border-radius: var(--radius);
  background: #fff;
}
.education-logo img { display: block; width: 100%; height: auto; object-fit: contain; }
.education-logo:focus-visible { outline: 2px solid var(--link); outline-offset: 3px; }
.education-logos { display: flex; flex-direction: column; gap: 0.4rem; }
.education-car img { width: auto; max-width: 100%; height: 100px; }
.education-iair { background: #fff; }
.education-iair img { height: auto; object-fit: contain; }


.experience-header { display: grid; grid-template-columns: minmax(0, 1fr) 96px; gap: 1rem; align-items: start; }
.experience-portrait { display: block; width: 96px; }
.experience-portrait img { display: block; width: 100%; height: auto; border-radius: 4px; }
.company-profile { padding: 0.65rem 0.8rem; margin-bottom: 0.85rem; background: var(--bg-alt); border-left: 2px solid var(--border); font-size: 0.8rem; }
.company-profile p { margin-bottom: 0.3rem; }
.company-profile p:last-child { margin-bottom: 0; }

.company-logos { display: flex; flex-wrap: wrap; gap: 0.6rem; margin: 0.65rem 0 0.8rem; }
.company-logo {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 140px;
  height: 64px;
  padding: 10px;
  border: 0;
  border-radius: var(--radius);
  background: #fff;
}
.company-logo img { display: block; max-width: 100%; max-height: 100%; object-fit: contain; }
.company-logo-square { overflow: hidden; }
.company-logo-square img { width: 100%; max-height: none; }
.company-logo:focus-visible { outline: 2px solid var(--link); outline-offset: 3px; }
.institute-logo { width: 200px; max-width: 100%; height: auto; min-height: 64px; }
.institute-logo img { width: 100%; height: auto; max-height: none; }

.joint-institute-logo { width: 100%; max-width: 480px; height: auto; min-height: 64px; padding: 14px; background: #15395b; border: 1px solid rgba(255, 255, 255, 0.75); box-shadow: 0 2px 8px rgba(21, 57, 91, 0.12); }
.joint-institute-logo img { width: 100%; height: auto; }

[data-theme="dark"] .education-logo,
[data-theme="dark"] .company-logo { box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.45), 0 2px 12px rgba(255, 255, 255, 0.12); }

/* =============================================
   PUBLICATIONS
   ============================================= */
.pub-list { list-style: none; }

.pub-item {
  padding: 0.9rem 0;
  border-bottom: 1px solid var(--border-light);
  transition: background var(--transition);
}
.pub-item:last-child { border-bottom: none; }

.pub-item .pub-title {
  font-weight: 600;
  font-size: 0.93rem;
  color: var(--text);
  margin-bottom: 0.2rem;
}
.pub-item .pub-authors {
  font-size: 0.84rem;
  color: var(--text-light);
  margin-bottom: 0.15rem;
}
.pub-item .pub-venue {
  font-size: 0.82rem;
  color: var(--text-lighter);
  font-style: italic;
}
.pub-item .pub-links {
  margin-top: 0.25rem;
  font-size: 0.8rem;
  overflow-wrap: anywhere;
}
.publications-page main, .publications-page .nav-inner { max-width: 1080px; }
.pub-card {
  display: grid;
  grid-template-columns: 210px minmax(0, 1fr);
  align-items: start;
  gap: 1.5rem;
  padding: 1.5rem 0;
}
.pub-content { min-width: 0; }
.pub-title-translation { font-size: 0.84rem; color: var(--text-light); margin-bottom: 0.3rem; }
.pub-contribution { margin: 0.6rem 0; font-size: 0.82rem; }
.pub-contribution p { margin-bottom: 0.15rem; }
.pub-thumbnail {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  aspect-ratio: 3 / 2;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #fff;
}
.pub-thumbnail img { display: block; width: 100%; height: 100%; object-fit: contain; }
.pub-thumbnail:focus-visible, .pub-actions a:focus-visible { outline: 2px solid var(--link); outline-offset: 3px; }
.pub-book .pub-thumbnail { width: 155px; max-width: 100%; aspect-ratio: 774 / 1000; margin: 0 auto; }
.pub-item .pub-actions { display: flex; flex-wrap: wrap; gap: 0.45rem; margin-top: 0.55rem; }
.pub-actions a {
  display: inline-block;
  padding: 0.25rem 0.65rem;
  border: 1px solid var(--border);
  border-radius: 3px;
  background: var(--bg-alt);
  font-weight: 500;
}
.pub-actions a:hover { border-color: var(--link); }
.pub-media { display: flex; flex-direction: column; gap: 0.6rem; }
.pub-award { aspect-ratio: 1454 / 1082; }

.project-affiliations { margin-top: 0.9rem; }
.project-label { font-size: 0.78rem; color: var(--text-light); }
.project-label { margin-bottom: 0.4rem; }
.project-logos {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 1rem 2rem;
  width: fit-content;
  max-width: 100%;
  padding: 1rem;
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  background: #fff;
}
.project-logos a { display: block; max-width: 100%; }
.project-logos img { display: block; max-width: 100%; height: auto; }

.pub-group-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--accent);
  margin: 1.5rem 0 0.8rem;
}

/* Collapsible publication and project sections */
.content-group { margin: 1.25rem 0; border-top: 2px solid var(--border); }
.content-group > summary { display: flex; align-items: center; gap: 0.6rem; padding: 0.7rem 0; cursor: pointer; list-style: none; border-bottom: 1px solid var(--border-light); }
.content-group > summary::-webkit-details-marker { display: none; }
.content-group > summary::before { content: "▸"; color: var(--accent); flex-shrink: 0; }
.content-group[open] > summary::before { transform: rotate(90deg); }
.content-group > summary:focus-visible { outline: 2px solid var(--link); outline-offset: 3px; }
.content-group > summary .pub-group-title { margin: 0; padding: 0; border: 0; }

/* Project cards */
.projects-page main, .projects-page .nav-inner { max-width: 1080px; }
.project-category-nav, .publication-category-nav { position: sticky; top: var(--nav-height); z-index: 90; height: auto; display: grid; grid-template-columns: 0.6fr 1.4fr 1.6fr 1.2fr; gap: 0.4rem; margin: 0.8rem 0 1.25rem; padding-bottom: 0.6rem; background: var(--bg); box-shadow: var(--shadow); backdrop-filter: none; }
.publication-category-nav { grid-template-columns: repeat(6, minmax(0, 1fr)); }
.project-category-nav a, .publication-category-nav a { display: flex; flex-direction: column; justify-content: center; padding: 0.6rem 0.4rem; border-radius: var(--radius); color: var(--text); text-align: center; font-size: 0.85rem; font-weight: 600; line-height: 1.5; }
.project-category-nav a span[lang="en"], .publication-category-nav a span[lang="en"] { display: block; margin-top: 0.2rem; color: var(--text-light); font-size: 0.7rem; font-weight: 400; }
.project-category-nav a:hover, .project-category-nav a[aria-current="location"], .publication-category-nav a:hover, .publication-category-nav a[aria-current="location"] { color: var(--accent); background: var(--bg-alt); }
.project-category-nav a:focus-visible, .publication-category-nav a:focus-visible { outline: 2px solid var(--link); outline-offset: 2px; }
.projects-page #project-home, .projects-page .content-group, .projects-page .project-card, .publications-page #publications-home, .publications-page .content-group, .publications-page .pub-item { scroll-margin-top: calc(var(--nav-height) + var(--category-nav-height, 4.5rem) + 1rem); }
.project-list { list-style: none; }
.project-card { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 2fr); gap: 1rem; align-items: start; padding: 1rem 0; border-bottom: 1px solid var(--border-light); }
.project-card:last-child { border-bottom: 0; }
.project-image { display: flex; align-items: center; justify-content: center; width: 100%; aspect-ratio: 3 / 2; overflow: hidden; background: #fff; border: 1px solid var(--border); border-radius: var(--radius); }
.project-image img { display: block; width: 100%; height: 100%; object-fit: contain; }
.project-image-placeholder { flex-direction: column; padding: 0.5rem; background: var(--bg-alt); color: var(--text-light); font-size: 0.72rem; line-height: 1.5; text-align: center; }
.project-copy { min-width: 0; }
.project-copy h3 { font-size: 0.95rem; margin-bottom: 0.3rem; }
.project-copy h3 .translation { font-size: 0.8rem; font-weight: 400; }
.project-role { font-size: 0.78rem; color: var(--accent); margin-bottom: 0.4rem; }
.project-description { font-size: 0.85rem; line-height: 1.6; margin-bottom: 0.3rem; }
.project-description.translation { font-size: 0.8rem; }
.project-card .project-affiliations { margin: 0.45rem 0 0.7rem; }
.project-card .project-affiliations .company-logos { margin: 0; }
.project-card .project-affiliations .project-label { margin: 0.5rem 0 0; }
.project-partner-logos .company-logo { flex: 0 0 100px; width: 100px; height: 52px; padding: 8px; }
.project-partner-logos .joint-institute-logo { flex: 1 1 240px; width: auto; max-width: 340px; min-height: 52px; padding: 10px; }
.project-vehicles { width: 100%; display: grid; gap: 0.3rem; padding: 0.4rem; background: #fff; border: 1px solid var(--border); border-radius: var(--radius); }
.project-vehicles figure { margin: 0; display: grid; grid-template-columns: 1fr 2rem; align-items: center; gap: 0.2rem; }
.project-vehicles img { display: block; width: 100%; height: auto; }
.pioneer-vehicles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.pioneer-vehicles figure { display: block; text-align: center; }
.pioneer-vehicles img { height: auto; aspect-ratio: 3 / 2; object-fit: contain; }
.pioneer-vehicles figure:last-child img { transform: scaleX(-1); }
.project-vehicles figcaption { font-size: 0.7rem; color: #555; }
.project-image-stack { display: grid; gap: 0.5rem; }
.project-image-stack .project-image { width: 100%; aspect-ratio: auto; }
.project-image-stack img { height: auto; }
.project-image-stack .project-image-crop { position: relative; }
.project-image-stack .project-image-crop img { position: absolute; top: 0; left: 0; max-width: none; }
.project-interview { margin: 0; }
.project-interview figcaption { padding-top: 0.4rem; font-size: 0.72rem; color: var(--text-lighter); }
.project-video { display: inline-block; margin-left: 0.25rem; padding: 0.05rem 0.3rem; border: 1px solid var(--border); border-radius: 3px; background: var(--bg-alt); white-space: nowrap; }
.project-video:hover { border-color: var(--link); }
@media (max-width: 640px) {
  .project-card { gap: 0.8rem; }
  .project-vehicles figure { grid-template-columns: 1fr; text-align: center; }
  .project-partner-logos { gap: 0.4rem; }
  .project-partner-logos .company-logo { flex-basis: calc((100% - 0.8rem) / 3); width: calc((100% - 0.8rem) / 3); height: 48px; padding: 6px; }
  .project-partner-logos .joint-institute-logo { flex-basis: 100%; width: 100%; max-width: 340px; min-height: 48px; padding: 10px; }
}

/* =============================================
   NEWS LIST
   ============================================= */
.news-list { list-style: none; }
.news-list li {
  display: flex;
  gap: 0.8rem;
  padding: 0.4rem 0;
  font-size: 0.9rem;
  color: var(--text-light);
}
.news-list .news-date {
  flex-shrink: 0;
  font-size: 0.8rem;
  color: var(--text-lighter);
  min-width: 85px;
}

/* =============================================
   FOOTER
   ============================================= */
footer {
  text-align: center;
  padding: 2rem 1rem;
  color: var(--text-lighter);
  font-size: 0.82rem;
  border-top: 1px solid var(--border-light);
}
footer a { color: var(--text-lighter); }
footer a:hover { color: var(--accent); }

/* =============================================
   RESPONSIVE
   ============================================= */
@media (max-width: 640px) {
  .timeline-item.education-item { grid-template-columns: minmax(0, 1fr); gap: 0.7rem; }
  .education-item .timeline-content { min-width: 0; }
  .pub-card { grid-template-columns: 100px minmax(0, 1fr); gap: 0.25rem 1rem; }
  .pub-card .pub-content { display: contents; }
  .pub-card > .pub-thumbnail, .pub-card > .pub-media { grid-column: 1; grid-row: 1 / 4; }
  .pub-card .pub-title, .pub-card .pub-authors, .pub-card .pub-venue { grid-column: 2; }
  .pub-card .pub-title-translation { grid-column: 2; }
  .pub-card .pub-contribution { grid-column: 1 / -1; }
  .pub-card .pub-ratings, .pub-card .pub-distinction, .pub-card .pub-links { grid-column: 1 / -1; }
  .profile { flex-direction: column; align-items: center; text-align: center; }
  .social-icons { justify-content: center; }
  .timeline-item { flex-direction: column; gap: 0.2rem; }
  .timeline-year { width: auto; }
  nav .nav-brand { font-size: 0.9rem; }
  nav .nav-links a { font-size: 0.82rem; padding: 0.3rem 0.5rem; }
  main { padding: 1.5rem 1rem 3rem; }
}

/* =============================================
   PRINT
   ============================================= */
@media print {
  nav, footer, .social-icons { display: none !important; }
  body { font-size: 12px; color: #000; background: #fff; }
  a { color: #000; }
}

/* Publication metadata */
.pub-ratings { margin: 0.5rem 0; font-size: 0.78rem; color: var(--text-light); }
.pub-ratings > div { display: grid; grid-template-columns: 13rem minmax(0, 1fr); gap: 0.4rem; margin: 0.15rem 0; }
.pub-ratings dt { font-weight: 600; }
.pub-ratings dd { margin: 0; overflow-wrap: anywhere; }
.pub-distinction { font-size: 0.78rem; color: var(--text-light); margin: 0.35rem 0; }
@media (max-width: 640px) {
  .pub-ratings > div { grid-template-columns: 1fr; gap: 0.1rem; margin: 0.4rem 0; }
}
