/* ---------- Theme tokens: change colours here ---------- */
:root {
  --bg: #fbf9f5;
  --surface: #ffffff;
  --ink: #1f2328;
  --muted: #5d6166;
  --rule: #e6e0d6;
  --accent: #1f5f5b;        /* deep teal */
  --accent-soft: #e5efed;
  --tan: #b89a74;
  --serif: "Source Serif 4", Georgia, "Times New Roman", serif;
  --sans: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --maxw: 1080px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #15181b; --surface: #1c2024; --ink: #e8e6e1; --muted: #a3a7ab;
    --rule: #2e3338; --accent: #7cc3bb; --accent-soft: #1f3432; --tan: #c7a982;
  }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font-family: var(--sans); font-size: 16px; line-height: 1.6;
}
a { color: var(--accent); text-decoration-thickness: 1px; text-underline-offset: 3px; }
a:hover { text-decoration-thickness: 2px; }
img { max-width: 100%; height: auto; }
.wrap { max-width: var(--maxw); margin: 0 auto; padding: 0 20px; }
.muted { color: var(--muted); }
.skip { position: absolute; left: -999px; }
.skip:focus { left: 12px; top: 12px; background: var(--surface); padding: 8px 12px; z-index: 10; }

/* ---------- Header / nav ---------- */
.site-header {
  position: sticky; top: 0; z-index: 5;
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(8px); border-bottom: 1px solid var(--rule);
}
.nav-row { display: flex; align-items: center; justify-content: space-between; height: 60px; }
.brand { font-family: var(--serif); font-size: 1.2rem; font-weight: 600; color: var(--ink); text-decoration: none; }
.nav { display: flex; gap: 4px; }
.nav a {
  color: var(--muted); text-decoration: none; font-weight: 500; font-size: .95rem;
  padding: 6px 12px; border-radius: 999px;
}
.nav a:hover { color: var(--ink); background: var(--accent-soft); }
.nav a.active { color: var(--accent); background: var(--accent-soft); }
.nav-toggle, .nav-burger { display: none; }

@media (max-width: 720px) {
  .nav-burger { display: block; width: 36px; height: 36px; cursor: pointer; position: relative; }
  .nav-burger span, .nav-burger span::before, .nav-burger span::after {
    position: absolute; left: 8px; width: 20px; height: 2px; background: var(--ink); content: "";
  }
  .nav-burger span { top: 17px; }
  .nav-burger span::before { left: 0; top: -6px; }
  .nav-burger span::after { left: 0; top: 6px; }
  .nav {
    display: none; position: absolute; top: 60px; left: 0; right: 0; flex-direction: column;
    background: var(--bg); border-bottom: 1px solid var(--rule); padding: 8px 20px 16px;
  }
  .nav-toggle:checked ~ .nav { display: flex; }
}

/* ---------- Home ---------- */
.hero { height: 240px; position: relative; overflow: hidden; }
.hero::before, .page-head::before, .site-footer::before {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background: var(--banner) center / auto 100% repeat-x;   /* geometric drawing, tiled across */
}
.hero::before { opacity: .9; }
.hero-shade { position: absolute; inset: 0; background: linear-gradient(to bottom, transparent 45%, var(--bg)); }
@media (prefers-color-scheme: dark) {
  .hero::before, .page-head::before, .site-footer::before { filter: invert(1) hue-rotate(180deg); }
}
.profile { display: flex; gap: 32px; align-items: flex-start; margin-top: -80px; position: relative; }
.avatar {
  width: 160px; height: 160px; border-radius: 50%; object-fit: cover; flex: none;
  border: 5px solid var(--bg); background: var(--surface); box-shadow: 0 4px 18px rgb(0 0 0 / .12);
}
.profile-text { padding-top: 88px; }
.profile h1 { font-family: var(--serif); font-weight: 600; font-size: 2rem; line-height: 1.2; margin: 0 0 6px; }
.profile p { margin: 0 0 10px; }
.role { font-size: 1.05rem; color: var(--accent); font-weight: 500; }
.label { font-size: .75rem; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); margin-right: 6px; }
.pill {
  display: inline-block; padding: 6px 14px; border: 1px solid var(--accent); border-radius: 999px;
  text-decoration: none; font-size: .9rem; font-weight: 500;
}
.pill:hover { background: var(--accent); color: var(--bg); }

