/* ============================================================
   Xie Lab — Stylesheet
   Fonts: Fraunces (display) + DM Sans (body) via Google Fonts
   ============================================================ */

:root {
  --bg: #FBF9F4;
  --bg-alt: #F2EBE3;
  --ink: #1A1A1A;
  --ink-muted: #5A5A5A;
  --rule: #D9D3C5;
  --brand: #9B1B1B;        /* deep crimson — matches logo */
  --brand-soft: #B8302E;
  --accent: #C8312D;       /* brighter red for stats/CTAs */
  --max: 1200px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
  background: var(--bg);
  color: var(--ink);
  font-family: 'DM Sans', system-ui, sans-serif;
  font-size: 17px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}

/* ---------- Typography ---------- */
h1, h2, h3, h4 {
  font-family: 'Fraunces', Georgia, serif;
  font-weight: 500;
  line-height: 1.05;
  letter-spacing: -0.02em;
  color: var(--ink);
}

h1 { font-size: clamp(2.5rem, 6vw, 5.5rem); font-variation-settings: "SOFT" 30, "opsz" 144; }
h2 { font-size: clamp(2rem, 4vw, 3.25rem); }
h3 { font-size: clamp(1.4rem, 2.5vw, 2rem); font-weight: 400; font-style: italic; }
h4 { font-size: 1.15rem; font-weight: 600; letter-spacing: 0.02em; text-transform: uppercase; font-family: 'DM Sans', sans-serif; }

p { margin-bottom: 1.1em; }
p.lead { font-size: 1.25rem; line-height: 1.55; color: var(--ink); max-width: 60ch; }

a { color: var(--brand); text-decoration: none; transition: color .2s; }
a:hover { color: var(--accent); }

.eyebrow {
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--brand);
  margin-bottom: 1.5rem;
  display: inline-block;
}

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

section { padding: 7rem 0; }

/* ---------- Header / Nav ---------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(251, 249, 244, 0.92);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--rule);
}
.nav {
  max-width: var(--max);
  margin: 0 auto;
  padding: 1rem 2rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.nav-logo img {
  height: 50px;
  width: auto;
  display: block;
}
.nav-links { display: flex; gap: 2.25rem; list-style: none; align-items: center; }
.nav-links a {
  color: var(--ink);
  font-size: 0.95rem;
  font-weight: 500;
  position: relative;
  padding: 0.25rem 0;
}
.nav-links a::after {
  content: '';
  position: absolute;
  left: 0; bottom: -2px;
  width: 0; height: 2px;
  background: var(--accent);
  transition: width .3s ease;
}
.nav-links a:hover::after,
.nav-links a.active::after { width: 100%; }

.nav-toggle { display: none; background: none; border: 0; font-size: 1.5rem; cursor: pointer; color: var(--ink); }

/* ---------- Hero ---------- */
.hero {
  padding: 6rem 0 5rem;
  position: relative;
  overflow: hidden;
}
.hero .container {
  max-width: none;
  padding-left: max(2rem, calc((100vw - 1200px) / 2 + 2rem));
  padding-right: 2rem;
}
.hero-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.7fr);
  gap: 2.5rem;
  align-items: center;
}
.hero h1 {
  margin-bottom: 1.5rem;
  font-size: clamp(2.1rem, 4vw, 4.2rem);
  overflow-wrap: break-word;
}
.hero h1 em {
  font-style: italic;
  color: var(--brand);
  font-variation-settings: "SOFT" 100;
}
.hero-tag {
  font-size: 1.2rem;
  color: var(--ink-muted);
  max-width: 50ch;
  margin-bottom: 2.5rem;
}
.hero-cta { display: flex; gap: 1rem; flex-wrap: wrap; }

.hero-image {
  position: relative;
}
.hero-image img {
  width: 100%;
  height: auto;
  display: block;
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-block;
  padding: 0.95rem 1.8rem;
  font-size: 0.95rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  border-radius: 2px;
  transition: all .25s;
  cursor: pointer;
  border: 1.5px solid transparent;
}
.btn-primary {
  background: var(--brand);
  color: var(--bg);
  border-color: var(--brand);
}
.btn-primary:hover { background: var(--accent); border-color: var(--accent); color: white; }
.btn-ghost {
  background: transparent;
  color: var(--ink);
  border-color: var(--ink);
}
.btn-ghost:hover { background: var(--ink); color: var(--bg); }

