/*
 * Polymath Global formal-paper presentation layer.
 *
 * Papers diverge from reports and guides on purpose. The paper is a white
 * plate in a centred column with the site chrome in the margins, set in a
 * Computer Modern family so it reads as the typeset document it is.
 *
 * Scope rule: every selector is rooted at .pg-paper so this cannot restyle
 * the generated banner, navigation, or footer.
 *
 * Font note: Latin Modern is the OpenType successor to Computer Modern.
 * Until the web fonts are self-hosted this falls back through the common
 * installed names to Times, which is the closest ubiquitous match.
 */

.pg-paper {
  --sheet: #ffffff;
  --sheet-ink: #101010;
  --sheet-ink-2: #3a3a3a;
  --sheet-line: #d4d4d4;
  --sheet-rule: #1a1a1a;
  --sheet-link: #14418c;
  --sheet-code: #f2f2f0;
  display: block;
  padding: 2.5rem 0 4rem;
  background: transparent;
}

.pg-paper *,
.pg-paper *::before,
.pg-paper *::after {
  box-sizing: border-box;
}

.pg-paper__layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 8.5in minmax(0, 1fr);
  gap: 2rem;
  align-items: start;
  width: calc(100% - 3rem);
  margin: 0 auto;
}

/* ---- the sheet ---- */

/* Geometry is the source's own: article class at its 10pt default, US
   Letter, margin=1in. That gives an 8.5in sheet with a 6.5in measure.
   Sizes are held in pt so they mean the same thing they mean in LaTeX. */
.pg-paper__sheet {
  grid-column: 2;
  width: 8.5in;
  max-width: 100%;
  padding: 1in;
  background: var(--sheet);
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.45);
  color: var(--sheet-ink);
  font-family: "Latin Modern Roman", "CMU Serif", "Computer Modern Roman",
    "Nimbus Roman", "Times New Roman", Times, serif;
  font-size: 10pt;
  line-height: 1.2;
  text-align: justify;
  hyphens: auto;
}

/* The banner is sticky, so anything scrolled to by an anchor has to clear
   it or the heading lands underneath. 92px is the offset already in use
   for the essay pages and for this page's own contents rail. Applied to
   every id-carrying element in the sheet so it covers section and
   subsection links from the rail, figure and table cross-references, and
   citation jumps into the bibliography alike (A-13). */
.pg-paper__sheet [id] {
  scroll-margin-top: 92px;
}

/* Paragraph indentation is the base layer's job, not this one's. LaTeXML
   reproduces LaTeX's own model: indent the first paragraph of a block,
   leave the paragraph opening a section flush, honour explicit indent and
   noindent marks, and leave paragraphs that are not part of a para block
   -- table cells among them -- unindented. The hand-rolled rule that used
   to live here indented every paragraph and then chased exceptions, which
   is what put a first-line indent inside every table cell (A-12).

   Only the indent width is corrected here: the base layer uses a generic
   2em, and the article class at 10pt sets \parindent to 15pt, which is
   1.5em at this size. */
.pg-paper__sheet .ltx_p {
  margin: 0;
}

.pg-paper__sheet .ltx_para > .ltx_p:first-child,
.pg-paper__sheet .ltx_title_abstract + .ltx_p {
  text-indent: 1.5em;
}

.pg-paper__sheet .ltx_indent > .ltx_p:first-child {
  text-indent: 1.5em !important;
}

/* Checked against page one of the PDF: every abstract paragraph is
   indented, not just the first. The L9 sheet set them all flush, which was
   carried forward pending this comparison and is now corrected (A-17). */
.pg-paper__sheet .ltx_abstract .ltx_p {
  text-indent: 1.5em;
}

/* ---- title block ---- */

/* The source builds its own title block with the titling package:
   \pretitle sets \LARGE\bfseries, and both \preauthor and \predate set
   \normalsize. So the title is bold at 17.28pt and the author and date sit
   at body size, not a size up (A-19, A-20). Natural wrapping rather than
   balanced: LaTeX fills the measure and breaks at the end of it, and
   balancing moved the title's break a word early against the PDF. */
.pg-paper__sheet .ltx_title_document {
  margin: 0 0 20pt;
  font-size: 17.28pt;
  font-weight: 700;
  line-height: 1.15;
  text-align: center;
}

.pg-paper__sheet .ltx_authors,
.pg-paper__sheet .ltx_dates {
  margin: 0 0 10pt;
  font-size: 10pt;
  text-align: center;
}

.pg-paper__sheet .ltx_dates {
  margin: 0 0 24pt;
}

/* The abstract sits in a quotation block at \small, inset half an inch
   each side, so it runs to a 5.5in measure against the body's 6.5in. */
