/*
 * Stylesheet for the in-browser "paper view": the post rendered as one
 * continuous LaTeX-style sheet. Loaded only on posts with `paper: true`.
 * Every rule is scoped under .paper-article so nothing leaks into the
 * regular page.
 */

/* Latin Modern: the LaTeX text font (Computer Modern's successor).
   Vendored from latex.css (GUST Font License). */
@font-face {
  font-family: 'Latin Modern Roman';
  src: url('/assets/fonts/latin-modern/LM-regular.woff2') format('woff2');
  font-weight: normal;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'Latin Modern Roman';
  src: url('/assets/fonts/latin-modern/LM-bold.woff2') format('woff2');
  font-weight: bold;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'Latin Modern Roman';
  src: url('/assets/fonts/latin-modern/LM-italic.woff2') format('woff2');
  font-weight: normal;
  font-style: italic;
  font-display: swap;
}

@font-face {
  font-family: 'Latin Modern Roman';
  src: url('/assets/fonts/latin-modern/LM-bold-italic.woff2') format('woff2');
  font-weight: bold;
  font-style: italic;
  font-display: swap;
}

/*
 * Lighten KaTeX to Latin Modern weight. KaTeX's own Computer Modern faces
 * render ~25% more ink than Latin Modern, so math looks bolder than the LM
 * body. Latin Modern is metric-compatible with Computer Modern, so shadowing
 * only the letter/digit/punctuation codepoints of KaTeX's faces with LM is
 * safe: these later same-family rules win for their unicode-range, and every
 * other codepoint (Greek, relations, big operators, delimiters) falls back
 * to KaTeX's own glyphs.
 */
@font-face {
  font-family: 'KaTeX_Main';
  src: url('/assets/fonts/latin-modern/LM-regular.woff2') format('woff2');
  font-weight: normal;
  font-style: normal;
  font-display: swap;
  unicode-range: U+0020-007E;
}

@font-face {
  font-family: 'KaTeX_Main';
  src: url('/assets/fonts/latin-modern/LM-bold.woff2') format('woff2');
  font-weight: bold;
  font-style: normal;
  font-display: swap;
  unicode-range: U+0020-007E;
}

@font-face {
  font-family: 'KaTeX_Main';
  src: url('/assets/fonts/latin-modern/LM-italic.woff2') format('woff2');
  font-weight: normal;
  font-style: italic;
  font-display: swap;
  unicode-range: U+0020-007E;
}

/* Math variables (KaTeX_Math is Computer Modern math italic): shadow only
   the latin letters; Greek and symbols stay with KaTeX. */
@font-face {
  font-family: 'KaTeX_Math';
  src: url('/assets/fonts/latin-modern/LM-italic.woff2') format('woff2');
  font-weight: normal;
  font-style: italic;
  font-display: swap;
  unicode-range: U+0041-005A, U+0061-007A;
}

