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

  --link-color: #36a;
  --visited-link-color: #6a60b0;
  --border-color: #a2a9b1;
  --subtle-bg: #f8f9fa;
  --button-color: #eaecf0;

  background-color: var(--subtle-bg);
  
  body {
    max-width: 99.75rem;
    margin: 0 auto;
    background-color: white;
    color: black;
    line-height: 1.375;
    font-family: sans-serif;
    padding: 0.5rem 1rem;
    min-height: 100vh;
    position: relative;
  }

  div.logo {
    text-align: center;
    line-height: 1.1;
    display: flex;
    flex-direction: column;
    width: fit-content;
    margin-left: 3.25rem;

    span.wordmark {
      font-size: 1.7rem;
      font-variant-caps: small-caps;
      font-family: 'Linux Libertine', serif;
    }

    span.tagline {
      font-size: 1rem;
      font-family: 'Linux Libertine', serif;
    }
  }

  button.change-theme {
    all: unset;
    color: var(--link-color);
    cursor: pointer;
    font-size: 1rem;
    line-height: 2rem;
    margin: 1rem 3.25rem;
    position: absolute;
    top: 0;
    right: 0;
    z-index: 4;
    
    &:hover, &:focus {
      text-decoration: underline;
    }
  }

  section.intro {
    max-width: 59.25rem;
    margin: 5rem auto 0;

    h1 {
      font-family: 'Nimbus Roman No9 L', serif;
      font-weight: normal;
      font-size: 1.8rem;
      border-bottom: 1px solid var(--border-color);
    }

    h2 {
      font-family: 'Nimbus Roman No9 L', serif;
      font-weight: normal;
      font-size: 1.5rem;
      border-bottom: 1px solid var(--border-color);
      margin: 1.25rem 0 0.25rem 0;
    }

    p {
      margin: 0.5rem 0 1rem 0;
      line-height: 1.6;
    }

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

      &:visited {
        color: var(--visited-link-color);
      }

      &:hover, &:focus {
        text-decoration: underline;
      }
    }

    button#reload-fun-fact {
      margin: 0;
      padding: 0;
      border: 0;
      background: none;
      font: inherit;
      font-size: 0.7rem;
      color: var(--link-color);
      position: relative;
      bottom: 0.4rem;

      &:before {
        content: '[';
        color: black;
      }

      &:after {
        content: ']';
        color: black;
      }

      &:hover, &:focus {
        text-decoration: underline;
        cursor: pointer;

        &:before, &:after {
          text-decoration: none;
        }
      }
    }

    ul {
      margin: 0.3rem 0 0 1.6rem;
      padding: 0;
      line-height: 1.625;

      li {
        padding-bottom: 0.1rem;
      }
    }

    p.stub {
      line-height: 2rem;
      display: flex;
      gap: 1rem;
      margin-top: 3rem;
      
      img {
        height: 2rem;
      }
    }
  }

  .catlinks {
    border: 1px solid var(--border-color);
    background: var(--subtle-bg);
    padding: 0.3125rem;
    line-height: 1.625;

    a.catlink {
      border-left: 1px solid var(--border-color);
      padding: 0 0.5rem;

      &:nth-of-type(2) {
        border-left: 0;
        padding-left: 0.25rem;
      }
    }
  }

  section.sponsors {
    margin: 6rem 2.75rem 0 2.75rem;
    border-top: 1px solid var(--border-color);
    padding-bottom: 5rem;
    display: flex;
    flex-direction: column;
    align-items: flex-start;

    h2 {
      font-size: 0.75rem;
      font-weight: normal;
      margin: 0.75rem 0;
    }

    p.buttons {
      display: flex;
      justify-content: flex-end;
      flex-wrap: wrap;
      gap: 0.5rem;
      --button-padding: 0.5rem;
      max-width: calc((88px * 4) + (var(--button-padding) * 3));
      margin-top: 0;
      align-self: flex-end;

      img {
        image-rendering: pixelated;
      }
    }
  }

  .hidden {
    display: none !important;
  }

  dialog[open] {
    position: fixed;
    top: 0;
    left: 0;
    min-height: 100vh;
    margin: 0;
    width: 20rem;
    max-width: calc(100vw - 2rem);
    box-sizing: border-box;
    border: 0;
    padding: 0.5rem;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    background-color: white;
    box-shadow: 0 0 0.25rem rgba(0, 0, 0, 0.3), 0.15rem 0 1rem rgba(0, 0, 0, 0.1);
    z-index: 9999999999;

    button[command="close"] {
      border: 0;
      padding: 0;
      margin: 0;
      font: inherit;
      display: flow;
      height: 2rem;
      line-height: 2rem;
      text-align: center;
      border-radius: 0.2rem;
      cursor: pointer;
      align-self: flex-end;
      background-color: var(--button-color);
      color: var(--textColor);
      font-size: 0.9rem;
      padding: 0 0.5rem;

      &:hover {
        background-color: var(--subtle-bg);
      }
    }

    h3 {
      font-weight: bold;
      font-size: 1rem;
      line-height: 1.3;
      /* vertical margins calibrated to
         match height above form */
      margin: 2.22rem 1rem;
    }

    form {
      width: 100%;
    }

    a.change-theme-button {
      display: flex;
      height: 3rem;
      margin: 0.5rem;
      align-items: center;
      color: inherit;
      text-decoration: none;
      border-radius: 0.2rem;
      
      &:hover:not(.current-theme) {
        background-color: var(--subtle-bg);
      }
      
      &.current-theme {
        background-color: var(--button-color);
      }

      input {
        margin: 0 0.75rem;
      }

      div {
        height: 2rem;
        width: 2rem;
        margin: 0 1rem 0 0.5rem;
        text-decoration: none;
      }
    }

    &::backdrop {
      background-color: rgba(0,0,0,0.4);
    }
  }
}

dialog a.change-theme-button div.knowledge-icon {
  height: 2rem;
  width: 2rem;
  border-radius: 0.2rem;
  background-color: white;
  line-height: 2rem;
  text-align: center;
  font-size: 1.7rem;
  font-variant-caps: small-caps;
  font-family: 'Linux Libertine', serif;
  color: black;

  &:before {
    content: 'W';
  }
}

@media(max-width: 800px) {
  html.knowledge {
    position: relative;

    --top-color: #4d4e4f;

    div.logo {
      position: absolute;
      top: 0;
      left: 0;
      width: 100%;
      padding: 0.8rem 0 1.2rem 1.2rem;
      margin: 0;
      z-index: 2;
      text-align: left;
      box-shadow: inset 0 -1px 3px rgba(0,0,0,0.08);
      line-height: 1.4375rem;

      span.wordmark {
        font-size: 1.5rem;
      }

      span.tagline {
        display: none;
      }

      background-color: #eaecf0;
      color: var(--top-color);
    }

    section.intro {
      margin-top: 5rem;
    }

    section.sponsors {
      margin-right: 1rem;
      margin-left: 1rem;
      text-align: center;

      p.buttons {
        justify-content: center;
      }
    }

    button.change-theme {
      color: transparent;
      font-size: 0;
      user-select: none;
      outline: revert-layer;
      margin: 0;
      height: 3.65rem;
      width: 3.65rem;
      display: flex;
      cursor: pointer;

      &:after {
        content: '👓';
        font-family: 'Noto Sans Symbols 2', sans-serif;
        color: var(--top-color);
        font-size: 1.5rem;
        line-height: 3.8rem;
        height: 3.4375rem;
        width: 3.4375rem;
        text-align: center;
      }
    }
  }
}