.arrow-link {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--brand);
  text-transform: uppercase;
  letter-spacing: 0.1em;
}
.arrow-link::after {
  content: '→';
  transition: transform .2s;
}
.arrow-link:hover::after { transform: translateX(4px); }

/* ---------- Mission / story sections ---------- */
.story { background: var(--bg-alt); }
.story-block { display: grid; grid-template-columns: 1fr 1fr; gap: 5rem; align-items: start; }
.story-block + .story-block { margin-top: 6rem; }
.story-block.reverse { direction: rtl; }
.story-block.reverse > * { direction: ltr; }

/* ---------- Stat callout ---------- */
.stat-callout {
  text-align: center;
  padding: 6rem 2rem;
  border-top: 1px solid var(--rule);
  border-bottom: 1px solid var(--rule);
  background: var(--bg);
}
.stat-number {
  font-family: 'Fraunces', serif;
  font-size: clamp(7rem, 18vw, 14rem);
  font-weight: 300;
  line-height: 1;
  color: var(--accent);
  font-variation-settings: "SOFT" 100, "opsz" 144;
  display: block;
  margin: 0.5rem 0;
}
.stat-label {
  font-size: 0.85rem;
  font-weight: 600;
  letter-spacing: 0.25em;
  text-transform: uppercase;
  color: var(--ink-muted);
}

/* ---------- Research areas ---------- */
.research-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0;
  margin-top: 4rem;
  border-top: 1px solid var(--rule);
}
.research-card {
  padding: 3rem 2rem;
  border-right: 1px solid var(--rule);
  border-bottom: 1px solid var(--rule);
  transition: background .25s;
  display: block;
  color: var(--ink);
}
.research-card:last-child { border-right: none; }
.research-card:hover { background: var(--bg-alt); color: var(--ink); }
.research-num {
  font-family: 'Fraunces', serif;
  font-style: italic;
  font-size: 3rem;
  color: var(--accent);
  display: block;
  margin-bottom: 1rem;
}
.research-card h3 { margin-bottom: 1rem; font-style: normal; font-weight: 500; }

/* ---------- Funders ---------- */
.funders {
  background: var(--bg-alt);
  padding: 5rem 0;
  text-align: center;
}
.funders h4 { color: var(--ink-muted); margin-bottom: 3rem; }
.funder-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 2rem;
  max-width: 1200px;
  margin: 0 auto;
  align-items: stretch;
}
.funder-logo {
  height: 170px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #fff;
  border: 1px solid var(--rule);
  border-radius: 8px;
  padding: 1.75rem 2rem;
}
.funder-logo img {
  max-height: 100%;
  max-width: 100%;
  object-fit: contain;
  display: block;
}

/* ---------- Footer ---------- */
.site-footer {
  background: var(--ink);
  color: var(--bg);
  padding: 4rem 0 2rem;
}
.site-footer a { color: var(--bg); }
.site-footer a:hover { color: var(--accent); }
.footer-grid {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr;
  gap: 3rem;
  margin-bottom: 3rem;
}
.footer-grid h4 { color: var(--bg); opacity: 0.6; margin-bottom: 1rem; font-size: 0.85rem; }
.footer-grid ul { list-style: none; }
.footer-grid li { margin-bottom: 0.5rem; }
.footer-bottom {
  padding-top: 2rem;
  border-top: 1px solid rgba(255,255,255,0.15);
  display: flex;
  justify-content: space-between;
  font-size: 0.85rem;
  opacity: 0.7;
}
.footer-logo {
  font-family: 'Fraunces', serif;
  font-size: 1.5rem;
  color: var(--bg);
  margin-bottom: 1rem;
  display: block;
}
.footer-logo em { color: var(--accent); font-style: italic; }

/* ---------- Page Header (for inner pages) ---------- */
.page-header {
  padding: 6rem 0 4rem;
  border-bottom: 1px solid var(--rule);
}
.page-header h1 { margin-bottom: 1rem; }

