@font-face {
  font-family: "JetBrains Mono";
  src: url("assets/fonts/JetBrainsMono-Regular.woff2") format("woff2");
  font-style: normal;
  font-weight: 400;
  font-display: swap;
}

:root {
  color-scheme: light;
  --paper: #fff;
  --ink: #19242f;
  --body: #35414e;
  --muted: #526474;
  --accent: #285780;
  --line: #d9e2e9;
  --tint: #f4f7fa;
  --sans: Inter, Arial, sans-serif;
  --serif: Georgia, "Times New Roman", serif;
  --mono: "JetBrains Mono", Consolas, monospace;
}

* { box-sizing: border-box; }

@media (prefers-reduced-motion: no-preference) {
  html { scroll-behavior: smooth; }
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--body);
  font: 1.125rem/1.7 var(--serif);
}

.page {
  width: min(760px, calc(100% - 3rem));
  margin: 0 auto;
}

a {
  color: var(--accent);
  text-decoration-color: #84a0b7;
  text-underline-offset: .19em;
}

a:hover { text-decoration-color: currentColor; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; }

.skip-link {
  position: absolute;
  inset: .75rem auto auto .75rem;
  z-index: 1;
  padding: .45rem .9rem;
  transform: translateY(-200%);
  background: var(--paper);
  font: 600 .95rem/1.5 var(--sans);
}

.skip-link:focus { transform: none; }

.masthead { padding-top: clamp(2rem, 6.6vw, 4.6rem); }

.metadata {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: .8rem;
  border-top: 1px solid var(--line);
  padding-top: .9rem;
  color: var(--muted);
  font: 500 .875rem/1.4 var(--sans);
}

.metadata span {
  color: var(--accent);
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
}

h1, h2, h3 {
  color: var(--ink);
  font-family: var(--sans);
  line-height: 1.14;
}

h1 {
  margin: 1.85rem 0 .8rem;
  max-width: 740px;
  font-size: clamp(2.45rem, 6.4vw, 4.2rem);
  font-weight: 750;
  letter-spacing: -.058em;
  text-wrap: balance;
}

.subtitle {
  margin: 0;
  color: var(--muted);
  font-size: clamp(1.18rem, 2.8vw, 1.55rem);
  font-style: italic;
  line-height: 1.43;
}

.abstract {
  margin-top: 2rem;
  border-left: 3px solid #567c9c;
  background: var(--tint);
  padding: 1.05rem 1.3rem 1.15rem;
}

.abstract .abstract-label {
  margin: 0;
  color: var(--accent);
  font: 700 .875rem/1.4 var(--sans);
  letter-spacing: .035em;
}

.abstract p { margin: .34rem 0 0; }

.contents { display: none; }

@media screen and (width < 68rem) {
  body::before {
    position: fixed;
    inset: 0 0 auto;
    z-index: 2;
    height: 2px;
    background: var(--accent);
    transform: scaleX(var(--reading-progress, 0));
    transform-origin: left;
    pointer-events: none;
    content: "";
  }
}

@media screen and (min-width: 68rem) {
  .page {
    --contents-width: 11.75rem;
    --contents-gap: 3.5rem;
    display: grid;
    grid-template-columns: var(--contents-width) minmax(0, 760px);
    align-items: start;
    column-gap: var(--contents-gap);
    width: min(calc(100% - 3rem), calc(760px + var(--contents-width) + var(--contents-gap)));
  }

  .page > article {
    grid-column: 2;
    grid-row: 1;
  }

  .page-footer { grid-column: 2; }

  .contents {
    position: sticky;
    top: 4.6rem;
    display: block;
    max-height: calc(100vh - 5.6rem);
    overflow: auto;
    padding: .25rem .25rem .35rem .3rem;
    font: 400 .875rem/1.4 var(--sans);
    scrollbar-width: thin;
  }

  .contents-label {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: .5rem;
    margin: 0 0 .8rem;
    color: var(--muted);
    font-weight: 600;
  }

  .contents-percentage {
    color: var(--accent);
    font-size: .75rem;
    font-variant-numeric: tabular-nums;
  }

  .contents-rail {
    position: relative;
    border-inline-start: 1px solid var(--line);
  }

  .reading-progress {
    position: absolute;
    inset-block: 0;
    inset-inline-start: -1px;
    width: 2px;
    background: #789bb8;
    transform: scaleY(var(--reading-progress, 0));
    transform-origin: top;
    pointer-events: none;
  }

  .contents ul {
    margin: 0;
    padding: 0;
    list-style: none;
  }

  .contents-rail > ul > li + li { margin-top: .22rem; }

  .contents a {
    position: relative;
    display: block;
    padding: .38rem .15rem .38rem .85rem;
    color: var(--body);
    font-weight: 600;
    text-decoration: none;
  }

  .contents ul ul a {
    padding: .32rem .15rem .32rem 1.65rem;
    color: var(--muted);
    font-size: .8125rem;
    font-weight: 400;
  }

  .contents a:hover { text-decoration: underline; }
  .contents a:focus-visible { outline-offset: 1px; }

  .contents a.is-parent-active {
    color: var(--accent);
    font-weight: 700;
  }

  .contents a.is-active {
    color: var(--ink);
    font-weight: 700;
  }

  .contents-indicator {
    position: absolute;
    inset-block-start: 0;
    inset-inline-start: -2px;
    width: 3px;
    height: 1.5rem;
    background: var(--accent);
    transform: translateY(calc(var(--indicator-center, 0px) - .75rem));
    pointer-events: none;
  }

  @media (prefers-reduced-motion: no-preference) {
    .contents-indicator { transition: transform 180ms ease-out; }
    .contents a { transition: color 140ms ease-out; }
  }
}

