body {
  --color-base: #eff1f5;
  --color-text: #4c4f69;
  --color-url: #1e66f5;
  --color-subtext: #5c5f77;
  --color-selection: #9ca0b0;
  --color-error: #d20f39;
  --color-warning: #df8e1d;
  --color-info: #1e66f5;
  --color-crust: #dce0e8;
  --color-overlay: #9ca0b0;
  --color-success: #40a02b;
}

@media (prefers-color-scheme: dark) {
  body {
    --color-base: #1e1e2e;
    --color-text: #cdd6f4;
    --color-url: #89b4fa;
    --color-subtext: #bac2de;
    --color-selection: #6c7086;
    --color-error: #f38ba8;
    --color-warning: #df8e1d;
    --color-info: #89b4fa;
    --color-crust: #11111b;
    --color-overlay: #9399b2;
    --color-success: #a6e3a1;
  }
}

.blue {
  color: var(--color-info);
}

.green {
  color: var(--color-success);
}

.red {
  color: var(--color-error);
}

.orange {
  color: var(--color-warning);
}

@media (prefers-color-scheme: dark) {
  img {
    -webkit-filter: invert(1);
    filter: invert(1);
  }

  figure > svg {
    -webkit-filter: invert(1);
    filter: invert(1);
  }
}

@keyframes strike {
  from {
    text-decoration-color: transparent;
  }

  to {
    text-decoration-color: auto;
  }
}

nav.container {
  padding: 1wem 0rem;
  width: 100%;
  display: flex;
  justify-content: space-between;
}

p {
  hyphens: auto;
}

pre {
  border: 1px solid var(--color-overlay);
  border-radius: 8px;
  overflow-x: auto;
  overflow-y: hidden;
  max-width: 100%;
  padding: 1rem;
  scrollbar-width: thin;
  scrollbar-color: var(--color-overlay) transparent;
}

pre::-webkit-scrollbar {
  height: 6px; /* thickness */
}
pre::-webkit-scrollbar-thumb {
  background: #888; /* scrollbar color */
  border-radius: 4px; /* rounded corners */
}
pre::-webkit-scrollbar-track {
  background: transparent; /* transparent track for overlay effect */
}

pre > code {
  border: 0px;
  font-family: "Courier New", Courier, monospace;
  font-size: 0.9rem;
}

code {
  padding-left: 0.2rem;
  padding-right: 0.2rem;
  background: var(--color-crust);
  font-family: "Courier New", Courier, monospace;
}

nav > ul {
  width: 16rem;
  padding: 0;
  list-style-type: none;
}

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

.error {
  background-color: var(--color-error);
  color: var(--color-base);
}

body {
  counter-set: activity example figure definition;
  background-color: var(--color-base);
  color: var(--color-text);
  font-family: "Courier New", Courier, monospace;
}

span.section-number.selected::after {
  color: #000;
}

h1 {
  margin-bottom: 0rem;
}

h2 {
  margin-top: 2rem;
  margin-bottom: -0.5rem;
  color: var(--color-subtext);
}

h3 {
  margin-top: 1.5rem;
  margin-bottom: -0.5rem;
  color: var(--color-subtext);
}

h4 {
  margin-top: 1.5rem;
  margin-bottom: -0.5rem;
  color: var(--color-subtext);
}

hgroup {
  margin-top: 1rem;
  margin-bottom: 1rem;

  > h1 {
    margin: 0rem;
  }

  > p {
    font-size: 110%;
    margin: 0;
    color: var(--color-subtext);
  }
}

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

a:visited {
  color: var(--color-url);
}

a.section-number {
  color: var(--color-overlay);
  transition: color 0.5s ease;
}

:target {
  animation: highlight 10s ease-in;
  animation-delay: -8s;
}

.references {
  padding-left: 0rem;
  margin-left: 0rem;
  margin-top: 1rem;
  margin-bottom: 1rem;
  font-size: 0.875rem;

  summary {
    color: var(--color-subtext);
  }
  summary::marker {
    margin-right: 1rem;
  }

  > ul {
    list-style: none;
    margin-top: 0rem;
  }
  li {
    margin: 0.2rem 0rem;
  }
  li::before {
    content: "📖";
  }
}

.toc {
  max-width: 30rem;
  margin: 0 auto;
  user-select: none;
  cursor: pointer;
  transition: 0.15s background linear;

  summary {
    text-align: center;
    color: var(--color-subtext);
    list-style: none;
  }

  ol {
    list-style-type: none;
  }

  > ol {
    margin-top: 1rem;
    padding: 0;
  }

  > ol ol {
    padding-inline-start: 2ch;
  }

  li > a {
    text-decoration: underline;
    color: var(--color-subtext);
    transition: color 0.5s ease;
    transition: text-decoration-color 0.5s ease-in-out;
    text-decoration-color: transparent;
    display: grid;
    grid-template-columns: auto max-content;
    align-items: end;
  }

  li > a > .toc-title {
    position: relative;
    overflow: hidden;
  }

  li > a .leaders::after {
    position: absolute;
    padding-left: 1rem;
    content: ".....................................";
    text-align: right;
  }

  li > a:hover {
    text-decoration-color: var(--color-subtext);
  }

  li > a > .toc-section {
    text-align: left;
    padding-left: 1rem;
  }

  li > a > .title {
    text-align: left;
  }
}

