:root {
  --body-width: 992px;
  --text-width: 620px;
  --bg-body: white;
  --bg-block: #f9f9f9;
  --border-color: #ddd;
  --box-shadow: 5px 5px 5px #eee;
}
* {
  box-sizing: border-box;
}
body {
  max-width: var(--body-width);
  min-height: calc(100vh - 3em);
  background-color: var(--bg-body);
  margin: auto;
  padding: 1em;
  line-height: 1.5;
  position: relative;
  display: flex;
  flex-direction: column;
  counter-reset: pageNumber;
}

/* header and footer areas */
.nav-top, .single .meta-line, .nav-bottom, .post-nav {
  display: flex;
  justify-content: space-between;
}
.home + footer > .nav-bottom {
  display: block;
}
.nav-top {
  margin-bottom: 1em;
  border-bottom: 1px solid;
}
.logo {
  font-weight: bold;
  margin-top: .5rem;
  img {
    display: none;
    max-height: 4rem;
    position: absolute;
    top: 2em;
  }
}
.menu {
  text-transform: uppercase;
  span {
    display: inline-block;
    margin: .5rem 0 0 .5em;
  }
  .active {
    border-bottom: 5px solid;
    margin-bottom: -5px;
  }
  .optional {
    display: none;
  }
}
footer {
  text-align: center;
  margin-top: 2rem;
}
.menu-bottom a + a::before {
  content: " · ";
}

/* code */
pre code {
  display: block;
  padding: 1em;
  overflow-x: auto;
  &:not([class]) {
    background: none;
  }
}
pre code, img[src$="#border"] {
  border: 1px solid var(--border-color);
  box-shadow: var(--box-shadow);
}
code {
  hyphens: none;
}
pre code, pre code:hover {
  white-space: pre-wrap;
  word-break: break-all;
}

/* misc elements */
.main, .home {
  hyphens: auto;
}
.main, .home, .terms {
  flex-grow: 1;
}
a {
  text-decoration: none;
  border-bottom: 1px dashed;
  color: initial;
}
@media (hover: hover) and (pointer: fine) {
  :not(.logo) > a:hover {
    position: relative;
    inset: 1px 0 0 1px;
  }
}
nav a, footer a, .archive a, sup a {
  border-bottom: none;
}
.anchor {
  &:not(:hover > *) { display: none; }
  & > a::before { content: "#"; }
}
.single .main {
  h2 {
    border-bottom: 1px solid var(--border-color);
  }
  h3 {
    font-variant: small-caps;
    text-align: center;
  }
}
li {
  margin: 4px 0;
}
hr {
  border-style: dashed;
  color: var(--border-color);
}
img, iframe, video {
  max-width: 100%;
}
#TableOfContents {
  background-color: var(--bg-block);
  padding: .5em;
  & > ul {
    margin: 0 auto;
    & > li > ul li {
      margin-right: 2em;
    }
  }
}
blockquote, .toc-list, .toc-list ul {
  border-left: 2px solid var(--border-color);
  padding-left: 1em;
}
.single blockquote {
  background: var(--bg-block);
  border-left-width: 5px;
  padding: 3px 1em 3px;
}
.post-nav {
  margin-top: 1rem;
  span {
    width: calc(50% - 1em);
    & + span {
      text-align: right;
    }
  }
}
table {
  min-width: 50%;
  margin: auto;
  border-top: 1px solid #aaa;
  border-bottom: 1px solid #aaa;
  thead th {
    border-bottom: 1px solid var(--border-color);
  }
  th, td {
    padding: 5px;
  }
  thead, tfoot, tr:nth-child(even), code {
    background: var(--bg-block);
  }
}

/* metadata */
.toc-line {
  display: flex;
  align-items: flex-end;
}
.dots {
  border-bottom: 2px dotted var(--border-color);
  margin: 0 .5em .5em;
  min-width: 10rem;
  flex-grow: 1;
}
.page-num {
  counter-increment: pageNumber;
  &::before {
    content: counter(pageNumber);
  }
}
.toc-list, .toc-list ul {
  list-style: none;
  margin-left: 1em;
}
.toc-line, .subtitle, .meta-line {
  font-weight: normal;
}
.author + .date::before {
  content: " / ";
}
h1.title, .toc-line > a {
  font-style: italic;
}
h1.title {
  margin-top: 1em;
}
h1.title::before {
  content: "❧";
  font-style: normal;
  font-weight: normal;
  font-size: 6em;
  color: var(--border-color);
  opacity: .5;
  position: absolute;
  inset: -.15em 0;
  z-index: -1;
}
.small, .term, .footnotes, li li {
  font-size: .9em;
}
.footnotes > hr {
  max-width: 20em;
  margin-left: 0;
}
.terms, #TableOfContents > ul > li > ul {
  display: flex;
  flex-wrap: wrap;
}
.terms li, .term {
  margin-left: 2em;
}
.term-cat + .term-tag::before {
  content: " · ";
}

@media (min-width: 768px) {
  body {
    padding: 3.5em 2.5em;
  }
  .main {
    margin: auto;
    width: var(--text-width);
  }
  pre, table, .fullwidth {
    width: calc(min(100vw, var(--body-width)) - 5rem);
    margin-left: calc(50% + 2.5rem - min(100vw, var(--body-width)) / 2);
  }
  .crop-h, .crop-v, .crop-c {
    position: absolute;
    z-index: -1;
  }
  .crop-h {
    inset: 2em 0;
    border-top: 1px solid;
    border-bottom: 1px solid;
  }
  .crop-v {
    inset: 0 2em;
    border-left: 1px solid;
    border-right: 1px solid;
  }
  .crop-c {
    inset: 1em;
    border: 1.5em solid var(--bg-body);
  }
  .menu {
    margin-left: 2em;
  }
  .menu span {
    margin-left: 1em;
  }
  h1.title::before {
    font-size: 6em;
    inset: 0;
  }
  .logo img, .menu .optional {
    display: inline-block;
  }
  .twocolumn {
    columns: 2;
  }
}

@media only screen and (min-width: 992px) {
  body {
    min-height: calc(100vh - 5em);
    margin: 2em auto;
  }
  .home {
    padding: 0 2em;
  }
  h1.title {
    margin-top: 2em;
    &::before {
      font-size: 9em;
      inset: -.1em 0;
    }
  }
  pre code {
    white-space: pre;
  }
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg-body: #dedad6;
    --bg-block: #d6d1cc;
    --border-color: #999;
    --box-shadow: 5px 5px 5px #ccc;
  }
  html, img, video, iframe {
    filter: invert(1);
  }
}
