/* 00-tokens.css */
/* Self-hosted, SIL Open Font License (see public/fonts/OFL-*.txt) */
@font-face {
  font-family: "Caveat";
  src: url("fonts/caveat-latin-wght-normal.woff2") format("woff2");
  font-weight: 400 700;
  font-display: swap;
}
@font-face { font-family: "Alegreya Sans"; src: url("fonts/alegreya-sans-latin-400-normal.woff2") format("woff2"); font-weight: 400; font-style: normal; font-display: swap; }
@font-face { font-family: "Alegreya Sans"; src: url("fonts/alegreya-sans-latin-400-italic.woff2") format("woff2"); font-weight: 400; font-style: italic; font-display: swap; }
@font-face { font-family: "Alegreya Sans"; src: url("fonts/alegreya-sans-latin-500-normal.woff2") format("woff2"); font-weight: 500; font-style: normal; font-display: swap; }
@font-face { font-family: "Alegreya Sans"; src: url("fonts/alegreya-sans-latin-700-normal.woff2") format("woff2"); font-weight: 700; font-style: normal; font-display: swap; }

:root {
  /* paper & ink */
  --paper: #fffefb;
  --paper-2: #f6f2ec;
  --ink: #2d2825;
  --ink-2: #554a44;
  --muted: #857a72;
  --line: rgb(45 40 37 / 0.12);
  --line-strong: rgb(45 40 37 / 0.22);
  --line-faint: rgb(45 40 37 / 0.06);

  /* accents: thyroid rose, plum (the axis), sage (the contours) */
  --rose: #5e3a8c;   /* primary: iodine violet (name kept for the cascade) */
  --iodine: #5e3a8c;
  --terracotta: #b05c4f;
  --rose-soft: #ece4f5;
  --plum: #6e3f52;
  --plum-soft: #eadde3;
  --sage: #5f7b6c;
  --sage-soft: #dfe7e1;


  /* topics */
  --t1: var(--terracotta);
  --t2: var(--sage);
  --t3: #4f6d8a;
  --ochre: #94672a;
  --t4: var(--ochre);

  --hand: "Caveat", "Segoe Print", "Bradley Hand", cursive;
  --serif: "Alegreya Sans", ui-sans-serif, system-ui, sans-serif; /* body */
  --sans: "Alegreya Sans", ui-sans-serif, system-ui, sans-serif;  /* UI */

  --narrow: 40rem;
  --wide: 72rem;
  --gutter: clamp(1rem, 4vw, 2rem);
  --space: clamp(3.5rem, 7vw, 5.5rem);

  /* hand-made, slightly uneven corners */
  --radius: 0.4rem 0.55rem 0.45rem 0.6rem / 0.55rem 0.4rem 0.6rem 0.45rem;
  --radius-sm: 0.2rem 0.3rem 0.22rem 0.32rem / 0.3rem 0.2rem 0.32rem 0.22rem;

  --shadow: none;
  color-scheme: light;
}


/* 10-base.css */
*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; padding: 0; }

html { scroll-behavior: smooth; scroll-padding-top: 5rem; -webkit-text-size-adjust: 100%; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

body {
  background: var(--paper);
  color: var(--ink);
  font-family: var(--serif);
  font-size: 1.125rem;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
}

::selection { background: var(--rose-soft); color: var(--ink); }

h1, h2, h3 { font-family: var(--hand); font-weight: 400; line-height: 1.05; letter-spacing: 0; text-wrap: balance; }
h1 { font-size: clamp(3.2rem, 8vw, 5rem); text-shadow: -1px 2px 0 #f3efef; }
h2 { font-size: clamp(2.3rem, 5vw, 3.1rem); }
h3 { font-size: 1.6rem; }
p { text-wrap: pretty; }

a { color: var(--rose); text-decoration: none; text-underline-offset: 0.18em; }
a:hover { text-decoration: underline; text-decoration-thickness: 1px; }
a:focus-visible, button:focus-visible, input:focus-visible, summary:focus-visible {
  outline: 2px solid var(--plum); outline-offset: 3px; border-radius: 4px;
}

img { max-width: 100%; display: block; }

.meta, .chip, .venue, .year, .small, .topbar, .pill, .more, summary, figcaption, .footer {
  font-family: var(--sans);
}
.small { font-size: 0.85rem; color: var(--ink-2); }
.venue { font-size: 0.85rem; color: var(--muted); }
.year { font-size: 0.8rem; color: var(--muted); font-variant-numeric: tabular-nums; }

.icon { width: 1.15rem; height: 1.15rem; flex: none; }
.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;
}
[hidden] { display: none !important; }


/* 20-layout.css */
.page {
  width: min(var(--wide), 100% - 2 * var(--gutter));
  margin-inline: auto;
  display: flex;
  flex-direction: column;
  gap: var(--space);
  padding-bottom: var(--space);
}

section { display: flex; flex-direction: column; align-items: center; gap: 1.5rem; }

.section-head {
  max-width: var(--narrow);
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.6rem;
}
.section-head { gap: 0.35rem; }
.section-head h2 { font-size: clamp(2.3rem, 4.6vw, 3rem); }
.section-intro { color: var(--ink-2); }

.card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.25rem 1.4rem;
}

