/* Article pages. Tokens, top bar and footer come from site.css. */
.site-bar {
  position: sticky;
  top: 0;
  z-index: 100;
}

/* ---------------------------------------------------------------- layout */
.post {
  display: grid;
  grid-template-columns: 220px minmax(0, 680px) 240px;
  grid-template-areas:
    ". header ."
    "toc article .";
  justify-content: center;
  column-gap: 48px;
  padding: 0 32px 64px;
}

.post-header { grid-area: header; }
.post-toc { grid-area: toc; }
.post-article { grid-area: article; min-width: 0; }

.post-end {
  grid-column: 2;
  min-width: 0;
}

/* ---------------------------------------------------------------- header */
.post-header {
  padding: 56px 0 28px;
  margin-bottom: 36px;
  border-bottom: 2px solid var(--ink);
}

.post-header h1 {
  margin: 0;
  font-size: clamp(34px, 4.4vw, 50px);
  font-weight: 400;
  line-height: 1.2;
}

.post-meta { margin: 16px 0 0; font-size: 15px; color: var(--muted); }

.post-abstract { margin-top: 24px; }
.post-abstract h2 { margin: 0 0 4px; font-size: 15px; font-weight: 700; letter-spacing: 0.04em; }
.post-abstract p { margin: 0; font-size: 17px; line-height: 1.75; }

.post-keywords { margin: 16px 0 0; font-size: 14px; color: var(--muted); }

/* ------------------------------------------------------------------- toc */
.post-toc {
  position: sticky;
  top: 72px;
  align-self: start;
  max-height: calc(100vh - 96px);
  overflow-y: auto;
  font-size: 14px;
  line-height: 1.5;
}

.post-toc summary {
  margin-bottom: 8px;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.04em;
  list-style: none;
  pointer-events: none;
}

.post-toc summary::-webkit-details-marker { display: none; }
.post-toc ol { margin: 0; padding: 0; list-style: none; }
.post-toc ol ol { padding-left: 12px; }
.post-toc li > a { display: block; padding: 4px 0; color: var(--muted); text-decoration: none; }
.post-toc li > a::before { content: attr(data-prefix) " "; font: 12px var(--mono); }
.post-toc a:hover { color: var(--link); }
.post-toc a.is-active { color: var(--ink); font-weight: 700; }

/* -------------------------------------------------------------- headings */
.post-article { font-size: 18px; line-height: 1.85; overflow-wrap: break-word; counter-reset: sidenote; }

.post-article h1, .post-article h2, .post-article h3,
.post-article h4, .post-article h5, .post-article h6 {
  font-weight: 400;
  line-height: 1.35;
}

.post-article h1 { margin: 2em 0 0.6em; font-size: 34px; }
.post-article h2 { margin: 2.2em 0 0.7em; padding-top: 0.7em; border-top: 1px solid var(--rule); font-size: 28px; }
.post-article > h2:first-child { margin-top: 0; padding-top: 0; border-top: 0; } /* the header's rule is right above */
.post-article h3 { margin: 1.9em 0 0.5em; font-size: 22px; }
.post-article h4 { margin: 1.7em 0 0.4em; font-size: 19px; font-weight: 700; }
.post-article h5, .post-article h6 { margin: 1.5em 0 0.4em; font-size: 18px; font-weight: 700; }

.post-article [data-prefix]::before {
  content: attr(data-prefix);
  margin-right: 0.6em;
  font: 400 0.68em var(--mono);
  color: var(--muted);
}

/* ------------------------------------------------------------------ body */
.post-article p { margin: 0.9em 0; }
.post-article > p { text-indent: 2em; }
.post-article > p.no-indent { text-indent: 0; }

.post-article a { color: var(--link); text-underline-offset: 3px; }
.post-article a:hover { text-decoration-thickness: 2px; }

.post-article ul, .post-article ol { padding-left: 1.6em; }
.post-article li { margin: 0.3em 0; }

.post-article blockquote {
  margin: 1.2em 0;
  padding: 0.1em 1.2em;
  background: var(--tint);
  color: var(--muted);
}

.post-article hr { margin: 2.4em 0; border: 0; border-top: 1px solid var(--rule); }
.post-article del { color: var(--muted); }
.post-article mark { background: var(--focus); color: inherit; }
.post-article img, .post-article video { display: block; max-width: 100%; height: auto; margin: 0 auto; }

.post-article figure { margin: 1.8em 0; }
.post-article figcaption { margin-top: 10px; font-size: 15px; line-height: 1.6; color: var(--muted); text-align: center; }

