/* base 1 */

:root {
  --fore: #181818;
  --back: #f8f8f8;
  --shade: #808080;
  --curve-circular: cubic-bezier(0.08, 0.82, 0.17, 1);
}

*, *::before, *::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--fore);
  background-color: var(--back);
  font-family: "Noto Sans", "Noto Sans CJK SC", "Segoe UI",
    "Microsoft YaHei UI", sans-serif;
  line-height: 1.5;
}

@media (max-width: 639px) {
  body {
    line-height: 1.8;
  }
}

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

pre, code, textarea {
  font-family: "Fira Sans Mono", "Noto Sans Mono", "DejaVu Sans Mono",
    "Consolas", monospace;
}

/* base 2 */

main {
  width: 29.7cm;
  max-width: 100%;
  margin: 1.5cm auto;
  padding: 0 1em;
}
main.frontpage {
  width: unset;
  margin: 1.5cm 8pt;
}

h1, h2, h3 {
  margin: 16pt 0;
}
h1 {
  text-align: center;
}
h2 {
  border-bottom: 1px solid var(--shade);
}

pre,
textarea {
  border-radius: 4pt;
  border: 1px solid var(--shade);
  padding: 0.75em 1em;
  background-color: transparent;
  color: inherit;
  width: 100%;
}
textarea {
  min-height: 20vh;
}

pre {
  overflow: auto;
}
pre.wrap {
  white-space: pre-wrap;
}
pre.break {
  word-break: break-all;
}
pre.fold {
  max-height: 5cm;
}

blockquote {
  margin: 0;
  font-style: italic;
}
blockquote {
  padding-left: 1em;
  border-left: 3px solid var(--fore);
}
[dir="rtl"] blockquote {
  padding-left: 0;
  border-left: none;
  padding-right: 1em;
  border-right: 3px solid var(--fore);
}

table {
  margin: 0 0.5em;
}
td {
  padding: 0 2pt;
  vertical-align: baseline;
}
td:nth-child(1) {
  text-wrap: nowrap;
}
ul {
  padding-left: 2em;
}
li, td {
  line-height: 1.8;
}
@media (max-width: 639px) {
  li, td {
    line-height: 2;
  }
}

/* base 3 */

.center {
  text-align: center;
}

.selectall {
  user-select: all;
}

.slogan, .caption {
  text-align: center;
  font-style: italic;
}
.caption {
  font-size: 0.9em;
}

abbr.extern {
  display: inline-block;
  width: 0;
  overflow: visible;
}
abbr.extern::after {
  display: inline-block;
  content: "↗";
  padding-left: 4pt;
  text-decoration: none;
  vertical-align: super;
  font-size: 0.67em;
}
[dir="rtl"] abbr.extern::after {
  content: "↖";
  padding-left: 0;
  padding-right: 4pt;
}

/* base 4 */

nav {
  margin: 1em 0;
  padding: 0 1em;
  width: 100%;
  line-height: 2;
  border-top: 1px solid var(--shade);
  border-bottom: 1px solid var(--shade);
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  background-color: var(--back);
  z-index: 1;
}

nav a {
  box-sizing: content-box;
  display: inline-block;
  text-decoration: none;
  padding: calc(0.5em + 2px) 1em calc(0.5em - 2px) 1em;
  height: 36px;
  border-top: 2px solid transparent;
  border-bottom: 2px solid transparent;
  transition: border 0.25s 0s ease-out;
  vertical-align: bottom;
}
nav a.logo {
  padding: 0.5em 0;
}
nav a:hover {
  border-bottom: 2px solid var(--fore);
}

@media (max-width: 599px) {
  nav {
    flex-direction: column;
    justify-content: center;
    text-align: center;
  }
  nav a {
    padding: 0 1em;
  }
}

footer {
  font-size: small;
  margin: 2cm 0 3cm 0;
  padding: 1em;
  border-top: 1px solid var(--shade);
  border-bottom: 1px solid var(--shade);
  text-align: center;
}

/* components */

.naitframe {
  display: block;
  margin: auto;
  width: 480px;
  max-width: 100%;
  height: 480px;
  max-height: calc(100vw - 2em);
  border: none;
}

.poster {
  width: 21cm;
  height: unset;
  max-width: 100%;
  margin: 0 max(0px, calc((min(100vw, 29.7cm) - 21cm) / 2 - 1em));
  display: block;
  border-radius: 4pt;
}

/* dark */

@media (prefers-color-scheme: dark) {
  :root {
    --fore: #c8c8c8;
    --back: #181818;
  }
  img.black, iframe.text {
    filter: invert(0.92);
  }
  img, iframe.img {
    filter: brightness(0.8);
  }
}