.sections { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-top: 40px; }
.section-card {
  display: flex; flex-direction: column; gap: 6px; padding: 20px; min-height: 140px;
  background: var(--surface); border: 1px solid var(--rule); border-radius: 12px;
  text-decoration: none; color: var(--ink); transition: border-color .15s, transform .15s;
}
.section-card:hover { border-color: var(--accent); transform: translateY(-2px); }
.section-title { font-family: var(--serif); font-size: 1.35rem; font-weight: 600; }
.section-sub { color: var(--muted); font-size: .9rem; line-height: 1.45; }
.arrow { margin-top: auto; color: var(--accent); }

.links { margin: 56px auto 24px; }
.links h2 { font-family: var(--serif); font-weight: 600; font-size: 1.5rem; margin: 0 0 16px; }
.link-groups { columns: 3 240px; column-gap: 32px; }
.link-group { break-inside: avoid; margin-bottom: 20px; }
.link-group h3 {
  font-size: .75rem; letter-spacing: .08em; text-transform: uppercase; color: var(--muted);
  margin: 0 0 6px; padding-bottom: 6px; border-bottom: 1px solid var(--rule);
}
.link-group ul { list-style: none; margin: 0; padding: 0; }
.link-group li { padding: 3px 0; font-size: .95rem; }

