/* Modern reset */
*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; padding: 0; }

html { scrollbar-gutter: stable; }

/* Variables */
:root {
    color-scheme: light dark;
    --font-size: 1.2rem;
    --line-height: 1.55;
    --mono-font-size: 1rem;
    --mono-line-height: 1.45;
    --font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
        Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji",
        "Segoe UI Symbol";
    --text-color: #2d2d2d;
    --background-color: #fff;
    --link-color: blue;
    --link-color-alt: darkblue;
    --primary-color: lightsteelblue;
    --primary-color-light: lightsteelblue;
    --secondary-color: aliceblue;
    --tertiary-color: whitesmoke;
}

/* Typography */
body {
    background: var(--background-color);
    color: var(--text-color);
    margin: 0 auto;
    max-width: 75ch;
    padding: 0 0.5rem;
}

body, input, textarea, select, button {
    font-family: var(--font-family);
    font-size: var(--font-size);
    line-height: var(--line-height);
}

h1, h2, h3, h4, h5, h6, p, blockquote, dl, img, figure {
    margin: 2rem 0;
}

h1, h2, h3, h4, h5, h6 {
    font-weight: bold;
    line-height: 1.2;
    text-wrap: balance;
}
h1 { font-size: 200%; }
h2 { font-size: 150%; }
h3 { font-size: 120%; }
h4, h5, h6 { font-size: 100%; }
h5, h6 { text-transform: uppercase; }

header h1 { border-bottom: 1px solid; }

a, a:visited { color: var(--link-color); }
a:hover, a:focus { color: var(--link-color-alt); }

:focus-visible {
    outline: 2px solid var(--link-color);
    outline-offset: 2px;
}

strong, time, b { font-weight: bold; }
em, dfn, i { font-style: italic; }
small { font-size: 80%; }

blockquote {
    background: var(--secondary-color);
    border-left: 10px solid var(--primary-color);
    font-family: Georgia, serif;
    padding: 1rem;
}
blockquote p:first-child { margin-top: 0; }
blockquote p:last-child { margin-bottom: 0; }

cite {
    font-family: Georgia, serif;
    font-style: italic;
    font-weight: bold;
    margin-top: 1rem;
}

kbd, code, samp, pre, var {
    font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
    font-size: var(--mono-font-size);
    line-height: var(--mono-line-height);
}
code, pre {
    background: var(--tertiary-color);
    border: 1px solid;
    overflow: auto;
    padding: 0.25rem 0.5rem;
}
pre { margin: 2rem 0; }
pre code { border: 0; padding: 0; }

/* Elements */
hr {
    background: var(--text-color);
    border: 0;
    height: 1px;
    margin: 4rem 0;
}

img {
    display: block;
    height: auto;
    max-width: 100%;
}

figure {
    border: 1px solid var(--primary-color);
    display: block;
    padding: 1rem;
    width: 100%;
}
figure img { margin: 0 auto; }
figure figcaption {
    font-size: 80%;
    margin-top: 0.5rem;
    text-align: center;
}

ul, ol { margin: 2rem 0; padding: 0 0 0 2rem; }
ul li, ol li { margin-bottom: 1rem; }
li > ul, li > ol { margin: 0.25rem 0 0.5rem; padding: 0 0 0 2rem; }
li > ul li, li > ol li { margin-bottom: 0.5rem; }

dl dd { padding-left: 2rem; }

table {
    border: 1px solid var(--primary-color);
    border-collapse: collapse;
    margin: 2rem 0;
    table-layout: fixed;
    text-align: left;
    width: 100%;
}
table caption { margin: 2rem 0; }
table tr { border-bottom: 1px solid var(--primary-color); }
thead th { position: sticky; top: 0; }
table tbody tr:nth-child(even) { background: var(--tertiary-color); }
table th { background: var(--secondary-color); font-weight: bold; }
table th, table td { padding: 0.5rem; }

input, textarea, select {
    appearance: none;
    background: var(--background-color);
    border: 1px solid var(--text-color);
    color: var(--text-color);
    display: block;
    margin: 0.5rem 0;
    padding: 0.8rem;
}
input:focus, input:active,
textarea:focus, textarea:active,
select:focus, select:active {
    background-color: var(--secondary-color);
    border-color: var(--link-color);
}

/* Mobile styling */
@media screen and (max-width: 48em) {
    :root {
        --font-size: 1rem;
        --line-height: 1.45;
    }
    table { table-layout: auto; }
}

/* Dark mode */
@media (prefers-color-scheme: dark) {
    :root {
        --text-color: #fff;
        --background-color: #191919;
        --link-color: orange;
        --link-color-alt: yellow;
        --primary-color: orange;
        --primary-color-light: dimgrey;
        --secondary-color: black;
        --tertiary-color: #2d2d2d;
    }

    table,
    table tr,
    table th:not(:last-of-type),
    table td:not(:last-of-type) {
        border-color: var(--text-color);
    }
    table thead th,
    table tfoot th {
        background-color: var(--primary-color-light);
    }
}
