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

html {
  -webkit-text-size-adjust: 100%;
}

body,
h1,
h2,
h3,
p,
ul,
ol,
li,
figure,
blockquote,
dl,
dd {
  margin: 0;
}

ul,
ol {
  padding: 0;
  list-style: none;
}

img,
svg {
  display: block;
  max-width: 100%;
}

a {
  color: inherit;
  text-decoration: inherit;
}

button,
input {
  font: inherit;
}

:root {
  --ink: #000;
  --paper: #faf8f1;
  --link: #3a4666;
}

.skip-link {
  position: absolute;
  top: 0.5rem;
  left: 0.5rem;
  z-index: 10;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--ink);
  background: var(--paper);
  color: var(--ink);
  transform: translateY(-200%);
}

.skip-link:focus {
  transform: translateY(0);
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: "Latin Modern Roman", "Computer Modern", serif;
  font-size: 18px;
  line-height: 1.6;
  text-rendering: optimizeLegibility;
}

@media (min-width: 1024px) and (max-width: 1919px) {
  body {
    font-size: clamp(18px, 0.6rem + 0.75vw, 21px);
  }
}

.page {
  max-width: 1600px;
  margin: 0 auto;
  padding: clamp(1.5rem, 4vw, 4rem);
}

.masthead {
  margin-bottom: 2.5rem;
}

.masthead__title {
  margin: 0;
  font-family: "GOST Type A", "Latin Modern Roman", serif;
  font-weight: 400;
  font-size: clamp(2.2rem, 5vw, 3.6rem);
  line-height: 1.05;
  letter-spacing: 0.01em;
}

.masthead__subtitle {
  margin: 0.4rem 0 0;
  font-size: clamp(1.05rem, 1.6vw, 1.25rem);
}

.links-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  margin-top: 1rem;
  break-inside: avoid;
}

.links-row a {
  color: var(--link);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.15em;
}

.links-row a:hover {
  text-decoration-thickness: 2px;
}

.links-row a + a::before {
  content: "";
  display: inline-block;
  width: 1px;
  height: 0.9em;
  margin: 0 0.75em;
  background: var(--ink);
  vertical-align: -0.1em;
}

.section-links {
  margin-top: 0.75rem;
  gap: 0.25em 1em;
}

.section-links a + a::before {
  content: none;
  display: none;
}

.paper {
  position: relative;
  column-count: 1;
  column-gap: 2.5rem;
}

.paper::before,
.paper::after {
  content: "";
  position: absolute;
  top: -0.8em;
  bottom: -0.8em;
  display: none;
  width: 1px;
  background: var(--ink);
  pointer-events: none;
}

@media (min-width: 640px) {
  .paper {
    column-count: 2;
  }

  .paper::before {
    display: block;
    left: 50%;
  }
}

@media (min-width: 1920px) {
  .paper {
    column-count: 3;
  }

  .paper::before {
    left: calc(33.3333% - 0.4167rem);
  }

  .paper::after {
    display: block;
    left: calc(66.6667% + 0.4167rem);
  }
}

/* Single-column article page. Scoped so the homepage layout stays untouched. */
.page--article {
  max-width: 960px;
}

.masthead--article {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.75rem 2rem;
  margin-bottom: 2.25rem;
}

.masthead__home {
  font-family: "GOST Type A", "Latin Modern Roman", serif;
  font-size: clamp(1.55rem, 1.2rem + 1.4vw, 2.1rem);
  line-height: 1.1;
  letter-spacing: 0.01em;
}

.article-nav a {
  color: var(--link);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.15em;
}

.article-nav a:hover {
  text-decoration-thickness: 2px;
}

.paper--article {
  column-count: 1;
  column-gap: 0;
}

.paper--article::before,
.paper--article::after {
  content: none;
  display: none;
}

@media (min-width: 640px) {
  .paper--article {
    column-count: 1;
    column-gap: 0;
  }
}

@media (min-width: 1920px) {
  .paper--article {
    column-count: 1;
    column-gap: 0;
  }
}

.article__header {
  margin-bottom: 2rem;
}

