/**
 * Adapted from The Monospace Web by Oskar Wickström
 * Licensed under the MIT License
 * 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.2rem;
    --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;
    }
}

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

/* Typography */

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

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

/* Links */

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

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

/* Horizontal rule — newspaper-style double line */

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

/* Header table */

.header {
    margin-bottom: calc(var(--line-height) * 2);
}

.header h1 {
    margin: 0;
}

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

/* Tables */

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

/* Navigation */

nav {
    margin: var(--line-height) 0;
}

nav a {
    margin-right: 2ch;
    text-transform: uppercase;
    font-weight: var(--font-weight-medium);
}

/* Lists */

ul {
    list-style-type: square;
    padding: 0 0 0 2ch;
    margin: 0 0 var(--line-height);
}

li {
    margin: 0;
    padding: 1.5ch 0 0 0;
}

li::marker {
    line-height: 0;
}

/* Images */

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

/* Portrait specific */

.portrait {
    float: left;
    margin: 0 2ch 1ch 0;
    width: 20ch;
}

/* Preformatted */

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

/* Scrollbar */

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

/* Footer */

footer {
    margin-top: calc(var(--line-height) * 2);
    color: var(--text-color-alt);
    font-size: 0.85rem;
}
