/* Shared styles for all pages */
/* ── Tokens (modelled on thinkingmachines.ai) ── */
:root {
  --bg:  #ffffff;
  --fg:  #282828;   /* body text */
  --fg2: #504945;   /* link hover */
  --fg4: #676767;   /* secondary text */
  --fg5: #969696;   /* faint */
  --hover: rgba(0, 0, 0, .04);

  --serif: 'Iowan Old Style', 'Iowan Old Style BT', 'Source Serif 4', Georgia, serif;
  --sans:  'Libre Franklin', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --wordmark: 'Chakra Petch', var(--sans);

  --column: 660px;
  --pad: 1.3rem;
}
/* Dark theme: follows the system unless the toggle has picked a theme */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg:  #161616;
    --fg:  #e6e3df;
    --fg2: #f4f1ec;
    --fg4: #a09c97;
    --fg5: #75716d;
    --hover: rgba(255, 255, 255, .07);
  }
}
:root[data-theme="dark"] {
  --bg:  #161616;
  --fg:  #e6e3df;
  --fg2: #f4f1ec;
  --fg4: #a09c97;
  --fg5: #75716d;
  --hover: rgba(255, 255, 255, .07);
}
:root { color-scheme: light; }
:root[data-theme="dark"] { color-scheme: dark; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { color-scheme: dark; } }

