@charset "UTF-8";

.smcp {
  font-feature-settings:
    "smcp" 1,
    "c2sc" 1;
  font-variant-numeric: oldstyle-nums;
  letter-spacing: 0.06rem;
  -webkit-hyphens: none;
  -ms-hyphens: none;
  hyphens: none;
}

@font-face {
  font-family: gitan;
  font-style: normal;
  font-weight: normal;
  font-stretch: normal;
  src: url("/fonts/gitan-regular.woff2") format("woff2");
  font-display: swap;
}

@font-face {
  font-family: gitan;
  font-style: italic;
  font-weight: normal;
  font-stretch: normal;
  src: url("/fonts/gitan-italic.woff2") format("woff2");
  font-display: swap;
}

@font-face {
  font-family: "Libertinus Math";
  src: url("/fonts/libertinus-math.woff2") format("woff2");
  font-display: swap;
}

:root {
  --fg: #111111;
  --bg: #fffff8;
  --muted: color-mix(in oklab, var(--fg) 40%, var(--bg) 60%);
  --bg-alt: #e3dce0;
  --accent: #c886b3;
  --accent-ink: #84395f;
  --diagram-blue: #416b98;
  --diagram-gold: #80601c;
  --diagram-green: #347454;

  color-scheme: light dark;
  font-family: gitan, palatino, serif;
}
header {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 10;
  padding: 0.75rem 1rem;
  background: var(--bg);
  font-size: 1rem;
}

@supports (animation-timeline: scroll(root block)) {
  header {
    animation: compact-header 1s linear both;
    animation-timeline: scroll(root block);
    animation-range: 0px 80px;

    a {
      animation: mute-header-link 1s linear both;
      animation-timeline: scroll(root block);
      animation-range: 0px 80px;
    }

    a:hover,
    a:focus-visible {
      animation: none;
      opacity: 1;
    }
  }
}

@keyframes compact-header {
  to {
    padding: 0.4rem 0.75rem;
    font-size: 0.8rem;
  }
}

@keyframes mute-header-link {
  to {
    color: var(--muted);
  }
}

@media (prefers-reduced-motion: reduce) {
  header,
  header a {
    animation: none;
  }
}

@media (prefers-color-scheme: dark) {
  :root {
    --fg: #fffff8;
    --bg: #111111;
    --bg-alt: #ccc;
    --accent-ink: var(--accent);
    --diagram-blue: #a3bee1;
    --diagram-gold: #dfc58d;
    --diagram-green: #a3cea8;
  }
}

html {
  font-size: 18px;
  accent-color: var(--accent);
}

::selection {
  color: var(--bg);
  background-color: var(--accent-ink);
}

body {
  color: var(--fg);
  background: var(--bg);

  width: 87.5%;
  margin-left: auto;
  margin-right: auto;
  padding-left: 12.5%;
  max-width: 1400px;
}

h1 {
  font-weight: 400;
  margin-top: 4rem;
  margin-bottom: 1.5rem;
  font-size: 3.2rem;
  line-height: 1;
}

h2 {
  font-style: italic;
  font-weight: 400;
  margin-top: 2.1rem;
  margin-bottom: 1.4rem;
  font-size: 2.2rem;
  line-height: 1;
}

h3 {
  font-style: italic;
  font-weight: 400;
  font-size: 1.7rem;
  margin-top: 2rem;
  margin-bottom: 1.4rem;
  line-height: 1;
}

h1 code,
h2 code,
h3 code {
  font-size: 0.8em;
}

a,
a:hover,
a:visited {
  color: inherit;
  text-underline-offset: 0.15em;
}

a:hover,
a:focus-visible {
  color: var(--accent-ink);
}

.prose :is(h1, h2, h3, h4, h5, h6) {
  position: relative;
  scroll-margin-top: 3rem;
}

.prose :is(.heading-anchor, .heading-permalink) {
  text-decoration: none;
}

.prose
  :is(h1, h2, h3, h4, h5, h6)
  > :is(.heading-anchor, .heading-permalink)::before {
  position: absolute;
  right: 100%;
  margin-right: 0.35em;
  color: var(--muted);
  font-style: normal;
}

.prose h1:hover > :is(.heading-anchor, .heading-permalink)::before {
  content: "#";
}
.prose h2:hover > :is(.heading-anchor, .heading-permalink)::before {
  content: "##";
}
.prose h3:hover > :is(.heading-anchor, .heading-permalink)::before {
  content: "###";
}
.prose h4:hover > :is(.heading-anchor, .heading-permalink)::before {
  content: "####";
}
.prose h5:hover > :is(.heading-anchor, .heading-permalink)::before {
  content: "#####";
}
.prose h6:hover > :is(.heading-anchor, .heading-permalink)::before {
  content: "######";
}

article {
  padding: 5rem 0rem;
}

time {
  display: block;
  font-size: 0.875rem;
  opacity: 0.7;
}

.note-list {
  list-style: none;
  padding: 0;

  li {
    padding: 1rem 0;
    border-bottom: 1px solid var(--bg-alt);
  }
}

p,
footer,
table {
  width: 55%;
}

dl,
ol,
ul {
  width: 50%;
  -webkit-padding-start: 5%;
}

dt:not(:first-child),
li:not(:first-child) {
  margin-top: 0.25rem;
}

img,
figure.diagram > svg {
  max-width: 100%;
  height: auto;
}

