/* ============================================================
   Mengdie (Flora) Wang — v3 "Timeline" variant
   Light, editorial, research-forward. Signature: vertical
   timeline rail with year markers. Sans-serif + indigo accent.
   ============================================================ */

:root {
  color-scheme: light;
  --bg: #ffffff;
  --surface: #ffffff;
  --surface-2: #eef1f6;
  --text: #16181d;
  --text-soft: #4a4f59;
  --text-muted: #878d99;
  --accent: #4f46e5;          /* indigo */
  --accent-2: #6d28d9;
  --accent-soft: #eceafe;
  --award: #b45309;           /* amber for award badge */
  --award-soft: #fef3c7;
  --talk: #0f766e;            /* teal for talks */
  --talk-soft: #d7f2ee;
  --blog: #b83280;            /* magenta for blogs */
  --blog-soft: #fbe3f1;
  --border: #e3e7ee;
  --rail: #d7dce6;
  --shadow: 0 1px 2px rgba(22, 24, 29, 0.04), 0 10px 30px rgba(22, 24, 29, 0.06);
  --shadow-hover: 0 4px 10px rgba(79, 70, 229, 0.10), 0 16px 40px rgba(22, 24, 29, 0.10);
  --radius: 16px;
  --maxw: 1040px;
  --font-sans: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-display: "Space Grotesk", "Inter", system-ui, sans-serif;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; scroll-padding-top: 84px; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 17px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  * { animation: none !important; transition: none !important; }
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 4px; }

.container { width: 100%; max-width: var(--maxw); margin: 0 auto; padding: 0 28px; }

.skip-link {
  position: absolute; left: -999px; top: 0;
  background: var(--accent); color: #fff; padding: 10px 16px; border-radius: 0 0 8px 0; z-index: 100; font-weight: 600;
}
.skip-link:focus { left: 0; }

/* ---------- Header / nav ---------- */
.site-header {
  position: sticky; top: 0; z-index: 50;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--border);
}
.nav {
  max-width: var(--maxw); margin: 0 auto; padding: 14px 28px;
  display: flex; align-items: center; justify-content: space-between;
}
.nav__brand { font-family: var(--font-display); font-weight: 700; font-size: 1.1rem; color: var(--text); letter-spacing: -0.01em; }
.nav__brand:hover { text-decoration: none; color: var(--accent); }
.nav__menu { list-style: none; display: flex; gap: 28px; margin: 0; padding: 0; }
.nav__menu a { color: var(--text-soft); font-size: 0.92rem; font-weight: 500; }
.nav__menu a:hover { color: var(--accent); text-decoration: none; }
.nav__toggle { display: none; background: none; border: 0; cursor: pointer; padding: 8px; }
.nav__toggle span { display: block; width: 22px; height: 2px; background: var(--text); margin: 4px 0; transition: 0.25s; }

/* ---------- Hero ---------- */
.hero { padding: 92px 0 56px; }
.hero__layout { display: flex; align-items: center; gap: 48px; }
.hero__text { flex: 1 1 auto; min-width: 0; }
.hero__photo {
  flex: 0 0 auto; width: 240px; height: 240px; border-radius: 50%;
  object-fit: cover; border: 4px solid var(--surface); box-shadow: var(--shadow-hover);
}
@media (max-width: 760px) {
  .hero__layout { flex-direction: column-reverse; align-items: flex-start; gap: 24px; }
  .hero__photo { width: 128px; height: 128px; }
}
.hero__eyebrow {
  color: var(--text-muted); font-weight: 600; font-size: 0.86rem;
  letter-spacing: 0.08em; text-transform: uppercase; margin: 0 0 16px;
}
.hero__name {
  font-family: var(--font-display); font-weight: 700;
  font-size: clamp(2.6rem, 7vw, 4.4rem); line-height: 1.02; margin: 0 0 22px; letter-spacing: -0.02em;
}
.hero__name span { color: var(--text); font-weight: 500; }
.hero__tagline { font-size: clamp(1.15rem, 2.4vw, 1.5rem); color: var(--text); max-width: 46ch; margin: 0 0 20px; font-weight: 500; }
.hero__intro { color: var(--text-soft); max-width: 68ch; margin: 0 0 30px; }
.hero__links { display: flex; flex-wrap: wrap; gap: 12px; margin-bottom: 44px; }