.post-article table {
  display: block;
  max-width: 100%;
  margin: 1.6em 0;
  overflow-x: auto;
  border-collapse: collapse;
  border-block: 2px solid var(--ink);
  font-size: 16px;
  line-height: 1.5;
}

.post-article th, .post-article td { padding: 8px 14px 8px 0; text-align: left; vertical-align: top; }
.post-article thead th { border-bottom: 1px solid var(--ink); font-weight: 700; }
.post-article tbody tr + tr td { border-top: 1px solid var(--rule); }

.katex-display { margin: 1.2em 0; padding: 0.3em 0; overflow-x: auto; overflow-y: hidden; }

/* ------------------------------------------------------------------ code */
.post-article code.inline {
  padding: 0.1em 0.35em;
  background: var(--tint);
  font: 0.86em var(--mono);
}

.post-article pre {
  margin: 1.4em 0;
  padding: 16px 18px;
  overflow-x: auto;
  background: var(--cap-bg);
  color: var(--cap-ink);
  font: 14px/1.6 var(--mono);
  tab-size: 2;
}

.post-article pre code, .post-article pre code.hljs { padding: 0; background: transparent; font: inherit; }

/* -------------------------------------------------------------- sidenotes */
.sidenote-number { counter-increment: sidenote; }

.sidenote-number::after {
  content: counter(sidenote);
  margin: 0 0.15em;
  color: var(--link);
  font: 0.7em var(--mono);
  vertical-align: super;
}

input.sidenote-toggle { position: absolute; width: 1px; height: 1px; opacity: 0; }

.sidenote {
  float: right;
  clear: right;
  width: 240px;
  margin: 0.3em -288px 0.8em 0;
  overflow-x: auto;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.6;
  text-indent: 0;
}

.sidenote::before {
  content: counter(sidenote) ". ";
  color: var(--link);
  font: 0.86em var(--mono);
}

/* --------------------------------------------------------------- embeds */
.embed {
  position: relative;
  height: 600px;
  max-height: 85vh;
  margin: 2em 0;
  background: var(--cap-bg);
}

.embed iframe { display: block; width: 100%; height: 100%; border: 0; }

.embed-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  background: rgba(26, 28, 31, 0.72);
  color: var(--cap-ink);
  font: 13px var(--mono);
  letter-spacing: 0.1em;
  cursor: pointer;
}

.embed-overlay:hover { background: rgba(26, 28, 31, 0.58); }

/* ------------------------------------------------------------- footnotes */
.footnotes {
  margin-top: 3em;
  padding-top: 1em;
  border-top: 1px solid var(--rule);
  font-size: 15px;
  line-height: 1.7;
}

.footnotes > div { margin: 0.4em 0; }
.footnotes a { overflow-wrap: anywhere; }
.focus { background: var(--focus); }

/* Created by tooltip.js for footnote previews. */
.tooltip {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 100;
  display: none;
  max-width: min(420px, calc(100vw - 32px));
  margin-bottom: 10px;
  padding: 8px 12px;
  background: var(--cap-bg);
  color: var(--cap-ink);
  font-size: 14px;
  line-height: 1.6;
}

.tooltip a { color: var(--cap-link); }

/* -------------------------------------------------------------- comments */
.post-comments { margin-top: 3em; padding-top: 1em; border-top: 1px solid var(--rule); font-size: 15px; color: var(--muted); }

/* ------------------------------------------------------------ responsive */
/* No room for a margin column: sidenotes open inline from their number. */
@media (max-width: 1279px) {
  .post { grid-template-columns: 200px minmax(0, 720px); }

  .sidenote-number { cursor: pointer; }

  .sidenote {
    display: none;
    float: none;
    width: auto;
    margin: 0.7em 0;
    padding: 10px 14px;
    background: var(--tint);
  }

  input.sidenote-toggle:checked + .sidenote { display: block; }
}

@media (max-width: 960px) {
  .post {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas: "header" "toc" "article";
    padding: 0 16px 48px;
  }

  .post-end { grid-column: 1; }
  .post-header { padding-top: 36px; margin-bottom: 20px; }

  .post-toc {
    position: static;
    max-height: none;
    margin-bottom: 8px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--rule);
  }

  .post-toc summary { margin: 0; padding: 10px 0; list-style: revert; pointer-events: auto; cursor: pointer; }

  .post-article { font-size: 17px; }
  .post-article h2 { font-size: 25px; }
  .post-article h3 { font-size: 21px; }
  .embed { height: 480px; margin-inline: -16px; }
  .post-article pre { margin-inline: -16px; }
}