@media (max-width: 860px) { .sections { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 600px) {
  .hero { height: 160px; }
  .profile { flex-direction: column; gap: 12px; margin-top: -70px; }
  .avatar { width: 128px; height: 128px; }
  .profile-text { padding-top: 0; }
  .profile h1 { font-size: 1.6rem; }
  .sections { grid-template-columns: 1fr; }
  .section-card { min-height: 0; }
}

/* ---------- Inner pages ---------- */
.page-head { position: relative; overflow: hidden; border-bottom: 1px solid var(--rule); padding: 48px 0 32px; }
.page-head::before { opacity: .28; }
.page-head::after { content: ""; position: absolute; inset: 0; pointer-events: none;
  background: linear-gradient(to right, var(--bg) 15%, color-mix(in srgb, var(--bg) 40%, transparent) 75%); }
.page-head .wrap { position: relative; z-index: 1; }
/* Pages with their own header photo (banner: in front matter): photo on the right, fading into the page on the left */
.page-head.photo::before { left: auto; width: min(60%, 640px); opacity: .6; filter: none;
  background: var(--banner) center 45% / cover no-repeat;
  -webkit-mask-image: linear-gradient(to right, transparent, #000 45%); mask-image: linear-gradient(to right, transparent, #000 45%); }
.page-head h1 { font-family: var(--serif); font-weight: 600; font-size: 2.4rem; margin: 0; line-height: 1.15; }
.subtitle { color: var(--muted); margin: 8px 0 0; font-size: 1.05rem; }
.page { padding-top: 32px; padding-bottom: 48px; }
.page.has-toc { display: grid; grid-template-columns: 200px minmax(0, 1fr); gap: 48px; }
.toc { position: sticky; top: 84px; align-self: start; font-size: .88rem; max-height: calc(100vh - 100px); overflow: auto; }
.toc-title { font-size: .72rem; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); margin: 6px 0 8px; }
.toc ul { list-style: none; margin: 0; padding: 0; }
.toc ul ul { padding-left: 12px; }
.toc li { margin: 2px 0; }
.toc ul ul li { margin: 6px 0; padding-left: 12px; text-indent: -12px; line-height: 1.3; } /* sub-headings: one per line, wrapped lines indented */
.toc ul ul li::before { content: "·"; display: inline-block; width: 12px; text-indent: 0; color: var(--muted); } /* dot marker before each sub-heading */
.toc a { color: var(--muted); text-decoration: none; }
.toc a:hover { color: var(--accent); }
@media (max-width: 860px) {
  .page.has-toc { display: block; }
  .toc { position: static; max-height: none; margin-bottom: 24px; padding: 12px 16px;
    border: 1px solid var(--rule); border-radius: 10px; background: var(--surface); }
  .toc > nav > ul > li > ul { display: flex; flex-wrap: wrap; gap: 2px 12px; padding-left: 0; }
  .toc > nav > ul > li > ul > li { margin: 2px 0; padding-left: 0; text-indent: 0; }
}

/* ---------- Prose ---------- */
.prose { max-width: 760px; }
.prose h2 {
  font-family: var(--serif); font-weight: 600; font-size: 1.6rem; margin: 40px 0 12px;
  padding-bottom: 6px; border-bottom: 2px solid var(--tan); display: inline-block;
}
.prose h2:first-child { margin-top: 0; }
.prose h3 { font-family: var(--serif); font-weight: 600; font-size: 1.2rem; margin: 28px 0 8px; color: var(--ink); }
.prose h2, .prose h3 { scroll-margin-top: 80px; }
.prose h2 + * { clear: both; }
.prose p { margin: 0 0 14px; }
.prose ul { padding-left: 20px; margin: 0 0 14px; }
.prose li { margin: 6px 0; }
.prose li::marker { color: var(--tan); }
.prose em { color: var(--muted); }
.prose table { width: 100%; border-collapse: collapse; font-size: .92rem; margin: 8px 0 20px; }
.prose th { text-align: left; font-size: .72rem; letter-spacing: .06em; text-transform: uppercase;
  color: var(--muted); font-weight: 600; border-bottom: 1px solid var(--rule); padding: 8px 10px 6px 0; }
.prose td { border-bottom: 1px solid var(--rule); padding: 8px 10px 8px 0; vertical-align: top; }
.prose td:nth-child(2), .prose td:nth-child(3) { color: var(--muted); white-space: nowrap; }
@media (max-width: 600px) { .prose td:nth-child(2), .prose td:nth-child(3) { white-space: normal; } }

/* cards (funded projects) */
.cards { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; margin: 8px 0 20px; }
.card { background: var(--surface); border: 1px solid var(--rule); border-left: 3px solid var(--accent);
  border-radius: 10px; padding: 14px 16px; font-size: .95rem; }
.card p { margin: 0 0 6px; }
.card p:last-child { margin: 0; color: var(--muted); }
@media (max-width: 600px) { .cards { grid-template-columns: 1fr; } }

/* publications */
.pubs ul { list-style: none; padding-left: 0; }
.pubs li { padding: 10px 0 10px 14px; border-left: 2px solid var(--rule); margin: 10px 0; color: var(--muted); font-size: .95rem; }
.pubs li p { margin: 0; }
.pubs li a:first-child, .pubs li strong { font-family: var(--serif); font-size: 1.05rem; font-weight: 600; }
.topics { font-size: .88rem; color: var(--muted); margin-top: -4px; }

/* ---------- Footer ---------- */
.site-footer { position: relative; overflow: hidden; border-top: 1px solid var(--rule); padding: 24px 0 32px; margin-top: 40px; font-size: .88rem; }
.site-footer::before { opacity: .12; }
.site-footer .wrap { position: relative; }
.site-footer p { margin: 0 0 4px; }

/* figures (research page) */
.figs { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; margin: 14px 0 22px; }
.figs.two { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.figs figure { margin: 0; background: #fff; border: 1px solid var(--rule); border-radius: 10px; padding: 10px;
  display: flex; flex-direction: column; justify-content: center; }
.figs img { display: block; width: 100%; height: 150px; object-fit: contain; }
.figs.two img { height: 170px; }
.figs figcaption { font-size: .78rem; color: #5d6166; margin-top: 6px; text-align: center; }
.card img.logo { display: block; height: 64px; width: auto; max-width: 100%; object-fit: contain; margin-bottom: 10px;
  background: #fff; border-radius: 6px; padding: 4px; }
.card img.thumb { display: block; width: 100%; height: 120px; object-fit: cover; border-radius: 6px; margin-bottom: 10px; background: #fff; }

/* two-column layout (Dissemination page) — set `wide: true` in a page's front matter */
.prose.wide { max-width: none; }
.twocol { display: grid; grid-template-columns: 1fr 1fr; gap: 48px; align-items: start; }
.twocol .col > h2:first-child { margin-top: 0; }
.twocol .col + .col { border-left: 1px solid var(--rule); padding-left: 48px; }
@media (max-width: 860px) {
  .twocol { grid-template-columns: 1fr; gap: 8px; }
  .twocol .col + .col { border-left: 0; padding-left: 0; border-top: 1px solid var(--rule); padding-top: 24px; }
}

/* project cards: identical image box + title style for every card */
.cards { align-items: stretch; }
.card { display: flex; flex-direction: column; gap: 12px; padding: 16px; }
.card p { margin: 0; }
.card img, .card img.logo, .card img.thumb {
  display: block; width: 100%; height: 96px; object-fit: contain !important;
  background: #fff; border: 1px solid var(--rule); border-radius: 8px; padding: 10px; margin: 0;
}
.card p, .card p:last-child { font-family: var(--serif); font-size: 1.05rem; line-height: 1.35; color: var(--ink); }
.card strong { font-weight: 600; }
.card a { color: var(--ink); text-decoration: none; }
.card a:hover { color: var(--accent); text-decoration: underline; }

/* lab members (Lab page, people listed in data/lab.yaml) */
.people { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 14px; margin: 10px 0 28px; }
.person { display: flex; gap: 16px; align-items: flex-start; background: var(--surface);
  border: 1px solid var(--rule); border-radius: 12px; padding: 16px; }
.person-photo { width: 76px; height: 76px; border-radius: 50%; object-fit: cover; flex: none; }
.person-photo.initials { display: flex; align-items: center; justify-content: center;
  background: var(--accent-soft); color: var(--accent); font-family: var(--serif); font-size: 1.5rem; font-weight: 600; }
.person-text p { margin: 0 0 3px; }
.person-name { font-family: var(--serif); font-size: 1.15rem; font-weight: 600; }
.person-role { color: var(--ink); font-size: .92rem; }
.person-meta { color: var(--muted); font-size: .85rem; }
.person-topic { font-size: .92rem; margin-top: 6px !important; }
.person-link { font-size: .88rem; }
.sections { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }

/* Lab page side panel (recruiting box + contents) */
.lab-layout { display: grid; grid-template-columns: minmax(0, 1fr) 270px; gap: 40px; align-items: start; }
.lab-layout > .prose { grid-column: 1; grid-row: 1; }
.lab-panel { grid-column: 2; grid-row: 1; position: sticky; top: 84px; display: flex; flex-direction: column; gap: 18px; }
.recruit { background: var(--accent-soft); border: 1px solid color-mix(in srgb, var(--accent) 35%, transparent);
  border-radius: 14px; padding: 18px; }
.recruit p { margin: 0 0 10px; }
.recruit-badge { display: flex; align-items: center; gap: 8px; font-family: var(--serif); font-weight: 600;
  font-size: 1.15rem; color: var(--accent); }
.recruit-badge .dot { width: 10px; height: 10px; border-radius: 50%; background: #2e9e5b; flex: none;
  box-shadow: 0 0 0 4px color-mix(in srgb, #2e9e5b 25%, transparent); }
.recruit-text { font-size: .92rem; line-height: 1.5; color: var(--ink); }
.recruit-btn { display: inline-block; background: var(--accent); color: var(--bg); text-decoration: none;
  font-weight: 600; font-size: .92rem; padding: 8px 16px; border-radius: 999px; margin: 2px 0 12px; }
.recruit-btn:hover { filter: brightness(1.1); }
.recruit-email { font-size: .85rem; color: var(--muted); word-break: break-word; margin: 0 !important; }
.lab-toc ul { list-style: none; margin: 0; padding: 0; font-size: .9rem; }
.lab-toc li { margin: 4px 0; }
.lab-toc a { color: var(--muted); text-decoration: none; }
.lab-toc a:hover { color: var(--accent); }
.lab-layout .people { grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
@media (max-width: 900px) {
  .lab-layout { display: block; }
  .lab-panel { position: static; margin-bottom: 28px; }
  .lab-toc { display: none; }
}

/* Home page photo: larger and square */
.avatar { width: 240px; height: 240px; border-radius: 14px; object-fit: cover; object-position: center 30%; }
@media (max-width: 600px) { .avatar { width: 180px; height: 180px; } }
/* Photo sits below the banner, its bottom level with the Google Scholar button */
@media (min-width: 601px) {
  .profile { margin-top: 28px; align-items: flex-end; }
  .profile-text { padding-top: 0; }
  .profile-text p:last-child { margin-bottom: 0; }
}
/* Photo spans the whole text block: top level with the name, bottom level with the Google Scholar button.
   The exact size is set by a small script in layouts/index.html (300px is the fallback). */
@media (min-width: 861px) {
  .profile { align-items: flex-start; }
  .profile .avatar { width: 300px; height: 300px; }
}
/* Narrower screens: photo above the text */
@media (max-width: 860px) {
  .profile { flex-direction: column; gap: 16px; align-items: flex-start; }
  .profile .avatar { width: 200px; height: 200px; }
}

/* Home banner: same faint drawing strength as the other pages' headers */
.hero::before { opacity: .28; }