.btn {
  display: inline-block; padding: 11px 20px; border-radius: 10px;
  border: 1px solid var(--border); background: var(--surface);
  color: var(--text); font-size: 0.92rem; font-weight: 600; transition: 0.2s;
}
.btn:hover { border-color: var(--accent); color: var(--accent); text-decoration: none; transform: translateY(-1px); box-shadow: var(--shadow); }
.btn--primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn--primary:hover { background: var(--accent-2); border-color: var(--accent-2); color: #fff; }

.hero__stats {
  list-style: none; margin: 0; padding: 0;
  display: grid; grid-template-columns: repeat(3, auto); gap: 40px; justify-content: start;
}
.hero__stats li { display: flex; flex-direction: column; }
.stat__num { font-family: var(--font-display); font-weight: 700; font-size: 2rem; color: var(--accent); line-height: 1; }
.stat__label { color: var(--text-muted); font-size: 0.88rem; margin-top: 6px; max-width: 18ch; }

/* ---------- Sections ---------- */
.section { padding: 64px 0; }
.section--focus { background: var(--surface-2); border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); }
.section__title {
  font-family: var(--font-display); font-weight: 700; font-size: clamp(1.6rem, 3vw, 2.1rem);
  margin: 0 0 10px; letter-spacing: -0.02em;
}
.section__lede { color: var(--text-muted); margin: 0 0 36px; max-width: 60ch; }

/* ---------- Focus cards ---------- */
.focus-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; margin-top: 28px; }
.focus-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 26px; box-shadow: var(--shadow); transition: 0.22s;
}
.focus-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-hover); border-color: color-mix(in srgb, var(--accent) 40%, var(--border)); }
.focus-card h3 { margin: 0 0 8px; font-size: 1.12rem; font-family: var(--font-display); }
.focus-card p { margin: 0; color: var(--text-soft); font-size: 0.95rem; }

/* ============================================================
   TIMELINE — the signature element
   ============================================================ */
.timeline {
  list-style: none; margin: 8px 0 0; padding: 0;
  position: relative;
}
/* the vertical rail */
.timeline::before {
  content: ""; position: absolute; top: 6px; bottom: 6px;
  left: 120px; width: 2px; background: var(--rail);
}

.tl-item {
  position: relative;
  padding: 0 0 40px 164px;   /* leave room for year column + rail */
}
.tl-item:last-child { padding-bottom: 0; }

/* year label sits left of the rail */
.tl-year {
  position: absolute; left: 0; top: 0; width: 108px;
  text-align: right;
  font-family: var(--font-display); font-weight: 600; font-size: 0.95rem;
  color: var(--accent); line-height: 1.3;
}

/* the dot on the rail */
.tl-marker {
  position: absolute; left: 113px; top: 4px;
  width: 16px; height: 16px; border-radius: 50%;
  background: var(--surface); border: 3px solid var(--accent);
  box-shadow: 0 0 0 4px var(--bg);
}

.tl-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 22px 26px; box-shadow: var(--shadow);
  transition: 0.22s; margin-bottom: 16px;
}
.tl-card:last-child { margin-bottom: 0; }
.tl-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-hover); border-color: color-mix(in srgb, var(--accent) 35%, var(--border)); }

.tl-card--highlight { border-left: 4px solid var(--accent); }
.tl-card--award { border-left: 4px solid var(--award); }
.tl-card--talk { border-left: 4px solid var(--talk); }
.tl-card--blog { border-left: 4px solid var(--blog); }

