/* Research-paper layout. Single column on screen, two-column journal layout
   when printed (which is how papers/build.py makes the PDFs). */

:root {
  --ink: #111111;
  --muted: #555555;
  --rule: #bdbdbd;
  --paper: #ffffff;
  --accent: #1d4ed8;
}

* { box-sizing: border-box; }

html { background: var(--paper); -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  padding: 0 16px 4rem;
  background: var(--paper);
  color: var(--ink);
  font-family: 'Source Serif 4', 'Times New Roman', Times, serif;
  font-size: 17px;
  line-height: 1.55;
  font-variant-numeric: oldstyle-nums;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration-color: #9a9a9a; text-underline-offset: 2px; }
a:hover { color: var(--accent); text-decoration-color: var(--accent); }

.paper-nav {
  max-width: 46rem;
  margin: 0 auto;
  padding: 1.25rem 0;
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  font: 400 13px/1.4 'JetBrains Mono', ui-monospace, monospace;
  color: var(--muted);
}

.paper { max-width: 46rem; margin: 0 auto; }

.paper-head { text-align: center; padding: 1.5rem 0 0.5rem; }

.running {
  font-size: 12.5px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  border-top: 1px solid var(--ink);
  border-bottom: 0.5px solid var(--rule);
  padding: 4px 0;
  margin-bottom: 1.6rem;
}

.paper-head h1 {
  font-size: 1.7rem;
  line-height: 1.22;
  font-weight: 700;
  margin: 0 0 1rem;
  text-wrap: balance;
}

.authors { font-size: 1.08rem; }
.authors sup, .affils sup { font-size: 0.68em; margin-left: 1px; }
.affils { font-size: 0.9rem; color: var(--muted); font-style: italic; margin-top: 0.2rem; }
.affils .corr { font-style: normal; margin-top: 0.15rem; font-size: 0.85rem; }

.abstract {
  text-align: justify;
  margin: 1.8rem 2.2rem 0.6rem;
  font-size: 0.93rem;
  line-height: 1.5;
  hyphens: auto;
}
.abstract h2 {
  text-align: center;
  font-size: 0.95rem;
  font-variant: small-caps;
  letter-spacing: 0.05em;
  margin: 0 0 0.4rem;
}
.abstract p { margin: 0 0 0.55rem; text-indent: 0; }
.abstract .keywords { margin-top: 0.7rem; }

.paper-body {
  margin-top: 1.4rem;
  border-top: 0.5px solid var(--rule);
  padding-top: 0.6rem;
  text-align: justify;
  hyphens: auto;
}

.paper-body h2 { font-size: 1.12rem; margin: 1.8rem 0 0.5rem; text-align: left; break-after: avoid; }
.paper-body h3 { font-size: 1rem; margin: 1.3rem 0 0.4rem; text-align: left; break-after: avoid; }
.paper-body h4 { font-size: 0.98rem; font-style: italic; font-weight: 600; margin: 1rem 0 0.3rem; }
.secnum { margin-right: 0.6em; }

.paper-body p { margin: 0 0 0.75rem; }
.paper-body ul, .paper-body ol { margin: 0 0 0.8rem; padding-left: 1.4rem; }
.paper-body li { margin-bottom: 0.25rem; }

code { font-family: 'JetBrains Mono', ui-monospace, monospace; font-size: 0.82em; }

.cite a { text-decoration: none; color: var(--accent); }

.equation {
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  margin: 0.9rem 0;
  overflow-x: auto;
}
.eqnum { position: absolute; right: 0; color: var(--ink); }

figure { margin: 1.3rem 0; break-inside: avoid; }
figcaption { font-size: 0.86rem; line-height: 1.4; text-align: left; margin-bottom: 0.45rem; }
figure.fig figcaption { margin: 0.45rem 0 0; }
figure.fig img { width: 100%; height: auto; display: block; }

.tbl-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table {
  border-collapse: collapse;
  width: 100%;
  font-size: 0.84rem;
  line-height: 1.35;
  font-variant-numeric: lining-nums tabular-nums;
  border-top: 1.2px solid var(--ink);
  border-bottom: 1.2px solid var(--ink);
}
thead th { border-bottom: 0.6px solid var(--ink); font-weight: 600; }
th, td { padding: 4px 7px; vertical-align: top; }
.a-l { text-align: left; } .a-r { text-align: right; } .a-c { text-align: center; }

.refs-h { margin-top: 2.2rem; }
.refs { font-size: 0.84rem; line-height: 1.4; padding-left: 1.8rem; text-align: left; }
.refs li { margin-bottom: 0.35rem; padding-left: 0.2rem; }
.refs li:target { background: #fff7d6; }

@media (max-width: 600px) {
  body { font-size: 16px; }
  .paper-head h1 { font-size: 1.38rem; }
  .abstract { margin: 1.4rem 0 0.5rem; }
  .paper-body, .abstract { text-align: left; hyphens: manual; }
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --ink: #e8e6e3;
    --muted: #a8a5a0;
    --rule: #4a4a4a;
    --paper: #161616;
    --accent: #8fb0ff;
  }
  :root:not([data-theme="light"]) .refs li:target { background: #3a3420; }
}

/* ------------------------------------------------------------ print / PDF */

@page { size: letter; margin: 0.8in 0.75in 0.85in; }

@media print {
  :root { --ink: #000; --muted: #333; --rule: #999; --paper: #fff; --accent: #000; }
  body { padding: 0; font-size: 9.6pt; line-height: 1.32; }
  .paper-nav { display: none; }
  .paper { max-width: none; }
  .paper-head { padding-top: 0; }
  .running { font-size: 7.5pt; margin-bottom: 14pt; }
  .paper-head h1 { font-size: 16pt; margin-bottom: 9pt; }
  .authors { font-size: 11pt; }
  .affils { font-size: 8.5pt; }
  .affils .corr { font-size: 8pt; }
  .abstract { font-size: 8.8pt; margin: 14pt 0.45in 6pt; }
  .abstract h2 { font-size: 9pt; }
  .paper-body {
    column-count: 2;
    column-gap: 0.28in;
    column-fill: auto;
    margin-top: 10pt;
    padding-top: 6pt;
    text-align: justify;
    hyphens: auto;
  }
  .paper-body h2 { font-size: 10.6pt; margin: 11pt 0 4pt; }
  .paper-body h3 { font-size: 9.8pt; margin: 8pt 0 3pt; }
  .paper-body p { margin: 0 0 5pt; orphans: 3; widows: 3; }
  .paper-body ul, .paper-body ol { margin-bottom: 5pt; padding-left: 12pt; }
  .paper-body li { margin-bottom: 1.5pt; }
  figure { margin: 8pt 0; }
  figure.tbl.wide { column-span: all; margin: 10pt 0; }
  figcaption { font-size: 8pt; }
  table { font-size: 7.6pt; }
  th, td { padding: 1.6pt 4pt; }
  .tbl-scroll { overflow: visible; }
  .refs-h { margin-top: 12pt; }
  .refs { font-size: 7.6pt; padding-left: 14pt; }
  a { text-decoration: none; }
}

.katex { font-size: 1.04em; }

@media print { figure.fig { column-span: all; margin: 10pt 0; } figure.fig img { max-width: 92%; margin: 0 auto; } }

/* Printed math must remain fully visible; browser scrollbars are unusable in PDFs. */
@media print {
  .equation { display: block; overflow: visible; break-inside: avoid; padding: 0 1.8em; }
  .equation .eqnum { top: 50%; transform: translateY(-50%); }
  .equation .katex-display { overflow: visible; }
  .refs { line-height: 1.25; }
  .refs li { margin-bottom: 0.05rem; }
}
