/* =====================================================
   Wenxin Chen — Personal Site
   Anthropic brand palette · Poppins + Lora
   ===================================================== */

:root {
  --dark:       #141413;
  --light:      #faf9f5;
  --mid-gray:   #b0aea5;
  --light-gray: #e8e6dc;
  --orange:     #d97757;
  --blue:       #6a9bcc;
  --font-head: 'Poppins', Arial, sans-serif;
  --font-body: 'Lora', Georgia, serif;

  --toc-w:     170px;
  --profile-w: 200px;
  --gap:       3.5rem;
}

/* ── Language toggle visibility ── */
.lang-en .zh { display: none !important; }
.lang-zh .en { display: none !important; }

/* ── Reset ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
section[id] { scroll-margin-top: 1.5rem; }
@media (max-width: 640px) { section[id] { scroll-margin-top: 3.5rem; } }

body {
  background: var(--light);
  color: var(--dark);
  font-family: var(--font-body);
  font-size: 17px;
  line-height: 1.8;
  -webkit-font-smoothing: antialiased;
}

/* ── Page grid ── */
.page {
  display: grid;
  grid-template-columns: var(--toc-w) 1fr var(--profile-w);
  grid-template-areas: "toc main profile";
  max-width: 1120px;
  margin: 0 auto;
  padding: 4rem 2rem;
  gap: var(--gap);
  min-height: 100vh;
}

/* =====================================================
   LEFT — Table of Contents
   ===================================================== */

.toc {
  grid-area: toc;
  position: sticky;
  top: 3.5rem;
  align-self: start;
  height: fit-content;
  /* Grid items default to min-width:auto; without this the horizontal pill
     strip on mobile forces the grid wider than the device and the browser
     zooms the whole page out to fit. */
  min-width: 0;
}

.toc-label {
  font-family: var(--font-head);
  font-size: 0.62rem;
  font-weight: 600;
  letter-spacing: 0.13em;
  text-transform: uppercase;
  color: var(--mid-gray);
  margin-bottom: 0.9rem;
}

.toc ul {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0;
}

.toc-link {
  display: block;
  font-family: var(--font-head);
  font-size: 0.8rem;
  font-weight: 400;
  color: var(--mid-gray);
  text-decoration: none;
  padding: 0.28rem 0.6rem;
  border-left: 2px solid transparent;
  transition: color 0.15s ease, border-color 0.15s ease;
  line-height: 1.5;
}

.toc-link:hover {
  color: var(--dark);
  border-left-color: var(--light-gray);
}

.toc-link.active {
  color: var(--orange);
  border-left-color: var(--orange);
  font-weight: 500;
  background: rgba(217, 119, 87, 0.07);
  border-radius: 0 4px 4px 0;
}

/* =====================================================
   CENTER — Main Content
   ===================================================== */

.content {
  grid-area: main;
  min-width: 0;
}

/* Sections */
section {
  padding-bottom: 3.5rem;
  margin-bottom: 3.5rem;
  border-bottom: 1px solid var(--light-gray);
}

section:last-child {
  border-bottom: none;
  margin-bottom: 0;
  padding-bottom: 5rem;
}

/* Headings */
h1, h2, h3 {
  font-family: var(--font-head);
  color: var(--dark);
  line-height: 1.2;
}

h1 {
  font-size: 2.2rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: 1.2rem;
}

section > h2 {
  font-size: 1.05rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  margin-bottom: 1.5rem;
  padding-left: 0.75rem;
  border-left: 3px solid var(--orange);
}

/* Intro paragraphs */
.intro {
  font-size: 0.97rem;
  line-height: 1.85;
  color: var(--dark);
  max-width: 62ch;
  margin-bottom: 0.9rem;
}

.intro strong { font-weight: 600; }
.intro em { font-style: italic; }

/* ── Education ── */
.edu-block {
  margin-top: 2.2rem;
}