.tl-badges { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.badge {
  display: inline-block; font-size: 0.72rem; font-weight: 700; letter-spacing: 0.03em;
  padding: 4px 11px; border-radius: 999px; text-transform: uppercase;
}
.badge--venue { color: var(--accent); background: var(--accent-soft); }
.badge--up { color: #fff; background: var(--accent-2); }
.badge--award { color: var(--award); background: var(--award-soft); }
.badge--role { color: var(--text-soft); background: var(--surface-2); }
.badge--edu { color: var(--text-soft); background: var(--surface-2); }
.badge--contrib { color: var(--accent); background: var(--accent-soft); }
.badge--talk { color: var(--talk); background: var(--talk-soft); }
.badge--blog { color: var(--blog); background: var(--blog-soft); }
.badge--code { color: var(--text-soft); background: var(--surface-2); font-family: var(--font-display); letter-spacing: 0.06em; }

.tl-title { margin: 0 0 4px; font-size: 1.18rem; line-height: 1.35; font-family: var(--font-display); letter-spacing: -0.01em; }
.tl-title a, .pub__title a { color: var(--text); text-decoration: none; }
.tl-title a:hover, .pub__title a:hover { color: var(--accent); text-decoration: underline; }

.tl-group { list-style: none; margin: 10px 0 0; padding: 0; display: grid; gap: 14px; }
.tl-group > li { display: grid; grid-template-columns: auto 1fr; gap: 6px 10px; align-items: start; }
.tl-group > li .badge--code { grid-row: 1 / 2; align-self: center; }
.tl-group > li > a { font-weight: 600; font-size: 1rem; line-height: 1.35; }
.tl-group > li > .tl-group-title { font-weight: 600; font-size: 1rem; line-height: 1.35; color: var(--text); }
.tl-card--blog .tl-group a { color: var(--text); }
.tl-card--blog .tl-group a:hover { color: var(--accent); text-decoration: underline; }
.tl-card--talk .tl-group a { color: var(--text); }
.tl-card--talk .tl-group a:hover { color: var(--accent); text-decoration: underline; }
.tl-group-note { grid-column: 2 / 3; color: var(--text-soft); font-size: 0.9rem; line-height: 1.5; }
.tl-group-foot { margin: 12px 0 0; font-size: 0.88rem; }
.tl-group--nocode > li { grid-template-columns: 1fr; }
.tl-group--nocode > li > a { grid-column: 1 / -1; }
.tl-group--nocode > li .tl-group-note { grid-column: 1 / -1; }
.tl-callout {
  margin: 12px 0 0; padding: 10px 14px; font-size: 0.9rem; line-height: 1.5;
  color: var(--text-soft); background: var(--surface-2);
  border-left: 3px solid var(--accent); border-radius: 0 8px 8px 0;
}
.tl-callout strong { color: var(--text); }

.impact-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 20px;
}
.impact-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 22px 24px; box-shadow: var(--shadow);
  transition: transform 0.2s, box-shadow 0.2s, border-color 0.2s;
}
.impact-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-hover); border-color: color-mix(in srgb, var(--accent) 35%, var(--border)); }
.impact-card h3 { margin: 0 0 8px; font-size: 1.08rem; font-family: var(--font-display); color: var(--accent); line-height: 1.3; }
.impact-card p { margin: 0; color: var(--text-soft); font-size: 0.95rem; line-height: 1.6; }
.impact-card strong { color: var(--text); font-weight: 700; }
.impact-proj { margin-top: 14px; }
.impact-proj:first-of-type { margin-top: 4px; }
.impact-proj h4 { margin: 0 0 6px; font-size: 0.98rem; color: var(--text); font-family: var(--font-display); }
.impact-bullets { margin: 0; padding-left: 18px; display: grid; gap: 5px; }
.impact-bullets li { color: var(--text-soft); font-size: 0.92rem; line-height: 1.5; }

.impact-stats {
  list-style: none; margin: 0 0 36px; padding: 22px 24px;
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow);
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 24px;
}
.impact-stats li { display: flex; flex-direction: column; }
@media (max-width: 560px) { .impact-stats { grid-template-columns: 1fr; } }

.author-me { color: var(--accent); font-weight: 700; }

