:root,
::backdrop {
    --sans-font: "Open Sans", sans-serif;
    --mono-font: "Droid Sans Mono", monospace;
    --standard-border-radius: 5px;

    --bg: #f0efea;
    --text: #23211c;
}

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

html {
    font-family: var(--sans-font);
    scroll-behavior: smooth;
    background-color: var(--bg);
    height: 100%;
}

/* Make the body a nice central block */
body {
    color: var(--text);
    font-size: 1.15rem;
    line-height: 1.5;
    display: grid;
    grid-template-columns: 1fr min(55rem, 90%) 1fr;
    margin: 0;
}
body > * {
    grid-column: 2;
}

/* Make the header bg full width, but the content inline with body */
/* TODO: I will need to find a way to get the header out of the nested divs. */
body > div > div > header {
    grid-column: 1 / -1;
}

body > div > div > header > *:only-child {
    margin-block-start: 2rem;
}

body > div > div > header h1 {
    max-width: 1200px;
    margin: 1rem auto;
}

body > div > div > header p {
    font-style: italic;
}

/* Add a little padding to ensure spacing is correct between content and header > nav */
main {
    padding-top: 1.5rem;
}

/* TODO: Why is the footer in a div? */
body > div > footer {
    margin-top: 4rem;
    padding: 2rem 1rem 1.5rem 1rem;
    font-size: 0.9rem;
    border-top: 1px solid var(--text);
}

/* Format headers */
h1 {
    font-size: 3rem;
}

h2 {
    font-size: 1.8rem;
    margin-top: 3rem;
}

p {
    margin: 1.5rem 0;
}

/* Prevent long strings from overflowing container */
p, h1, h2, h3, h4, h5, h6 {
    overflow-wrap: break-word;
}

/* Fix line height when title wraps */
h1,
h2,
h3 {
    line-height: 1.1;
}

/* Reduce header size on mobile */
@media only screen and (max-width: 720px) {
    h1 {
        font-size: 2.5rem;
    }

    h2 {
        font-size: 2.1rem;
    }

    h3 {
        font-size: 1.75rem;
    }

    h4 {
        font-size: 1.25rem;
    }
}

/* Format links & buttons */
a,
a:visited {
    /* Make links semibold */
    font-weight: 600;
    color: var(--text);
}

a:hover {
    text-decoration: none;
}

/* Format navigation */
nav {
    line-height: 2;
    padding: 1rem 0 0 0;
    border-bottom: 1px solid var(--text);
    font-weight: 600;
}

/* Use flexbox to allow items to wrap, as needed */
nav ul {
    align-content: space-around;
    align-items: center;
    justify-content: left;
    list-style-type: none;
    padding: 0;
}

/* List items are inline elements, make them behave more like blocks */
nav ul li {
    margin: 0 4rem 0 0;
    display: inline-block;
    font-weight: 600;
}

nav a,
nav a:visited {
    margin: 0 2rem 2rem 0.5rem;
    color: var(--text);
    display: inline-block;
    text-decoration: underline;
}

nav a:hover,
nav a.current,
nav a[aria-current="page"] {
    border-color: var(--text);
    color: var(--text);
    cursor: pointer;
    text-decoration: none;
}

section {
    border-top: 1px solid var(--text);
    border-bottom: 1px solid var(--text);
    padding: 2rem 1rem;
    margin: 3rem 0;
}

/* Don't double separators when chaining sections */
section + section,
section:first-child {
    border-top: 0;
    padding-top: 0;
}

section:last-child {
    border-bottom: 0;
    padding-bottom: 0;
}

table {
    border-collapse: collapse;
    margin: 1.5rem 0;
}

figure > table {
    width: max-content;
    margin: 0;
}

td,
th {
    border: 1px solid var(--text);
    text-align: start;
    padding: 0.5rem;
}

th {
    font-weight: 600;
}

table caption {
    font-weight: 600;
    margin-bottom: 0.5rem;
}

/* Misc body elements */
hr {
    border: none;
    height: 1px;
    margin: 1rem auto;
}

figure {
    margin: 0;
    display: block;
    overflow-x: auto;
}

.figure {
    margin: 2rem auto;
    display: flex;
    flex-direction: column;
    text-align: center;
}

.figure-number {
    display: none;
}

.figure > p {
    font-style: italic;
}

sup, sub {
    vertical-align: baseline;
    position: relative;
}

sup {
    top: -0.4em;
}

sub {
    top: 0.3em;
}
