/* vim: set ts=2 sw=2 et: */
:root {
  --toolbar: #d4d0c8;
  --background: #696969;
}

html, body {
  margin: 0;
  padding: 0;
  font-family: sans-serif;
  background: var(--background);
}

body {
  margin: calc(24px + 1rem) 0 0 0;
}

* { box-sizing: border-box; }

.site-nav {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
}

nav {
  background: linear-gradient(to right, var(--toolbar) 80%, white);
  display: flex;
  align-items: center;
  padding: 1px 0.5rem;
  border-bottom: 2px solid gray;

  h1 {
    font-size: 1rem;
    margin: 0;
    word-wrap: nowrap;
  }

  a, button {
    color: black;
    text-decoration: none;
    border: none;
    padding: 0;
    margin: 0;
    background: transparent;
    font-size: 16px;
    cursor: pointer;
  }

  ul {
    display: flex;
    list-style: none;
    margin: 0;
    padding: 0;
  }

  li {
    position: relative;
    height: 24px;
    font-size: 16px;
    cursor: pointer;
  }

  li:hover > a, li:active > a, li:hover > button, li:active > button {
    text-decoration: underline;
  }

  & > ul {
    padding: 0 0 0 0.5rem;
    background: var(--toolbar);
  }

  & > ul > li {
    padding: 0 0.25rem;
    border: 1px solid transparent;

    ul,
    ul li:hover > ul,
    ul li:focus-within > ul {
      display: none;
      background: white;
      flex-direction: column;
      position: absolute;
      border: 1px solid gray;
      left: 0;
      top: 23px;
      z-index: 99;

      li {
        min-width: 200px;
        background: linear-gradient(to right, var(--toolbar) 30px, white 5px, white);
        padding-left: 33px;

        &:hover:not(.divider),
        &:active:not(.divider),
        &:focus-within:not(.divider) {
          background: linear-gradient(to right, var(--toolbar) 30px, #DCDCDC 5px, #DCDCDC);
        }

        &.divider {
          cursor: auto;
        }
      }

      .note {
        color: darkgray;
      }

      .toolbar-heading {
        padding: 0 0.5rem 0 calc(30px);
        background: var(--toolbar);
      }

      .icon {
        width: 18px;
        height: 18px;
        position: absolute;
        left: 4px;
        text-align: center;
      }

      .icon-right {
        position: absolute;
        right: 3px;
      }

      a {
        display: block;
        color: black;
        max-width: 100%;
        text-wrap: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
      }
    }

    ul li:hover > ul,
    ul li:active > ul,
    ul li:focus-within > ul {
      display: flex;
      width: 350px;
      right: -350px;
      top: -1px;
      left: auto;
    }

    &:hover, &:active, &:focus-within {
      border-left: 1px solid white;
      border-top: 1px solid white;
      border-bottom: 1px solid silver;
      border-right: 1px solid silver;

      & > ul {
        display: flex;
      }
    }
  }
}

main {
  max-width: 820px;
  margin: 1rem auto;
  background: white;

  h1 {
    margin: 0;
    padding: 0 1rem;
    font-size: 20px;
    background: var(--toolbar);
    border-left: 2px solid white;
    border-top: 2px solid white;
    border-bottom: 2px solid silver;
    border-right: 2px solid silver;
  }

  .date {
    padding: 0 1rem;
  }

  article {
    padding: 0 1rem 0.5rem 1rem;
  }

  img {
    max-width: 100%;
  }
}

#about {
  background: linear-gradient(to bottom, var(--toolbar) 33px, white 5px, white);
  border: 2px solid gray;
  position: relative;

  h1 {
    margin: 0;
    padding: 0;
    font-size: 18px;
  }

  button {
    position: absolute;
    top: 3px;
    right: 3px;
    width: 22px;
    height: 22px;
    text-align: center;
    font-weight: bold;
    border-radius: 0;
    border: 2px solid gray;
    cursor: pointer;
  }
}

blockquote {
  background-color: #B0C4DE;
  margin: 0;
  padding: 0 1rem;

  blockquote {
    margin-right: 0;
    margin-left: 0;
  }
}

hr {
  border-top: 1px solid #878787;
  border-bottom: 1px solid var(--toolbar);
  border-right: 0;
  border-left: 0;
}

.next-prev {
  display: grid;
  grid-template-columns: auto;

  .prev {
    grid-column: 1;
  }

  .next {
    grid-column: 2;
    text-align: right;
  }
}

pre {
  background-color: #ddd;
  padding: 0.25rem 1rem;
  max-width: 100%;
  overflow-x: auto;

  .include {
    color: #800;
  }

  .keyword, .repeat, .type_qualifier, .keyword_function {
    color: #008;
  }

  .type, .type, .type {
    color: #44F;
  }

  .string {
    color: #484;
    font-style: italic;
  }

  .comment {
    color: #333;
  font-style: italic;
  }

  .gi {
    color: green;
  }

  .gd {
    color: red;
  }

  .gu {
    color: blue;
  }

  .variable {
    color: black;
  }

  .function_builtin {
    color: #008;
  }
}

article {
  img, video, iframe {
    /* !important for asciinema frames */
    display: block !important;
    margin: 1rem auto !important;
    max-width: 90%;

    @media(max-width: 640px) {
      max-width: calc(100% - 2rem);
    }
  }
}

figure {
  img {
    display: block;
    margin: 0 auto;
  }

  figcaption {
    text-align: center;
  }
}

.articles {
  display: grid;
  grid-template-columns: auto 1fr;

  .date {
    text-align: right;
    border-right: 4px groove #ccc;
    margin-right: 15px;
  }
}

.alert {
  .heading {
    display: block;
    margin: 0;
    padding: 0 1rem;
    font-size: 20px;
    background: #8B0000;
    color: white;
    border-top: 2px solid grey;
    border-bottom: 2px solid silver;
  }

  p {
    margin: 0;
    padding: 1rem;
    border-bottom: 2px solid silver;
  }
}

.profile {
  float: right;
  max-width: 256px;
  margin: 0 !important;
  border-left: 2px solid grey;
  border-top: 2px solid grey;
  border-bottom: 2px solid silver;
  border-right: 2px solid silver;
}

.clearfix {
  clear: both;
}

@media(max-width: 640px) {
  nav {
    background: var(--toolbar);
  }

  .site-nav {
    position: inherit;

    ul {
      display: none;
    }
  }

  body {
    margin-top: 0;
  }
}
