/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at https://mozilla.org/MPL/2.0/.
 */


* {
    box-sizing: border-box;
}

.hidden {
    display: none;
}

html {
    font-size: 16px;
    line-height: 1.30;
    color: var(--article-text-color);
    text-rendering: optimizeLegibility;
    font-family: 'Source Sans Pro', sans-serif;
    letter-spacing: 0.01em;
    height: 100%;
}

body {
    margin: 0;
    height: 100vh;
    display: grid;
    grid-template-columns: minmax(0, 1fr) 96ch minmax(0, 1fr); /* 80 ch + 2*12 ch */
    grid-template-rows: auto 1fr;
    grid-template-areas:
        "c11 c12 c13"
        "c21 c22 c23";

    .c11 { grid-area: c11; }
    .c12 { grid-area: c12; }
    .c13 { grid-area: c13; }
    .c21 { grid-area: c21; }
    .c22 { grid-area: c22; }
    .c23 { grid-area: c23; }

    &.visible {
        opacity: 1;
    }
}

.top-nav {
    background-color: var(--topnav-bg-color);
    padding: 0.5em 0;
    ul {
        display: flex;
        gap: 1.5em;
        margin: 0;
        padding: 1rem 0;
        list-style: none;
        align-items: center;
        justify-content: left;
    }
    .left, .right {
        display: flex;
        gap: 1.5em;
        align-items: center;
    }
    .right {
        margin-left: auto;
    }
    .link {
        a {
            text-decoration: none;
            font-weight: normal;
            text-transform: uppercase;
            color: var(--link-color);
        }
    }
}

article, .reviewer {
    position: relative;
    height: 100%;
    font-style: normal;
    background-color: var(--article-bg-color);
    margin: 0;
    padding: 12ch;
    border-left: solid 1px var(--border-color);
    border-right: solid 1px var(--border-color);
    border-top: solid 1px var(--border-color);
    border-radius: 2px;

    ul, ol {
        padding-left: 1em;
        li {
            unicode-bidi: isolate;
            margin-bottom: 1rem;
        }
        li:last-child {
            margin-bottom: 0;
        }
    }
}

.reviewer {
    .buttons {
        display: flex;
        justify-content: flex-end;
        margin: 1rem 0;
        button {
            margin-left: 1rem;
        }
    }
}

article > div.outline-2:first-of-type > h2 {
    margin-top: 0;
}

h1, h2, h3, h4, h5 {
    display: block;
    font-weight: normal;
    unicode-bidi: isolate;
    margin-top: 4ch;
    text-decoration: underline;
}

code.privacy {
    font-size: 0.80em;
    margin-left: 1ch;
    border-radius: 2px;

    &.private {
        background-color: var(--color-red-300);
    }

    &.public {
        background-color: var(--color-green-300);
    }
}

h1 {
    font-size: 1.75em;
    margin-top: 0;
    margin-bottom: 4em;
    text-align: center;
}

h2 {
    font-size: 1.5em;
}

p {
    display: block;
    margin-block-start: 1em;
    margin-block-end: 1em;
    margin-inline-start: 0px;
    margin-inline-end: 0px;
    unicode-bidi: isolate;
}

figure {
    text-align: center;
    margin: 2rem 0;

    img {
        border: 1px solid var(--article-text-color);
        border-radius: 2px
    }

    figurecaption {
        text-align: center;
    }
}

strong {
    font-weight: bold;
}

pre {
    font-family: 'JetBrains Mono', monospace;
}

pre.src, code {
    font-family: 'JetBrains Mono', monospace;
    color: var(--src-text-color);
    font-size: 0.8em;
}

pre.src {
    border: 1px solid var(--src-border-color);
    background-color: var(--src-bg-color);
    border-radius: 2px;
    padding: 0.5em;
    margin: 2rem 0;
    overflow-x: auto;
}

code {
    padding: 0 0.25em;
    background-color: var(--src-bg-color);
}

.todo, .done {
    font-family: 'JetBrains Mono', monospace;
    font-weight: bold;
    color: var(--article-bg-color);
    font-size: 0.7em;
    padding: 0.1em 0.2em;
    border-radius: 2px;
    margin-right: 0.33em;
    text-decoration: none !important;

    &.TODO {
        background-color: var(--kw-todo-bg-color);
    }

    &.DOING {
        background-color: var(--kw-doing-bg-color);
    }

    &.DONE {
        background-color: var(--kw-done-bg-color);
    }

}