.edu-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.edu-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 22px 24px; box-shadow: var(--shadow);
}
.edu-card h3 { margin: 0 0 4px; font-size: 1.12rem; font-family: var(--font-display); }
.edu-org { margin: 0; color: var(--accent); font-weight: 600; font-size: 0.95rem; }
.edu-meta { margin: 2px 0 8px; color: var(--text-muted); font-size: 0.86rem; }
.edu-note { margin: 0; color: var(--text-soft); font-size: 0.9rem; line-height: 1.5; }
@media (max-width: 640px) { .edu-grid { grid-template-columns: 1fr; } }
@media (max-width: 640px) {
  .tl-group > li { grid-template-columns: 1fr; }
  .tl-group-note { grid-column: 1 / -1; }
}

.tl-org { margin: 0 0 6px; color: var(--text); font-weight: 600; font-size: 0.95rem; }
.tl-authors { margin: 0 0 8px; color: var(--text-muted); font-size: 0.9rem; font-style: italic; }
.tl-desc { margin: 0; color: var(--text-soft); font-size: 0.96rem; }
.tl-desc strong, .tl-points strong { color: var(--text); font-weight: 700; }

.tl-points { margin: 14px 0 0; padding-left: 20px; }
.tl-points li { margin-bottom: 11px; color: var(--text-soft); font-size: 0.96rem; }
.tl-points li:last-child { margin-bottom: 0; }

/* ---------- Additional publications ---------- */
.pub-list { list-style: none; margin: 28px 0 0; padding: 0; display: grid; gap: 12px; }
.pub {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; padding: 16px 20px; box-shadow: var(--shadow); transition: 0.2s;
}
.pub:hover { border-color: color-mix(in srgb, var(--accent) 35%, var(--border)); transform: translateY(-2px); }
.pub__title { margin: 0 0 4px; font-size: 1rem; line-height: 1.4; font-family: var(--font-display); }
.pub__authors { margin: 0; color: var(--text-muted); font-size: 0.88rem; font-style: italic; }

/* ---------- Writing & Research (two-column) ---------- */
.writing-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 40px; margin-top: 28px; align-items: start; }
.writing-col__title { font-family: var(--font-display); font-size: 1.1rem; margin: 0 0 16px; padding-bottom: 8px; border-bottom: 2px solid var(--accent-soft); }
.writing-col .pub-list { margin: 0; }
.writing-col .pub-list--compact .pub { padding: 12px 16px; }
.link-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.link-list a {
  display: flex; justify-content: space-between; gap: 12px; align-items: center;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 10px; padding: 12px 16px; color: var(--text);
  font-weight: 500; font-size: 0.92rem; line-height: 1.35; transition: 0.2s;
}
.link-list a:hover { text-decoration: none; border-color: var(--accent); color: var(--accent); transform: translateX(2px); box-shadow: var(--shadow); }
.link-list span { color: var(--accent); font-weight: 700; flex-shrink: 0; }
.writing-foot { margin: 14px 0 0; font-size: 0.9rem; }
@media (max-width: 760px) { .writing-grid { grid-template-columns: 1fr; gap: 28px; } }

/* ---------- Talks ---------- */
.talks-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 28px; margin-top: 28px; }
.talk-group__title { font-size: 1.02rem; margin: 0 0 14px; padding-bottom: 8px; border-bottom: 2px solid var(--accent-soft); font-family: var(--font-display); }
.plain-list { list-style: none; margin: 0; padding: 0; }
.plain-list li { margin-bottom: 12px; color: var(--text-soft); font-size: 0.92rem; }
.plain-list strong { color: var(--text); font-weight: 600; }

.talks-sub { font-family: var(--font-display); font-size: 1.1rem; margin: 48px 0 18px; }
.blog-grid {
  list-style: none; margin: 0; padding: 0;
  display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px;
}
.blog-grid a {
  display: flex; justify-content: space-between; gap: 12px; align-items: center;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; padding: 16px 18px; color: var(--text);
  font-weight: 500; font-size: 0.95rem; transition: 0.2s;
}
.blog-grid a:hover { text-decoration: none; border-color: var(--accent); color: var(--accent); transform: translateY(-2px); box-shadow: var(--shadow); }
.blog-grid span { color: var(--accent); font-weight: 700; flex-shrink: 0; }
.blog-note { margin: 18px 0 0; font-size: 0.92rem; }

