:root {
  --fg: #222;
  --article-bg: #fff;
  --page-bg: #ccc;
  --nav-bg: var(--page-bg);
  --link-color: blue;
  --button-bg: color-mix(in oklab, var(--article-bg), black 10%);
  --visited-link-color: purple;
  --overlay-color: rgba(0, 0, 0, 0.25);
  --github-icon-url: url(GitHub-Mark-32px.png);
  --star-color: orange;

  --shadow-elevation-low: 0px 2px 4px -1px rgba(0, 0, 0, 0.6);
  --shadow-elevation-medium: 0px 30px 60px rgba(0, 0, 0, 0.6);
  --shadow-elevation-high: 0px 60px 120px rgba(0, 0, 0, 0.6);

  --inset-concave: inset 0px -2px 2px -2px rgba(255, 255, 255, 0.4),
    inset 0px 2px 3px 0px rgba(0, 0, 0, 0.4);

  --inset-convex: inset 0px 2px 2px -2px rgba(255, 255, 255, 0.4),
    inset 0px -2px 2px 0px rgba(0, 0, 0, 0.4);
}

@media (prefers-color-scheme: dark) {
  :root {
    --fg: #ccc;
    --article-bg: #222;
    --page-bg: #000000;
    --link-color: orange;
    --visited-link-color: chocolate;
    --overlay-color: rgba(0, 0, 0, 0.5);
    --github-icon-url: url(GitHub-Mark-Light-32px.png);
    --star-color: yellow;
    --button-bg: color-mix(in oklab, var(--article-bg), white 10%);
  }
}

body {
  font-family: sans-serif;
  color: var(--fg);
  background-color: var(--page-bg);
  margin: 0;
  display: grid;
  grid-template-areas:
    "title"
    "nav"
    "main";

  > header {
    padding: 1rem;
    grid-area: title;
    display: flex;
    align-items: center;
    justify-content: space-between;
  }
}

main {
  grid-area: main;
  display: flex;
  flex-direction: column;
  gap: 1em;
}

nav {
  grid-area: nav;
  display: none;
  background-color: var(--nav-bg);

  .show-nav & {
    display: block;
  }
}

h1 {
  padding: 0;
  margin: 0;
  grid-area: title;
  font-size: 1.5rem;
}

a:link {
  color: var(--link-color);
}

a:not(.button):visited {
  color: var(--visited-link-color);
}

article {
  padding: 1rem;
  background-color: var(--article-bg);

  header {
    display: grid;
    align-items: center;
    grid-template-columns: 1fr auto;
    grid-template-areas:
      "title controls"
      "subtitle controls";

    h2 {
      grid-area: title;
      margin: 0;
    }

    .subtitle {
      grid-area: subtitle;
    }

    .button {
      grid-area: controls;
    }
  }
}

button,
.button {
  color: inherit;
  background-color: var(--button-bg);
  box-shadow:
    var(--inset-convex),
    var(--shadow-elevation-low),
    0px 0px 0px 1px rgba(0, 0, 0, 0.6);
  border: none;
  box-sizing: border-box;
  font-weight: bold;
  text-decoration: none;
  border-radius: 4px;
  padding: 2px 1em;

  &:active {
    box-shadow:
      var(--inset-concave),
      0px 0px 0px 1px rgba(0, 0, 0, 0.6);
  }
}

#nav-button {
  width: 21px;
  height: 21px;
  box-sizing: content-box;
  padding: 1ex;
}

img[src$="thumb.webp"] {
  width: 128px;
  height: 128px;
  object-fit: contain;
}

i[title="recommended"] {
  color: var(--star-color);
  font-style: normal;
}

@media (min-width: 900px) {
  :root {
    --nav-bg: var(--article-bg);
  }

  body {
    display: grid;
    gap: 1rem;
    grid-template-columns: fit-content(8in) 250px;
    grid-template-areas:
      "title title"
      "main nav";
    justify-content: center;
    align-items: flex-start;
  }

  nav {
    position: sticky;
    top: 0;
    display: block;
  }

  h1 {
    font-size: 2rem;
    padding: 1rem 0 0 0;
  }

  #nav-button {
    display: none;
  }
}

a[href^="https://web.archive.org"]:after
{
  content: "(archived)";
  font-style: italic;
}

a[href^="https://github.com"]:after
{
  content: "";
  display: inline-block;
  font-style: italic;
  height: 1em;
  width: 1em;
  background-size: 1em;
  background-image: var(--github-icon-url);
  vertical-align: bottom;
}

@media (pointer: coarse) {
  .link-list li + li {
    padding-top: 0.5rem;
  }
}

@media print {
  :root {
    --page-bg: white;
  }

  article {
    border: 1px solid currentcolor;
  }

  nav {
    display: none;
  }
}

table-of-contents {
  display: contents;
}