.edu-block h2 {
  font-size: 1.05rem;
  font-weight: 600;
  margin-bottom: 1rem;
  padding-left: 0.75rem;
  border-left: 3px solid var(--orange);
}

.edu-item {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--light-gray);
}

.edu-item:last-child { border-bottom: none; }

.edu-school {
  display: block;
  font-family: var(--font-head);
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--dark);
}

.edu-degree {
  display: block;
  font-size: 0.83rem;
  color: var(--mid-gray);
  margin-top: 0.1rem;
}

.edu-courses {
  display: block;
  font-size: 0.78rem;
  color: var(--mid-gray);
  margin-top: 0.25rem;
  line-height: 1.5;
}

.edu-date {
  font-family: var(--font-head);
  font-size: 0.78rem;
  color: var(--mid-gray);
  white-space: nowrap;
  flex-shrink: 0;
  padding-top: 0.1rem;
}

/* ── Badge ── */
.badge {
  display: inline-block;
  font-family: var(--font-head);
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  color: var(--orange);
  background: rgba(217, 119, 87, 0.09);
  border: 1px solid rgba(217, 119, 87, 0.28);
  border-radius: 4px;
  padding: 0.18rem 0.48rem;
  white-space: nowrap;
  flex-shrink: 0;
  align-self: flex-start;
}

/* ── Badge neutral variant ── */
.badge-neutral {
  color: var(--mid-gray);
  background: rgba(176, 174, 165, 0.10);
  border-color: rgba(176, 174, 165, 0.30);
}

/* ── Cards (publications & projects with teaser figure) ── */
.card {
  display: grid;
  grid-template-columns: 230px minmax(0, 1fr);
  gap: 1.25rem;
  align-items: start;
  margin-bottom: 2rem;
}

.card:last-child { margin-bottom: 0; }

.card-media {
  overflow: hidden;
  border-radius: 8px;
  border: 1px solid var(--light-gray);
  background: #fff;
}

.card-media a { display: block; height: 100%; }

.card-media img {
  display: block;
  width: 100%;
  height: auto;
  padding: 3%;
  box-sizing: border-box;
  transition: transform 0.3s ease;
}

.card-media a:hover img { transform: scale(1.03); }

.card-body { min-width: 0; }

.card-meta {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-bottom: 0.45rem;
}

.card-year {
  font-family: var(--font-head);
  font-size: 0.75rem;
  color: var(--mid-gray);
}

.card-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin: 0.5rem 0 0.55rem;
}

.card-links a {
  font-family: var(--font-head);
  font-size: 0.72rem;
  font-weight: 500;
  color: var(--dark);
  text-decoration: none;
  border: 1px solid var(--light-gray);
  border-radius: 999px;
  padding: 0.18rem 0.6rem;
  transition: border-color 0.15s ease, color 0.15s ease, background 0.15s ease;
}

.card-links a:hover {
  color: var(--orange);
  border-color: var(--orange);
  background: rgba(217, 119, 87, 0.06);
}

.card-tldr {
  font-size: 0.85rem;
  line-height: 1.6;
  color: var(--dark);
  margin-top: 0.35rem;
}

.card-body .bullets { margin-top: 0.5rem; }

@media (max-width: 900px) {
  .card {
    grid-template-columns: 1fr;
    gap: 0.8rem;
  }
  .card-media { max-width: 420px; }
}

/* ── Publications ── */

.pub-title {
  font-family: var(--font-head);
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--dark);
  margin-bottom: 0.3rem;
  line-height: 1.45;
}

/* ── Inline links in content (pub titles, lab names) ── */
.pub-title a,
.exp-org a,
.exp-role a {
  color: inherit;
  font: inherit;
  text-decoration: underline;
  text-decoration-color: var(--orange);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.2em;
  transition: color 0.15s ease, text-decoration-color 0.15s ease;
}

.pub-title a:hover,
.exp-org a:hover,
.exp-role a:hover {
  color: var(--orange);
}