.grid-3 {
  width: 100%;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 15rem), 1fr));
  gap: 1.25rem;
}

.meta {
  display: flex; gap: 0.75rem; align-items: baseline; justify-content: space-between;
  font-size: 0.78rem; color: var(--muted);
}

.more { font-size: 0.9rem; font-weight: 500; margin-top: auto; }

.chip {
  display: inline-flex; align-items: center; gap: 0.45rem;
  font-size: 0.88rem;
  color: var(--ink-2);
  background: color-mix(in oklab, var(--paper) 80%, transparent);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  padding: 0.35rem 0.85rem;
  cursor: pointer;
  transition: background 0.2s, color 0.2s, border-color 0.2s;
}
.chip span:not(.topic-dot) { color: var(--muted); font-variant-numeric: tabular-nums; }
.chip:hover { border-color: var(--ink-2); }
.chip.is-on { background: var(--ink); border-color: var(--ink); color: var(--paper); }
.chip.is-on span:not(.topic-dot) { color: color-mix(in oklab, var(--paper) 70%, transparent); }

.dated-list { list-style: none; width: min(100%, var(--narrow)); display: flex; flex-direction: column; }
.dated-list li {
  display: grid; grid-template-columns: 3.25rem 1fr; gap: 1rem;
  padding: 0.9rem 0; border-top: 1px solid var(--line);
}
.dated-list li:last-child { border-bottom: 1px solid var(--line); }
.dated-list .year { padding-top: 0.2rem; }

.footer {
  width: min(var(--wide), 100% - 2 * var(--gutter));
  margin: 0 auto;
  padding: 2rem 0 3rem;
  border-top: 1px solid var(--line);
  display: flex; justify-content: center; gap: 2rem; flex-wrap: wrap;
  font-size: 0.85rem; color: var(--muted);
}

/* edit mode (unchanged behaviour) */
.edit-indicator {
  position: fixed; right: 1rem; bottom: 1rem; z-index: 200;
  font: 0.78rem var(--sans); color: var(--muted);
  opacity: 0; pointer-events: none;
}
body.config-edit-mode .edit-indicator { opacity: 0.8; }
body.config-edit-mode [data-source-file] { cursor: pointer; outline: 2px dashed color-mix(in oklab, var(--rose) 60%, white); outline-offset: 0.35rem; }
body.config-edit-mode [data-source-file]:hover { outline-style: solid; }