* { box-sizing: border-box; margin: 0; padding: 0; }
html { overflow-x: hidden; scroll-behavior: smooth; scroll-padding-top: 1.5rem; }
body {
  font-family: var(--serif);
  font-size: 17px;
  line-height: 1.6;
  background: var(--bg);
  color: var(--fg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
::selection { background: color-mix(in srgb, var(--fg) 14%, transparent); }

a { color: inherit; }

/* ── Header nav (top right, sans) ── */
.site-nav {
  display: flex;
  justify-content: flex-end;
  gap: 1.75rem;
  padding: 1rem 1.3rem;
  font-family: var(--sans);
  font-size: 15px;
}
.site-nav a { text-decoration: none; transition: color .3s ease-in-out; }
/* Small wordmark on the left of the nav, used on subpages */
.site-nav .navbar-logo {
  margin-right: auto;
  font-family: var(--wordmark);
  font-weight: 400;
  font-size: 17px;
  line-height: 25px;
  letter-spacing: 1.7px;
  text-transform: uppercase;
  color: var(--fg4);
}
.site-nav .navbar-logo:hover { color: var(--fg); }
.site-nav a:hover { color: var(--fg4); }

/* ── Theme toggle ── */
.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  margin: -1px 0 0 -.25rem;
  padding: 0;
  border: 0;
  border-radius: 100px;
  background: transparent;
  color: inherit;
  cursor: pointer;
  transition: color .3s ease-in-out, background-color .2s ease;
}
.theme-toggle:hover { color: var(--fg4); background: var(--hover); }
.theme-toggle:focus-visible { outline: 1px solid var(--fg4); outline-offset: 2px; }
.theme-toggle svg { width: 16px; height: 16px; }
/* Show the moon in light mode and the sun in dark mode */
.theme-toggle .sun { display: none; }
:root[data-theme="dark"] .theme-toggle .sun { display: block; }
:root[data-theme="dark"] .theme-toggle .moon { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-toggle .sun { display: block; }
  :root:not([data-theme="light"]) .theme-toggle .moon { display: none; }
}

/* ── Wordmark ── */
.masthead {
  text-align: center;
  padding: 1.6rem var(--pad) 1.35rem;
  animation: fadeIn .6s ease-in-out;
}
.logo {
  display: inline-block;
  font-family: var(--wordmark);
  font-weight: 400;
  font-size: clamp(3em, 8vw, 3.4em);
  line-height: 1.3;
  letter-spacing: .05em;
  text-transform: uppercase;
  text-decoration: none;
  color: var(--fg);
}
/* Brownian bridge under the name, spanning the text column (see brownian.js) */
.bridge {
  display: block;
  width: 100%;
  max-width: var(--column);
  height: 64px;
  margin: 1.2rem auto 0;
  overflow: visible;
  cursor: pointer;
}
.bridge path {
  fill: none;
  stroke: var(--fg4);
  stroke-width: 1;
  stroke-linejoin: round;
  stroke-linecap: round;
}
@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

/* ── Main column ── */
main {
  width: 100%;
  max-width: calc(var(--column) + 2 * var(--pad));
  margin: 0 auto;
  padding: 1.5rem var(--pad) 4rem;
  flex: 1;
  animation: fadeIn .6s ease-in-out;
}
main p { margin-bottom: 1.8rem; }
main p a {
  text-decoration: underline;
  text-decoration-color: color-mix(in srgb, var(--fg4) 30%, transparent);
  text-underline-offset: 2px;
  transition: color .3s ease-in-out, text-decoration-color .3s ease-in-out;
}
main p a:hover {
  color: var(--fg2);
  text-decoration-color: color-mix(in srgb, var(--fg2) 30%, transparent);
}
em { font-style: italic; }

h2 {
  font-family: var(--sans);
  font-weight: 400;
  font-size: 1.5rem;
  line-height: 1.25;
  letter-spacing: -.02em;
  margin: 2.8rem 0 1rem;
}

/* ── Lists: title left, secondary right (TM job-listing style) ── */
.rows { list-style: none; margin-bottom: 1.8rem; }
.rows li {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 2rem;
  margin-bottom: .75rem;
}
.rows .meta {
  color: var(--fg4);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.rows a {
  color: var(--fg);
  text-decoration: none;
  position: relative;
}
/* Underline that draws in from the left on hover */
.rows a::after {
  content: "";
  position: absolute;
  left: 0;
  bottom: 0;
  width: 100%;
  height: .5px;
  margin-bottom: 2px;
  background: var(--fg);
  transform: scaleX(0);
  transform-origin: bottom right;
  transition: transform .2s ease-out;
}
.rows a:hover::after { transform: scaleX(1); transform-origin: bottom left; }
/* Inline links inside a row (e.g. the IRTG) keep the row's look, with a faint underline */
.rows span a {
  text-decoration: underline;
  text-decoration-color: color-mix(in srgb, var(--fg4) 30%, transparent);
  text-underline-offset: 2px;
  transition: color .3s ease-in-out;
}
.rows span a:hover { color: var(--fg4); }

/* Φ with stacked super/subscript, e.g. Φ⁴₃ */
.phi { white-space: nowrap; }
.ss {
  display: inline-flex;
  flex-direction: column;
  vertical-align: .5em;
  font-size: .7em;
  line-height: 1.05;
  margin-left: .06em;
}

/* ── Footer ── */
footer {
  width: 100%;
  max-width: calc(var(--column) + 2 * var(--pad));
  margin: 0 auto;
  padding: 1.5rem var(--pad) 2.5rem;
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  font-family: var(--sans);
  font-size: 13px;
  color: var(--fg5);
}
footer a { text-decoration: none; transition: color .3s ease-in-out; }
footer a:hover { color: var(--fg); }

@media (max-width: 600px) {
  .site-nav { justify-content: center; flex-wrap: wrap; gap: .25rem 1.25rem; }
  .site-nav .navbar-logo { flex-basis: 100%; margin: 0 0 .5rem; text-align: center; }
  .rows li { flex-direction: column; gap: 0; }
}

/* ── List pages (modelled on the Connectionism index) ── */
.page-title {
  font-family: var(--sans);
  font-size: 1.6rem;
  font-weight: 400;
  letter-spacing: -.015em;
  line-height: 1.1;
  padding-top: 1rem;
}
.page-subtitle {
  margin: .5rem 0 0;
  font-family: var(--sans);
  font-size: 15px;
  color: var(--fg4);
}
/* Lattice φ⁴ simulation below the publication list (see phi4.js) */
.field { margin: 3rem 0 0; }
.field canvas {
  display: block;
  width: 100%;
  height: 80px;
  image-rendering: pixelated;
  transition: opacity .4s ease;
}
/* While a temperature is still being burned in off-screen */
.field.is-loading canvas { opacity: .25; }
.field figcaption {
  margin-top: .6rem;
  font-family: var(--sans);
  font-size: 13px;
  line-height: 1.6;
  color: var(--fg5);
}
.field-modes button {
  padding: 0;
  border: 0;
  background: none;
  font: inherit;
  color: var(--fg5);
  cursor: pointer;
  transition: color .2s ease;
}
.field-modes button:hover { color: var(--fg4); }
.field-modes button[aria-pressed="true"] {
  color: var(--fg);
  text-decoration: underline;
  text-decoration-color: color-mix(in srgb, var(--fg) 30%, transparent);
  text-underline-offset: 2px;
}
.post-group {
  list-style: none;
  padding-top: 1.6rem;
}
.post-group li { position: relative; padding-bottom: .4rem; }
.post-group li + li { padding-top: .4rem; }
.post-group li + li::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  border-top: 1px solid color-mix(in srgb, var(--fg4) 16%, transparent);
  pointer-events: none;
}
.post-item-link {
  display: block;
  margin: 0 -1.6rem;
  padding: 1rem 1.6rem;
  border-radius: 8px;
  color: inherit;
  line-height: 1.4;
  text-decoration: none;
}
/* On narrow screens the bleed must not exceed the page padding, or the row
   hangs off both edges (hidden by overflow-x, but clipped and off-target). */
@media (max-width: 600px) {
  .post-item-link { margin-inline: calc(-1 * var(--pad)); padding-inline: var(--pad); }
}
.post-info { display: flex; flex-direction: column; align-items: flex-start; gap: .25rem; }
.post-title {
  display: inline-block;
  margin: 0;
  font-family: var(--serif);
  line-height: 1.4;
  letter-spacing: normal;
  font-size: 17px;
  font-weight: 500;
  text-wrap: balance;
  text-decoration: underline transparent;
  text-underline-offset: 2px;
  transition: color .2s, text-decoration-color .2s;
}
.author-date {
  font-family: var(--sans);
  font-size: 15px;
  color: var(--fg4);
  transition: color .2s;
}
.post-item-link time {
  display: block;
  margin-top: .25rem;
  font-family: var(--sans);
  font-size: 15px;
  color: var(--fg4);
  font-variant-numeric: tabular-nums;
  transition: color .2s;
}
@media (min-width: 768px) {
  .post-item-link {
    display: grid;
    grid-template-columns: 5.5rem 1fr;
    align-items: baseline;
    gap: 1.5rem;
    margin: 0 -1.5rem;
    padding: 1.2rem 1.5rem;
  }
  .post-info { grid-area: 1 / 2; }
  .post-item-link time { grid-area: 1 / 1; margin-top: 0; white-space: nowrap; }
}
@media (hover: hover) {
  .post-item-link:hover .post-title {
    text-decoration-color: color-mix(in srgb, var(--fg2) 30%, transparent);
  }
  .post-item-link:hover .author-date,
  .post-item-link:hover time { color: var(--fg); }
}
/* ── CV page: same rhythm as the publication list, adapted to entries ── */
main p.cv-summary { margin: 1.8rem 0 0; }
.cv-section h2 { margin: 2.8rem 0 .2rem; font-size: 1.25rem; }
.cv-list { list-style: none; }
.cv-list > li {
  position: relative;
  padding: 1.2rem 0;
  line-height: 1.4;
}
.cv-list > li + li::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  border-top: 1px solid color-mix(in srgb, var(--fg4) 16%, transparent);
}
.cv-when {
  display: block;
  font-family: var(--sans);
  font-size: 15px;
  color: var(--fg4);
  font-variant-numeric: tabular-nums;
}
.cv-what { display: flex; flex-direction: column; gap: .25rem; margin-top: .25rem; }
.cv-title {
  margin: 0;
  font-family: var(--serif);
  font-size: 17px;
  font-weight: 500;
  line-height: 1.4;
  letter-spacing: normal;
}
.cv-where {
  font-family: var(--sans);
  font-size: 15px;
  color: var(--fg4);
}
.cv-where a {
  text-decoration: underline;
  text-decoration-color: color-mix(in srgb, var(--fg4) 30%, transparent);
  text-underline-offset: 2px;
  transition: color .3s ease-in-out;
}
.cv-where a:hover { color: var(--fg); }
main p.cv-text { margin: 0; font-size: 16px; line-height: 1.5; }
.cv-points {
  list-style: none;
  margin-top: .55rem;
  font-size: 16px;
  line-height: 1.5;
}
.cv-points li { position: relative; padding-left: 1.1rem; }
.cv-points li + li { margin-top: .4rem; }
.cv-points li::before {
  content: "–";
  position: absolute;
  left: 0;
  color: var(--fg5);
}
@media (min-width: 768px) {
  .cv-list > li {
    display: grid;
    grid-template-columns: 5.5rem 1fr;
    align-items: baseline;
    gap: 1.5rem;
  }
  .cv-what { margin-top: 0; }
  .cv-when { white-space: nowrap; }
}
.list-note {
  margin: 2rem 0 0;
  font-family: var(--sans);
  font-size: 15px;
  color: var(--fg4);
}
.list-note a {
  text-decoration: underline;
  text-decoration-color: color-mix(in srgb, var(--fg4) 30%, transparent);
  text-underline-offset: 2px;
  transition: color .3s ease-in-out;
}
.list-note a:hover { color: var(--fg); }

