/* Global variables. */
:root,
::backdrop {
    /* Set sans-serif & mono fonts */
    --sans-font: -apple-system, BlinkMacSystemFont, "Avenir Next", Avenir,
    "Nimbus Sans L", Roboto, "Noto Sans", "Segoe UI", Arial, Helvetica,
    "Helvetica Neue", sans-serif;
    --mono-font: Consolas, Menlo, Monaco, "Andale Mono", "Ubuntu Mono", monospace;
    --standard-border-radius: 5px;

    /* Default (light) theme */
    --bg: #fff;
    --accent-bg: #f5f7ff;
    --text: #212121;
    --text-light: #585858;
    --border: #898EA4;
    --accent: #0d47a1;
    --accent-hover: #1266e2;
    --accent-text: var(--bg);
    --code: #d81b60;
    --preformatted: #444;
    --marked: #ffdd33;
    --disabled: #efefef;
}

/* Dark theme */
@media (prefers-color-scheme: dark) {
    :root,
    ::backdrop {
        color-scheme: dark;
        --bg: #212121;
        --accent-bg: #2b2b2b;
        --text: #dcdcdc;
        --text-light: #ababab;
        --accent: #ffb300;
        --accent-hover: #ffe099;
        --accent-text: var(--bg);
        --code: #f06292;
        --preformatted: #ccc;
        --disabled: #111;
    }
    /* Add a bit of transparency so light media isn't so glaring in dark mode */
    img,
    video {
        opacity: 0.8;
    }
}

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

html {
    /* Set the font globally */
    font-family: var(--sans-font);
    scroll-behavior: smooth;
}

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

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

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

p {
    margin: 1.5rem 0;
}

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

/* Fix line height when title wraps */
h1,
h2 {
    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;
    }

}

pre {
    background-color: var(--accent-bg);
    border: 1px solid var(--border);
    border-radius: var(--standard-border-radius);
    margin-bottom: 1rem;
}

section h2:first-child {
    margin-top: 1rem;
}

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

/* Format tables */
table {
    border-collapse: collapse;
    margin: 1.5rem 0;
}

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

th {
    background-color: var(--accent-bg);
    font-weight: bold;
}

tr:nth-child(even) {
    /* Set every other cell slightly darker. Improves readability. */
    background-color: var(--accent-bg);
}

pre {
    padding: 1rem 1.4rem;
    max-width: 100%;
    overflow: auto;
}