/* 30-sections.css */
/* ---------- compact header ---------- */
.hero { display: flex; flex-direction: column; align-items: center; gap: 0.9rem; padding: clamp(2.5rem, 7vh, 4rem) 0 0; text-align: center; }
.id-row { display: flex; align-items: center; justify-content: center; gap: clamp(0.9rem, 2.5vw, 1.4rem); }
.portrait {
  width: clamp(4.5rem, 10vw, 6rem); height: auto; aspect-ratio: 1; object-fit: cover; flex: none;
  border-radius: 50%; border: 3px solid #fff; box-shadow: 0 0 0 1px var(--line);
}
.id-text { text-align: left; }
.hero h1 { font-size: clamp(2.8rem, 7vw, 4.2rem); line-height: 0.95; text-shadow: -1px 2px 0 #f3efef; }
.role { font: 1rem var(--sans); color: var(--muted); margin-top: 0.15rem; }
.tagline { max-width: 34rem; font-size: 1rem; color: var(--ink-2); }
.badge-line { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 0.35rem; }
.badge {
  font: 0.88rem var(--sans); color: var(--ink-2);
  padding: 0.18rem 0.7rem; border: 1px solid var(--line); border-radius: var(--radius-sm); background: #fff;
}
.badge:hover { color: var(--rose); border-color: var(--rose); text-decoration: none; }
.badge-sep { width: 1px; height: 1rem; background: var(--line-strong); margin: 0 0.3rem; }

/* ---------- lately (bento) ---------- */
.bento { width: 100%; display: grid; grid-template-columns: 1.65fr 1fr; gap: 1.1rem; }
.feature { display: grid; grid-template-columns: minmax(10rem, 0.8fr) 1.2fr; gap: 1.4rem; padding: 0.75rem; }
.feature-photo { position: relative; margin: 0; }
.feature-photo img { width: 100%; height: 100%; max-height: 30rem; object-fit: cover; object-position: 50% 25%; border-radius: var(--radius-sm); }
.feature-photo figcaption { position: absolute; left: 0.6rem; bottom: 0.5rem; font: 0.68rem var(--sans); color: rgb(255 255 255 / 0.9); }
.feature-body { display: flex; flex-direction: column; gap: 0.6rem; padding: 0.6rem 0.75rem 0.6rem 0; }
.feature h3 { font-size: 2.3rem; }
.feature-sub { color: var(--ink-2); }
.feature blockquote { border-left: 2px solid var(--rose); padding: 0.2rem 0 0.2rem 1rem; margin: 0.3rem 0; }
.feature blockquote p { font-style: italic; font-size: 1.05rem; line-height: 1.5; color: var(--ink); }
.feature blockquote .translation { font: 0.82rem/1.45 var(--sans); font-style: normal; color: var(--muted); margin-top: 0.4rem; }
.feature-text { color: var(--ink-2); font-size: 0.95rem; }
.news-stack { display: flex; flex-direction: column; gap: 1.1rem; }
.news-card { display: flex; flex-direction: column; gap: 0.45rem; flex: 1; }
.news-card h3 { font-size: 1.6rem; }
.news-card p:not(.meta) { color: var(--ink-2); font-size: 0.94rem; }
@media (max-width: 56rem) {
  .bento { grid-template-columns: 1fr; }
  .news-stack { flex-direction: row; flex-wrap: wrap; }
  .news-card { flex: 1 1 16rem; }
}
@media (max-width: 34rem) {
  .feature { grid-template-columns: 1fr; }
  .feature-photo img { max-height: 22rem; aspect-ratio: 4 / 5; }
  .feature-body { padding: 0 0.5rem 0.5rem; }
}

/* ---------- two-column splits ---------- */
.split { width: 100%; display: grid; grid-template-columns: 1.6fr 1fr; gap: 1.5rem 2.5rem; align-items: start; }
.split-even { grid-template-columns: 1fr 1fr; gap: 1.1rem; }
.col { display: flex; flex-direction: column; gap: 1.1rem; }
@media (max-width: 56rem) { .split, .split-even { grid-template-columns: 1fr; } }

.mini-head { font-size: 1.6rem; margin-bottom: 0.4rem; }

/* ---------- about ---------- */
.prose { display: flex; flex-direction: column; gap: 1rem; }
.prose .lead { font-size: 1.15rem; line-height: 1.6; color: var(--ink); }
.prose .lead::first-letter { float: left; font-family: var(--hand); font-weight: 400; font-size: 3.6em; line-height: 0.8; padding: 0.05em 0.12em 0 0; color: var(--rose); }
.prose p { color: var(--ink-2); font-size: 1rem; }
.glance { position: sticky; top: 5rem; }
.glance h3 { font-size: 1.7rem; margin-bottom: 0.4rem; }
.glance dl { display: flex; flex-direction: column; }
.glance dl > div { display: grid; grid-template-columns: 6.5rem 1fr; gap: 0.75rem; padding: 0.6rem 0; border-top: 1px solid var(--line); }
.glance dt { font: 0.78rem var(--sans); color: var(--muted); padding-top: 0.15rem; }
.glance dd { font-size: 0.95rem; line-height: 1.45; }
@media (max-width: 56rem) { .glance { position: static; } }

/* ---------- research ---------- */
.theme-card { display: flex; flex-direction: column; gap: 0.55rem; }
.theme-top { display: flex; align-items: center; gap: 0.7rem; }
.theme-card p { color: var(--ink-2); font-size: 0.94rem; }
.glyph {
  width: 1.15em; height: 1.15em; flex: none; color: var(--tc, var(--muted));
  fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round;
}
.glyph .fill { fill: currentColor; stroke: none; opacity: 0.18; }
.theme-top .glyph { width: 2rem; height: 2rem; }
.t-1 { --tc: var(--t1); } .t-2 { --tc: var(--t2); } .t-3 { --tc: var(--t3); } .t-4 { --tc: var(--t4); }
.theme-card .more { color: var(--tc); }
.selected { width: 100%; }

/* ---------- shared compact lists ---------- */
.compact-list { list-style: none; width: 100%; }
.compact-list > li { display: grid; grid-template-columns: 3rem 1fr; gap: 0.9rem; padding: 0.6rem 0; border-top: 1px solid var(--line); }
.compact-list > li:last-child { border-bottom: 1px solid var(--line); }
.card .compact-list > li:last-child { border-bottom: 0; padding-bottom: 0; }
.compact-list .year { padding-top: 0.15rem; }
.compact-list a { color: var(--ink); }
.compact-list a:hover { color: var(--rose); }
.compact-list.dense > li { padding: 0.45rem 0; font-size: 0.95rem; line-height: 1.35; }
.compact-list .nl { display: block; font: italic 0.8rem var(--serif); color: var(--muted); margin-top: 0.1rem; }
.compact-list.two-col { columns: 2 22rem; column-gap: 2.5rem; }
.compact-list.two-col > li { break-inside: avoid; }
.appearances { width: 100%; }

/* ---------- writing & media ---------- */
.video { padding: 0.5rem; margin: 0; }
.video video { width: 100%; aspect-ratio: 16 / 9; border-radius: var(--radius-sm); background: var(--paper-2); display: block; }
.video figcaption { text-align: center; font-size: 0.78rem; color: var(--muted); padding: 0.5rem 0 0.15rem; }
.press .mini-head { text-align: center; }
.press-logos { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 1rem 1.75rem; padding: 0.25rem 0; }
.press-logos img { height: 1.35rem; width: auto; max-width: 7rem; filter: grayscale(1); opacity: 0.6; transition: opacity 0.2s, filter 0.2s; }
.press-logos a:hover img { filter: none; opacity: 1; }
.nemo-head { display: flex; flex-direction: column; align-items: flex-start; text-align: left; gap: 0.5rem; margin-bottom: 0.5rem; }
.nemo-head img { width: 9rem; height: auto; }
.nemo-head p { color: var(--ink-2); font-size: 0.86rem; line-height: 1.45; }

/* ---------- path ---------- */
.steps { list-style: none; }
.step { display: grid; grid-template-columns: 5.4rem 1fr; gap: 0.9rem; padding: 0.7rem 0; border-top: 1px solid var(--line); }
.step .year { padding-top: 0.2rem; }
.step-head { display: flex; justify-content: space-between; gap: 0.75rem; align-items: flex-start; }
.step-head img { height: 1.6rem; width: auto; max-width: 4rem; object-fit: contain; opacity: 0.75; flex: none; }
.step-title { font-size: 0.98rem; line-height: 1.35; }
.institution { font: 0.82rem var(--sans); color: var(--muted); margin-top: 0.15rem; }
.distinction { font: 0.72rem var(--sans); color: var(--plum); background: var(--plum-soft); border-radius: var(--radius-sm); padding: 0.05rem 0.5rem; white-space: nowrap; vertical-align: 0.1em; }
.step details { margin-top: 0.3rem; }
.step details > p { font-size: 0.88rem; color: var(--ink-2); margin-top: 0.35rem; }

details summary { font: 0.8rem var(--sans); color: var(--rose); cursor: pointer; width: fit-content; list-style: none; }
details summary::-webkit-details-marker { display: none; }
details summary::before { content: "+ "; }
details[open] summary::before { content: "− "; }

/* ---------- publications ---------- */
.pub-controls { width: 100%; display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 0.75rem 1rem; }
.chips { display: flex; flex-wrap: wrap; justify-content: center; gap: 0.4rem; }
.chip .glyph { width: 1.05rem; height: 1.05rem; }
.chip.is-on .glyph { color: var(--paper); }
.search { width: min(100%, 20rem); }
.search input {
  width: 100%; font: 0.9rem var(--sans); color: var(--ink);
  padding: 0.45rem 1rem; border-radius: var(--radius-sm);
  border: 1px solid var(--line-strong); background: color-mix(in oklab, var(--paper) 85%, transparent);
}
.topic-desc { max-width: var(--narrow); text-align: center; color: var(--ink-2); font-size: 0.92rem; }

.pub-list { list-style: none; width: 100%; columns: 2 28rem; column-gap: 2.5rem; }
.pub { break-inside: avoid; display: grid; grid-template-columns: 2.6rem 1fr; gap: 0.6rem; padding: 0.7rem 0; border-top: 1px solid var(--line); }
.pub .year { padding-top: 0.2rem; }
.pub-title { font-size: 0.97rem; line-height: 1.38; }
.pub-glyph { display: inline-flex; vertical-align: -0.2em; margin-right: 0.35rem; }
.pub-title a { color: var(--ink); }
.pub-title a:hover { color: var(--rose); }
.pub-meta { display: flex; flex-direction: column; gap: 0.05rem; margin-top: 0.2rem; }
.pub-authors { font: 0.8rem/1.4 var(--sans); color: var(--ink-2); }
.pub-authors strong { color: var(--ink); font-weight: 600; }
.pub .venue { font-size: 0.78rem; }
.pub details { margin-top: 0.3rem; }
.pub details > p { margin-top: 0.5rem; font-size: 0.88rem; color: var(--ink-2); }
.badges { display: flex; align-items: center; gap: 0.75rem; margin-top: 0.6rem; flex-wrap: wrap; }
.doi { font: 0.74rem var(--sans); color: var(--muted); }
.empty { color: var(--muted); font-style: italic; }

.news-card h3 .year, .feature h3 .year { font-family: var(--sans); font-weight: 400; font-size: 0.8rem; margin-left: 0.35rem; vertical-align: 0.15em; }

/* research posts grouped by institution */
.insts { list-style: none; }
.inst { padding: 0.75rem 0; border-top: 1px solid var(--line); }
.inst-head { display: flex; justify-content: space-between; align-items: center; gap: 0.75rem; margin-bottom: 0.2rem; }
.inst-name { font-weight: 500; }
.inst-head img { height: 1.6rem; width: auto; max-width: 4.5rem; object-fit: contain; opacity: 0.75; }
.inst-roles { list-style: none; }
.inst-roles .step { border-top: 0; padding: 0.35rem 0; }
@media (max-width: 34rem) { .badge-sep { flex-basis: 100%; height: 0; margin: 0; background: none; } }

/* ---------- list separators: headings get a clear rule, items a faint one ---------- */
.card .mini-head, .glance h3 { margin-bottom: 0.25rem; }
.compact-list > li, .step, .inst, .glance dl > div, .pub { border-top-color: var(--line-faint); }
.compact-list > li:last-child { border-bottom-color: var(--line-faint); }
.card .compact-list > li:first-child, .card .steps > .step:first-child, .insts > .inst:first-child, .glance dl > div:first-child { border-top: 0; }

/* ---------- chapter menu (fades in after the header) ---------- */
.chapters {
  position: fixed; top: 0.6rem; left: 50%; z-index: 50; transform: translateX(-50%);
  display: flex; align-items: center; gap: 0.9rem; max-width: calc(100vw - 1rem);
  padding: 0.3rem 0.35rem 0.3rem 0.9rem;
  background: rgb(255 255 255 / 0.88); -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
  border: 1px solid var(--line); border-radius: var(--radius);
  font: 0.9rem var(--sans);
  opacity: 0; visibility: hidden; transition: opacity 0.35s ease, visibility 0s linear 0.35s;
}
.chapters.is-visible { opacity: 1; visibility: visible; transition: opacity 0.35s ease; }
.chapters-name { font: 400 1.35rem/1 var(--hand); color: var(--ink); white-space: nowrap; }
.chapters-links { display: flex; gap: 0.1rem; overflow-x: auto; scrollbar-width: none; }
.chapters-links a { color: var(--ink-2); padding: 0.2rem 0.6rem; border-radius: var(--radius-sm); white-space: nowrap; transition: background 0.2s, color 0.2s; }
.chapters-links a:hover { background: var(--paper-2); text-decoration: none; }
.chapters-links a.is-active { background: var(--ink); color: #fff; }
@media (max-width: 40rem) { .chapters-name { display: none; } .chapters { padding-left: 0.35rem; } }
@media (prefers-reduced-motion: reduce) { .chapters, .chapters.is-visible { transition: none; } }

/* four research themes: 4 across, then 2×2, then stacked (never 3 + 1) */
#research .grid-3 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 64rem) { #research .grid-3 { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 34rem) { #research .grid-3 { grid-template-columns: 1fr; } }