/* ── Notes: list page with full dates, and single posts ── */
@media (min-width: 768px) {
  .post-group--dates .post-item-link { grid-template-columns: 7rem 1fr; }
}
.article-header { padding-top: 1rem; }
.article-title {
  font-family: var(--sans);
  font-size: 2rem;
  font-weight: 400;
  line-height: 1.15;
  letter-spacing: -.02em;
  text-wrap: balance;
}
main p.article-meta {
  margin: .75rem 0 0;
  font-family: var(--sans);
  font-size: 15px;
  color: var(--fg4);
}
.draft-label {
  padding: .1rem .45rem;
  border-radius: 100px;
  background: var(--hover);
  font-size: 12px;
  letter-spacing: .04em;
  text-transform: uppercase;
}
.article-body { margin-top: 2.4rem; }
.article-body p { margin: 0 0 1.25rem; }
.article-body a {
  text-decoration: underline;
  text-decoration-color: color-mix(in srgb, var(--fg4) 30%, transparent);
  text-underline-offset: 2px;
  transition: color .3s ease-in-out;
}
.article-body a:hover { color: var(--fg2); }
.article-body h2 { margin: 2.6rem 0 .8rem; font-size: 1.35rem; }
.article-body h3 {
  margin: 2rem 0 .6rem;
  font-family: var(--sans);
  font-size: 1.1rem;
  font-weight: 500;
}
.article-body ul, .article-body ol { margin: 0 0 1.25rem; padding-left: 1.3rem; }
.article-body li + li { margin-top: .3rem; }
.article-body blockquote {
  margin: 1.6rem 0 1.6rem .2rem;
  padding: .1rem 0 .1rem 1.2rem;
  border-left: 2px solid color-mix(in srgb, var(--fg4) 35%, transparent);
  color: var(--fg2);
}
.article-body blockquote p:last-child { margin-bottom: 0; }
.article-body code {
  font-family: ui-monospace, SFMono-Regular, 'SF Mono', Menlo, Consolas, monospace;
  font-size: .86em;
  padding: .05em .3em;
  border-radius: 4px;
  background: var(--hover);
}
.article-body pre {
  margin: 1.4rem 0 1.6rem;
  padding: 1rem 1.1rem;
  border-radius: 8px;
  background: var(--hover);
  overflow-x: auto;
  line-height: 1.5;
}
.article-body pre code { padding: 0; background: none; font-size: 13.5px; }
.article-body figure { margin: 2rem 0; }
.article-body img { display: block; max-width: 100%; height: auto; }
.article-body figcaption {
  margin-top: .6rem;
  font-family: var(--sans);
  font-size: 13px;
  line-height: 1.5;
  color: var(--fg5);
}
.article-body table {
  width: 100%;
  margin: 1.4rem 0 1.8rem;
  border-collapse: collapse;
  font-family: var(--sans);
  font-size: 15px;
  font-variant-numeric: tabular-nums;
}
.article-body th {
  text-align: left;
  font-weight: 500;
  padding: 0 .75rem .5rem 0;
  border-bottom: 1px solid color-mix(in srgb, var(--fg4) 35%, transparent);
}
.article-body td {
  padding: .5rem .75rem .5rem 0;
  border-bottom: 1px solid color-mix(in srgb, var(--fg4) 16%, transparent);
}
.article-body hr {
  margin: 2.4rem 0;
  border: 0;
  border-top: 1px solid color-mix(in srgb, var(--fg4) 16%, transparent);
}
.article-body .katex { font-size: 1.05em; }
.article-body .katex-display { margin: 1.4rem 0; overflow-x: auto; overflow-y: hidden; padding: .2rem 0; }
main p.article-back { margin: 3rem 0 0; font-family: var(--sans); font-size: 15px; }
.article-back a { text-decoration: none; color: var(--fg4); transition: color .3s ease-in-out; }
.article-back a:hover { color: var(--fg); }