.pub-authors {
  font-size: 0.82rem;
  color: var(--mid-gray);
  line-height: 1.55;
  margin-bottom: 0.15rem;
}

.pub-venue {
  font-size: 0.8rem;
  font-style: italic;
  color: var(--mid-gray);
}

/* ── Experience ── */
.exp-item {
  margin-bottom: 2rem;
}

.exp-item:last-child { margin-bottom: 0; }

.exp-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  margin-bottom: 0.65rem;
}

.exp-org {
  display: block;
  font-family: var(--font-head);
  font-weight: 600;
  font-size: 0.92rem;
  color: var(--dark);
}

.exp-role {
  display: block;
  font-size: 0.82rem;
  color: var(--mid-gray);
  font-style: italic;
  margin-top: 0.1rem;
}

.exp-date {
  font-family: var(--font-head);
  font-size: 0.78rem;
  color: var(--mid-gray);
  white-space: nowrap;
  flex-shrink: 0;
}

.sub-project {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.55rem;
}

.sub-name {
  font-family: var(--font-head);
  font-weight: 600;
  font-size: 0.88rem;
  color: var(--dark);
}

/* ── Bullets ── */
.bullets {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.bullets li {
  font-size: 0.88rem;
  line-height: 1.72;
  color: var(--dark);
  padding-left: 1.1rem;
  position: relative;
}

.bullets li::before {
  content: '–';
  position: absolute;
  left: 0;
  color: var(--mid-gray);
}

code {
  font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
  font-size: 0.84em;
  background: var(--light-gray);
  padding: 0.1em 0.35em;
  border-radius: 3px;
}

/* ── Projects ── */
.proj-item {
  margin-bottom: 2rem;
}

.proj-title-row {
  display: flex;
  align-items: baseline;
  gap: 0.75rem;
  margin-bottom: 0.5rem;
}

.proj-name {
  font-family: var(--font-head);
  font-weight: 700;
  font-size: 1rem;
  color: var(--dark);
}

.proj-link {
  font-family: var(--font-head);
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--orange);
  text-decoration: none;
}

.proj-link:hover { text-decoration: underline; }

.proj-desc {
  font-size: 0.88rem;
  line-height: 1.75;
  color: var(--dark);
  max-width: 60ch;
  margin-bottom: 0.7rem;
}

.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-bottom: 0.7rem;
}

.tag {
  font-family: var(--font-head);
  font-size: 0.7rem;
  font-weight: 500;
  color: var(--mid-gray);
  background: var(--light-gray);
  border-radius: 100px;
  padding: 0.12rem 0.55rem;
  letter-spacing: 0.02em;
}

/* ── Skills ── */
.skills-table {
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
}

.skill-row {
  display: grid;
  grid-template-columns: 110px 1fr;
  gap: 1rem;
  align-items: baseline;
}

.skill-key {
  font-family: var(--font-head);
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--mid-gray);
  letter-spacing: 0.02em;
}

.skill-val {
  font-size: 0.88rem;
  color: var(--dark);
}

/* ── Awards ── */
.awards-list {
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
}

.award-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1rem;
  font-size: 0.9rem;
}

.award-date {
  font-family: var(--font-head);
  font-size: 0.78rem;
  color: var(--mid-gray);
  white-space: nowrap;
  flex-shrink: 0;
}

/* =====================================================
   RIGHT — Profile Sidebar
   ===================================================== */