.pg-paper__sheet .ltx_abstract {
  margin: 24pt 0.5in 0;
  font-size: 9pt;
  line-height: 1.2;
  text-align: justify;
}

.pg-paper__sheet .ltx_title_abstract {
  margin-bottom: 8pt;
  font-size: 10pt;
  font-weight: 700;
  text-align: center;
}

/* ---- headings ---- */

/* LaTeXML embeds the real section/subsection/appendix numbers and letters
   as literal text in a ltx_tag span, generated from LaTeX's own counters.
   No CSS counter reconstruction is needed or wanted here. */
.pg-paper__sheet .ltx_title_section,
.pg-paper__sheet .ltx_title_subsection,
.pg-paper__sheet .ltx_title_subsubsection,
.pg-paper__sheet .ltx_title_appendix {
  font-weight: 700;
  line-height: 1.3;
  text-align: left;
}

/* \section \Large, \subsection \large, \subsubsection \normalsize. */
.pg-paper__sheet .ltx_title_section,
.pg-paper__sheet .ltx_title_appendix {
  margin: 20pt 0 8pt;
  font-size: 14.4pt;
}

.pg-paper__sheet .ltx_title_subsection {
  margin: 16pt 0 6pt;
  font-size: 12pt;
}

.pg-paper__sheet .ltx_title_subsubsection {
  margin: 12pt 0 4pt;
  font-size: 10pt;
}

.pg-paper__sheet .ltx_tag_section,
.pg-paper__sheet .ltx_tag_subsection,
.pg-paper__sheet .ltx_tag_subsubsection,
.pg-paper__sheet .ltx_tag_appendix {
  margin-right: 0.3em;
}

.pg-paper__sheet .ltx_title_bibliography {
  margin: 20pt 0 8pt;
  font-size: 14.4pt;
  font-weight: 700;
  text-align: left;
}

.pg-paper__sheet .ltx_title_footnote {
  font-weight: 700;
}

/* ---- links, lists, quotes ---- */

.pg-paper__sheet a {
  color: var(--sheet-link);
  text-decoration: none;
  overflow-wrap: anywhere;
}

.pg-paper__sheet a:hover {
  text-decoration: underline;
}

.pg-paper__sheet ul,
.pg-paper__sheet ol {
  margin: 6pt 0;
  padding-left: 1.8em;
  text-align: left;
}

.pg-paper__sheet li {
  margin-bottom: 0.3rem;
}

.pg-paper__sheet blockquote {
  margin: 1rem 0 1rem 1.6em;
  color: var(--sheet-ink-2);
}

/* ---- figures and tables ----
   Both share ltx_figure / ltx_table, ltx_caption with a ltx_tag carrying
   the real "Figure N:" / "Table N:" text already, and TikZ diagrams arrive
   as inline <svg>, already vector, already numbered. */

.pg-paper__sheet .ltx_figure,
.pg-paper__sheet .ltx_table {
  max-width: 100%;
  margin: 14pt auto;
  text-align: center;
}

.pg-paper__sheet .ltx_graphics,
.pg-paper__sheet svg.ltx_picture {
  display: block;
  max-width: 100%;
  height: auto;
  margin: 0 auto;
}

.pg-paper__sheet .ltx_caption {
  max-width: none;
  margin: 8pt auto 0;
  font-size: 9pt;
  line-height: 1.2;
  text-align: left;
  text-indent: 0;
}

.pg-paper__sheet .ltx_tag_figure,
.pg-paper__sheet .ltx_tag_table {
  font-weight: 700;
}

.pg-paper__sheet .ltx_tabular {
  width: 100%;
  margin: 0 auto;
  border-collapse: collapse;
  font-size: 9pt;
  text-align: left;
}

.pg-paper__sheet .ltx_th,
.pg-paper__sheet .ltx_td {
  padding: 0.4rem 0.6rem;
  vertical-align: top;
}

/* Rules come from the source's own \toprule, \midrule and \bottomrule,
   which the converter records per cell. Only weight and ink are corrected
   here; the mapping stays the converter's. The base layer draws its heavy
   rules as a 3px double line, where booktabs draws single rules at two
   weights -- heavy top and bottom, light mid. The rules that used to live
   here were hand-rolled off thead and last-row position instead, so they
   did not follow the source. */
.pg-paper__sheet .ltx_border_tt {
  border-top: 1.1pt solid var(--sheet-rule);
}

.pg-paper__sheet .ltx_border_bb {
  border-bottom: 1.1pt solid var(--sheet-rule);
}

.pg-paper__sheet .ltx_border_t {
  border-top: 0.6pt solid var(--sheet-rule);
}

