/* ==============================
   Reset
   Design tokens live in tokens.css — load that first.
   ============================== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; font-size: 18px; }

body {
  font-family: 'Lora', serif;
  font-weight: 400;
  color: var(--text);
  background: var(--bg);
  line-height: 1.8;
}

a {
  color: var(--navy);
  text-decoration: underline;
  text-decoration-color: var(--border);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.18em;
  transition: color 0.14s, text-decoration-color 0.14s;
}
a:hover { color: var(--accent); text-decoration-color: var(--accent); }

/* ==============================
   Progress Bar
   ============================== */
#progress-bar {
  position: fixed;
  top: 0;
  left: 0;
  height: 2px;
  width: 0%;
  background: var(--accent);
  z-index: 9999;
  transition: width 0.1s linear;
}

/* ==============================
   Navigation
   ============================== */
#navbar {
  position: sticky;
  top: 0;
  background: var(--bg);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
  z-index: 100;
}

.nav-inner {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 2rem;
  height: 56px;
  display: flex;
  align-items: center;
  gap: 2rem;
}

.nav-name {
  font-family: 'Lora', Georgia, serif;
  font-weight: 600;
  font-size: 0.88rem;
  color: var(--navy);
  letter-spacing: 0.01em;
  flex-shrink: 0;
  text-decoration: none;
}
.nav-name:hover { color: var(--accent); text-decoration: none; }

.nav-links {
  list-style: none;
  display: flex;
  gap: 1.75rem;
  margin-left: auto;
}

.nav-links a {
  font-family: 'Lora', Georgia, serif;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--muted);
  text-decoration: none;
  letter-spacing: 0.05em;
  font-variant: small-caps;
  transition: color 0.15s;
}
.nav-links a:hover { color: var(--navy); text-decoration: none; }
.nav-links a.active { color: var(--navy); }

.nav-toggle {
  display: none;
  background: none;
  border: none;
  font-size: 1.2rem;
  cursor: pointer;
  color: var(--navy);
  margin-left: auto;
}

.nav-mobile {
  display: none;
  list-style: none;
  flex-direction: column;
  padding: 0.5rem 2rem 1rem;
  border-top: 1px solid var(--border);
}

.nav-mobile.open { display: flex; }

.nav-mobile a {
  font-family: 'Newsreader', Georgia, 'Iowan Old Style', serif;
  font-size: 0.88rem;
  font-weight: 500;
  color: var(--navy);
  padding: 0.45rem 0;
  text-decoration: none;
}

/* ==============================
   Layout
   ============================== */
main {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 2rem;
}

.layout {
  display: grid;
  grid-template-columns: 250px minmax(0, 1fr);
  gap: 4rem;
  align-items: start;
}

.sidebar {
  position: sticky;
  top: 72px;
  padding: 3.5rem 0 3rem;
  text-align: center;
}

.content {
  min-width: 0;
}

section {
  padding: var(--section-pad);
}
section:first-child { padding-top: 3.5rem; }
#welcome { padding-bottom: 1.5rem; }
#research { padding-top: 1.5rem; }
/* Single divider above CV anchors the embedded iframe block —
   every other section separates via white space + h2 underline. */
#cv { border-top: 1px solid var(--border); }

/* ==============================
   Standalone pages
   Research, Resources, and CV use this full-width reading layout rather
   than the profile-sidebar grid on the home page.
   ============================== */
.page-main {
  max-width: 1240px;
  padding: 0 2rem;
}

.page-content {
  max-width: 1100px;
  margin: 0 auto;
  padding: 4.5rem 0 5rem;
}

.page-header {
  max-width: 820px;
  margin-bottom: 3.75rem;
}

.eyebrow {
  font-family: 'Lora', Georgia, serif;
  font-size: 0.76rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  color: var(--muted);
  font-variant: small-caps;
  margin-bottom: 0.55rem;
}

.page-header h1 {
  font-family: var(--font-display);
  font-size: clamp(2.3rem, 5vw, 3.5rem);
  font-weight: 700;
  line-height: 1.12;
  letter-spacing: -0.035em;
  color: var(--navy);
  margin-bottom: 1.2rem;
}