a {
    outline-color: transparent;
    text-decoration: underline;
    color: var(--link-color);
}

table {
    border-collapse: collapse;
    width: 100%;
    margin-block-start: 1em;
    margin-block-end: 1em;
}

th, td {
    border: 1px solid var(--table-border-color);
    padding: 0.5em;
    text-align: left;
}

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

td.org-left {
    text-align: left;
}

nav#table-of-contents {
    margin-left: auto;
    padding-left: 0.2rem;
    padding-right: 1rem;
    width: fit-content;
    overflow-y: auto;
    max-height: 80vh;
    position: sticky;
    top: 1rem;
    ul, ol {
        margin-inline-start: 0px;
        margin-inline-end: 0px;
        padding-inline-start: 1em;
        list-style-type: none;
    }

    & > h2:first-child {
        margin-top: 0;
        font-size: 1rem;
    }

    #text-table-of-contents > ul:first-child {
        padding-left: 0;
    }
}

.c23 {
    display: flex;
    flex-direction: column;
    padding-left: 1rem;
}


blockquote {
    background-color: var(--color-blue-grey-50);
    border-left: 4px solid var(--color-blue-grey-900);
    margin: 2rem 0;
    padding: 1rem 1.5rem;
    font-style: italic;
    color: var(--color-blue-grey-900);
    border-radius: 2px;
}

:root {
    --color-beige: #fbf7f0;
    --color-black: #000000;

    --color-blue-warmer: #3546c2;

    --color-white: #FFFFFF;
    --color-blue-900: #0D47A1;
    --color-blue-grey-100: #CFD8DC;
    --color-blue-grey-50: #ECEFF1;
    --color-blue-grey-900: #263238;
    --color-green-900: #1B5E20;
    --color-green-300: #81C784;
    --color-indigo-50: #E8EAF6;
    --color-indigo-900: #1A237E;
    --color-orange-50: #FFF3E0;
    --color-orange-900: #E65100;
    --color-red-50: #FFEBEE;
    --color-red-300: #E57373;
    --color-red-900: #B71C1C;
}

:root {
    --article-bg-color: var(--color-beige);
    --article-text-color: var(--color-black);

    --link-color: var(--color-blue-warmer);

    --src-bg-color: var(--color-orange-50);
    --src-border-color: var(--color-orange-900);
    --src-text-color: var(--article-text-color);

    --kw-todo-bg-color: var(--color-red-900);
    --kw-doing-bg-color: var(--color-orange-900);
    --kw-done-bg-color: var(--color-green-900);
    --kw-text-color: var(--article-white);

    --table-th-bg-color: var(--color-blue-grey-100);
    --table-border-color: var(--color-blue-grey-900);

    --border-color: var(--color-blue-grey-900);

    --topnav-bg-color: var(--article-white);
}

.exercise {
    display: none;
}

form.discussion {
    margin: 2rem 0;
    display: none;
    flex-direction: column;
    gap: 1rem;

    .email {
        display: inherit;
        flex-direction: inherit;
    }

    .content {
        display: inherit;
        flex-direction: inherit;
        textarea {
            margin-bottom: 1rem;
        }
    }

    button {
        align-self: flex-end;
    }
}

/* --- Responsive layout for mobile --- */
@media (max-width: 1100px) {
    html {
        font-size: 14px;
    }

    body {
        display: flex;
        flex-direction: column;
        max-width: 85ch;
        margin: auto;
    }

    main {
        flex: 1;
    }

    .c11, .c13, .c21, .c23 {
        display: none;
    }

    .c12 {
        background-color: var(--article-bg-color);
    }

    .c12, .c22 {
        position: relative;
        width: 100%;
        grid-area: unset;
    }

    .c12 {
        padding: 0 1rem;
    }

    article, .reviewer {
        padding: 1rem;
        border-radius: 0;
        border-left: none;
        border-right: none;
    }

    .top-nav {
        ul {
            justify-content: center;
            flex-wrap: wrap;
            gap: 1em;
        }

        .right {
            margin-left: 0;
        }
    }
}
