/* Source Serif 4, self-hosted (SIL Open Font License, see fonts/OFL.txt).
   Variable font: one upright file covers weights 400-600. */
@font-face {
  font-family: "Source Serif 4";
  src: url("fonts/source-serif-4-latin.woff2") format("woff2");
  font-weight: 200 900;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Source Serif 4";
  src: url("fonts/source-serif-4-latin-italic.woff2") format("woff2");
  font-weight: 200 900;
  font-style: italic;
  font-display: swap;
}

:root {
  --bg: #fdfcfa;
  --text: #1c1b19;
  --muted: #5f5d58;
  --rule: #dcd9d2;
  --link: #003c82;           /* same blue as the CV's links */
  --chip: #a19c92;
  --award: #8a5a00;
  --code-bg: #f3f1ec;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #161615;
    --text: #e8e6e1;
    --muted: #a3a09a;
    --rule: #3a3936;
    --link: #8db4ec;
    --chip: #6e6b65;
    --award: #e0b45c;
    --code-bg: #22211f;
  }
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; scroll-padding-top: 4.5rem; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Source Serif 4", Georgia, "Times New Roman", serif;
  font-size: 18px;
  line-height: 1.6;
}

main, footer {
  max-width: 42rem;
  margin: 0 auto;
  padding: 0 16px;
}

main { padding-top: 2.5rem; }

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

p { margin: 0; }
p.gap { margin-top: 0.75rem; }   /* 404 page */

/* ---------- header ---------- */

h1 {
  font-size: 2rem;
  font-weight: 600;
  line-height: 1.15;
  margin: 0;
}

.role { color: var(--muted); margin-top: 0.25rem; text-wrap: balance; }
.nowrap { white-space: nowrap; }
.market { margin-top: 0.2rem; font-weight: 600; text-wrap: balance; }

.contact {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 1.25rem;
  margin-top: 1rem;
  font-size: 0.95rem;
}
.contact a {
  display: inline-flex;
  align-items: center;
  gap: 0.35em;
}
.icon {
  width: 1.05em;
  height: 1.05em;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.75;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.icon.orcid circle { fill: #a6ce39; stroke: none; }
.icon.orcid text {
  fill: #fff;
  stroke: none;
  font: 600 11px system-ui, -apple-system, sans-serif;
}

/* ---------- top bar ---------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--bg);
  border-bottom: 1px solid var(--rule);
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 0.8rem;
}
.topbar-inner {
  max-width: 42rem;
  margin: 0 auto;
  padding: 0.15rem 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
}
.topbar-name {
  color: var(--text);
  font-weight: 600;
  white-space: nowrap;
  opacity: 0;
  visibility: hidden;   /* also keeps it out of the Tab order while hidden */
  transition: opacity 0.2s, visibility 0.2s;
}
.scrolled .topbar-name { opacity: 1; visibility: visible; }
.topbar-links {
  display: flex;
  gap: 1.1rem;
  margin-left: auto;
  overflow-x: auto;
  white-space: nowrap;
}
.topbar-links a { color: var(--muted); padding: 0.45rem 0; }  /* ~32px tall tap target */
.topbar-name { padding: 0.45rem 0; }
.topbar-links a.cv { color: var(--link); }
.topbar-links a:focus-visible { outline-offset: -2px; }  /* the scrolling row would clip an outside ring */

#about { margin-top: 2.25rem; }

/* ---------- sections ---------- */

section { margin-top: 3.5rem; }

h2 {
  font-size: 1.05rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text);
  border-bottom: 1px solid var(--rule);
  padding-bottom: 0.35rem;
  margin: 0 0 1.5rem;
}

h3 {
  font-size: 1rem;
  font-weight: 400;
  font-style: italic;
  margin: 1.5rem 0 0.4rem;
}
h2 + h3 { margin-top: 0; }

ul { list-style: none; margin: 0; padding: 0; }

/* ---------- papers ---------- */

.paper + .paper { margin-top: 2.1rem; }
.paper > p + p { margin-top: 0.1rem; }
.paper .title { font-weight: 600; line-height: 1.35; text-wrap: balance; }
.authors, .venue { font-size: 0.95rem; }
.authors { color: var(--muted); }
.me { color: var(--text); font-weight: 600; }
.note { font-size: 0.85rem; }

.award, .sitenote {
  display: flex;
  align-items: flex-start;
  gap: 0.4em;
  font-size: 0.95rem;
}
.paper > .award, .paper > .sitenote { margin-top: 0.4rem; }
.award { color: var(--award); }
.award span, h3 { text-wrap: balance; }
.sitenote { color: var(--muted); }
.award .icon, .sitenote .icon { margin-top: 0.22em; }

.links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin-top: 0.7rem;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 0.75rem;
}
.links a, .links summary {
  border: 1px solid var(--chip);
  border-radius: 4px;
  padding: 0.1rem 0.5rem;
  color: var(--link);
  cursor: pointer;
}
.links a:hover, .links summary:hover {
  border-color: var(--link);
  background: var(--code-bg);
  text-decoration: none;
}
.links summary { list-style: none; }
.links summary::-webkit-details-marker { display: none; }
.links details[open] summary { border-color: var(--link); background: var(--code-bg); }
.paper > pre.bibtex { display: none; }
.paper:has(.links details[open]) > pre.bibtex { display: block; }
pre.bibtex {
  margin: 0.6rem 0 0;
  padding: 0.6rem 0.75rem;
  background: var(--code-bg);
  border-radius: 4px;
  font-size: 0.75rem;
  line-height: 1.45;
  white-space: pre-wrap;        /* wrap long lines on phones; still valid BibTeX */
  overflow-wrap: anywhere;
  user-select: all;
}

/* ---------- talks, teaching, education ---------- */

.plain li + li { margin-top: 1.1rem; }
.plain .item { display: block; text-wrap: balance; }
.plain .item, .rows li > span:first-child { line-height: 1.4; }
.plain .meta { display: block; font-size: 0.95rem; color: var(--muted); }

.rows li {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
}
.rows .when { font-size: 0.95rem; }
.rows li + li { margin-top: 0.45rem; }
.rows li { align-items: baseline; }
.rows .when { color: var(--muted); white-space: nowrap; }

@media (max-width: 480px) {
  body { font-size: 17px; }
  main { padding-top: 2rem; }
  h1 { font-size: 1.75rem; }
  .topbar-name { display: none; }
  .topbar-links { gap: 0.9rem; margin: 0 auto; }
  .rows li { flex-direction: column; gap: 0; }
  .paper + .paper { margin-top: 2.1rem; }
  .links a, .links summary { padding: 0.3rem 0.65rem; }
  .rows li + li { margin-top: 0.8rem; }
}

/* ---------- footer ---------- */

footer {
  margin-top: 3.5rem;
  padding-bottom: 2.5rem;
  font-size: 0.85rem;
  color: var(--muted);
}
footer p {
  border-top: 1px solid var(--rule);
  padding-top: 1rem;
}

/* ---------- very wide screens: scale text and column together ---------- */

@media (min-width: 1800px) {
  html { font-size: 17.5px; }
  body { font-size: 19.5px; }
}

/* ---------- print ---------- */

@media print {
  .topbar, .links, pre.bibtex { display: none !important; }
  body { background: #fff; color: #000; font-size: 11pt; }
  a { color: inherit; }
  main { padding-top: 0; }
  section { margin-top: 1.5rem; }
  .paper, .plain li, .rows li { break-inside: avoid; }
  h2 { break-after: avoid; }
}
