:root {
    --background-color: #fff;
    --background-color-2: #f9f9fb;
    --background-color-3: hsl(240, 2%, 88%);
    --header-background: #212938;
    --header-foreground: var(--background-color-2);
    --text-color: #333;
    --text-color-subtle: hsl(245, 5%, 61%);
    --blue: hsl(216, 74%, 46%);
    --string-color: #008000;
    --number-color: #a31515;
    --error-background-color: #fdd;
    --warning-background-color: #ffd;
}

@media (prefers-color-scheme: dark) {
    :root {
        color-scheme: dark;
        --background-color: hsl(220, 5%, 8%);
        --background-color-2: hsla(0, 0%, 100%, 0.03);
        --background-color-3: hsla(0, 0%, 100%, 0.1);
        --text-color: #e2e4e9;
        --text-color-subtle: hsla(243, 65%, 93%, 0.36);
        --blue: hsl(213, 60%, 58%);
        --string-color: hsl(0, 58%, 70%);
        --number-color: #b5cea8;
        --error-background-color: #ff000038;
        --warning-background-color: #ffff0021;
    }
}

* {
    box-sizing: border-box;
}

html {
    background: var(--background-color);
    color: var(--text-color);
}

body {
    position: relative;
    max-width: 1000px;
    margin: 0 auto;
    padding: 20px;
    padding-top: 0;
    box-sizing: content-box;
    font-family: system-ui, -apple-system, BlinkMacSystemFont, Segoe UI, Roboto, Oxygen, Ubuntu, Cantarell, Droid Sans, Helvetica Neue, Arial, sans-serif;
    font-size: 15px;
    line-height: 1.6;
    display: grid;
    grid-column-gap: 40px;
}

@media screen and (min-width: 768px) {
    body {
        grid-template-columns: minmax(auto, max-content) auto;
    }
}

.top-nav + main {
    grid-column: 1 / -1;
}

main {
    margin-bottom: 100px;
}

h1 {
    margin-top: 0;
}

a, a:visited {
    text-decoration: none;
    color: var(--blue);
}

a:hover {
    text-decoration: underline;
}

a.active {
    font-weight: bold;
    color: unset;
}

hr {
    border: none;
    border-top: 1px solid var(--background-color-3);
    margin: 30px 0;
}

pre, code, .sourceCode {
    font-family: SFMono-Regular, Consolas, "Liberation Mono", Menlo, monospace !important;
}

:not(pre) > code {
    font-size: 92%;
}

.sourceCode, pre code {
    font-size: 12px;
    line-height: 1.5;
}

div.sourceCode {
    position: relative;
    background: var(--background-color-2);
    border: 1px solid var(--background-color-3);
    border-radius: 2px;
}

pre {
    padding: 10px 15px;
}

.top-nav {
    display: grid;
    grid-template-columns: 1fr;
    grid-template-rows: auto auto;
    grid-row-gap: 20px;
    align-items: center;
    padding: 30px 0;
    grid-column: 1 / -1;
}

.top-nav h1 {
    font-weight: 900;
    font-family: Arial Black, system-ui, -apple-system, BlinkMacSystemFont, Segoe UI, Roboto, Oxygen, Ubuntu, Cantarell, Droid Sans, Helvetica Neue, Arial, sans-serif;
    font-size: 2.5em;
    line-height: 1;
    margin: 0;
    margin-right: 15px;
}

.top-nav h1 a {
    color: unset;
    text-decoration: unset;
}

.links {
    white-space: nowrap;
}

@media screen and (min-width: 360px) {
    .top-nav {
        grid-template-columns: max-content auto;
        grid-template-rows: none;
    }

    .links {
        text-align: right;
        margin-top: 0;
    }
}

.links a + a {
    margin-left: 15px;
}

.side-nav {
    white-space: nowrap;
}

.side-nav > ul {
    padding: 0;
    list-style-type: none;
}

section {
    margin: 30px 0;
}

.intro {
    margin-top: 0;
}

.intro-grid {
    display: grid;
    grid-gap: 30px;
    grid-template-rows: auto auto;
}

@media screen and (min-width: 768px) {
    .intro-grid {
        grid-template-columns: 1fr 1fr;
        grid-template-rows: none;
    }
}

.intro-grid section,
.intro-grid .sourceCode {
    margin: 0;
}

.intro h1 {
    font-size: 28px;
    font-weight: 400;
    line-height: 1.4;
    margin: 40px 0;
}

.intro h1 strong {
    font-weight: 700;
}

.intro p {
    max-width: 1000px;
    margin: 0 auto;
}

.intro .CodeMirror-scroll {
    max-height: 400px;
}

.features {
    display: grid;
    grid-template-columns: 1fr;
    grid-gap: 30px;
    margin: 30px 0;
}

.features h2 {
    color: var(--text-color-subtle);
    margin-top: 0;
    margin-bottom: 5px;
}

@media screen and (min-width: 768px) {
    .features {
        grid-template-columns: 1fr 1fr 1fr;
    }
}

h4 {
    margin-top: 0;
    margin-bottom: 3px;
}

.block {
    margin: 0;
}

.block p {
    margin: 0;
}

.block.wide {
    grid-column: 1 / -1;
}

button, a.button {
    border: none;
    border-radius: 2px;
    background: var(--background-color-3);
    color: inherit;
    padding: 10px 15px;
    height: 30px;
    cursor: pointer;
    font-size: inherit;
}

a.button {
    display: inline-block;
    height: auto;
}

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

button:focus {
    outline: none;
}

.editor {
    overflow: auto;
    tab-size: 4;
}

.CodeMirror {
    font-family: inherit;
    background: unset !important;
    color: var(--text-color-subtle);
    height: auto;
    width: 100%;
}

.CodeMirror-lines {
    padding: 10px 0 !important;
}

.CodeMirror-line,
.CodeMirror-linewidget .diagnostic {
    padding: 0 15px !important;
}

.diagnostic {
    color: var(--text-color);
    padding: 0 4px;
    white-space: pre-wrap;
}

.diagnostic.error {
    background-color: var(--error-background-color);
}

.diagnostic.warning {
    background-color: var(--warning-background-color);
}

button.run {
    position: absolute;
    right: 20px;
    top: 10px;
    z-index: 10;
    padding: 15px;
    border-radius: 50%;
    background: var(--background-color-3);
    background-image: url("lib/play-button.svg");
    background-repeat: no-repeat;
    background-position: center;
    background-size: contain;
    text-indent: -10000px; /* Hide text except from screen readers */
}

button.run:active {
    transform: scale(0.9);
}

.output {
    display: none;
    width: 100%;
    padding: 10px 15px;
    border-top: 1px solid var(--background-color-3);
    white-space: pre-wrap;
    overflow: auto;
}

.stderr {
    color: red;
}

.bottom-links {
    margin: 40px auto;
    display: flex;
    gap: 20px;
    align-items: center;
    justify-content: center;
    width: fit-content;
    flex-wrap: wrap;
}

.bottom-links a {
    width: fit-content;
}