.page-header > p:last-child {
  font-family: var(--font-body);
  font-size: 1.3rem;
  line-height: 1.55;
  color: var(--muted);
}

.page-content > section {
  padding: 0;
  margin-bottom: 4rem;
}

.page-content > section:last-child { margin-bottom: 0; }

.page-content h2 {
  font-size: 1.75rem;
  margin-bottom: 1.6rem;
}

.resources-skills {
  padding-top: 3.5rem !important;
  border-top: 1px solid var(--border);
}

.cv-page { max-width: 1180px; }
.cv-page .page-header { margin-bottom: 2.25rem; }
.cv-page .cv-embed { margin-top: 0; }
.cv-page .cv-embed iframe { height: min(78vh, 1100px); }

h2 {
  font-family: var(--font-display);
  font-size: 1.55rem;
  font-weight: 700;
  letter-spacing: -0.015em;
  color: var(--navy);
  margin-bottom: 1.5rem;
  padding-bottom: 0.5rem;
  border-bottom: 2px solid var(--navy);
}

/* ==============================
   Sidebar / About
   ============================== */
.about-photo {
  text-align: center;
  margin-bottom: 1.5rem;
}

.about-photo img,
.photo-placeholder {
  width: 180px;
  height: 180px;
  border-radius: 50%;
  object-fit: cover;
  display: block;
  margin: 0 auto;
}

.photo-placeholder {
  background: var(--navy);
  color: #FFFFFF;
  font-family: 'Lora', Georgia, serif;
  font-size: 2.15rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  letter-spacing: 0.05em;
}

h1 {
  font-family: var(--font-display);
  font-size: 1.45rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--navy);
  margin-bottom: 0.3rem;
  line-height: 1.3;
}

.name-cn {
  /* Prefer locally available KaiTi; use downloaded Xingcao if it is absent. */
  font-family: KaiTi, STKaiti, "Kaiti SC", "BiauKai", 'Zhi Mang Xing', cursive;
  font-weight: 700;
  color: var(--navy);
  font-size: 1.38rem;
  line-height: 1;
  margin-left: 0.2em;
}

.name-phonetic {
  font-size: 0.9rem;
  color: var(--muted);
  font-family: 'Lora', serif;
  font-style: italic;
  margin-bottom: 0.5rem;
  letter-spacing: 0.03em;
}

.about-title {
  font-family: 'Newsreader', Georgia, 'Iowan Old Style', serif;
  font-size: 0.95rem;
  color: var(--navy);
  margin-bottom: 1rem;
  font-weight: 500;
  line-height: 1.6;
}

.about-bio {
  font-size: 1.05rem;
  margin-bottom: 0.9rem;
  color: var(--text);
  line-height: 1.85;
}

.about-links {
  display: flex;
  justify-content: center;
  gap: 1.1rem;
  margin-top: 1.35rem;
}

.about-links a {
  color: var(--navy);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  line-height: 1;
  text-decoration: none;
  transition: color 0.15s;
}
.about-links a:hover { color: var(--accent); text-decoration: none; }
.about-links a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

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

/* ==============================
   Research Section
   ============================== */
.subsection-title {
  font-family: 'Lora', Georgia, serif;
  font-size: 1.0rem;
  font-weight: 600;
  font-variant: small-caps;
  letter-spacing: 0.05em;
  color: var(--muted);
  margin: 2rem 0 0.75rem;
  display: flex;
  align-items: center;
  gap: 0.45rem;
}
.subsection-title:first-child { margin-top: 0; }

.paper {
  margin-bottom: 1.75rem;
  padding-bottom: 1.75rem;
  border-bottom: 1px solid var(--border);
}
.paper:last-child { border-bottom: none; margin-bottom: 0; padding-bottom: 0; }

.paper-featured {
  display: grid;
  grid-template-columns: 225px minmax(0, 1fr);
  gap: 1.25rem;
  align-items: stretch;
}

.paper-figure {
  position: relative;
  width: 100%;
  min-height: 0;
  margin: 0;
}

.paper-figure a {
  position: absolute;
  inset: 0;
  display: block;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: #fff;
  box-shadow: var(--shadow-xs);
  line-height: 0;
  text-decoration: none;
  transition: border-color 0.15s, box-shadow 0.15s, transform 0.15s;
}