.profile {
  grid-area: profile;
  position: sticky;
  top: 3.5rem;
  align-self: start;
  height: fit-content;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.avatar {
  width: 140px;
  height: 140px;
  border-radius: 50%;
  object-fit: cover;
  box-shadow: 0 0 0 3px var(--light), 0 0 0 5px var(--orange), 0 6px 20px rgba(0, 0, 0, 0.10);
  margin-bottom: 0.9rem;
}

.profile-name {
  font-family: var(--font-head);
  font-size: 0.97rem;
  font-weight: 600;
  color: var(--dark);
  margin-bottom: 0.3rem;
}

.profile-sub {
  font-family: var(--font-head);
  font-size: 0.76rem;
  color: var(--mid-gray);
  line-height: 1.6;
}

.links {
  margin-top: 1.2rem;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  width: 100%;
}

.link-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-family: var(--font-head);
  font-size: 0.78rem;
  color: var(--dark);
  text-decoration: none;
  padding: 0.4rem 0.65rem;
  border: 1px solid var(--light-gray);
  border-radius: 7px;
  transition: border-color 0.15s ease, color 0.15s ease;
}

.link-item:hover {
  border-color: var(--orange);
  color: var(--orange);
  background: rgba(217, 119, 87, 0.06);
}

.link-item:hover svg {
  opacity: 1;
}

.link-item svg {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
  opacity: 0.65;
}

/* ── Language toggle button ── */
.lang-toggle {
  font-family: var(--font-head);
  font-size: 0.74rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--orange);
  background: rgba(217, 119, 87, 0.08);
  border: 1px solid rgba(217, 119, 87, 0.25);
  border-radius: 6px;
  padding: 0.3rem 0.75rem;
  cursor: pointer;
  margin-top: 0.8rem;
  transition: background 0.15s ease, border-color 0.15s ease;
  width: fit-content;
  align-self: center;
}

.lang-toggle:hover {
  background: rgba(217, 119, 87, 0.15);
  border-color: var(--orange);
}

/* =====================================================
   BLOG — Listing & Post pages
   ===================================================== */

.blog-wrap {
  max-width: 680px;
  margin: 0 auto;
  padding: 3rem 2rem 5rem;
}

.blog-nav {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 3rem;
}

.blog-nav-sep {
  color: var(--light-gray);
  font-family: var(--font-head);
  font-size: 0.82rem;
}

.blog-back {
  font-family: var(--font-head);
  font-size: 0.82rem;
  color: var(--mid-gray);
  text-decoration: none;
  transition: color 0.15s ease;
}

.blog-back:hover { color: var(--orange); }

/* Index page */
.blog-index-title {
  font-family: var(--font-head);
  font-size: 1.9rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: 0.5rem;
}

.blog-index-desc {
  font-size: 0.9rem;
  color: var(--mid-gray);
  margin-bottom: 2.5rem;
  font-family: var(--font-head);
}

.blog-post-list {
  list-style: none;
}

.blog-post-item {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1rem;
  padding: 0.85rem 0;
  border-bottom: 1px solid var(--light-gray);
}

.blog-post-item:first-child { border-top: 1px solid var(--light-gray); }

.blog-post-link {
  font-family: var(--font-head);
  font-size: 0.92rem;
  font-weight: 500;
  color: var(--dark);
  text-decoration: none;
  transition: color 0.15s ease;
}

.blog-post-link:hover { color: var(--orange); }

.blog-post-date {
  font-family: var(--font-head);
  font-size: 0.76rem;
  color: var(--mid-gray);
  white-space: nowrap;
  flex-shrink: 0;
}

.blog-empty {
  font-size: 0.9rem;
  color: var(--mid-gray);
  font-family: var(--font-head);
}

/* Individual post */
.blog-post-title {
  font-size: 1.9rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: 0.5rem;
}

.blog-post-meta {
  font-family: var(--font-head);
  font-size: 0.78rem;
  color: var(--mid-gray);
  margin-bottom: 2.5rem;
}

.blog-post-content {
  font-size: 0.97rem;
  line-height: 1.85;
}

