body {
  background-color: var(--color-surface);
  color: var(--color-on-surface);
}

[id] {
  scroll-margin-top: 4em;

  &:target {
    position: relative;

    &::before {
      content: "Aww, you came to see me!";
      position: absolute;
      top: -1.5rem;
      font-size: 0.9rem;
      font-style: italic;
      color: var(--color-on-blue);
    }
  }
}

header,
main,
aside {
  padding: 1rem;
}

header {
  color: var(--color-on-purple);
  background-color: var(--color-purple);
  min-height: 30vb;
  display: grid;
  place-content: center;
  text-align: center;
  border-bottom: 2px dashed;

  small {
    margin-top: 0.5rem;
  }
}

main {
  display: grid;
  grid-gap: 5rem;
  grid-gap: max(15vb, 5rem);
}

main,
aside {
  max-width: 60rem;
  max-width: 100ch;
  margin: 8vb auto;
}

body > footer {
  background-color: var(--color-purple);
  color: var(--color-on-purple);
  text-align: center;
  padding: 1rem;

  > :last-child {
    margin-top: 0.5rem;
  }
}

aside {
  border-top: 1px dashed;
  color: var(--color-on-purple);
}

article {
  max-width: 60rem;
  max-width: calc(100ch - 2rem);

  > p + p {
    margin-top: 1rem;
  }

  footer {
    margin-top: 1rem;
    font-size: 0.9rem;
  }
}

details:not(#toc) {
  margin-top: 2rem;

  summary {
    background-color: var(--color-on-surface);
    color: var(--color-surface);
  }
}

summary {
  cursor: pointer;
  padding: 0.5em;

  &:focus {
    outline: 2px solid transparent;
    box-shadow: inset 0 0 0 2px var(--color-purple),
      0 0 0 2px var(--color-on-purple);
    border-radius: 0.15em;
  }
}

$category-colors: (
  "layout": "red",
  "component": "yellow",
  "grid": "blue",
  "flexbox": "green",
);

@each $category, $color in $category-colors {
  .category-#{$category} {
    background-color: var(--color-#{$color});
    color: var(--color-on-#{$color});
  }
}

.actions {
  --item-padding: 0.15em 0.35em;

  display: grid;
  grid-gap: 1rem;
  justify-content: start;
  align-items: center;
  margin: 0.5rem 0 1.5rem;
  font-size: 0.85rem;

  @media (min-width: 30rem) {
    grid-auto-flow: column;
  }

  button {
    display: inline-flex;
    align-items: center;
    padding: var(--item-padding);
    border: 1px solid var(--color-on-blue);
    font: inherit;
    background-color: var(--color-on-blue);
    color: var(--color-blue);
    border-radius: 0.25em;
    line-height: inherit;
    cursor: pointer;

    svg {
      fill: currentColor;
      width: 1.25em;
      margin-right: 0.5em;
    }

    &:focus {
      outline: 2px solid transparent;
      box-shadow: 0 0 0 2px var(--color-blue), 0 0 0 4px var(--color-on-blue);
    }
  }
}

.categories {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  gap: 1rem;

  li {
    padding: var(--item-padding);
    border: 1px dotted;
    border-radius: 0.25em;
  }
}

.link-github {
  display: inline-flex;
  align-items: center;
  line-height: 1;
  justify-self: center;
  margin-top: 1.25rem;
  margin-bottom: 1.25rem;

  svg {
    width: 1.25em;
    fill: currentColor;
    margin-right: 0.25em;
    transform: translateY(-5%);
  }
}

.hidden {
  width: 0;
  height: 0;
  overflow: hidden;
  position: absolute;
}

.headline {
  display: grid;
  grid-template-columns: min-content auto;

  .anchor {
    grid-row-start: 1;
    align-self: start;
    font-size: 1rem;
    line-height: 1;
    transform: translateX(-50%) translateY(25%);
    text-decoration: none;
    opacity: 0.75;

    &:hover,
    &:focus {
      text-decoration: underline;
      text-underline-offset: 0.25em;
      opacity: 1;
    }
  }
}

nav {
  position: sticky;
  top: -1px;
  z-index: 1;
  background-color: var(--color-blue);
  border-bottom: 1px solid var(--color-on-blue);
}

#toc {
  position: relative;
  margin: 0 auto;
  width: fit-content;

  summary {
    color: var(--color-on-blue);
  }

  ol {
    margin: 0;
    padding: 0.5rem 1rem 0.5rem 2.5rem;
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    width: min(35ch, 90vi);
    max-height: calc(100vb - 4em);
    overflow-y: auto;
    background: var(--color-surface);
    box-shadow: 0.15em 0.15em 0.3em -0.1em rgba(black, 0.45);
    border-radius: 0.25em;
    border: 1px solid;
    z-index: 1;

    a {
      display: block;
      line-height: 1.3;
      text-decoration: none;
      padding: 0.5em 0;
    }

    li + li a {
      border-top: 1px solid var(--color-purple);
    }

    li::marker {
      color: var(--color-on-purple);
    }
  }
}