.paper-figure a:hover {
  border-color: var(--accent);
  box-shadow: var(--shadow-sm);
  transform: translateY(-1px);
}

.paper-figure img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.paper-copy { min-width: 0; }

.paper-featured > .paper-abstract {
  grid-column: 1 / -1;
}

.paper-title {
  font-family: 'Lora', serif;
  font-size: 1rem;
  font-weight: 700;
  font-style: normal;
  color: var(--navy);
  margin-bottom: 0.4rem;
  line-height: 1.45;
}

.paper-title-link {
  color: inherit;
  text-decoration: none;
}
.paper-title-link:hover {
  color: var(--accent);
  text-decoration: none;
}

.paper-authors {
  font-family: 'Newsreader', Georgia, 'Iowan Old Style', serif;
  font-size: 0.78rem;
  color: var(--muted);
  margin-bottom: 0.65rem;
}

/* Abstract disclosure — triangle after the title */
.abstract-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.32rem;
  margin-left: 0.5rem;
  padding: 0.1rem 0.4rem;
  border: none;
  background: transparent;
  color: var(--muted);
  font-family: 'Lora', Georgia, serif;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  cursor: pointer;
  vertical-align: middle;
  transition: color 0.15s;
}
.abstract-toggle:hover { color: var(--accent); }
.abstract-toggle i {
  font-size: 0.85em;
  transition: transform 0.2s var(--ease-expo);
}
.abstract-toggle[aria-expanded="true"] i { transform: rotate(90deg); }
.abstract-toggle-label { line-height: 1; }

.paper-abstract {
  display: grid;
  grid-template-rows: 0fr;
  transition: grid-template-rows 0.3s var(--ease-expo);
}
.paper-abstract.open { grid-template-rows: 1fr; }
.paper-abstract-inner { overflow: hidden; }
.paper-abstract.open .paper-abstract-inner { margin: 0.5rem 0 0.2rem; }
.paper-abstract p {
  font-family: 'Newsreader', Georgia, 'Iowan Old Style', serif;
  font-size: 0.82rem;
  line-height: 1.6;
  color: var(--text);
  text-align: justify;
  padding: 0.7rem 0.9rem;
  margin: 0;
  background: var(--card);
  border-left: 2px solid var(--border);
  border-radius: 0 3px 3px 0;
}
.paper-authors a { color: var(--muted); }
.paper-authors a:hover { color: var(--accent); }

.paper-links {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-top: 0.7rem;
}
.paper-link {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-family: 'Lora', Georgia, serif;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  padding: 0.28rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 3px;
  color: var(--navy);
  background: var(--card);
  text-decoration: none;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
}
.paper-link:hover {
  border-color: var(--accent);
  color: var(--accent);
  text-decoration: none;
}
.paper-link i { font-size: 0.9em; opacity: 0.85; }

.paper-tags {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
  margin-bottom: 0.75rem;
}