.blog-post-content p          { margin-bottom: 1.2rem; }
.blog-post-content h2         { font-family: var(--font-head); font-size: 1.2rem; font-weight: 600; margin: 2rem 0 0.8rem; }
.blog-post-content h3         { font-family: var(--font-head); font-size: 1rem; font-weight: 600; margin: 1.5rem 0 0.6rem; }
.blog-post-content a          { color: var(--orange); text-underline-offset: 3px; }
.blog-post-content ul,
.blog-post-content ol         { padding-left: 1.5rem; margin-bottom: 1.2rem; }
.blog-post-content li         { margin-bottom: 0.35rem; line-height: 1.75; }
.blog-post-content blockquote { border-left: 3px solid var(--orange); padding-left: 1rem; color: var(--mid-gray); margin: 1.5rem 0; }
.blog-post-content pre        { background: var(--light-gray); padding: 1rem 1.25rem; border-radius: 6px; overflow-x: auto; margin-bottom: 1.2rem; }
.blog-post-content pre code   { background: none; padding: 0; font-size: 0.85em; }
.blog-post-content img        { max-width: 100%; border-radius: 6px; margin: 1rem 0; }

.blog-footer {
  margin-top: 4rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--light-gray);
}

@media (max-width: 640px) {
  .blog-wrap { padding: 2rem 1.25rem 4rem; }
  .blog-post-title,
  .blog-index-title { font-size: 1.5rem; }
}

/* =====================================================
   RESPONSIVE — Tablet & Mobile
   ===================================================== */

/* Tablet (≤ 900px): hide TOC, two-column layout */
@media (max-width: 900px) {
  .page {
    grid-template-columns: 110px 1fr var(--profile-w);
    grid-template-areas: "toc main profile";
    gap: 1.75rem;
    padding: 3rem 1.5rem;
  }
  .toc-label { display: none; }
  .toc-link {
    font-size: 0.74rem;
    padding: 0.22rem 0.5rem;
  }
  .profile {
    padding-left: 1.5rem;
    border-left: 1px solid var(--light-gray);
  }
}

/* Mobile (≤ 640px): single column, profile on top */
@media (max-width: 640px) {
  .page {
    grid-template-columns: 1fr;
    grid-template-areas:
      "profile"
      "toc"
      "main";
    padding: 1.75rem 1.25rem;
    gap: 1.25rem;
  }
  .toc {
    position: sticky;
    top: 0;
    z-index: 5;
    background: var(--light);
    margin: 0 -1.25rem;
    padding: 0.5rem 1.25rem;
    border-bottom: 1px solid var(--light-gray);
  }
  .toc-label { display: none; }
  .toc ul {
    flex-direction: row;
    gap: 0.35rem;
    overflow-x: auto;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
  }
  .toc ul::-webkit-scrollbar { display: none; }
  .toc-link {
    white-space: nowrap;
    font-size: 0.74rem;
    padding: 0.3rem 0.7rem;
    border: 1px solid var(--light-gray);
    border-left: 1px solid var(--light-gray);
    border-radius: 999px;
  }
  .toc-link.active {
    border-color: var(--orange);
    border-radius: 999px;
  }

  /* Profile card becomes a horizontal strip */
  .profile {
    position: static;
    padding-left: 0;
    border-left: none;
    flex-direction: row;
    align-items: center;
    text-align: left;
    gap: 1rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid var(--light-gray);
    flex-wrap: wrap;
  }

  .profile > .avatar {
    width: 72px;
    height: 72px;
    margin-bottom: 0;
    flex-shrink: 0;
  }

  .profile-info {
    flex: 1;
    min-width: 0;
  }

  .profile-name {
    margin-bottom: 0.15rem;
  }

  .links {
    flex-direction: row;
    flex-wrap: wrap;
    width: 100%;
    gap: 0.4rem;
    margin-top: 0.85rem;
  }

  .link-item {
    flex: 0 1 auto;
  }

  h1 {
    font-size: 1.7rem;
  }

  .edu-item,
  .exp-header,
  .award-row {
    flex-direction: column;
    gap: 0.25rem;
  }

  .edu-date,
  .exp-date,
  .award-date {
    white-space: normal;
  }
}