figure.diagram > svg {
  [fill="#000000"] {
    fill: var(--fg);
  }
  [stroke="#000000"] {
    stroke: var(--fg);
  }
  [fill="#ffffff"] {
    fill: var(--bg);
  }
  [stroke="#ffffff"] {
    stroke: var(--bg);
  }

  [fill="#0074d9"] {
    fill: var(--diagram-blue);
  }
  [stroke="#0074d9"] {
    stroke: var(--diagram-blue);
  }
  [fill="#ff4136"] {
    fill: var(--accent-ink);
  }
  [stroke="#ff4136"] {
    stroke: var(--accent-ink);
  }
  [fill="#ffdc00"] {
    fill: var(--diagram-gold);
  }
  [stroke="#ffdc00"] {
    stroke: var(--diagram-gold);
  }
  [fill="#2ecc40"] {
    fill: var(--diagram-green);
  }
  [stroke="#2ecc40"] {
    stroke: var(--diagram-green);
  }
}

figure {
  padding: 0;
  border: 0;
  font-size: 100%;
  font: inherit;
  vertical-align: baseline;
  max-width: 55%;
  -webkit-margin-start: 0;
  -webkit-margin-end: 0;
  margin: 0 0 3em 0;

  figcaption {
    float: right;
    clear: right;
    margin-right: -60%;
    width: 50%;
    margin-top: 0.3rem;
    font-size: 1.1rem;
    line-height: 1.6;
  }
  &.fullwidth {
    max-width: 90%;
    figcaption {
      float: none;
      clear: none;
      width: 55%;
      margin: 0.5rem 0 0;
    }
    img {
      width: 100%;
    }
  }
}

math {
  font-family: "Libertinus Math", "Cambria Math", serif;
  font-size: 1.08em;
}
math[display="block"] {
  font-size: 1.3em;
  margin-block: 1.5rem;
  overflow-x: auto;
  overflow-y: hidden;
}

[role="doc-endnotes"] {
  margin-top: 3rem;
  width: 55%;
  border-top: 1px solid var(--bg-alt);
  font-size: 0.875rem;
  ol {
    padding: 0;
  }
  [role="doc-backlink"] {
    color: var(--accent-ink);
    margin-right: 0.1em;
  }
}

code,
pre > code {
  font-family: Consolas, "Liberation Mono", Menlo, Courier, monospace;
  font-size: 1rem;
  line-height: 1.42;
  -webkit-text-size-adjust: 100%;
}

input.margin-toggle {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

label.sidenote-number {
  display: inline-block;
  max-height: 2rem;
  cursor: pointer;
}

label.sidenote-number::after {
  content: attr(data-number);
  color: var(--accent-ink);
  font-size: 1rem;
  position: relative;
  top: -0.5rem;
  left: 0.1rem;
}

label.margin-toggle:has(+ input.margin-toggle:focus-visible) {
  outline: 2px solid var(--accent-ink);
}

label.margin-toggle:not(.sidenote-number) {
  display: none;
  color: var(--accent-ink);
  cursor: pointer;
}

.sidenote,
.marginnote {
  float: right;
  clear: right;
  margin-right: -60%;
  width: 50%;
  margin-top: 0.3rem;
  margin-bottom: 0;
  font-size: 1.1rem;
  line-height: 1.3;
  vertical-align: baseline;
  position: relative;

  p:first-child {
    margin-top: 0;
  }

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

.sidenote::before {
  content: attr(data-number);
  color: var(--accent-ink);
  display: inline-block;
  margin-right: 0.2em;
  font-size: 1rem;
  position: relative;
  top: -0.5rem;
}

@media (max-width: 760px) {
  .prose
    :is(h1, h2, h3, h4, h5, h6)
    > :is(.heading-anchor, .heading-permalink)::before {
    display: none;
  }

  @supports (animation-timeline: scroll(root block)) {
    header {
      animation-name: hide-mobile-header;
    }
  }

  @keyframes hide-mobile-header {
    to {
      opacity: 0;
      visibility: hidden;
    }
  }

  @media (prefers-reduced-motion: reduce) {
    header {
      display: none;
    }
  }

  @supports not (animation-timeline: scroll(root block)) {
    header {
      display: none;
    }
  }

  body {
    width: 84%;
    padding-left: 8%;
    padding-right: 8%;
  }

  hr,
  p,
  footer,
  table {
    width: 100%;
  }

  pre > code {
    width: 97%;
  }

  dl,
  ol,
  ul {
    width: 90%;
  }

  figure {
    max-width: 90%;
    display: flex;
    flex-direction: column;

    figcaption,
    &.fullwidth figcaption {
      float: none;
      order: 1;
      width: auto;
      max-width: none;
      margin: 0.5rem 0 0;
    }
  }

  label.margin-toggle:not(.sidenote-number) {
    display: inline;
  }

  .sidenote,
  .marginnote {
    display: none;
  }

  .margin-toggle:checked + .sidenote,
  .margin-toggle:checked + .marginnote {
    display: block;
    float: none;
    left: auto;
    width: 100%;
    margin: 1rem 0;
  }

  label {
    cursor: pointer;
  }

  div.table-wrapper,
  table {
    width: 85%;
  }

  img {
    width: 100%;
  }

  [role="doc-endnotes"] {
    width: 100%;
  }
}