.pg-paper__sheet .ltx_border_b {
  border-bottom: 0.6pt solid var(--sheet-rule);
}

.pg-paper__sheet .ltx_border_l {
  border-left: 0.6pt solid var(--sheet-rule);
}

.pg-paper__sheet .ltx_border_r {
  border-right: 0.6pt solid var(--sheet-rule);
}

/* No table in either source sets its header row in bold -- verified across
   every \toprule in both files. The bold came from the browser's default
   <th> styling. Reset it so emphasis comes only from the source's markup
   (A-15). */
.pg-paper__sheet .ltx_th {
  font-weight: inherit;
}

/* Every wrapping column in both papers is ragged right: they are reached
   either through the sources' own L column type, defined as
   >{\raggedright\arraybackslash}p{}, or through that prefix written out in
   full. Verified across every column specification in both files. The
   converter sees only the underlying p{} and marks the cells justified,
   which sets them solid and opens word gaps the PDF does not have. Restore
   the source's ragged right (A-16). */
.pg-paper__sheet .ltx_td.ltx_align_justify,
.pg-paper__sheet .ltx_th.ltx_align_justify {
  text-align: left;
}

/* Tables that overrun the measure scroll rather than break layout. */
.pg-paper__sheet .ltx_table {
  overflow-x: auto;
}

/* ---- code and maths ----
   LaTeXML's math is native MathML with real numbering and \eqref links
   already resolved, so no client-side renderer is required. */

.pg-paper__sheet code,
.pg-paper__sheet pre {
  font-family: "Latin Modern Mono", ui-monospace, "Courier New", Courier,
    monospace;
  font-size: 0.92em;
}

.pg-paper__sheet pre {
  overflow-x: auto;
  padding: 0.8rem 1rem;
  background: var(--sheet-code);
  text-align: left;
  text-indent: 0;
}

.pg-paper__sheet .ltx_font_typewriter {
  overflow-wrap: anywhere;
  word-break: break-word;
}

.pg-paper__sheet math {
  font-size: 1.02em;
}

/* Inline formulas sit in the running text; LaTeXML marks them ltx_Math
   without a display wrapper, so no extra styling is needed there. */

/* Display equations: a full-measure table with two flexible pad cells
   either side of the centred formula, and the number pinned at the right
   margin. Matches the source's \[ ... \] centring exactly. */
.pg-paper__sheet .ltx_eqn_table {
  display: block;
  width: 100%;
  max-width: 100%;
  margin: 10pt 0;
  border-collapse: collapse;
  overflow-x: auto;
}

.pg-paper__sheet .ltx_eqn_center_padleft,
.pg-paper__sheet .ltx_eqn_center_padright {
  width: 50%;
}

.pg-paper__sheet .ltx_eqn_table .ltx_align_center {
  text-align: center;
  white-space: nowrap;
}

.pg-paper__sheet .ltx_eqn_eqno {
  width: 1%;
  white-space: nowrap;
  text-align: right;
  padding-left: 1em;
}

/* ---- footnotes ----
   The paper's own disclosure travels as a footnote right after the
   abstract. It carries need-to-know information, so it renders inline and
   visible at that position rather than hidden behind a hover affordance. */

/* The base layer styles notes as hover tooltips -- absolutely positioned,
   boxed, drop-shadowed, hidden until hover. This paper's note is not a
   tooltip, so that chrome is undone here and the note is set as a rule-off
   block at the foot of the front matter, which is where the PDF puts it. */
.pg-paper__sheet .ltx_note_content {
  display: block;
  position: static;
  left: auto;
  max-width: none;
  margin: 10pt 0.5in 0;
  padding: 6pt 0 0;
  border: 0;
  border-top: 0.6pt solid var(--sheet-line);
  border-radius: 0;
  background: none;
  box-shadow: none;
  font-size: 9pt;
  line-height: 1.3;
  text-align: left;
  text-indent: 0;
}

.pg-paper__sheet .ltx_note,
.pg-paper__sheet .ltx_note_outer {
  display: block;
  max-width: 100%;
  overflow-wrap: anywhere;
}

/* The disclosure is raised with the source's own mark-less footnote command,
   so the PDF prints no marker at all -- not in the body and not on the note.
   LaTeXML has no way to know that and emits a dagger in both places. Every
   footnote in both papers is this same mark-less disclosure, so suppressing
   the marker outright is correct here (A-18). */
.pg-paper__sheet .ltx_note_mark {
  display: none;
}