.article__title {
  margin: 0;
  font-family: "GOST Type A", "Latin Modern Roman", serif;
  font-weight: 400;
  font-size: clamp(1.9rem, 1.3rem + 2.2vw, 2.9rem);
  line-height: 1.12;
  letter-spacing: 0.01em;
}

.paper .article__meta {
  margin-top: 0.75rem;
  font-size: 0.95rem;
  line-height: 1.5;
}

.paper--article figure {
  margin: 1.75rem 0;
}

.paper--article figure img {
  width: auto;
  max-width: 100%;
  height: auto;
  margin-inline: auto;
}

.paper--article pre {
  max-width: 100%;
  margin: 1.5rem 0;
  padding: 0.9rem 1.1rem;
  overflow-x: auto;
  border: 1px solid rgba(0, 0, 0, 0.16);
  border-radius: 2px;
  background: #f3efe4;
  font-size: 0.85em;
  line-height: 1.5;
  white-space: pre;
  hyphens: none;
  -webkit-overflow-scrolling: touch;
}

.paper--article pre code {
  font-family: "Latin Modern Mono", ui-monospace, "SFMono-Regular", monospace;
  font-size: 1em;
  padding: 0;
  border: 0;
  background: none;
  white-space: inherit;
}

.paper--article :not(pre) > code {
  padding: 0.08em 0.24em;
  border-radius: 2px;
  background: rgba(0, 0, 0, 0.05);
  font-family: "Latin Modern Mono", ui-monospace, "SFMono-Regular", monospace;
  font-size: 0.9em;
}

.paper--article hr {
  margin: 2.25rem 0;
  border: 0;
  border-top: 1px solid var(--ink);
}

.paper h2 {
  margin: 0 0 0.4em;
  font-family: "GOST Type A", "Latin Modern Roman", serif;
  font-weight: 400;
  font-size: clamp(1.7rem, 1.2rem + 2vw, 2.2rem);
  font-variant-caps: small-caps;
  letter-spacing: 0.06em;
  break-after: avoid;
  break-inside: avoid;
}

.paper section + section {
  margin-top: 2.5rem;
}

.paper p {
  margin: 0;
  orphans: 2;
  widows: 2;
}

.paper p + p {
  margin-top: 0.8em;
}

.paper a {
  color: var(--link);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.15em;
}

.paper a:hover {
  text-decoration-thickness: 2px;
}

::selection {
  background: var(--link);
  color: var(--paper);
}

a:focus-visible {
  outline: 2px solid var(--link);
  outline-offset: 2px;
}

.paper--error {
  column-count: 1;
}

.paper--error ul {
  margin: 0.75rem 0 0;
  padding-left: 1.25rem;
}

@media print {
  @page {
    size: A4;
    margin: 18mm 16mm;
  }

  body {
    background: #fff;
    color: #000;
    font-size: 10.5pt;
    line-height: 1.4;
  }

  .page {
    max-width: none;
    padding: 0;
  }

  .masthead {
    margin-bottom: 1.5rem;
  }

  .masthead__title {
    font-size: 24pt;
  }

  .masthead__subtitle {
    font-size: 12pt;
  }

  .links-row a,
  .links-row a:hover,
  .paper a,
  .paper a:hover {
    color: #000;
    text-decoration: underline;
    text-decoration-thickness: 1px;
  }

  .paper {
    column-count: 2;
    column-gap: 8mm;
    column-rule: 0.5pt solid #000;
  }

  .paper::before,
  .paper::after {
    display: none;
  }

  .paper h2 {
    font-size: 14pt;
  }

  .paper p {
    white-space: normal;
    text-align: justify;
    hyphens: auto;
    orphans: 3;
    widows: 3;
  }

  .section-links {
    break-inside: avoid;
  }

  .paper--article {
    column-count: 1;
    column-gap: 0;
    column-rule: 0;
  }

  .paper--article figure {
    margin: 4mm 0;
    break-inside: avoid;
  }

  .paper--article pre {
    padding: 4mm;
    overflow: visible;
    border: 0.5pt solid #000;
    background: transparent;
    font-size: 8.5pt;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    break-inside: avoid;
  }
}
