/**
 * leanhtu.com — based on The Monospace Web by Oskar Wickström (MIT)
 * https://github.com/owickstrom/the-monospace-web
 */
@import url('https://fonts.cdnfonts.com/css/jetbrains-mono-2');

:root {
  --font-family: "JetBrains Mono", monospace;
  --line-height: 1.20rem;
  --border-thickness: 2px;
  --text-color: #000;
  --text-color-alt: #666;
  --background-color: #fff;
  --background-color-alt: #eee;

  --font-weight-normal: 500;
  --font-weight-medium: 600;
  --font-weight-bold: 800;

  font-family: var(--font-family);
  font-optical-sizing: auto;
  font-weight: var(--font-weight-normal);
  font-style: normal;
  font-variant-numeric: tabular-nums lining-nums;
  font-size: 16px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --text-color: #fff;
    --text-color-alt: #aaa;
    --background-color: #000;
    --background-color-alt: #111;
  }
}

:root[data-theme="light"] {
  --text-color: #000;
  --text-color-alt: #666;
  --background-color: #fff;
  --background-color-alt: #eee;
}
:root[data-theme="dark"] {
  --text-color: #fff;
  --text-color-alt: #aaa;
  --background-color: #000;
  --background-color-alt: #111;
}

* {
  box-sizing: border-box;
}

* + * {
  margin-top: var(--line-height);
}

html {
  display: flex;
  width: 100%;
  margin: 0;
  padding: 0;
  flex-direction: column;
  align-items: center;
  background: var(--background-color);
  color: var(--text-color);
}

body {
  position: relative;
  width: 100%;
  margin: 0;
  padding: var(--line-height) 2ch;
  max-width: calc(min(100ch, round(down, 100%, 1ch)));
  line-height: var(--line-height);
  overflow-x: hidden;
}

body.reading {
  max-width: calc(min(100ch, round(down, 100%, 1ch)));
}

@media screen and (max-width: 480px) {
  :root {
    font-size: 14px;
  }
  body {
    padding: var(--line-height) 1ch;
  }
}

h1, h2, h3, h4, h5, h6 {
  font-weight: var(--font-weight-bold);
  margin: calc(var(--line-height) * 2) 0 var(--line-height);
  line-height: var(--line-height);
}

h1 {
  font-size: 2rem;
  line-height: calc(2 * var(--line-height));
  margin-bottom: calc(var(--line-height) * 2);
  text-transform: uppercase;
}
h2 {
  font-size: 1rem;
  text-transform: uppercase;
}

hr {
  position: relative;
  display: block;
  height: var(--line-height);
  margin: calc(var(--line-height) * 1.5) 0;
  border: none;
  color: var(--text-color);
}
hr:after {
  display: block;
  content: "";
  position: absolute;
  top: calc(var(--line-height) / 2 - var(--border-thickness));
  left: 0;
  width: 100%;
  border-top: calc(var(--border-thickness) * 3) double var(--text-color);
  height: 0;
}

a {
  text-decoration-thickness: var(--border-thickness);
}

a:link, a:visited {
  color: var(--text-color);
}

p {
  margin-bottom: var(--line-height);
  word-break: break-word;
  word-wrap: break-word;
  hyphens: auto;
}

strong { font-weight: var(--font-weight-bold); }
em { font-style: italic; }

table {
  position: relative;
  top: calc(var(--line-height) / 2);
  width: calc(round(down, 100%, 1ch));
  border-collapse: collapse;
  margin: 0 0 calc(var(--line-height) * 2);
}

th, td {
  border: var(--border-thickness) solid var(--text-color);
  padding:
    calc((var(--line-height) / 2))
    calc(1ch - var(--border-thickness) / 2)
    calc((var(--line-height) / 2) - (var(--border-thickness)));
  line-height: var(--line-height);
  vertical-align: top;
  text-align: left;
}
table tbody tr:first-child > * {
  padding-top: calc((var(--line-height) / 2) - var(--border-thickness));
}
th { font-weight: 700; }

.width-min { width: 0%; }
.width-auto { width: 100%; }