/* ---- bibliography ----
   Manual thebibliography with natbib's numbers option: in-text citations
   already render as [N], but LaTeXML keeps the author-year label the
   source's \bibitem carries for its own optional display. Suppressing that
   and numbering the list from its own order matches the in-text numbers
   exactly, since citation numbers are assigned by list position. */

.pg-paper__sheet .ltx_biblist {
  margin: 8pt 0 0;
  padding: 0;
  list-style: none;
  counter-reset: ltx-bib;
}

.pg-paper__sheet .ltx_bibitem {
  position: relative;
  margin: 0 0 8pt;
  padding-left: 2.2em;
  font-size: 9pt;
  line-height: 1.3;
  text-align: left;
  text-indent: 0;
  counter-increment: ltx-bib;
}

.pg-paper__sheet .ltx_bibitem .ltx_tag_bibitem {
  display: none;
}

.pg-paper__sheet .ltx_bibitem::before {
  position: absolute;
  left: 0;
  content: "[" counter(ltx-bib) "]";
  font-weight: 700;
}

.pg-paper__sheet .ltx_bibblock {
  display: inline;
  overflow-wrap: anywhere;
}

/* The PDF's internal cross-references and citations print black, not
   coloured, so links stay ink-coloured everywhere in the sheet except
   where the paper's own chrome (the download strip) uses site colour. */
.pg-paper__sheet a {
  color: var(--sheet-ink);
}

.pg-paper__sheet a:hover {
  color: var(--sheet-link);
}

/* ---- contents rail ---- */

.pg-paper__nav {
  grid-column: 3;
  justify-self: end;
  width: min(250px, 100%);
  scrollbar-width: none;
  -ms-overflow-style: none;
  position: sticky;
  top: 92px;
  max-height: calc(100vh - 120px);
  overflow-y: auto;
  padding: 1.1rem 1.2rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel);
  color: var(--text-muted);
  font-size: 0.84rem;
  line-height: 1.4;
}

.pg-paper__nav::-webkit-scrollbar {
  display: none;
}

.pg-paper__nav-title {
  margin-bottom: 0.7rem;
  color: var(--text);
  font-family: ui-monospace, Consolas, monospace;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.pg-paper__nav a {
  display: block;
  padding: 0.2rem 0;
  color: var(--text-muted);
}

.pg-paper__nav a:hover {
  color: var(--accent-2);
}

.pg-paper__nav a[data-level="2"] {
  padding-left: 0.9em;
  font-size: 0.79rem;
}

/* ---- download strip ---- */

.pg-paper__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  width: min(1240px, calc(100% - 3rem));
  margin: 0 auto 1.4rem;
}

.pg-paper__action {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.45rem 0.85rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--panel);
  color: var(--text);
  font-size: 0.84rem;
}

.pg-paper__action:hover {
  border-color: var(--accent-2);
  text-decoration: none;
}

/* ---- citation block ---- */

/* Sits below the paper now, so it needs to clear the foot of the sheet
   rather than butt against it. */
.pg-paper__cite {
  width: min(1240px, calc(100% - 3rem));
  margin: 2.75rem auto 1.4rem;
  padding: 0.9rem 1.1rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel);
  color: var(--text-muted);
  font-size: 0.86rem;
}

.pg-paper__cite-plain {
  margin: 0 0 0.6rem;
}

.pg-paper__cite-bibtex {
  overflow-x: auto;
  margin: 0;
  padding: 0.7rem 0.9rem;
  background: var(--panel-2);
  border-radius: 6px;
  font-family: ui-monospace, Consolas, monospace;
  font-size: 0.78rem;
  line-height: 1.5;
  white-space: pre;
}

/* ---- responsive ---- */

@media (max-width: 1024px) {
  .pg-paper__layout {
    grid-template-columns: minmax(0, 1fr);
  }

  .pg-paper__sheet,
  .pg-paper__nav {
    grid-column: 1;
  }

  .pg-paper__nav {
    position: static;
    justify-self: stretch;
    width: 100%;
    max-height: none;
    order: -1;
  }
}

@media (max-width: 640px) {
  .pg-paper__sheet {
    padding: 1.2rem;
    text-align: left;
    hyphens: manual;
  }

  .pg-paper__sheet p {
    text-indent: 0;
    margin-bottom: 0.9rem;
  }
}

@media (max-width: 420px) {
  .pg-paper__sheet :where(.ltx_p, .ltx_para, .ltx_section, .ltx_subsection, .ltx_appendix) {
    min-width: 0;
    overflow-wrap: anywhere;
  }
}

@media print {
  .pg-paper {
    padding: 0;
  }

  .pg-paper__nav,
  .pg-paper__actions {
    display: none;
  }

  .pg-paper__sheet {
    padding: 0;
    box-shadow: none;
  }
}

