@font-face {
  font-family: 'ET Book';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('/fonts/et-book/et-book-roman-line-figures.woff') format('woff');
}

@font-face {
  font-family: 'ET Book';
  font-style: italic;
  font-weight: 400;
  font-display: swap;
  src: url('/fonts/et-book/et-book-display-italic-old-style-figures.woff') format('woff');
}

@font-face {
  font-family: 'ET Book';
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url('/fonts/et-book/et-book-bold-line-figures.woff') format('woff');
}

:root {
  --canvas: #f5f4ef;
  --ink: #1f1e1a;
  --muted: #68645b;
  --line: #e1ddd1;
  --soft: #f3f0e7;
  --link: #205d93;
  --link-hover: #b65f13;
  --serif: 'ET Book', Palatino, Georgia, serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  display: flex;
  flex-direction: column;
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background: var(--canvas);
  font-family: var(--serif);
  font-size: 18px;
  font-optical-sizing: auto;
  line-height: 1.68;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--link);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.16em;
}

a:hover {
  color: var(--link-hover);
}

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

.site-header {
  border-bottom: 1px solid var(--line);
}

.site-header__inner,
.site-footer__inner {
  width: min(100% - 40px, 1040px);
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}

.site-header__inner {
  min-height: 68px;
}

.site-mark {
  color: var(--ink);
  font-size: 19px;
  font-weight: 700;
  text-decoration: none;
}

.site-nav {
  display: flex;
  gap: 22px;
  font-size: 14px;
}

.site-nav a {
  color: var(--muted);
  text-decoration: none;
}

.site-nav a:hover {
  color: var(--ink);
}

.blog-shell {
  width: min(100% - 40px, 880px);
  margin: 0 auto;
  padding: 88px 0 96px;
}

.blog-intro {
  max-width: 660px;
  margin-bottom: 68px;
}

.blog-intro--compact {
  margin-bottom: 42px;
}

.archive-header {
  margin-bottom: 26px;
}

.archive-search {
  margin-bottom: 52px;
}

.archive-year + .archive-year {
  margin-top: 56px;
}

.archive-year > h2 {
  margin: 0 0 12px;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 400;
  letter-spacing: 0.08em;
}