.tag {
  font-family: 'Lora', Georgia, serif;
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  padding: 0.2rem 0.6rem;
  border-radius: 2px;
  font-variant: small-caps;
}
.tag-wip { background: #eef3fb; color: #1d3a6e; }
.tag-presented { background: #e6efff; color: #0046ad; }

/* ==============================
   CV Section
   ============================== */
.cv-button {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--navy);
  color: #FFFFFF;
  font-family: 'Lora', Georgia, serif;
  font-size: 0.78rem;
  font-weight: 600;
  padding: 0.6rem 1.4rem;
  border-radius: 3px;
  text-decoration: none;
  letter-spacing: 0.03em;
  transition: background 0.15s;
}
.cv-button:hover { background: var(--accent); color: #FFFFFF; text-decoration: none; }

.cv-updated {
  font-family: 'Newsreader', Georgia, 'Iowan Old Style', serif;
  font-size: 0.78rem;
  color: var(--muted);
  margin-left: 1rem;
  letter-spacing: 0.01em;
}

.cv-embed {
  margin-top: 1.75rem;
  border: 1.5px solid var(--text);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  background: var(--card);
}
.cv-embed iframe {
  display: block;
  width: 100%;
  height: 700px;
  border: none;
}

/* ==============================
   Footer
   ============================== */
footer {
  text-align: center;
  padding: 2.5rem 2rem;
  font-family: 'Newsreader', Georgia, 'Iowan Old Style', serif;
  font-size: 0.65rem;
  color: var(--muted);
  border-top: 1px solid var(--border);
  letter-spacing: 0.03em;
}

/* ==============================
   Responsive
   ============================== */
@media (max-width: 700px) {
  .layout {
    grid-template-columns: 1fr;
    gap: 0;
  }

  .sidebar {
    position: static;
    padding: 2.5rem 0 2rem;
    margin-top: 0;
    background: transparent;
    border-bottom: 1px solid var(--border);
    border-radius: 0;
    box-shadow: none;
    text-align: center;
  }

  .about-links {
    align-items: center;
  }

  .photo-placeholder,
  .about-photo img {
    width: 110px;
    height: 110px;
  }

  .nav-links { display: none; }
  .nav-toggle { display: block; }

  .paper-figure {
    width: min(100%, 280px);
    aspect-ratio: 8 / 5;
  }

  .paper-featured {
    grid-template-columns: 1fr;
    gap: 1rem;
  }

  .cv-embed iframe { height: 450px; }

  .page-main { padding: 0 1.25rem; }
  .page-content { padding: 3rem 0 3.5rem; }
  .page-header { margin-bottom: 2.75rem; }
  .page-header h1 { font-size: 2.25rem; }
  .page-header > p:last-child { font-size: 1.12rem; }
  .page-content > section { margin-bottom: 3rem; }
  .cv-page .page-header > p:last-child { font-size: 1rem; }
}

/* ==============================
   Learning Materials
   Simple stacked entries — title, meta, description, link row.
   Thin separator between items, no border, no hover transform.
   ============================== */
.material-item {
  background: transparent;
  border: none;
  border-radius: 0;
  padding: 0 0 0.75rem 0;
  margin-bottom: 0.75rem;
  box-shadow: none;
  border-bottom: 1px dashed var(--border);
}
.material-item:last-of-type {
  margin-bottom: 0;
  padding-bottom: 0;
  border-bottom: none;
}

.material-title {
  font-family: 'Lora', serif;
  font-size: 1.0rem;
  font-weight: 700;
  font-style: normal;
  color: var(--navy);
  margin-bottom: 0.1rem;
  line-height: 1.35;
}

.material-meta {
  font-family: 'Newsreader', Georgia, 'Iowan Old Style', serif;
  font-size: 0.78rem;
  color: var(--muted);
  margin-bottom: 0.3rem;
  letter-spacing: 0.01em;
}

.material-desc {
  font-size: 0.88rem;
  color: var(--text);
  line-height: 1.55;
  margin-bottom: 0.45rem;
}

.material-links { display: flex; gap: 0.4rem; flex-wrap: wrap; }

.material-link {
  font-family: 'Lora', Georgia, serif;
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  font-variant: small-caps;
  color: var(--navy);
  background: var(--border);
  padding: 0.2rem 0.65rem;
  border-radius: 2px;
  text-decoration: none;
  transition: background 0.14s, color 0.14s;
}
.material-link:hover { background: var(--navy); color: #fff; text-decoration: none; }

.material-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

.material-chip {
  font-family: 'Newsreader', Georgia, 'Iowan Old Style', serif;
  display: flex;
  flex-direction: column;
  padding: 0.55rem 0.85rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  text-decoration: none;
  color: var(--navy);
  transition: border-color 0.14s, background 0.14s;
  min-width: 110px;
}
.material-chip:hover { border-color: var(--navy); background: #fff; text-decoration: none; color: var(--navy); }

.material-chip span {
  font-family: 'Lora', Georgia, serif;
  font-size: 0.78rem;
  font-weight: 500;
  font-variant: small-caps;
  letter-spacing: 0.03em;
  color: var(--muted);
  margin-top: 0.2rem;
}

.material-chip { font-size: 0.78rem; font-weight: 500; }

/* ==============================
   Compact one-line-per-item list. Used across Learning Materials
   subsections — each entry fits a single visual row at typical
   reading widths.
   ============================== */
.compact-list {
  list-style: none;
  padding: 0;
  margin: 0;
  font-size: 0.88rem;
  line-height: 1.55;
  color: var(--text);
}
.compact-list li {
  padding: 0.3rem 0 0.3rem 1rem;
  border-bottom: 1px dashed var(--border);
  position: relative;
}
.compact-list li:last-child { border-bottom: none; }
.compact-list li::before {
  content: "›";
  position: absolute;
  left: 0;
  top: 0.3rem;
  color: var(--accent);
  font-weight: 700;
}
.compact-list a {
  color: var(--navy);
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: border-color 0.14s, color 0.14s;
}
.compact-list a:hover {
  color: var(--accent);
  border-bottom-color: var(--accent);
  text-decoration: none;
}
.compact-list code {
  font-family: 'SFMono-Regular', Consolas, monospace;
  font-size: 0.78rem;
  background: var(--border);
  padding: 0.05em 0.35em;
  border-radius: 2px;
  color: var(--navy);
}

/* ==============================
   Skills
   Cards with subtle depth + hover lift.
   ============================== */
.skills-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.skill-item {
  padding: 1.2rem 1.35rem;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-xs);
  transition: box-shadow 0.18s var(--ease-expo),
              transform 0.18s var(--ease-expo),
              border-color 0.18s var(--ease-expo);
}
.skill-item:hover {
  border-color: var(--navy);
  box-shadow: var(--shadow-sm);
  transform: translateY(-2px);
}

.skill-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.4rem;
}

.skill-name {
  font-family: 'Lora', Georgia, serif;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--navy);
}

.skill-badge {
  font-family: 'Lora', Georgia, serif;
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  font-variant: small-caps;
  padding: 0.18rem 0.6rem;
  border-radius: 2px;
  white-space: nowrap;
  flex-shrink: 0;
}
.skill-available { background: #e6efff; color: #0046ad; }
.skill-build     { background: #eef3fb; color: #1d3a6e; }

.skill-desc {
  font-size: 0.88rem;
  color: var(--text);
  line-height: 1.7;
  margin-bottom: 0.45rem;
}

.skill-source {
  font-family: 'Newsreader', Georgia, 'Iowan Old Style', serif;
  font-size: 0.78rem;
  color: var(--muted);
  text-decoration: none;
  border-bottom: 1px solid var(--border);
  transition: color 0.14s, border-color 0.14s;
}
.skill-source:hover { color: var(--navy); border-color: var(--navy); text-decoration: none; }

.skill-footer {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.skill-file {
  font-family: 'Newsreader', Georgia, 'Iowan Old Style', serif;
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--navy);
  text-decoration: none;
  margin-left: auto;
  white-space: nowrap;
  transition: color 0.14s;
}
.skill-file:hover { color: var(--accent); text-decoration: none; }

.subsection-icon {
  font-size: 0.8em;
  opacity: 0.65;
  margin-right: 0.35em;
}

.skill-icon {
  font-size: 0.85em;
  opacity: 0.6;
  margin-right: 0.3em;
}

/* ==============================
   Motion — page-load staggered reveal
   JS adds .visible when each .reveal-up enters the viewport
   (or on first paint for above-the-fold elements).
   ============================== */
.reveal-up {
  opacity: 0;
  transform: translateY(14px);
  transition: opacity 0.55s var(--ease-expo),
              transform 0.55s var(--ease-expo);
  will-change: opacity, transform;
}
.reveal-up.visible {
  opacity: 1;
  transform: none;
}
@media (prefers-reduced-motion: reduce) {
  .reveal-up,
  .reveal-up.visible {
    opacity: 1;
    transform: none;
    transition: none;
  }
}

/* ==============================
   Asymmetry — controlled grid-break
   On desktop the sidebar name allows the long Chinese characters to
   exhale slightly past the sidebar's right edge into the gutter.
   Mobile collapses to flat (no overflow).
   ============================== */
@media (min-width: 701px) {
  .sidebar h1 { white-space: nowrap; }
  .sidebar .name-cn {
    font-family: KaiTi, STKaiti, "Kaiti SC", "BiauKai", serif;
    font-size: 0.95em;
    line-height: inherit;
    color: var(--navy);
    display: inline-block;
    transform: translateX(0.15em);
  }
}