section {
  scroll-margin-top: calc(3rem);
}

@keyframes highlight {
  from {
    background-color: var(--color-warning);
  }

  to {
    background-color: var(--color-base);
  }
}

a.section-number:hover {
  color: var(--color-url);
}

.container {
  position: relative;
  width: 100%;
  max-width: 65ch;
  margin: 0 auto;
}

blockquote {
  font-style: italic;
}

blockquote.warning {
  padding-left: 1rem;
  border-left: 3px solid var(--color-warning);
}

blockquote.alert {
  padding-left: 1rem;
  border-left: 3px solid var(--color-error);
}

blockquote.info {
  padding-left: 1rem;
  border-left: 3px solid var(--color-info);
}

footer {
  margin-top: 3rem;
  margin-bottom: 2rem;
  border-top: var(--color-subtext) 1px solid;

  > p {
    font-size: 0.8rem;
  }
}

.checklist {
  padding-left: 2rem;
  margin: 1rem 3rem;
  border-left: 3px solid var(--color-info);

  p {
    margin: 0.5rem;
  }
}

#graph {
  .link {
    stroke: var(--color-text);
  }

  .node:hover {
    fill: var(--color-url);
    stroke: var(--color-url);
    cursor: pointer;
  }

  .node circle {
    transition: 0.5s;
    fill: var(--color-base);
    stroke: var(--color-text);
    stroke-width: 1.5px;
  }

  .node:hover circle {
    fill: var(--color-base);
    stroke: var(--color-url);
    stroke-width: 3px;
  }

  .label {
    transition: 0.5s;
    font-size: 12px;
  }
}

table {
  border-collapse: collapse;
  margin: 0 auto;
  font-size: 85%;

  th,
  td {
    text-align: left;
    padding: 0.2em 0.5em;
  }

  thead tr:first-child th {
    border-top: 2px solid var(--color-text);
  }

  thead tr:last-child th {
    border-bottom: 1.5px solid var(--color-text);
  }

  tbody tr:last-child td {
    border-bottom: 2px solid var(--color-text);
  }

  tr.break {
    background-color: var(--color-crust);
  }

  th,
  td {
    border-left: none;
    border-right: none;
  }
}

.note {
  margin: 1rem 0rem;
  padding: 0.5rem 1rem;

  border-left: 2px solid var(--color-info);

  :first-child {
    margin-top: 0;
  }
  :last-child {
    margin-bottom: 0;
  }

  > .name {
    font-size: 1rem;
    font-weight: 500;
    margin-bottom: 0.5rem;
  }

  > p {
    margin: 0.5rem 0;
  }
}

.note.activity {
  border-color: var(--color-success);
  counter-increment: activity;
  > .name::before {
    content: "Activity " counter(activity) ": ";
    font-weight: 700;
  }
}

.note.definition {
  counter-increment: definition;
  > .name::before {
    content: "Definition " counter(definition) ": ";
    font-weight: 700;
  }
}

.note.example {
  border-color: var(--color-info);
  counter-increment: example;
  > .name::before {
    content: "Example " counter(example) ": ";
    font-weight: 700;
  }
}

.hint:last-child {
  border-bottom: 0px solid;
  padding-bottom: 0rem;
}

.hint {
  border-left: 0;
  border-top: 1px solid var(--color-crust);
  border-bottom: 1px solid var(--color-crust);
  padding: 0.5rem;

  .hint-name {
    font-style: italic;
    margin: 0;
    margin-bottom: 0.2rem;
  }

  .hint-content {
    display: none;
  }
}

.hint:hover > .hint-content {
  display: block;
}

figure {
  box-sizing: border-box;
  counter-increment: figure;
  border: 1px solid var(--color-crust);
  padding: 0.5rem;
  margin: 1rem 0rem;

  img {
    width: 100%;
  }

  figcaption {
    margin-top: 1rem;
    margin-left: 1ch;
    margin-bottom: 1ch;
    font-size: 0.875rem;

    > *:first-child {
      margin-top: 0;
    }

    > *:first-child::before {
      content: "Figure " counter(figure) " ";
      font-weight: 700;
    }

    > *:last-child {
      margin-bottom: 0;
    }
  }
  > p {
    font-style: italic;
  }
}

.bibliography {
  li {
    list-style-type: none;
    font-size: 0.9rem;
    padding: 0rem;
  }

  p {
    text-indent: -1rem;
  }
}

@media (max-width: 140ch) {
  figure.margin-figure {
    position: none;
    margin: 1rem auto;
    width: 100%;
  }

  figure {
    figcaption {
      width: 100%;
      float: none;
    }
  }
}

@media (min-width: 140ch) {
  figure.margin-figure {
    position: absolute;
    transition: all 0.5s cubic-bezier(0.5, 0, 0.5, 1);
    background: var(--color-base);
    right: -34ch;
    width: 30ch; /* figure takes a slice of the margin */
    font-size: 0.875rem;

    figcaption {
      width: 100%;
    }
  }

  figure.margin-figure:hover {
    width: 50rem;
    z-index: 10;
  }
}

math {
  font-size: 1em;
  font-family: "STIX Two Math", "Latin Modern Math", "Cambria Math", serif;
  line-height: 1.3;
  color: var(--color-text, #111);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

math[display="block" i] {
  margin: 0.5rem;
}
