* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

/*************************************************
 * Layout                                        *
 *************************************************/

body {
    display: flex;
    flex-direction: column;

    gap: 1rem;
    padding: 1rem;

    /* ensure the body covers at least the whole screen */
    min-height: 100vh;

    font-family: sans-serif;
}

body>header {
    display: flex;
    flex-direction: row;
    align-items: center;
    padding: 0.25rem;
    gap: 1rem;
}

body>header ul {
    display: flex;
    flex-direction: row;
    gap: 0.5rem;
}

body>header ul li {
    display: inline-block;
}

body>header hr {
    width: 1px;
    display: block;
    align-self: stretch;
}

body>header search {
    width: 17em;
    display: flex;
    flex-direction: row;
}

body>header search input {
    flex: 1;
}

header>.site-title {
    font-size: 2em;
    font-weight: bold;
}

main#wiki {
    display: grid;

    grid-template-columns: min-content auto;
    grid-template-rows: max-content;

    gap: 1rem;
}


main#wiki nav {
    align-self: start;
}

main#syscalls {
    display: grid;

    grid-template-columns: 100%;
    grid-template-rows: auto;

    gap: 1rem;
}

main#livedemo {
    /* make the live demo always be a screen-covering part*/
    flex: 1;

    display: grid;

    grid-template-columns: 100%;
    grid-template-rows: min-content 1fr min-content;

    gap: 1rem;
}

/*************************************************
 * Styling                                       *
 *************************************************/

.panel,
.hdoc-admonition {
    padding: 0.5rem;
    border: 2px ridge silver;
    background-color: #EEE;
    box-shadow: black 4px 4px 8px;
}

.panel.breadcrumbs {
    padding: 0;
}

ul.breadcrumbs {
    display: block;
}

ul.breadcrumbs li {
    padding: 0;
    display: inline-block;
    list-style: none;
}

ul.breadcrumbs li a {
    padding: 0.5rem;
    display: inline-block;
}

ul.breadcrumbs li:hover {
    background-color: silver;
}

ul.breadcrumbs li:not(:first-of-type)::before {
    position: relative;
    left: -0.25em;
    width: 0;
    content: '.';
    display: inline-block;
    background-color: unset;
    pointer-events: none;
    text-align: center;
}


/*************************************************
 * Tree View                                     *
 *************************************************/

ul.treeview {
    padding-left: 1em;
}

ul.treeview li {
    list-style-type: "❓";
    white-space: nowrap;
}

ul.treeview li.folder {
    list-style-type: "📂";
    /* 📁 📂*/
}

ul.treeview li.file {
    list-style-type: "📄";
    /*📃📄📝📰🗎*/
}

ul.treeview li[data-indent="0"] {
    margin-left: 0em;
}

ul.treeview li[data-indent="1"] {
    margin-left: 1em;
}

ul.treeview li[data-indent="2"] {
    margin-left: 2em;
}

ul.treeview li[data-indent="3"] {
    margin-left: 3em;
}

ul.treeview li[data-indent="4"] {
    margin-left: 4em;
}

ul.treeview li[data-indent="5"] {
    margin-left: 5em;
}

ul.treeview li[data-indent="6"] {
    margin-left: 6em;
}

ul.treeview li[data-indent="7"] {
    margin-left: 7em;
}

ul.treeview li[data-indent="8"] {
    margin-left: 8em;
}

ul.treeview li[data-indent="9"] {
    margin-left: 9em;
}

div.flex-spacer {
    flex: 1;
    visibility: hidden;
}

/*************************************************
 * Code Doc Theming                              *
 *************************************************/

.docs-container h1 {
    border-bottom: 1px dashed;
    margin-bottom: 1em;
}

.docs-container h2 {
    border-bottom: 1px solid;
    margin-top: 1em;
    margin-bottom: 0.5em;
}

.docs-container ul {
    column-width: 15em;
    margin-left: 2em;
}

.docs-container dl {
    display: grid;
    gap: 0.5em;
    grid-template-columns: 100%;
}

.docs-container dl>div {
    border: 1px solid;
    padding: 0.5em;
    border-color: #373737;
}

.docs-container dl dd p {
    margin-left: 2rem;
    margin-top: 0.5em;
    margin-bottom: 0.5em;
}

/*************************************************
 * Syntax Highlighting                           *
 *************************************************/

code .tok-kw {
    color: blue;
}

code .tok-type {
    color: slateblue;
}

code .tok-name {
    color: purple;
}

/*************************************************
 * Markdown Theming                              *
 *************************************************/

* {
    --markup-block-spacing: 0.75em;
    --hdoc-callout-bar-width: 3rem;
    --hdoc-callout-icon-size: 1.5rem;
}

.markup-container {
    overflow-x: auto;
}

.markup-container ul,
.markup-container ol {
    margin-left: 1.5em;
}

.markup-container h1~p.hdoc-doc-meta {
    opacity: 50%;
}

.markup-container header {
    border-bottom: 1px dashed black;
}

.markup-container :is(h2, h3, h4, h5, h6) {
    margin-top: 1em;
}

/* Paragraph */
.markup-container :is(p, ul, ol, table, pre) {
    line-height: 125%;
    margin-block: 0.75em;
}

.markup-container li :is(p, ul, ol, table, pre) {
    margin-block-start: 0;
    margin-block-end: 0;
}

.hdoc-tip {
    --hdoc-callout-icon: "💡";
    --hdoc-callout-color: green;
    --hdoc-callout-bg: #ecfdf5;
}

.hdoc-note {
    --hdoc-callout-icon: "ℹ️";
    --hdoc-callout-color: cornflowerblue;
    --hdoc-callout-bg: #eff6ff;
}