/* ---------- Contact ---------- */
.contact-list { list-style: none; margin: 28px 0 0; padding: 0; max-width: 620px; }
.contact-list li { display: grid; grid-template-columns: 110px 1fr; gap: 14px; padding: 12px 0; border-bottom: 1px solid var(--border); align-items: baseline; }
.contact-list li:last-child { border-bottom: 0; }
.contact-list span { color: var(--text-muted); font-size: 0.82rem; text-transform: uppercase; letter-spacing: 0.05em; font-weight: 600; }
.contact-list p { margin: 0; }

/* ---------- Footer ---------- */
.site-footer { border-top: 1px solid var(--border); padding: 28px 0; }
.site-footer .container { display: flex; justify-content: space-between; align-items: center; }
.site-footer p { margin: 0; color: var(--text-muted); font-size: 0.9rem; }
.to-top { font-size: 0.9rem; font-weight: 600; }

/* ---------- Responsive ---------- */
@media (max-width: 860px) {
  .focus-grid, .talks-grid { grid-template-columns: 1fr 1fr; }
  .blog-grid { grid-template-columns: 1fr; }
}

@media (max-width: 680px) {
  .nav__toggle { display: block; }
  .nav__menu {
    position: absolute; top: 100%; left: 0; right: 0;
    flex-direction: column; gap: 0; background: var(--bg);
    border-bottom: 1px solid var(--border);
    max-height: 0; overflow: hidden; transition: max-height 0.3s ease;
  }
  .nav__menu.open { max-height: 340px; }
  .nav__menu li { border-top: 1px solid var(--border); }
  .nav__menu a { display: block; padding: 14px 28px; }

  .focus-grid, .talks-grid { grid-template-columns: 1fr; }
  .section { padding: 48px 0; }
  .hero { padding: 60px 0 40px; }
  .hero__stats { grid-template-columns: 1fr; gap: 20px; }

  /* Timeline collapses: rail + year move inline to the left edge */
  .timeline::before { left: 7px; }
  .tl-item { padding: 0 0 36px 36px; }
  .tl-year {
    position: static; width: auto; text-align: left;
    margin: 0 0 12px -36px; padding-left: 36px;
    font-size: 0.9rem;
  }
  .tl-marker { left: 0; top: 2px; }
}

/* Research portfolio preview */
.hero { padding: 76px 0 42px; }
.hero__tagline { font-family: var(--font-display); font-size: clamp(1.4rem, 2.6vw, 1.9rem); line-height: 1.3; max-width: 35ch; }
.hero__intro { margin-bottom: 16px; }
.hero__links { margin: 24px 0 12px; }
.section-kicker { text-transform: uppercase; letter-spacing: .1em; color: var(--accent); font-size: .76rem; font-weight: 700; margin: 0 0 9px; }
.research-interest { color: var(--text-soft); max-width: 76ch; margin: 28px 0 0; }
.research-stack { display: grid; gap: 18px; }
.research-stack .tl-card { margin: 0; padding: 28px 30px; }
.research-stack .tl-title { font-size: 1.45rem; }
.research-question { color: var(--text); font-weight: 500; margin: 10px 0; }
.research-method { color: var(--text-soft); font-size: .88rem; margin: 16px 0 12px; }
.resource-links { display: flex; gap: 24px; }
.text-link { font-size: .9rem; font-weight: 600; }
.engineering-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; }
.engineering-grid .impact-card p + p { margin-top: 14px; }
.talks-two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 40px; margin-top: 30px; }
@media (max-width: 860px) { .engineering-grid { grid-template-columns: 1fr; } }
@media (max-width: 680px) { .talks-two-col { grid-template-columns: 1fr; gap: 24px; } .research-stack .tl-card { padding: 22px; } .nav__menu a { padding: 12px 28px; } }
@media (max-width: 560px) {
  .contact-list li { grid-template-columns: 1fr; gap: 3px; }
  .contact-list a { overflow-wrap: anywhere; }
  .site-footer .container { flex-wrap: wrap; gap: 12px; }
}