.header { margin-bottom: calc(var(--line-height) * 2); }
.header h1 { margin: 0; }
.header tr td:last-child { text-align: right; }

.subtitle {
  display: block;
  color: var(--text-color-alt);
  font-weight: var(--font-weight-normal);
  margin-top: calc(var(--line-height) / 2);
}

img, video {
  display: block;
  width: 100%;
  object-fit: contain;
  overflow: hidden;
}
img { font-style: italic; color: var(--text-color-alt); }

.video-embed {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  border: var(--border-thickness) solid var(--text-color);
}
.audio-embed {
  display: block;
  width: 100%;
  height: 152px;
  border: var(--border-thickness) solid var(--text-color);
}
.audio-embed.audio-embed-tall { height: 352px; }

pre {
  white-space: pre;
  overflow-x: auto;
  margin: var(--line-height) 0;
  overflow-y: hidden;
}
pre, code { font-family: var(--font-family); }
code { font-weight: var(--font-weight-medium); }

figure {
  margin: calc(var(--line-height) * 2) 3ch;
  overflow-x: auto;
  overflow-y: hidden;
}
figcaption {
  display: block;
  font-style: italic;
  margin-top: var(--line-height);
}

ul, ol { padding: 0; margin: 0 0 var(--line-height); }
ul { list-style-type: square; padding: 0 0 0 2ch; }
ol { list-style-type: none; counter-reset: item; padding: 0; }
ol ul, ol ol, ul ol, ul ul { padding: 0 0 0 3ch; margin: 0; }
ol li:before {
  content: counters(item, ".") ". ";
  counter-increment: item;
  font-weight: var(--font-weight-medium);
}
li { margin: 0; padding: 0; }
li::marker { line-height: 0; }

blockquote {
  border-left: calc(var(--border-thickness) * 2) solid var(--text-color);
  padding-left: 2ch;
  margin: var(--line-height) 0;
  color: var(--text-color-alt);
  font-style: italic;
}

::-webkit-scrollbar { height: var(--line-height); }

/* Site-specific: navigation & post list */

nav.site-nav {
  margin: 0 -1ch calc(var(--line-height) * 2);
  border-top: var(--border-thickness) solid var(--text-color);
  border-bottom: var(--border-thickness) solid var(--text-color);
  padding: calc(var(--line-height) / 2 - var(--border-thickness)) 0;
  display: flex;
  gap: 0;
  flex-wrap: wrap;
}
nav.site-nav a {
  font-weight: var(--font-weight-medium);
  text-transform: uppercase;
  padding: 0 1ch;
}
nav.site-nav a[aria-current="page"] {
  background: var(--text-color);
  color: var(--background-color);
  text-decoration: none;
}

.theme-toggle {
  margin-left: auto;
  margin-top: 0;
  font-family: inherit;
  font-size: inherit;
  font-weight: var(--font-weight-medium);
  text-transform: uppercase;
  background: none;
  border: none;
  padding: 0 1ch;
  color: var(--text-color);
  cursor: pointer;
  line-height: var(--line-height);
}
.theme-toggle:hover { text-decoration: underline; }

.post-list { width: 100%; }
.post-list th, .post-list td { vertical-align: top; }
.post-list td:first-child { white-space: nowrap; }
.post-list a { font-weight: var(--font-weight-medium); }

article.post .post-meta {
  color: var(--text-color-alt);
  margin-top: calc(var(--line-height) * -1);
  margin-bottom: var(--line-height);
}

.topic-toc {
  list-style-type: none;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0 3ch;
}
.topic-toc li { white-space: nowrap; }
.topic-toc a { font-weight: var(--font-weight-medium); }

.topic-section[hidden] { display: none; }
.topic-section tbody tr[hidden] { display: none; }

.topic-tag {
  text-decoration: none;
  font-weight: var(--font-weight-medium);
}
.topic-tag:hover { text-decoration: underline; }

footer.site-footer {
  margin-top: calc(var(--line-height) * 3);
  padding-top: var(--line-height);
  border-top: var(--border-thickness) solid var(--text-color);
  color: var(--text-color-alt);
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 2ch;
}