.paper-article {
  font-family: 'Latin Modern Roman', 'KaTeX_Main', 'Times New Roman', Georgia, serif;
  font-size: 10.5pt;
  line-height: 1.38;
  color: #111111;
  text-align: justify;
  hyphens: auto;
  -webkit-hyphens: auto;

  /* Force the light palette regardless of the site theme: the cloned content
     still matches the site's syntax-highlighting selectors, which read these
     custom properties. Values mirror the :root light theme in main.scss. */
  --background-color: #ffffff;
  --surface-color: #ffffff;
  --surface-elevated-color: #f4f5f6;
  --text-color: #0f1419;
  --text-muted-color: #536471;
  --link-color: #1a4c8b;
  --link-visited-color: #1a4c8b;
  --link-hover-color: #1a4c8b;
  --border-color: #e3e6e8;
  --code-bg: #f5f5f5;
  --code-border-color: #dddddd;
  --blockquote-border: #e5e5e5;
  --blockquote-bg: rgba(148, 163, 184, 0.08);
  --code-hl-comment: #998;
  --code-hl-comment-preproc: #999;
  --code-hl-error-fg: #a61717;
  --code-hl-error-bg: #e3d2d2;
  --code-hl-generic-deleted-fg: #000;
  --code-hl-generic-deleted-bg: #fdd;
  --code-hl-generic-deleted-specific-bg: #faa;
  --code-hl-generic-inserted-fg: #000;
  --code-hl-generic-inserted-bg: #dfd;
  --code-hl-generic-inserted-specific-bg: #afa;
  --code-hl-generic-error: #a00;
  --code-hl-generic-heading: #999;
  --code-hl-generic-output: #888;
  --code-hl-generic-prompt: #555;
  --code-hl-generic-subheading: #aaa;
  --code-hl-generic-traceback: #a00;
  --code-hl-keyword-type: #458;
  --code-hl-number: #099;
  --code-hl-string: #d14;
  --code-hl-string-regex: #009926;
  --code-hl-string-symbol: #990073;
  --code-hl-name-attr: #008080;
  --code-hl-name-builtin: #0086b3;
  --code-hl-name-class: #458;
  --code-hl-name-constant: #008080;
  --code-hl-name-entity: #800080;
  --code-hl-name-exception: #900;
  --code-hl-name-function: #900;
  --code-hl-name-namespace: #555;
  --code-hl-name-tag: #000080;
  --code-hl-name-variable: #008080;
  --code-hl-whitespace: #bbb;
}

/* ---- Title block (LaTeX \maketitle) ---- */

.paper-article .paper-titleblock {
  text-align: center;
  margin: 0 0 2em;
}

.paper-article .paper-title {
  font-family: inherit;
  font-size: 17pt;
  font-weight: normal;
  line-height: 1.25;
  margin: 0 0 1em;
  text-align: center;
}

.paper-article .paper-author {
  font-size: 12pt;
  margin: 0 0 0.5em;
  text-indent: 0;
}

.paper-article .paper-date {
  font-size: 10.5pt;
  margin: 0;
  text-indent: 0;
}

.paper-article .paper-abstract {
  margin: 2em 3em 0;
  text-align: justify;
  font-size: 9.5pt;
}

.paper-article .paper-abstract-heading {
  display: block;
  text-align: center;
  font-size: 10pt;
  font-weight: bold;
  margin: 0 0 0.6em;
}

.paper-article .paper-abstract p {
  text-indent: 0;
  margin: 0;
}

/* ---- Body typography ---- */

/* LaTeX-style paragraphs: no gap, first-line indent. */
.paper-article p {
  margin: 0;
  text-indent: 16pt;
}

.paper-article .paper-titleblock p,
.paper-article h1 + p,
.paper-article h2 + p,
.paper-article h3 + p,
.paper-article h4 + p,
.paper-article li p,
.paper-article blockquote p:first-child,
.paper-article .post-content > p:first-child {
  text-indent: 0;
}

/* The LIVE article element moves in with its site classes; neutralize the
   site's typography so the paper fonts inherit through. */
.paper-article .post-content {
  font-family: inherit;
  font-size: inherit;
  line-height: inherit;
}

/* Site widgets that make no sense on paper. Only the site's own chrome —
   the interactive figures keep their buttons and controls. */
.paper-article .code-block__toolbar {
  display: none;
}

/* heading-links.js wraps heading text in an anchor; render it as plain text. */
.paper-article .heading-anchor,
.paper-article .heading-anchor:visited {
  color: inherit;
  text-decoration: none;
}

/* Interactive figures: the paper sheet is always light, so pin the accent
   palette even when the site theme is dark. The neutral --lbd-* colors
   already resolve from the light variables defined on .paper-article. */
.paper-viewer .paper-article .lbd-demo {
  --lbd-orange: #d97706;
  --lbd-accent: #3b82f6;
  --lbd-red: #dc2626;
}

.paper-article h1,
.paper-article h2,
.paper-article h3,
.paper-article h4 {
  font-family: inherit;
  font-weight: bold;
  text-align: left;
  break-after: avoid;
  page-break-after: avoid;
}

