/* Long-form posts. Load after main.css on pages with <main class="article">. */

:root{
  --code-bg:#15171c;
  --note:#c9c6bf;
  --mono:ui-monospace,SFMono-Regular,"JetBrains Mono",Menlo,Consolas,monospace;
}

/* ── layout ───────────────────────────────────────────
   Wide screens: a sticky contents rail on the left, the
   680px reading column in the middle, an empty column on
   the right so the text stays centered on the page.      */

main.article{
  max-width:1180px;
  padding-left:28px;
  padding-right:28px;
}

.article-grid{
  display:grid;
  grid-template-columns:minmax(0,1fr) minmax(0,680px) minmax(0,1fr);
  gap:0 48px;
}

.article-grid > .masthead{grid-column:2;grid-row:1}
.article-grid > article{grid-column:2;grid-row:2;min-width:0}

/* ── masthead ─────────────────────────────────────── */

.article h1{
  font-size:2.05rem;
  line-height:1.18;
  margin-bottom:10px;
}

.dek{
  color:var(--note);
  font-size:1.08rem;
  line-height:1.5;
  margin-bottom:14px;
}

.article .dateline{margin-bottom:34px}
.dateline .sep{margin:0 .45em}

figure.hero{margin:0 0 40px}
figure.hero img,
figure.hero svg,
figure.hero canvas{display:block;width:100%;height:auto}

/* ── contents ─────────────────────────────────────── */

.toc{
  grid-column:1;
  grid-row:2;
  justify-self:end;
  width:200px;
  font-size:.82rem;
  line-height:1.45;
}

.toc nav{
  position:sticky;
  top:40px;
  display:block;
  margin:0;
}

.toc .label{
  color:var(--muted);
  text-transform:uppercase;
  letter-spacing:.14em;
  font-size:.7rem;
  margin-bottom:10px;
}

.toc ol{list-style:none}
.toc li{margin-bottom:7px}
.toc a{color:var(--muted);text-decoration:none}
.toc a:hover{color:var(--ink)}

/* ── prose ────────────────────────────────────────── */

.article article p,
.article article ul,
.article article ol{margin-bottom:18px}

.article article ul,
.article article ol{padding-left:1.35em}
.article article li{margin-bottom:6px}
.article article li > ul,
.article article li > ol{margin:6px 0 0}

.article h2{
  /* undo the small-caps section label from main.css */
  font-size:1.32rem;
  font-weight:700;
  text-transform:none;
  letter-spacing:-.01em;
  color:var(--ink);
  line-height:1.3;
  margin:56px 0 16px;
  padding:0;
  border:0;
  scroll-margin-top:24px;
}

.article h3{
  font-size:1.06rem;
  font-weight:700;
  margin:34px 0 10px;
  scroll-margin-top:24px;
}

a.anchor{
  margin-left:.35em;
  color:var(--muted);
  text-decoration:none;
  opacity:0;
  transition:opacity .15s;
}

h2:hover a.anchor,
h3:hover a.anchor,
a.anchor:focus-visible{opacity:1}

blockquote{
  margin:0 0 22px;
  padding:2px 0 2px 18px;
  border-left:2px solid var(--rule);
  color:var(--note);
  font-style:italic;
}

blockquote p:last-child{margin-bottom:0}

hr{
  border:0;
  border-top:1px solid var(--rule);
  margin:44px 0;
}

/* ── theorem environments ─────────────────────────── */

.env{
  margin:0 0 22px;
  padding:14px 18px;
  border-left:2px solid var(--path);
  background:rgba(143,184,208,.05);
}

.env > p:last-child{margin-bottom:0}

.env .env-head{
  font-weight:700;
  font-style:normal;
}

.env .env-head.env-name{font-weight:400}

.env.theorem,
.env.lemma,
.env.conjecture{font-style:italic}

.env.definition,
.env.remark{border-left-color:var(--muted);background:rgba(255,255,255,.025)}

.proof{margin:0 0 22px}
.proof > .env-head{font-style:italic;margin-right:.3em}
.proof .qed{float:right;color:var(--muted)}

/* ── code ─────────────────────────────────────────── */

code{
  font-family:var(--mono);
  font-size:.84em;
  background:var(--code-bg);
  padding:.12em .36em;
  border-radius:3px;
}

.code{margin:0 0 24px}

