@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: #555;
  --background-color: #fff;
  --background-color-alt: #f3f3f3;

  --hl-comment: #666;
  --hl-keyword: #000;
  --hl-string: #333;
  --hl-number: #111;
  --hl-type: #222;
  --hl-func: #000;
  --hl-attr: #444;

  --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:not([data-theme="light"]) {
    --text-color: #fff;
    --text-color-alt: #aaa;
    --background-color: #000;
    --background-color-alt: #111;

    --hl-comment: #888;
    --hl-keyword: #fff;
    --hl-string: #ccc;
    --hl-number: #e5e5e5;
    --hl-type: #ddd;
    --hl-func: #fff;
    --hl-attr: #bbb;
  }
}

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

  --hl-comment: #888;
  --hl-keyword: #fff;
  --hl-string: #ccc;
  --hl-number: #e5e5e5;
  --hl-type: #ddd;
  --hl-func: #fff;
  --hl-attr: #bbb;
}

* {
  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(80ch, round(down, 100%, 1ch)));
  line-height: var(--line-height);
  overflow-x: hidden;
}

@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, .site-title {
  font-size: 2rem;
  line-height: calc(2 * var(--line-height));
  margin-bottom: calc(var(--line-height) * 2);
  text-transform: uppercase;
  font-weight: var(--font-weight-bold);
}

h2 {
  font-size: 1.5rem;
  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);
  text-underline-offset: 2px;
}

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;
}

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

sub {
  position: relative;
  display: inline-block;
  margin: 0;
  vertical-align: sub;
  line-height: 0;
  width: calc(1ch / 0.75);
  font-size: .75rem;
}

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,
.header .site-title {
  margin: 0;
}

.header .site-title a {
  text-decoration: none;
}

.header .subtitle {
  display: block;
  margin-top: 0;
  color: var(--text-color-alt);
}

.header tr td:last-child {
  text-align: right;
}

.header .nav-cell {
  text-align: left !important;
}

.header tr:last-child > * {
  vertical-align: middle;
}

.site-nav {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-start;
  gap: 0.5rem 2ch;
  margin-top: 0;
}

.site-nav > * {
  margin-top: 0;
}

.nav-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 2ch;
  margin-top: 0;
}

.nav-links a {
  margin-top: 0;
  text-decoration: none;
  white-space: pre;
}

.nav-links a:hover {
  text-decoration: underline;
  text-decoration-thickness: var(--border-thickness);
}

.nav-links a[aria-current="page"] {
  font-weight: var(--font-weight-bold);
  text-decoration: underline;
  text-decoration-thickness: var(--border-thickness);
}

.theme-toggle {
  margin-top: 0;
  border: none;
  padding: 0;
  background: transparent;
  color: var(--text-color);
  font: inherit;
  line-height: var(--line-height);
  text-transform: none;
  text-decoration: underline;
  text-decoration-thickness: var(--border-thickness);
  text-underline-offset: 2px;
  cursor: pointer;
  white-space: pre;
}

.theme-toggle:hover {
  background: transparent;
}

.theme-toggle:focus {
  --border-thickness: 2px;
  outline: none;
}

.theme-toggle:focus-visible {
  outline: 2px solid var(--text-color);
  outline-offset: 2px;
}

img, video {
  display: block;
  width: 100%;
  object-fit: contain;
  overflow: hidden;
}

img {
  font-style: italic;
  color: var(--text-color-alt);
}

details {
  border: var(--border-thickness) solid var(--text-color);
  padding: calc(var(--line-height) - var(--border-thickness)) 1ch;
  margin-bottom: var(--line-height);
}

summary {
  font-weight: var(--font-weight-medium);
  cursor: pointer;
}

details[open] summary {
  margin-bottom: var(--line-height);
}

details :last-child {
  margin-bottom: 0;
}

pre {
  white-space: pre;
  overflow-x: auto;
  margin: var(--line-height) 0;
  overflow-y: hidden;
  border: var(--border-thickness) solid var(--text-color);
  background: var(--background-color-alt);
  padding: calc(var(--line-height) / 2) 1ch;
}

.highlight pre {
  margin: var(--line-height) 0;
}

figure pre {
  margin: 0;
}