.article-section {
  margin-top: 3.85rem;
}

.article-section,
.article-section h3[id],
#references {
  scroll-margin-top: 1.3rem;
}

.article-section h2 {
  margin: 0 0 1rem;
  font-size: clamp(1.68rem, 3.5vw, 2.2rem);
  letter-spacing: -.04em;
  text-wrap: balance;
}

.section-number {
  margin-inline-end: .3em;
  color: var(--accent);
  font-size: .58em;
  font-variant-numeric: tabular-nums;
  letter-spacing: .02em;
  vertical-align: .08em;
}

.article-section h3 {
  margin: 1.7rem 0 .55rem;
  font-size: 1.18rem;
  line-height: 1.4;
  letter-spacing: -.015em;
}

.article-section p { margin: 0 0 1rem; }
.article-section p:last-child { margin-bottom: 0; }
.article-section strong { color: var(--ink); }

figure {
  margin: 1.65rem auto 1.75rem;
}

.chart {
  max-width: 630px;
}

.chart.teaser {
  max-width: 100%;
}

.chart img {
  display: block;
  width: 100%;
  height: auto;
  margin: 0 auto;
}

figcaption {
  margin: .55rem 0 0;
  color: var(--muted);
  font: 400 .9rem/1.55 var(--sans);
}

figcaption strong { color: var(--ink); }

table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.25rem 0 1.6rem;
  font: 400 .95rem/1.5 var(--sans);
  font-variant-numeric: tabular-nums;
}

th, td {
  padding: .56rem .7rem;
  border-bottom: 1px solid var(--line);
  text-align: start;
  vertical-align: top;
}

th:first-child { padding-inline-start: .5rem; }
thead th { background: var(--tint); color: var(--ink); font-weight: 700; }
tbody th { color: var(--body); font-weight: 500; }
table :is(th, td):not(:first-child) {
  text-align: right;
  white-space: nowrap;
}

#setup-table :is(th, td):last-child {
  text-align: start;
  white-space: normal;
}

code { font: 400 .82em/1.5 var(--mono); }

p code {
  overflow-wrap: anywhere;
  border-radius: 3px;
  background: var(--tint);
  padding: .1em .25em;
}

.references {
  margin-top: 3.1rem;
  font-size: .94em;
  line-height: 1.6;
}

.references h3 {
  margin: 0 0 .8rem;
  font-size: 1.05rem;
}

.references p {
  margin: 0 0 .7rem;
  scroll-margin-top: 1.3rem;
}

.references p:last-child { margin-bottom: 0; }

.page-footer {
  margin: 3.4rem 0 0;
  padding: 1.08rem 0 2.4rem;
  border-top: 1px solid var(--line);
  font: 600 .875rem/1.4 var(--sans);
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

@media (max-width: 500px) {
  body { font-size: 1.0625rem; }
  .page { width: min(760px, calc(100% - 2.25rem)); }
  .metadata { font-size: .81rem; }
  h1 { margin-top: 1.4rem; }
  .abstract { margin-top: 1.55rem; padding: .85rem .85rem .95rem; }
  .article-section { margin-top: 2.85rem; }
  .article-section h2 { font-size: clamp(1.64rem, 5.5vw, 1.9rem); }
  table { font-size: .87rem; }
  th, td { padding: .5rem .3rem; }
  th:first-child { padding-inline-start: .28rem; }
  figcaption { font-size: .875rem; }
}

@media print {
  .page { width: 100%; }
  .masthead { padding-top: 0; }
  .contents, .page-footer, .skip-link { display: none; }
  figure, table { break-inside: avoid; }
  .article-section h2 { break-after: avoid; }
}

.site-return {
  margin: 0 0 .9rem;
  font: 600 .875rem/1.4 var(--sans);
}
