html,
body {
    margin: 0;
}

body {
    background: var(--primary-bg);
    font-family: var(--sans);

    --sans: 'IBM Plex Sans', sans-serif;
    --mono: 'IBM Plex Mono', monospace;

    /* color variables taken from Merlot */
    --primary-bg: #f9fafb;
    --primary-text: #111111;
    --secondary-bg: #f3f4f6;
    --secondary-text: #9b9b9b;
    --hover-bg: #eaebec;
    --active-bg: #dcdfe4;
    --translucent: rgba(249, 250, 251, .8);
    --transparent: rgba(249, 250, 251, 0);

    /* repl text colors */
    --error: #da1111;
}

.dark {
    --primary-bg: #2f3437;
    --primary-text: #ebebeb;
    --secondary-bg: #373c3f;
    --secondary-text: #a4a7a9;
    --hover-bg: #474c50;
    --active-bg: #626569;
    --translucent: rgba(47, 52, 55, .8);
    --transparent: rgba(47, 52, 55, 0);

    --error: #ff554c;
}

a {
    color: var(--primary-text);
}

button {
    font-size: 1em;
}

pre,
code,
input,
select,
option,
textarea {
    color: var(--primary-text);
    font-size: 1em;
    font-family: var(--mono);
}

.app {
    display: flex;
    flex-direction: column;
    width: 100%;
    height: 100vh;
    overflow: hidden;
    color: var(--primary-text);
    background: var(--primary-bg);
}

header {
    height: 50px;
    flex-grow: 0;
    flex-shrink: 0;
    justify-content: space-between;
    box-sizing: border-box;
    padding: 0 10px;
    background: var(--secondary-bg);
    border-bottom: 2px solid var(--active-bg);
}

header,
header nav {
    display: flex;
    flex-direction: row;
    align-items: center;
}

nav a {
    margin: 0 8px;
}

nav a:hover {
    text-decoration: underline;
}

.left-nav {
    justify-content: flex-start;
}

.right-nav {
    justify-content: flex-end;
}

nav a {
    text-decoration: none;
}

header select {
    font-family: var(--sans);
    margin: 0 8px;
    cursor: pointer;
    background: var(--primary-bg);
    border-radius: 4px;
    padding: 2px 6px;
}

.workspace {
    display: flex;
    flex-direction: row;
    flex-grow: 1;
    flex-shrink: 1;
    justify-content: space-between;
    height: 0;
    width: 100%;
}

.editor,
.repl {
    position: relative;
    height: 100%;
    width: 0;
    flex-grow: 1;
    flex-shrink: 1;
}

.editor + .repl {
    border-left: 2px solid var(--active-bg);
}

.editorContainer {
    height: 100%;
    width: 100%;
}

.editorContainer .CodeMirror {
    height: 100%;
    font-family: var(--mono);
}

.editor .runButton {
    padding: 8px 12px;
    border-radius: 4px;
    position: absolute;
    top: 8px;
    right: 8px;
    cursor: pointer;
    color: var(--primary-bg);
    background: var(--primary-text);
    border: 0;
    transition: background-color .15s;
    z-index: 100;
}

.editor .runButton:hover {
    background: var(--secondary-text);
}

.repl {
    overflow-x: hidden;
}

.replTerm {
    line-height: 1.5em;
}

.replTerm code {
    white-space: pre-wrap;
    display: block;
    box-sizing: border-box;
    padding: 0 8px;
    word-break: break-all;
}

.repl .prog-line {
    font-weight: bold;
    cursor: pointer;
}

.repl .prog-line:hover {
    background: var(--hover-bg);
}

.repl .result-line {
    font-style: italic;
    color: var(--secondary-text);
}

.repl .error-line {
    color: var(--error);
    font-style: italic;
}

.inputLine {
    display: flex;
    flex-direction: row;
    font-family: var(--mono);
    background: var(--hover-bg);
    padding: 0 8px;
    /* to not overlap with credits, ergonomics */
    margin-bottom: 3em;
}

.embedded .inputLine {
    /* vertical real estate is at a premium in embedded mode */
    margin-bottom: 0;
}

.inputPrompt {
    white-space: pre;
    font-weight: bold;
}

.addToEditorButton {
    display: none;
    float: right;
    background: transparent;
    border: 0;
    color: var(--secondary-text);
    font-family: var(--mono);
    cursor: pointer;
}

.replLine:hover .addToEditorButton {
    display: inline;
}

.addToEditorButton:hover {
    text-decoration: underline;
}

textarea.replInputLine {
    font-size: 1em;
    height: 1.5em; /* match line-height */
    padding: 0;
    margin: 0;
    border: 0;
    background: transparent;
    outline: none;
    flex-grow: 1;
    font-family: var(--mono);
    line-height: 1.5em;
    resize: none;
}

textarea.replInputLine::placeholder {
    font-style: italic;
    color: var(--secondary-text);
}

.credits {
    position: fixed;
    right: 6px;
    bottom: 6px;
    font-size: 12px;
    text-align: right;
}

.credits,
.credits a {
    color: var(--secondary-text);
}

.aboutBackButton {
    background: transparent;
    border: 0;
    cursor: pointer;
    padding: 0;
    margin: 0;
    color: var(--secondary-text);
    margin-top: 1em;
}

.aboutBackButton:hover {
    text-decoration: underline;
}

.aboutPage {
    background: var(--primary-bg);
    overflow-y: auto;
}

.aboutContent {
    width: calc(100% - 36px);
    max-width: 68ch;
    margin: 0 18px;
    margin-bottom: 6em;
}

.aboutContent p,
.aboutContent li {
    line-height: 1.5em;
}

.aboutContent code {
    background: var(--hover-bg);
    border-radius: 3px;
    padding: 1px 4px 2px 4px;
}

/* embedded mode, /?=embed=1 for <iframe> use */

.embedded .workspace {
    flex-direction: column;
}
.embedded .editor,
.embedded .repl {
    height: 0;
    width: 100%;
}
.embedded .editor + .repl {
    border-top: 2px solid var(--active-bg);
    border-left: 0;
}

@media only screen and (max-width: 700px) {
    .desktop {
        display: none;
    }
    .workspace {
        flex-direction: column;
    }
    .editor,
    .repl {
        height: 0;
        width: 100%;
    }
    .editor + .repl {
        border-top: 2px solid var(--active-bg);
        border-left: 0;
    }
}