pre, code {
  font-family: var(--font-family);
}

code {
  font-weight: var(--font-weight-medium);
  background: var(--background-color-alt);
  padding: 0 0.4ch;
}

pre code {
  background: transparent;
  padding: 0;
  font-weight: var(--font-weight-normal);
}

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;
}

#TOC {
  margin-bottom: calc(var(--line-height) * 2);
}

#TOC ul {
  margin-bottom: 0;
}

.post-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 2ch;
  color: var(--text-color-alt);
  margin-top: calc(var(--line-height) * -0.5);
  margin-bottom: calc(var(--line-height) * 1.5);
}

.post-meta > * {
  margin-top: 0;
}

.post-list {
  list-style-type: none;
  padding: 0;
}

.post-item {
  margin-bottom: calc(var(--line-height) * 1.5);
}

.post-item-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.25rem 1.5ch;
}

.post-item-head > * {
  margin-top: 0;
}

.post-date {
  color: var(--text-color-alt);
  white-space: pre;
}

.post-title {
  font-weight: var(--font-weight-bold);
}

.post-summary {
  margin-top: 0.25rem;
  margin-bottom: 0.25rem;
  color: var(--text-color-alt);
}

.tag-list {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 0 1ch;
  margin-top: 0;
}

.tag-list > * {
  margin-top: 0;
}

.tag {
  color: var(--text-color-alt);
  text-decoration: none;
}

.tag:hover {
  color: var(--text-color);
  text-decoration: underline;
}

.post-nav {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0.5rem 2ch;
  margin-top: calc(var(--line-height) * 2);
  padding-top: var(--line-height);
  border-top: var(--border-thickness) solid var(--text-color);
}

.post-nav > * {
  margin-top: 0;
}

.section-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0 2ch;
}

.section-actions > * {
  margin-top: 0;
}

.site-footer {
  margin-top: calc(var(--line-height) * 2);
  color: var(--text-color-alt);
}

.footer-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0.5rem 2ch;
  margin-top: 0;
}

.footer-row > * {
  margin-top: 0;
}

.footer-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0 2ch;
}

.footer-links > * {
  margin-top: 0;
}

button, input, textarea {
  border: var(--border-thickness) solid var(--text-color);
  padding:
    calc(var(--line-height) / 2 - var(--border-thickness))
    calc(1ch - var(--border-thickness));
  margin: 0;
  font: inherit;
  font-weight: inherit;
  background: var(--background-color);
  color: var(--text-color);
  line-height: normal;
  -webkit-appearance: none;
}

button:focus, input:focus {
  --border-thickness: 3px;
  outline: none;
}

button {
  text-transform: uppercase;
  font-weight: var(--font-weight-medium);
  cursor: pointer;
}

button:hover {
  background: var(--background-color-alt);
}

/* Chroma syntax highlighting */
.chroma .c,
.chroma .ch,
.chroma .cm,
.chroma .c1,
.chroma .cs,
.chroma .cp,
.chroma .cpf {
  color: var(--hl-comment);
  font-style: italic;
}

.chroma .k,
.chroma .kc,
.chroma .kd,
.chroma .kn,
.chroma .kp,
.chroma .kr {
  color: var(--hl-keyword);
  font-weight: var(--font-weight-bold);
}

.chroma .kt {
  color: var(--hl-type);
  font-weight: var(--font-weight-bold);
}

.chroma .s,
.chroma .sa,
.chroma .sb,
.chroma .sc,
.chroma .dl,
.chroma .sd,
.chroma .s2,
.chroma .se,
.chroma .sh,
.chroma .si,
.chroma .sx,
.chroma .sr,
.chroma .s1,
.chroma .ss {
  color: var(--hl-string);
}

.chroma .m,
.chroma .mb,
.chroma .mf,
.chroma .mh,
.chroma .mi,
.chroma .il,
.chroma .mo {
  color: var(--hl-number);
}

.chroma .nf,
.chroma .fm {
  color: var(--hl-func);
  font-weight: var(--font-weight-medium);
}

.chroma .nb,
.chroma .nc,
.chroma .na {
  color: var(--hl-attr);
}

.chroma .o,
.chroma .ow {
  color: var(--text-color);
}