.hdoc-warning {
    --hdoc-callout-icon: "⚠️";
    --hdoc-callout-color: gold;
    --hdoc-callout-bg: #fffbeb;
}

.hdoc-danger {
    --hdoc-callout-icon: "🛑";
    --hdoc-callout-color: crimson;
    --hdoc-callout-bg: #fef2f2;
}

.markup-container .hdoc-admonition {
    margin-block: 1em;
    position: relative;
}

.markup-container :is(.hdoc-tip, .hdoc-note, .hdoc-warning, .hdoc-danger) {
    background-color: var(--hdoc-callout-bg);
    padding-left: var(--hdoc-callout-bar-width);
    position: relative;
    min-height: var(--hdoc-callout-bar-width);

    padding-top: 0.25em;
    padding-bottom: 0.25em;
}


.markup-container :is(.hdoc-tip, .hdoc-note, .hdoc-warning, .hdoc-danger)::before {
    display: flex;
    content: var(--hdoc-callout-icon);
    position: absolute;
    left: 0;
    top: 0;
    height: 100%;

    width: var(--hdoc-callout-bar-width);
    font-size: var(--hdoc-callout-icon-size);
    align-items: center;
    justify-content: center;
    border-left: 3px solid var(--hdoc-callout-color);
}

.markup-container .hdoc-admonition.hdoc-quote::before {
    display: block;
    content: '❝';
}

.markup-container .hdoc-admonition.hdoc-quote::after {
    display: block;
    content: '❞';
    text-align: right;
}

.markup-container .hdoc-admonition.hdoc-spoiler::before {
    display: block;
    content: "Spoiler! (hover to reveal)";
    opacity: 50%;
    font-size: 75%;
}

.markup-container .hdoc-admonition.hdoc-spoiler>* {
    filter: blur(6px);
    transition: filter 120ms ease;
}

.markup-container .hdoc-admonition.hdoc-spoiler:hover>*,
.markup-container .hdoc-admonition.hdoc-spoiler:focus-within>*
.markup-container .hdoc-admonition.hdoc-spoiler[tabindex="0"]:focus>* {
    filter: none;
    transition: filter 120ms ease;
}

.markup-container .hdoc-footnotes {
    font-size: 75%;
}

.markup-container .hdoc-footnotes ol li {
    list-style-type: decimal;
}

.markup-container pre {
    display: block;
    border: 1px solid gray;
    padding: 0.5em;
    overflow-x: auto;
}

.markup-container figure {
    text-align: center;
}

.markup-container table {
    border-collapse: collapse;
    min-width: 100%;
}

.markup-container table thead :is(th),
.markup-container table tbody :is(tr, th, td) {
    border: 1px solid gray;
}

.markup-container table :is(th, td) {
    padding: 0.25rem;
}


.markup-container table :is(th, td) p {
    margin-block: 1.25em;
    margin-block-start: 0;
    margin-block-end: 0;
}


.markup-container table th[scope="row"] {
    border-right: 1px solid gray;
    text-align: left;
}

.markup-container table th[scope="rowgroup"] {
    padding-top: 1rem;
    text-align: left;
}

.markup-container table tr:has(th[scope="rowgroup"]) td {
    border-right: 1px solid silver;
}

.markup-container table tr:has(th[scope="rowgroup"]) th {
    border-left: 1px solid silver;
}

.markup-container table thead th,
.markup-container table tbody tr:nth-of-type(even) {
    background-color: rgba(0, 0, 0, 5%);
}

.markup-container table thead td.top-left {
    visibility: hidden;
}

.markup-container img {
    max-width: 100%;
}

/*************************************************
 * Live Demo                                     *
 *************************************************/

.toolbar {
    display: flex;
    flex-direction: row;
    gap: 0.5rem;
}

.toolbar button {
    height: 2rem;
    padding: 2pt;
    border: 2px outset silver;
    background-color: #DDD;
}

.toolbar button:not(:disabled):active {
    border: 2px inset silver;
    background-color: #FFF;
}

.toolbar button:not(:disabled):is(:hover, :focus) {
    background-color: #EEE;
}

.toolbar button svg {
    width: 100%;
    height: 100%;
}

.toolbar button:disabled {
    background-color: gray;
}

.toolbar button:disabled svg {
    fill: silver;
}

.console {
    min-height: 180pt;
}

/* textarea.console {
    resize: none;

    overflow: scroll;

    height: 12em;
    padding: 0.25rem;

    background-color: #000;
    color: #FFF;

    width: 100%;
    tab-size: 2em;

    border: 1px solid black;
} */

.monitor-parent {
    display: grid;

    align-items: center;
    justify-items: center;

    overflow: auto;
    position: relative;
}

.monitor {
    border: 3px inset silver;
    max-width: 100%;
}

#emulator_status {
    display: flex;
    flex-direction: column;

    position: absolute;
    left: 0.5rem;
    top: 0.5rem;
}

#emulator_status li {
    list-style: none;
}

#emulator_status li label {
    font-family: monospace;
}

button#launch_button {
    border: 1px solid black;
    border-radius: 100%;
    width: 6rem;

    margin-left: auto;
    margin-right: auto;
    display: block;

    background-color: white;
}

button#launch_button ~ p {
    font-size: 75%;
    max-width: 20em;
    margin-top: 1em;
    text-align: center;
} 

#livedemo:not(.launched) #screen_container,
#livedemo:not(.launched) #emulator_status {
    display: none;
}

#livedemo.launched .hide-when-launched {
    display: none;
}