.paper-article h1:not(.paper-title),
.paper-article h2 {
  font-size: 12pt;
  margin: 1.7em 0 0.8em;
}

.paper-article h3 {
  font-size: 10.5pt;
  margin: 1.4em 0 0.6em;
}

.paper-article h4 {
  font-size: 10.5pt;
  font-style: italic;
  font-weight: normal;
  margin: 1.2em 0 0.5em;
}

.paper-article .heading-number {
  margin-right: 0.6em;
}

/* The site draws "#" markers before headings; papers do not. */
.paper-article h1::before,
.paper-article h2::before,
.paper-article h3::before,
.paper-article h4::before,
.paper-article h5::before,
.paper-article h6::before {
  content: none !important;
  display: none !important;
}

.paper-article a {
  color: var(--link-color);
  text-decoration: none;
}

/* Concept links carry dotted underlines on the site; print them as plain text. */
.paper-article a.concept-link,
.paper-article a.concept-link:visited {
  color: inherit;
  text-decoration: none;
}

.paper-article ul,
.paper-article ol {
  margin: 0.6em 0 0.6em 2em;
}

.paper-article li {
  margin-bottom: 0.15em;
}

.paper-article blockquote {
  margin: 0.8em 2em;
  padding: 0;
  border: none;
  background: none;
  font-size: 10pt;
  font-style: italic;
  color: #333333;
}

.paper-article hr {
  border: none;
  border-top: 0.5pt solid #000000;
  width: 30%;
  margin: 1.5em auto;
}

/* ---- Math ---- */

/* KaTeX upscales math to 1.21em so Computer Modern matches taller text
   fonts. The paper body is already Computer Modern, so math renders at
   text size, exactly like LaTeX. */
.paper-article .katex {
  font-size: 1em;
}

.paper-article .katex-display {
  margin: 0.9em 0;
  break-inside: avoid;
  page-break-inside: avoid;
  overflow-x: auto;
  overflow-y: hidden;
  text-indent: 0;
}

/* ---- Code ---- */

.paper-article pre,
.paper-article code {
  font-size: 8.5pt;
  text-align: left;
  text-indent: 0;
}

.paper-article pre {
  background: var(--code-bg);
  border: 0.5pt solid var(--code-border-color);
  border-radius: 0;
  padding: 6pt 8pt;
  margin: 0.8em 0;
  white-space: pre-wrap;
  overflow-wrap: break-word;
  line-height: 1.35;
}

.paper-article code {
  background: none;
  border: none;
  padding: 0;
}

/* ---- Figures, images, tables ---- */

.paper-article img,
.paper-article svg,
.paper-article video {
  max-width: 100%;
  height: auto;
  display: block;
  margin: 0.9em auto;
  break-inside: avoid;
  page-break-inside: avoid;
}

.paper-article figure {
  margin: 0.9em 0;
  text-align: center;
  break-inside: avoid;
  page-break-inside: avoid;
}

.paper-article figcaption {
  font-size: 9pt;
  text-align: center;
  margin-top: 0.4em;
}

/* booktabs look: rules above and below the table, one under the header row.
   `border: none` first: the site styles tables with a four-side shorthand,
   and overriding only top/bottom would leave its faint side borders. */
.paper-article table {
  font-size: 9pt;
  border-collapse: collapse;
  border: none;
  border-top: 1pt solid #000000;
  border-bottom: 1pt solid #000000;
  margin: 0.9em auto;
  break-inside: avoid;
  page-break-inside: avoid;
}

.paper-article table tr,
.paper-article table tr:nth-child(even) {
  background: none;
}

.paper-article th,
.paper-article td {
  border: none;
  padding: 2.5pt 8pt;
  background: none;
  text-align: left;
}

.paper-article thead th {
  border-bottom: 0.5pt solid #000000;
}

/* ---- Footnotes (kramdown end-of-document block) ---- */

.paper-article .footnotes {
  margin-top: 2em;
  border-top: 0.5pt solid #000000;
  padding-top: 0.5em;
  font-size: 8.5pt;
}

.paper-article .footnotes p {
  text-indent: 0;
}
