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

body {
  line-height: 1.5;
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  font-family: system-ui, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";
  padding: 1rem;
}

/* ======= */
/* Margins */
/* ======= */

body {
  margin: 0;
}

h1, header:has(h1) {
  margin-top: 1.5rem;
}

h2, header:has(h2) {
  margin-top: 1.2rem;
}

h3, header:has(h3), h4 {
  margin-top: 1rem;
}

header, h1, h2, h3, h4, h5, h6 {
  margin-bottom: 0px;

  form {
    margin-top: 0rem;
  }
}

p, ul, pre {
  margin-top: 1rem;
  margin-bottom: 0;
}

ol, ul {
  margin-top: 0.5rem;
  margin-bottom: 0;
}

div, section, table + h2, nav, img {
  margin-top: 1rem;
}

fieldset {
  margin-top: 1.5rem;
}

dl {
  margin-bottom: 1rem;
}

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

/* =========== */
/* End margins */
/* =========== */

h1, h2, h3, h4, h5, h6 {
  overflow-wrap: break-word;
  text-wrap: wrap;
  font-weight: normal;
}

h1 {
  border-bottom: 1px solid var(--light-gray);
  padding-bottom: 0.5rem;
}

h2 {
  border-bottom: 1px solid var(--lightest-gray);
  padding-bottom: 0.3rem;
}

/* h3 { */
/*   border-bottom: 1px solid var(--lightest-gray); */
/*   padding-bottom: 0.3rem; */
/* } */

h4 {
  font-size: 1.1rem;
}

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

  &:visited {
    color: var(--link-color);
  }
  &:hover {
    text-decoration: underline;
  }
}

aside.left-sidebar {
  border-right: 1px solid lightgray;
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 1.5rem;
  overflow-y: auto;

  nav {
    display: block;
  }

  header, nav {
    margin-bottom: 1rem;
  }

  header img {
    max-width: 200px;
  }

  nav, footer {
    section {
      margin-left: 0.7rem;
      margin-bottom: 0.3rem;
      font-size: 0.9rem;
      margin-top: 0;
    }

    div {
      display: flex;
      justify-content: space-between;

      > a:first-child {
        flex: 1;
      }
    }

    span * {
      display: inline-block;
    }
  }

  a {
    display: block;
    color: black;
    &:visited {
      color: black;
    }
  }
  span {
    color: var(--gray);
  }

  footer {
    margin-top: 2rem;
  }
}

h1, h2, h3 {
  &:has(div.buttons), &:has(nav) {
    display: grid;
    grid-template-columns: max-content max-content;
    justify-content: space-between;
    align-items: center;

    div.buttons {
      display: flex;
      align-items: center;
      gap: 0.5rem;
      font-size: 1rem;
    }

    nav {
      grid-column: 1 / span 2;
      font-size: 1rem;
      margin-top: 0px;
    }
  }
}

dl {
  display: grid;
  grid-template-columns: max-content auto;
  gap: 0rem 0.6rem;
}

dt {
  grid-column-start: 1;
}

dd {
  grid-column-start: 2;
}

nav {
  display: flex;
  gap: 0.2rem 0.7rem;
  flex-wrap: wrap;
}

pre {
  padding: 1rem;
  background-color: gainsboro;
}

img {
  max-width: 100%;
}