/* ── CV page: same rhythm as the publication list, adapted to entries ── */
main p.cv-summary { margin: 1.8rem 0 0; }
.cv-section h2 { margin: 2.8rem 0 .2rem; font-size: 1.25rem; }
.cv-list { list-style: none; }
.cv-list > li {
  position: relative;
  padding: 1.2rem 0;
  line-height: 1.4;
}
.cv-list > li + li::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  border-top: 1px solid color-mix(in srgb, var(--fg4) 16%, transparent);
}
.cv-when {
  display: block;
  font-family: var(--sans);
  font-size: 15px;
  color: var(--fg4);
  font-variant-numeric: tabular-nums;
}
.cv-what { display: flex; flex-direction: column; gap: .25rem; margin-top: .25rem; }
.cv-title {
  margin: 0;
  font-family: var(--serif);
  font-size: 17px;
  font-weight: 500;
  line-height: 1.4;
  letter-spacing: normal;
}
.cv-where {
  font-family: var(--sans);
  font-size: 15px;
  color: var(--fg4);
}
main p.cv-text { margin: 0; font-size: 16px; line-height: 1.5; }
.cv-points {
  list-style: none;
  margin-top: .55rem;
  font-size: 16px;
  line-height: 1.5;
}
.cv-points li { position: relative; padding-left: 1.1rem; }
.cv-points li + li { margin-top: .4rem; }
.cv-points li::before {
  content: "–";
  position: absolute;
  left: 0;
  color: var(--fg5);
}
@media (min-width: 768px) {
  .cv-list > li {
    display: grid;
    grid-template-columns: 5.5rem 1fr;
    align-items: baseline;
    gap: 1.5rem;
  }
  .cv-what { margin-top: 0; }
  .cv-when { white-space: nowrap; }
}
.list-note {
  margin: 2rem 0 0;
  font-family: var(--sans);
  font-size: 15px;
  color: var(--fg4);
}
.list-note a {
  text-decoration: underline;
  text-decoration-color: color-mix(in srgb, var(--fg4) 30%, transparent);
  text-underline-offset: 2px;
  transition: color .3s ease-in-out;
}
.list-note a:hover { color: var(--fg); }

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