/* Computer Modern Unicode (SIL OFL, fonts/OFL.txt), subset and renamed. */
@font-face { font-family: "Paper Serif"; src: url("fonts/serif-roman.woff2") format("woff2"); font-display: swap; }
@font-face { font-family: "Paper Serif"; src: url("fonts/serif-italic.woff2") format("woff2"); font-style: italic; font-display: swap; }
@font-face { font-family: "Paper Serif"; src: url("fonts/serif-bold.woff2") format("woff2"); font-weight: bold; font-display: swap; }
@font-face { font-family: "Paper Serif"; src: url("fonts/serif-bold-italic.woff2") format("woff2"); font-weight: bold; font-style: italic; font-display: swap; }
@font-face { font-family: "Paper Mono"; src: url("fonts/mono.woff2") format("woff2"); font-display: swap; }

:root {
  color-scheme: light dark;
  --bg: #ffffff;
  --fg: #111111;
  --muted: #555555;
  --rule: #111111;
  --faint-rule: #cccccc;
  --link: #1f4b99;
  --target: #fff4c2;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #18181a;
    --fg: #e2e2e0;
    --muted: #a0a09c;
    --rule: #e2e2e0;
    --faint-rule: #48484c;
    --link: #93b4f0;
    --target: #3b3520;
  }
}

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: 19px/1.5 "Paper Serif", "Latin Modern Roman", "Times New Roman", serif;
  font-kerning: normal;
  text-rendering: optimizeLegibility;
}

article {
  max-width: 36em;
  margin: 0 auto;
  padding: 4em 1em 5em;
  text-align: justify;
  hyphens: auto;
}

/* Title block, abstract and contents, as \maketitle and the abstract environment draw them */
header {
  text-align: center;
  margin-bottom: 2.5em;
}

h1 {
  font-size: 1.75em;
  font-weight: normal;
  line-height: 1.25;
  margin: 0 0 0.8em;
  hyphens: manual;
}

.author {
  font-size: 1.2em;
  margin: 0 0 0.6em;
}

.meta {
  margin: 0.25em 0;
}

.abstract,
.contents {
  font-size: 0.9em;
  margin: 0 2.5em 2em;
}

.abstract h2,
.contents h2 {
  font-size: 1em;
  text-align: center;
  margin: 0 0 0.4em;
}

.contents ol {
  margin: 0;
  text-align: left;
}

/* Sections */
h2 {
  font-size: 1.3em;
  line-height: 1.3;
  margin: 2em 0 0.7em;
  text-align: left;
  hyphens: manual;
}

h3 {
  font-size: 1.08em;
  margin: 1.6em 0 0.5em;
  text-align: left;
  hyphens: manual;
}

p {
  margin: 0;
}

/* Paragraphs are set apart by an indent, not by space */
p + p {
  text-indent: 1.5em;
}

ul,
ol {
  margin: 0.6em 0;
  padding-left: 1.6em;
}

li + li {
  margin-top: 0.2em;
}

:is(ul, ol, pre, figure, .table) + p {
  margin-top: 0.6em;
}

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

a:hover {
  text-decoration: underline;
}

sup {
  font-size: 0.7em;
  line-height: 0;
}

code {
  font-family: "Paper Mono", "Latin Modern Mono", ui-monospace, monospace;
  font-size: 0.95em;
  hyphens: none;
}

pre {
  margin: 0.9em 0;
  padding: 0.2em 0 0.2em 1em;
  border-left: 1px solid var(--faint-rule);
  overflow-x: auto;
  text-align: left;
  line-height: 1.4;
}

pre code {
  font-size: 0.8em;
}

/* Figures and booktabs-style tables */
figure {
  margin: 1.8em 0;
}

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

figcaption {
  font-size: 0.88em;
  margin-top: 0.6em;
}

figcaption:first-child {
  margin: 0 0 0.6em;
}

/* Wide tables may stick out of the text column on both sides, like table* in LaTeX */
.table {
  width: min(100vw - 2em, 50em);
  margin: 1.2em 0 1.2em 50%;
  transform: translateX(-50%);
  overflow-x: auto;
}

figure .table {
  margin: 0 0 0 50%;
}

table {
  border-collapse: collapse;
  margin: 0 auto;
  font-size: 0.85em;
  line-height: 1.35;
  text-align: left;
  hyphens: manual;
  border-top: 1.5px solid var(--rule);
  border-bottom: 1.5px solid var(--rule);
}

th,
td {
  padding: 0.3em 0.6em;
  vertical-align: top;
}

th {
  font-weight: normal;
  border-bottom: 0.75px solid var(--rule);
  vertical-align: bottom;
}

th:first-child,
td:first-child {
  padding-left: 0;
}

th:last-child,
td:last-child {
  padding-right: 0;
}

.right {
  text-align: right;
}

.center {
  text-align: center;
}

.notes {
  font-size: 0.85em;
}

/* The "checked on" line and the list of sources */
#источники + p,
.sources {
  font-size: 0.75em;
  line-height: 1.4;
}

.sources {
  text-align: left;
  hyphens: manual;
}

.sources li + li {
  margin-top: 0.15em;
}

.sources a {
  overflow-wrap: anywhere;
}

/* The source a citation link jumped to */
li:target {
  background: var(--target);
}

@media (max-width: 600px) {
  body {
    font-size: 17px;
  }

  article {
    padding-top: 2em;
    text-align: left;
  }

  .abstract,
  .contents {
    margin-left: 0;
    margin-right: 0;
  }
}

@media print {
  @page {
    size: A4;
    margin: 2cm;
  }

  :root {
    --bg: #ffffff;
    --fg: #000000;
    --rule: #000000;
    --link: #000000;
  }

  body {
    font-size: 11pt;
  }

  article {
    max-width: none;
    padding: 0;
  }

  figure,
  .table,
  pre {
    break-inside: avoid;
  }

  pre {
    white-space: pre-wrap;
  }
}