.eyebrow {
  margin: 0 0 12px;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

.blog-intro h1,
.article-header h1 {
  margin: 0;
  letter-spacing: -0.025em;
  line-height: 1.08;
}

.blog-intro h1 {
  font-size: clamp(38px, 6vw, 58px);
  font-weight: 400;
}

.blog-intro > p:last-child {
  max-width: 590px;
  margin: 22px 0 0;
  color: var(--muted);
  font-size: 19px;
  line-height: 1.55;
}

.post-list {
  border-top: 1px solid var(--line);
}

.post-card {
  position: relative;
  display: grid;
  grid-template-columns: 130px minmax(0, 1fr) 32px;
  gap: 24px;
  align-items: start;
  padding: 28px 0 30px;
  border-bottom: 1px solid var(--line);
}

.post-card__meta {
  display: flex;
  flex-direction: column;
  gap: 3px;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.025em;
  text-transform: uppercase;
}

.post-card__body h2,
.post-card__body h3 {
  margin: -3px 0 8px;
  font-size: 23px;
  font-weight: 700;
  line-height: 1.25;
}

.post-card__body h2 a,
.post-card__body h3 a {
  color: var(--ink);
  text-decoration: none;
}

.post-card__body h2 a:hover,
.post-card__body h3 a:hover {
  color: var(--link-hover);
}

.post-card__body p {
  margin: 0;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.55;
}

.post-card__arrow {
  color: var(--muted);
  font-size: 20px;
  text-decoration: none;
}

.article-shell {
  width: min(100% - 40px, 720px);
  margin: 0 auto;
  padding: 44px 0 96px;
}

.article-topbar {
  margin-bottom: 48px;
  font-family: var(--mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.article-topbar a {
  color: var(--muted);
  text-decoration: none;
}

.article-header {
  margin-bottom: 42px;
}

.article-header h1 {
  max-width: 690px;
  font-size: clamp(38px, 7vw, 56px);
  font-weight: 400;
}

.article-deck {
  margin: 20px 0 0;
  color: var(--muted);
  font-size: 19px;
  line-height: 1.5;
}

.article-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-top: 20px;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.draft-badge {
  padding: 2px 6px;
  border: 1px solid var(--line);
  border-radius: 999px;
}

.article-toc {
  margin: 0 0 48px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--soft);
}

.article-toc summary {
  cursor: pointer;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.06em;
  list-style: none;
  text-transform: uppercase;
}

.article-toc summary::-webkit-details-marker {
  display: none;
}

.article-toc summary::before {
  content: '▸';
  display: inline-block;
  margin-right: 8px;
}

.article-toc[open] summary::before {
  content: '▾';
}

.article-toc nav > ul {
  margin-bottom: 4px;
}

.article-toc ul {
  margin: 12px 0 0;
  padding-left: 20px;
}

.article-toc ul ul {
  margin-top: 4px;
}

.article-toc li {
  margin: 4px 0;
  color: var(--muted);
  font-size: 14px;
}

.article-toc a {
  color: inherit;
  text-decoration: none;
}

.article-toc a:hover {
  color: var(--ink);
}

.article-body {
  font-size: 18px;
  line-height: 1.72;
}

.article-body > :first-child {
  margin-top: 0;
}

.article-body p,
.article-body ul,
.article-body ol,
.article-body blockquote,
.article-body pre,
.article-body table,
.article-body figure {
  margin-top: 0;
  margin-bottom: 1.35em;
}

.article-body h1,
.article-body h2,
.article-body h3,
.article-body h4 {
  scroll-margin-top: 24px;
  line-height: 1.22;
}

.article-body h1,
.article-body h2 {
  margin: 1.55em 0 0.7em;
  font-size: 27px;
}

.article-body h3 {
  margin: 1.55em 0 0.65em;
  font-size: 21px;
}

.article-body h4 {
  margin: 1.45em 0 0.55em;
  font-size: 18px;
}

.article-body strong {
  font-weight: 700;
}

.article-body li {
  margin: 0.35em 0;
}

/* Nested numbered lists are procedural algorithms, not ordinary prose lists. */
.article-body > ol:has(ol) {
  margin: 1.7em 0 2em;
  padding: 18px 20px 18px 44px;
  overflow-x: auto;
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--soft);
  font-size: 15px;
  line-height: 1.65;
}

.article-body > ol:has(ol) li {
  margin: 0.48em 0;
  padding-left: 0.2em;
}

.article-body > ol:has(ol) ol {
  margin: 0.55em 0;
  padding-left: 1.7em;
}

.article-body > ol:has(ol) .katex-display {
  margin: 1em 0;
}

.article-body blockquote {
  margin-left: 0;
  padding: 0.15em 0 0.15em 1.15em;
  color: var(--muted);
  border-left: 2px solid var(--line);
}

.article-body img {
  width: auto;
  max-height: 620px;
  margin: 2rem auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.article-body .note-figure {
  margin: 2.4rem 0;
}

.note-figure__frame {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffef9;
}

.article-body .note-figure__frame img {
  width: 100%;
  max-height: none;
  margin: 0;
  border: 0;
  border-radius: 0;
}

.note-figure__caption {
  display: block;
  margin-top: 10px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.45;
}

.note-figure__caption strong {
  color: var(--ink);
  font-weight: 700;
}

.note-figure__caption p {
  display: inline;
  margin: 0;
}

.note-figure__credit {
  display: block;
  margin-top: 3px;
  font-size: 12px;
}

.note-figure__frame--diagram {
  padding: clamp(18px, 4vw, 34px);
  background:
    linear-gradient(rgba(32, 93, 147, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(32, 93, 147, 0.035) 1px, transparent 1px),
    #f7f4eb;
  background-size: 24px 24px;
}

.loop-demo {
  font-family: var(--mono);
}

.loop-demo__topline {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  color: var(--muted);
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.loop-demo__toggle {
  padding: 5px 9px;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--canvas);
  font: inherit;
  font-size: 10px;
  cursor: pointer;
}

.loop-demo__toggle:hover,
.loop-demo__toggle:focus-visible {
  color: var(--ink);
  border-color: var(--muted);
}

.loop-demo__track {
  position: relative;
  display: grid;
  grid-template-columns: 1fr auto 1fr auto 1fr;
  align-items: center;
  gap: 10px;
  padding-bottom: 30px;
}

.loop-demo__stage {
  min-width: 0;
  padding: 16px 13px;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 7px;
  background: rgba(251, 250, 244, 0.92);
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition: border-color 160ms ease, box-shadow 160ms ease, transform 160ms ease;
}

.loop-demo__stage:hover,
.loop-demo__stage:focus-visible {
  border-color: #9da9b2;
}

.loop-demo__stage.is-active {
  color: var(--ink);
  border-color: var(--link);
  box-shadow: 0 5px 18px rgba(32, 93, 147, 0.12);
  transform: translateY(-2px);
}

.loop-demo__number,
.loop-demo__stage > span:last-child {
  display: block;
  font-size: 9px;
  line-height: 1.35;
}

.loop-demo__number {
  margin-bottom: 12px;
  color: var(--link);
}

.loop-demo__stage strong {
  display: block;
  margin-bottom: 5px;
  font-family: var(--serif);
  font-size: 20px;
  line-height: 1;
}

.loop-demo__stage > span:last-child {
  color: var(--muted);
}

.loop-demo__arrow {
  color: var(--link);
  font-size: 18px;
}

.loop-demo__return {
  position: absolute;
  right: 7%;
  bottom: 0;
  left: 7%;
  color: var(--muted);
  font-size: 9px;
  text-align: center;
}

.loop-demo__return::before,
.loop-demo__return::after {
  content: '';
  position: absolute;
  top: 50%;
  width: 24%;
  border-top: 1px solid var(--line);
}

.loop-demo__return::before {
  left: 0;
}

.loop-demo__return::after {
  right: 0;
}

.loop-demo__readout {
  display: grid;
  grid-template-columns: 60px 1fr;
  gap: 12px;
  min-height: 42px;
  margin: 20px 0 0;
  padding-top: 16px;
  color: var(--muted);
  border-top: 1px solid var(--line);
  font-size: 11px;
  line-height: 1.55;
}

.loop-demo__readout strong {
  color: var(--link);
}

.article-body code {
  padding: 0.1em 0.34em;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--soft);
  font-family: var(--mono);
  font-size: 0.82em;
}

.article-body pre {
  padding: 16px 18px;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 7px;
  color: var(--muted);
  background: var(--soft);
  line-height: 1.55;
}

.article-body pre code {
  padding: 0;
  border: 0;
  color: inherit;
  background: transparent;
}

.article-body .highlight,
.article-body .highlight pre {
  color: var(--muted);
  background: var(--soft);
}

.article-body .highlight span {
  color: inherit;
}

.article-body table {
  display: block;
  width: 100%;
  overflow-x: auto;
  border-collapse: collapse;
  font-size: 15px;
}

.article-body th,
.article-body td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
}

.article-body hr {
  margin: 3rem 0;
  border: 0;
  border-top: 1px solid var(--line);
}

.article-body .katex-display {
  margin: 1.6em 0;
  padding: 0.2em 0;
  overflow-x: auto;
  overflow-y: hidden;
}

.article-pagination {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 28px;
  margin-top: 72px;
  padding-top: 24px;
  border-top: 1px solid var(--line);
}

.article-pagination__item {
  color: var(--ink);
  text-decoration: none;
}

.article-pagination__item--next {
  text-align: right;
}

.article-pagination__item span {
  display: block;
  margin-bottom: 4px;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.article-pagination__item strong {
  display: block;
  font-size: 15px;
  line-height: 1.35;
}

.site-footer {
  margin-top: auto;
  border-top: 1px solid var(--line);
}

.site-footer__inner {
  min-height: 88px;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.03em;
}

.site-footer__inner > span {
  margin-left: auto;
}

.search-field {
  display: block;
  margin-bottom: 28px;
}

.search-field input {
  width: 100%;
  padding: 14px 16px;
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 7px;
  outline: 0;
  background: var(--soft);
  font: inherit;
}

.search-field input:focus {
  border-color: var(--muted);
}

.empty-state {
  color: var(--muted);
}

.error-page {
  min-height: 66vh;
  padding-top: 110px;
}

.error-page h1 {
  margin: 0 0 14px;
  font-size: clamp(38px, 7vw, 58px);
  font-weight: 400;
  line-height: 1.08;
}

.error-page p:not(.eyebrow) {
  margin: 0 0 24px;
  color: var(--muted);
}

.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;
}

@media (max-width: 680px) {
  body {
    font-size: 17px;
  }

  .site-header__inner,
  .site-footer__inner,
  .blog-shell,
  .article-shell {
    width: min(100% - 28px, 100%);
  }

  .site-header__inner {
    min-height: 60px;
  }

  .site-nav {
    gap: 14px;
    font-size: 13px;
  }

  .blog-shell {
    padding: 58px 0 72px;
  }

  .blog-intro {
    margin-bottom: 48px;
  }

  .post-card {
    grid-template-columns: 1fr 24px;
    gap: 10px 16px;
  }

  .post-card__meta {
    grid-column: 1 / -1;
    flex-direction: row;
    gap: 10px;
  }

  .post-card__body h2,
  .post-card__body h3 {
    font-size: 21px;
  }

  .article-shell {
    padding: 30px 0 72px;
  }

  .article-topbar {
    margin-bottom: 38px;
  }

  .article-header h1 {
    font-size: 39px;
  }

  .article-body {
    font-size: 17px;
  }

  .article-body > ol:has(ol) {
    padding: 14px 14px 14px 36px;
    font-size: 14px;
  }

  .note-figure__frame--diagram {
    padding: 16px;
  }

  .loop-demo__track {
    grid-template-columns: 1fr;
    gap: 8px;
    padding-bottom: 28px;
  }

  .loop-demo__arrow {
    height: 8px;
    line-height: 8px;
    text-align: center;
    transform: rotate(90deg);
  }

  .loop-demo__stage {
    padding: 12px;
  }

  .loop-demo__number {
    margin-bottom: 5px;
  }

  .loop-demo__return {
    right: 0;
    left: 0;
  }

  .loop-demo__readout {
    grid-template-columns: 1fr;
    gap: 3px;
  }

  .article-pagination {
    grid-template-columns: 1fr;
  }

  .article-pagination__item--next {
    text-align: left;
  }

  .site-footer__inner {
    align-items: flex-start;
    flex-direction: column;
    justify-content: center;
    gap: 4px;
  }
}