.code .filename{
  display:flex;
  justify-content:space-between;
  font-family:var(--mono);
  font-size:.74rem;
  color:var(--muted);
  background:var(--code-bg);
  border:1px solid var(--rule);
  border-bottom:0;
  padding:7px 14px;
  border-radius:4px 4px 0 0;
}

.code .filename a{color:var(--muted)}

pre{
  font-family:var(--mono);
  font-size:.8rem;
  line-height:1.6;
  background:var(--code-bg);
  border:1px solid var(--rule);
  border-radius:4px;
  padding:14px 16px;
  overflow-x:auto;
  tab-size:2;
}

.code .filename + pre{border-radius:0 0 4px 4px}

pre code{background:none;padding:0;font-size:inherit;border-radius:0}

/* hand-applied highlighting: wrap tokens in these spans */
pre .kw{color:#c9a6e8}
pre .ty{color:var(--path)}
pre .cm{color:#6b6e76;font-style:italic}
pre .st{color:#b8d08f}
pre .sorry{color:#e8a07a;font-weight:700}

/* ── math ─────────────────────────────────────────── */

.katex{font-size:1.06em}

.katex-display{
  margin:22px 0;
  overflow-x:auto;
  overflow-y:hidden;
  padding:2px 0;
}

/* numbered display equations: <div class="eq" id="eq-1">$$…$$</div> */
.eq{position:relative}
.eq[data-n]::after{
  content:"(" attr(data-n) ")";
  position:absolute;
  right:0;
  top:50%;
  transform:translateY(-50%);
  color:var(--muted);
  font-size:.86rem;
}

/* ── figures and tables ───────────────────────────── */

figure{margin:30px 0}

figure img,
figure svg{display:block;max-width:100%;height:auto;margin:0 auto}

figure.placeholder .box{
  display:flex;
  align-items:center;
  justify-content:center;
  aspect-ratio:16 / 7;
  border:1px dashed var(--rule);
  color:var(--muted);
  font-size:.82rem;
  font-family:var(--mono);
}

figcaption{
  margin-top:10px;
  color:var(--muted);
  font-size:.84rem;
  line-height:1.5;
  text-align:center;
}

.table-wrap{overflow-x:auto;margin:0 0 24px}

table{
  border-collapse:collapse;
  width:100%;
  font-size:.88rem;
  font-variant-numeric:tabular-nums;
}

th,td{
  text-align:left;
  padding:7px 12px 7px 0;
  border-bottom:1px solid var(--rule);
}

th{
  color:var(--muted);
  font-weight:400;
  font-size:.78rem;
  text-transform:uppercase;
  letter-spacing:.08em;
}

td.num,th.num{text-align:right;padding-right:0}

/* ── footnotes ────────────────────────────────────── */

sup.fn{line-height:0;font-size:.72em;margin-left:1px}
sup.fn a{text-decoration:none;color:var(--path)}

.footnotes{
  margin-top:56px;
  padding-top:18px;
  border-top:1px solid var(--rule);
  font-size:.86rem;
  color:var(--note);
}

.footnotes ol{padding-left:1.3em}
.footnotes li{margin-bottom:10px;scroll-margin-top:24px}
.footnotes li p{margin-bottom:0}
.footnotes a.back-ref{text-decoration:none;color:var(--muted);margin-left:.3em}

/* ── references ───────────────────────────────────── */

.references{
  list-style:none;
  padding:0 !important;
  font-size:.88rem;
}

.references li{
  padding-left:2.2em;
  text-indent:-2.2em;
  margin-bottom:10px;
}

.references .key{color:var(--muted);margin-right:.5em}

/* ── narrow ───────────────────────────────────────── */

@media (max-width:1180px){
  .article-grid{grid-template-columns:minmax(0,680px);justify-content:center}
  .article-grid > .masthead,
  .article-grid > .toc,
  .article-grid > article{grid-column:1;grid-row:auto}
  .toc{justify-self:stretch;width:auto}
  .toc nav{position:static;margin-bottom:34px;padding-left:16px;border-left:1px solid var(--rule)}
}

@media (max-width:560px){
  main.article{padding-left:22px;padding-right:22px}
  .article h1{font-size:1.62rem}
  .env{padding:12px 14px}
  pre{font-size:.76rem}
}

/* two images side by side, wrapping on narrow screens */
figure.pair .panels{
  display:flex;
  flex-wrap:wrap;
  justify-content:space-between;
  align-items:flex-start;
  gap:24px 20px;
}

figure.pair .panels img{margin:0;max-width:100%}

@media (max-width:720px){
  figure.pair .panels{justify-content:center}
}