/* ---------- People ---------- */
.people-section { padding: 5rem 0; }
.people-section + .people-section { padding-top: 4rem; }
.people-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 3rem;
  margin-top: 3rem;
}
.person-card .photo {
  aspect-ratio: 1 / 1.15;
  background: var(--bg-alt);
  border-radius: 2px;
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Fraunces', serif;
  font-style: italic;
  font-size: 3rem;
  color: var(--brand);
  background-image: linear-gradient(135deg, #F0DDD8 0%, #F2EBE3 100%);
}
.person-card h4 { font-size: 1.1rem; text-transform: none; letter-spacing: 0; margin-bottom: 0.25rem; font-family: 'DM Sans', sans-serif; }
.person-card p { font-size: 0.9rem; color: var(--ink-muted); margin: 0; }

/* ---------- Publications ---------- */
.pub-list { list-style: none; }
.pub-item {
  padding: 2rem 0;
  border-bottom: 1px solid var(--rule);
  display: grid;
  grid-template-columns: 80px 1fr;
  gap: 2rem;
  align-items: start;
}
.pub-year {
  font-family: 'Fraunces', serif;
  font-style: italic;
  font-size: 1.5rem;
  color: var(--accent);
}
.pub-title { font-weight: 600; margin-bottom: 0.5rem; font-size: 1.05rem; }
.pub-authors { color: var(--ink-muted); font-size: 0.95rem; margin-bottom: 0.5rem; }
.pub-journal { font-style: italic; font-size: 0.9rem; color: var(--ink-muted); }
.pub-journal a { color: var(--brand); font-style: normal; font-weight: 500; }

/* ---------- Contact ---------- */
.contact-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 5rem; }
.contact-info p { margin-bottom: 0.5rem; }
.contact-info strong { display: block; font-size: 0.8rem; letter-spacing: 0.15em; text-transform: uppercase; color: var(--ink-muted); margin-top: 1.5rem; margin-bottom: 0.25rem; }

/* ---------- Animations ---------- */
@keyframes rise {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}
.rise { animation: rise .8s ease-out backwards; }
.rise.d1 { animation-delay: 0.1s; }
.rise.d2 { animation-delay: 0.25s; }
.rise.d3 { animation-delay: 0.4s; }
.rise.d4 { animation-delay: 0.55s; }

/* ---------- Responsive ---------- */
@media (max-width: 860px) {
  section { padding: 4rem 0; }
  .hero { padding: 3rem 0; }
  .hero-grid,
  .story-block,
  .research-grid,
  .footer-grid,
  .contact-grid { grid-template-columns: 1fr; gap: 2.5rem; }
  .research-card { border-right: none; }
  .nav-logo img { height: 40px; }
  .nav-links {
    display: none;
    position: absolute;
    top: 100%; left: 0; right: 0;
    background: var(--bg);
    flex-direction: column;
    padding: 2rem;
    gap: 1.5rem;
    border-bottom: 1px solid var(--rule);
  }
  .nav-links.open { display: flex; }
  .nav-toggle { display: block; }
  .pub-item { grid-template-columns: 1fr; gap: 0.5rem; }
  .footer-bottom { flex-direction: column; gap: 1rem; }
}


/* ---------- Keywords line (hero) ---------- */
.keywords {
  margin-top: 2rem;
  font-size: 0.85rem;
  color: var(--ink-muted);
  letter-spacing: 0.01em;
  max-width: 55ch;
}
.keywords strong {
  color: var(--brand);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 0.72rem;
  display: block;
  margin-bottom: 0.4rem;
}

/* ---------- Key questions (research themes) ---------- */
.key-questions {
  margin: 1.75rem 0;
  padding: 1.5rem 1.75rem;
  background: var(--bg-alt);
  border-left: 3px solid var(--accent);
  border-radius: 2px;
}
.story .key-questions { background: var(--bg); }
.key-questions h4 {
  font-size: 0.78rem;
  letter-spacing: 0.15em;
  color: var(--ink-muted);
  margin-bottom: 1rem;
}
.key-questions ul { list-style: none; }
.key-questions li {
  position: relative;
  padding-left: 1.5rem;
  margin-bottom: 0.6rem;
  line-height: 1.5;
}
.key-questions li:last-child { margin-bottom: 0; }
.key-questions li::before {
  content: '→';
  position: absolute;
  left: 0;
  color: var(--accent);
  font-weight: 600;
}

/* ---------- Approach list (How we work) ---------- */
.approach-list {
  list-style: none;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.75rem 2rem;
  margin: 2rem 0;
}
.approach-list li {
  position: relative;
  padding-left: 1.75rem;
  font-weight: 500;
}
.approach-list li::before {
  content: '✦';
  position: absolute;
  left: 0;
  color: var(--accent);
}
@media (max-width: 860px) {
  .approach-list { grid-template-columns: 1fr; }
}
