/* overall layout */
* { box-sizing: border-box; }
body {
  margin: 0 auto 0;
  line-height: 1.5;
  overflow-x: hidden;
}
main, .menu ul, .footer, .single section, .post-nav {
  max-width: 800px;
  margin: 0 auto 0;
}
main {
  display: block;
  hyphens: auto;
}
.list main {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  & > * {
    flex: 1 0 100%;
  }
  & > .post-card {
    flex: 0 0 calc(50% - .5em);
  }
}
.menu, .container { padding: 0 1em 0; }
.post-card { margin-top: 1em; }
.article-list, .single main, .single .appendix {
  margin-top: 2em;
  padding: 1em;
  box-shadow: 0 0 8px #ccc;
  background: #fff;
}
.article-meta { background: #f8f8f8; }
.article-meta .terms, main .side > *, figcaption { font-size: .9em; }
.single .appendix { background: none; }

/* header and footer areas */
.menu {
  background: #fafafa;
  box-shadow: 0px 10px 10px -5px rgba(0,0,0,0.1);
}

.sticky-top {
  position: sticky;
  top: 0;
  z-index: 2;
}
.menu li, .terms li, .footer li { display: inline-block; }
footer { background: darkslategray; }
.menu ul {
  padding: 1em 0 1em;
  display: flex;
}
.article-meta, .menu a, .footer a, .terms a, .bg-number {
  text-decoration: none;
  padding: 5px;
  border-radius: 5px;
}
.menu a, .footer a { margin: 1px; }
.menu a, .pagination a, .article-meta a { color: darkslategray; }
.menu a:hover, .menu .active, .summary::first-letter, .footer a:hover, .terms a:hover, .bg-number {
  background: lightslategray;
  color: #fff;
}
.menu, .article-meta, .post-nav { text-align: center; }
.menu ul, .terms, .footer ul { padding-left: 0; }
.menu .left {
  flex-grow: 1;
  font-weight: 600;
  text-align: left;
}
.title {
  font-size: 1.1em;
  line-height: 1em;
}
.terms a {
  border: 1px solid lightslategray;
  line-height: 2em;
}
.terms a, .bg-number {
  padding: 1px 5px;
}
.footer {
  display: flex;
  justify-content: space-between;
  a { text-decoration: none; }
}
footer { margin-top: 2em; }

hr {
  border-style: dashed;
  color: #ddd;
  width: 50%;
}
.footnotes hr { margin-left: 0; }
.appendix div:not(:last-child):not(.side) {
  border-bottom: 1px dashed lightslategray;
  padding-bottom: 1em;
  margin-bottom: 1em;
}

/* code */
pre code {
  display: block;
  padding: 1em;
  border: 1px solid #ddd;
  overflow-x: auto;
}
.appendix pre code { white-space: pre-wrap; }

h3.side-left { text-align: right; }

.spacer { width: 1em; }
.spacer-left { border-left: 1px dashed; }
.spacer-right { border-right: 1px dashed; }

/* search */
.search .menu li, .search .container, .search footer, .search-results { display: none; }
.search #menu-search, .search .search-results {
  display: flex;
  width: 100%;
}
.search #menu-search div:first-child { flex-grow: 1; }
.search input, .search #menu-search a {
  padding: .5em;
  font-size: 1.5em;
}
.search input {
  width: 100%;
  background: transparent;
  border: none;
  border-bottom: 2px solid lightslategray;
}
.search-results b {
  font-weight: normal;
  background: orange;
}

/* misc elements */
img, iframe, video { max-width: 100%; }
iframe, video {
  display: block;
  margin: auto;
}
.title, code, .article-list .side-title { hyphens: none; }
blockquote, code, .article tbody tr:nth-child(odd) { background: #f9f9f9; }
blockquote {
  border-left: 5px solid #ccc;
  padding: 1px 0 1px 1em;
  margin: auto;
}
.categories {
  text-transform: uppercase;
  font-size: .8em;
}
.article-list a, .footer a {
  text-decoration: none;
  color: #000;
}
.article-list h1 {
  a {
    width: 100%;
    display: inline-block;
  }
  a:hover { color: #71a5d4; }
  border-bottom: 1px solid #ddd;
  margin: 5px 0px 10px;
}
.article-list {
  .side-title { transform: rotate(90deg); }
  &:nth-child(even):not(.post-card) .side-title { transform: rotate(-90deg); }
  table {
    margin: 0;
    border: none;
    border-collapse: collapse;
    width: 100%;
    table-layout: fixed;
  }
  td { padding: 0; }
}
#TOC {
  .numbered {
    padding-left: 0;
    li { list-style: none; }
    ul { padding-left: 1em; }
  }
  .active { font-weight: bold; }
}
.side-title { width: 3em; }
.side-title h1 { border: none; }
.post-card .side-title h1 a, .post-card .spacer-right, .appendix h3 { color: lightslategray; }
.appendix h3 { text-align: right; }
.summary { margin-top: .5em; }
.summary::first-letter {
  font-size: 3.5em;
  padding: .1em .2em .1em .1em;
  margin: 0 .1em 0 0;
  display: inline-block;
  float: left;
  line-height: 1em;
}
.pagination { text-align: center; }
.pagination li { display: inline; }
.pagination a { padding: 0 .2em; }
.active a, #TOC a { text-decoration: none; }
.post-nav { margin: 1em auto; }
.post-nav span {
  display: inline-block;
  width: 45%;
}
.nav-prev { text-align: right; }
.nav-next { text-align: left; }
.footer, .footer a { color: #fff; }
.more { font-style: italic; }
.hidden { display: none; }
.draft {
  background: repeating-linear-gradient( 135deg, white, white 10px, #ffd4a3 12px, #ffd4a3 12px );
}
.watermark {
  position: fixed;
  transform: rotate(-45deg);
  font-size: 12em;
  width: 100%;
  color: lightgray;
  opacity: 0.3;
  left: 0;
  text-align: center;
  top: 50%;
}
table {
  margin: 1em auto auto;
  border-top: 1px solid #666;
  border-bottom: 1px solid #666;
}
table thead th { border-bottom: 1px solid #ddd; }
th, td { padding: 5px; }

/* responsive */
@media (max-width: 1264px) {
  .appendix h3 { text-align: initial; }
}
@media (max-width: 800px) {
  li.optional { display: none; }
  .article-list { margin-top: 1.5em; }
  .list main .post-card { flex: inherit; }
  .menu ul, .footer { flex-wrap: wrap; }
  .search input, .search #menu-search a { font-size: 1em; }
}

/* dark theme */
@media (prefers-color-scheme: dark) {
  body {
    background-color: darkslategray;
    filter: invert(1);
  }
  img { filter: invert(1); }
  .article-list { box-shadow: 0 0 8px #333; }
}
