:root {
  --bg: #e5e0da;
  --text: #583b1f;
  --olive: #7e7b46;
  --lavender: #c2bfcb;
  --cream: #eae6e1;
  --rule: #d2c7bc;
  --heading-font: "Manrope", system-ui, sans-serif;
  --body-font: "Poppins", system-ui, sans-serif;
  --page-pad: 4vw;
  --max-page: 1400px;
  --site-title: clamp(21px, 0.6vw + 1rem, 24px);
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;    /* keeps the footer at the bottom of short pages */
  background: var(--bg);
  color: var(--text);
  font: 400 1rem/1.5 var(--body-font);
}

a { color: inherit; text-underline-offset: 0.2em; }

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

h1, h2, h3, h4 {
  font-family: var(--heading-font);
  font-weight: 500;
  letter-spacing: -0.015em;
  line-height: 1.25;
  margin: 2.75rem 0 0.75rem;
}
h1 { font-size: clamp(2.1rem, 2vw + 1.4rem, 3rem); line-height: 1.12; letter-spacing: -0.02em; }
h2 { font-size: clamp(1.5rem, 0.6vw + 1.2rem, 1.75rem); }
h3 { font-size: 1.3rem; margin-top: 2.25rem; }
h4 { font-size: 1.1rem; margin-top: 2rem; }

p { margin: 1rem 0; }

.visually-hidden {
  position: absolute;
  width: 1px; height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* Header */
.site-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem 2rem;
  padding: 1.5vw var(--page-pad);
}
.site-title {
  font: 500 var(--site-title)/1.2 var(--heading-font);
  letter-spacing: -0.02em;
  color: var(--olive);
  text-decoration: none;
}
.site-header nav { display: flex; gap: 3.5vw; }
.site-header nav a { color: var(--olive); text-decoration: none; }
.site-header nav a[aria-current="page"],
.site-header nav a:hover { text-decoration: underline; }

main {
  flex: 1;
  width: 100%;
  max-width: var(--max-page);
  margin: 0 auto;
  padding: var(--page-pad) var(--page-pad) 0;
}

/* Footer */
.site-footer {
  padding: 2rem var(--page-pad);
  background: var(--text);
  color: var(--cream);
  text-align: center;
}
.site-footer a { color: var(--lavender); }

/* Home: a centred reading list, posts separated by thin rules */
.post-list { max-width: 56rem; margin: 0 auto; padding: 1rem 0 6rem; }
.post-card {
  display: grid;
  grid-template-columns: 14rem 1fr;
  gap: 2.5rem;
  align-items: start;
  padding: 2.75rem 0;
  border-top: 1px solid var(--rule);
}
.post-card:first-child { border-top: 0; padding-top: 0; }
.post-card-image img { width: 100%; aspect-ratio: 1; object-fit: cover; }
.post-card-text { padding-top: 0.25rem; }
.post-card h2 { font-size: clamp(1.4rem, 0.9vw + 1rem, 1.85rem); line-height: 1.25; margin: 0; }
.post-card h2 a { text-decoration: none; }
.post-card h2 a:hover { text-decoration: underline; text-decoration-thickness: 1px; }
.post-meta-line { margin-top: 0.5rem; font-size: 0.875rem; color: var(--olive); }
.post-card p { margin: 0.9rem 0 0; max-width: 38rem; }

/* Posts: a ~70-character text column; images may use the full 56rem */
.post { max-width: 56rem; margin: 0 auto; }
.post-header, .prose > * { max-width: 40rem; margin-inline: auto; }
.prose > figure { max-width: 100%; }
.post-header { margin-bottom: 2.5rem; }
.post-header h1 { margin: 0; }
.post-header .post-meta-line { margin-top: 0.9rem; font-size: 0.9rem; }

.prose { font-size: 1.0625rem; line-height: 1.75; }
.prose, .page { overflow-wrap: anywhere; }   /* long URLs wrap on phones */
.prose > :first-child { margin-top: 0; }
.prose p { margin-bottom: 1.25rem; margin-top: 0; }
.prose ul, .prose ol { padding-left: 1.4rem; margin-bottom: 1.25rem; }
.prose li + li,
.prose li > ul,
.prose li > ol { margin-top: 8px; }
/* References: the last section, set smaller below a thin rule */
.prose #references, .prose #supporting-research {
  margin-top: 3.5rem;
  padding-top: 2.5rem;
  border-top: 1px solid var(--rule);
}
.prose #references ~ p,
.prose #supporting-research ~ p { font-size: 0.875rem; line-height: 1.6; margin-bottom: 0.75rem; }
.prose blockquote {
  margin: 2rem auto;
  padding-left: 1.25rem;
  border-left: 3px solid var(--olive);
  font-style: italic;
}

/* Compact table of contents: wrap it in <div class="toc" markdown="1"> */
.prose .toc { font-size: 0.9rem; line-height: 1.4; }
.prose .toc p,
.prose .toc ul { margin: 0.25rem 0; }
.prose .toc li + li { margin-top: 0; }

/* Images never upscale past their natural width; captions appear on hover. */
.prose figure {
  position: relative;
  width: fit-content;
  max-width: 100%;
  margin: 2.5rem auto;
}
.prose figcaption {
  position: absolute;
  inset: auto 0 0;
  max-height: 75%;
  overflow-y: auto;
  padding: 1.75rem 1rem;
  background: rgb(0 0 0 / 0.7);
  color: #bbb;
  line-height: 1.7;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.1s ease-out;
}
.prose figure:hover figcaption,
.prose figure:focus-within figcaption { opacity: 1; visibility: visible; }

/* Previous / next post */
.post-pagination {
  display: flex;
  justify-content: space-between;
  gap: 2rem;
  max-width: 56rem;
  margin: 5rem auto 0;
  padding: 2rem 0 4rem;
  border-top: 1px solid var(--rule);
}
.post-pagination a {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex: 0 1 45%;
  font: 500 clamp(1.15rem, 0.5vw + 1rem, 1.4rem)/1.3 var(--heading-font);
  letter-spacing: -0.02em;
  text-decoration: none;
}
.post-pagination .next { margin-left: auto; justify-content: flex-end; text-align: right; }
.post-pagination a:hover span { text-decoration: underline; text-decoration-thickness: 1px; }
.post-pagination svg {
  flex: none;
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
}

/* Musings: short pieces in a narrow column, separated by rules */
.page-musings {
  max-width: 42rem;
  margin: 0 auto 5rem;
  font-size: 1.0625rem;
  line-height: 1.75;
}
.page-musings h3 { font-size: 1.35rem; line-height: 1.25; letter-spacing: -0.01em; margin: 0 0 0.75rem; }
.page-musings h3:not(:first-of-type) {
  margin-top: 3rem;
  padding-top: 3rem;
  border-top: 1px solid var(--rule);
}

@media (max-width: 767px) {
  :root { --page-pad: 6vw; }
  .site-header { padding-block: 1.25rem; }
  .post-list { padding-top: 0; }
  .post-card { grid-template-columns: 1fr; gap: 1rem; padding: 2rem 0; }
  .post-card-image img { aspect-ratio: 3 / 2; }
  .post-pagination { flex-direction: column; }
}
