html {
    --max-screen-width: calc(100vw - var(--panel-gap)*2);
    --max-panel-width: calc(100vw - var(--panel-gap)*2);
    overflow: hidden;
    scrollbar-width: none;

    position: fixed;
}

* {
    font-family: 'Trebuchet MS';
    font-size: 25px;
    color: var(--color-text);
}

body {
    display: flex;

    flex-flow: row nowrap;
    gap: var(--panel-gap);
    justify-content: space-between;
    align-content: stretch;

    width: var(--max-screen-width);
    height: calc(100vh - var(--panel-gap)*2);

    margin: 0px;
    padding: var(--panel-gap);

    background-color: var(--color-bg);

    overflow: auto;
    scrollbar-width: none;

    scrollbar-width: thin;
}

#main-layout {
    display: flex;

    height: calc(100vh - var(--panel-gap)*2);

    flex-direction: column;

    align-items: flex-start;
    justify-content: flex-start;

    flex-grow: 1;
    flex-shrink: 0;
}

/* DEBUGGER */

#debug {
    display: flex;

    flex-flow: column nowrap;

    width: 300px;
}

#debug h1 {
    width: 100%;
    height: auto;

    margin: 0px;
}

#debug .debug-menu {
    display: flex;

    flex-flow: row nowrap;
    justify-content: space-between;

    margin-right: 0px;

    font-size: 1em;
}

#debug .debug-menu button {
    font-size: inherit;
    padding: 3px;
}

#debug hr {
    width: 100%;
    margin-top: 5px;
    margin-bottom: 5px;

    color: var(--color-ui);
}

#program-debug {
    display: flex;
    flex-flow: column nowrap;

    height: 100%;
}

#program-debug .profiler label {
    display: block;

    font-size: 20px;

    color: var(--color-text);

    pointer-events: none;
}

#program-debug .profiler label::selection {
    background-color: transparent;
}

#registers {
    display: flex;

    flex-flow: column wrap;
    align-content: space-evenly;
    justify-content: flex-start;

    height: 32em;
    line-height: 2em;

    font-size: 0.5em;
}

#registers span {
    flex-grow: 0;
    flex-shrink: 0;

    width: 5em;

    font-size: inherit;

    color: var(--color-ui);

    cursor: default;
    user-select: none;
    white-space: pre;

    transition: color 0.25s;
}

#registers span.highlight {
    color: var(--highlight-color);
    font-weight: bold;
    transition: color 0s;
}

#registers span.used {
    color: var(--color-ui-active);
    font-weight: bold;
}

#registers span:hover {
    color: var(--color-text);
    transition: color 0s;
}

#registers span::selection {
    background-color: transparent;
}

#debug .screen {
    display: none;

    flex-flow: column nowrap;
    align-items: center;
    justify-content: center;

    gap: 5px;
}

#debug .screen canvas {
    aspect-ratio: 4/3;
    width: calc(100% - 10px);
    background-color: var(--color-console);
    image-rendering: pixelated;
}

#memory-debug {
    display: none;
    flex-flow: column nowrap;
    gap: 5px;

    overflow: hidden;
}

#memory-debug .mem-menu {
    width: 100%;

    margin: 0px;
    padding: 0px;

    font-size: 16px;
}


#memory-debug .mem-menu * {
    font-size: inherit;
    display: inline-block;
    width: auto;
}

#memory-debug .mem-menu button {
    aspect-ratio: 1;
}

#memory {
    display: flex;

    flex-flow: column wrap;
    align-content: space-evenly;
    justify-content: flex-start;

    height: calc(1.25em*33);
    line-height: 1.25em;

    font-size: 0.5em;
}

#memory span {
    flex-grow: 0;
    flex-shrink: 0;

    width: 5em;

    font-size: inherit;

    color: var(--color-ui-active);

    cursor: default;
    user-select: none;
    white-space: pre;

    transition: color 0.25s;
}

.container {
    display: flex;

    gap: var(--panel-gap);
}

.panel {
    padding: 5px;

    background-color: var(--color-panel);
    border-radius: 3px;
}

.menu-container {
    display: flex;

    flex-flow: wrap;

    max-width: var(--max-panel-width);
    width: 100%;
}

.title-container {
    flex-shrink: 1;
    flex-grow: 0;

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

.title {
    font-size: 10;
    font-weight: bold;

    margin: 0px;
    padding: 0px;

    cursor: default;
}

.run-container {
    flex-shrink: 1;
    flex-grow: 0;
}

.zoom-container {
    flex-shrink: 1;
    flex-grow: 0;
}

.options-container {
    flex-shrink: 1;
    flex-grow: 1;

    align-items: stretch;
    justify-content: flex-start;

    min-height: calc(1em + 10px);
}

.options-container #syntax-option {
    margin-left: auto;
}

.ide-container {
    display: flex;

    flex-grow: 1; /*Editor area full height*/
    width: 100%;/*calc(100vw - var(--panel-gap)*2);*/

    justify-items: flex-start;

    overflow-y: scroll;
    overflow-x: hidden;
    scrollbar-width: none;
}

/* EDITOR FONT SETTINGS */

.editor-container, #lineNum {
    font-family: var(--editor-font);
    font-size: var(--editor-font-size);
    line-height: 1.2em;
}

.editor-container *, #lineNum * {
    font-family: inherit;
    font-size: inherit;
    line-height: inherit;
}

#lineNum {
    display: flex;

    flex-flow: column nowrap;
    align-items: stretch;
    gap: 0px;

    width: calc(2em + 5px);

    flex-shrink: 0;
    flex-grow: 0;

    margin: 0px;
    padding: 5px;

    word-break: keep-all;
    word-wrap: normal;

    overflow: hidden;
}

#lineNum span {
    display: block;

    text-align: right;

    border-left: 2px solid transparent;

    transition: all 0.1s;
}

#lineNum span.highlight {
    color: var(--highlight-color);
    border-left: 2px solid var(--highlight-color);
    background-color: var(--highlight-bg);

    transition: all 0s;
}

#lineNum span.flash {
    animation: lineNumFlash 3s ease-out;
}

@keyframes lineNumFlash {
    0% {
        color: var(--highlight-color);
        border-left: 2px solid var(--highlight-color);
        background-color: var(--highlight-bg);
    }

    100% {
        color: var(--color-text);
        border-left: 2px transparent;
        background-color: transparent;
    }
}

#lineNum span.error {
    color: var(--error-color);
    border-left: 2px solid var(--error-color);
    background-color: var(--error-bg);

    transition: all 0.25s;
}

#lineNum span.finish {
    color: var(--finish-color);
    border-left: 2px solid var(--finish-color);
    background-color: var(--finish-bg);

    transition: all 0.25s;
}

.editor-container {
    position: relative;
    display: flex;

    flex-grow: 1;

    /* 3gap + 2*2 padding (lineNUm + textarea) = 35px */
    --editor-width: calc( 100vw - (2em + 5px) - (var(--panel-gap)*3 + 4*5px) );
}

#editor {
    position: relative;
    display: block;

    flex-grow: 1;

    
    max-width: var(--editor-width);

    margin: 0px;
    padding: 5px;

    resize: none;
    outline: none;

    background-color: var(--color-panel);
    color: transparent;
    caret-color: var(--color-text);

    border: 0px transparent;
    border-radius: 3px;

    overflow: scroll;
    scrollbar-width: none;

    white-space: pre;

    transition: all 0.1s;
}

#syntaxHighlight {
    /* span pointer events*/
    --event: none;

    position: absolute;
    display: block;

    width: var(--editor-width);
    height: calc(100% - var(--panel-gap)*2);

    margin: 0px;
    padding: 5px;

    border: 0px transparent;
    border-radius: 3px;

    pointer-events: none;
    -webkit-user-select: none;
    user-select: none;

    overflow: hidden;

    white-space: pre;
    z-index: 1000;

    transition: all 0.1s;
}

#syntaxHighlight * {
    pointer-events: none;
}

#syntaxHighlight span:is( .func, .label, .const ) {
    pointer-events: var(--event);
}

#syntaxHighlight span:is( .func, .label, .const ):hover {
    text-decoration: underline;
}

#syntaxHighlight::selection, #syntaxHighlight *::selection {
    background-color: transparent;
}

.console-container {
    display: flex;

    flex-direction: column;
    flex-shrink: 0;

    width: calc(100% - var(--panel-gap));
    height: auto;
    min-height: 200px;

    padding: 3px;
}

.console-container-header {
    display: flex;
    flex-direction: row;

    gap: 5px;
}

.console-container-header h1 {
    width: calc(100% - 6px);
    height: auto;

    margin: 0px;
    margin-top: 5px;
    padding: 0px;
    padding-left: 5px;
}

.console-container-header button {
    aspect-ratio: 1/1;
    font-size: inherit;
    max-height: 34px;
}

#console, .screen-container {
    width: calc(100% - 6px);
    height: 200px;
    min-height: 200px;
    max-height: 75vh;

    margin: 0px;
    padding: 3px;

    background-color: var(--color-console);

    border: 0px transparent;
    border-radius: 3px;
}

#console {
    position: relative;

    font-family: var(--editor-font);

    resize: none;
    outline: none;

    word-break: break-all;
    word-wrap: normal;
}

.screen-container {
    display: none;
    flex-flow: row nowrap;

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

    background-color: var(--color-bg);
}

.screen-container canvas {
    aspect-ratio: 4/3;

    height: 100%;

    min-width: 50px;
    min-height: 50px;

    image-rendering: pixelated;

    background-color: var(--color-console);
}

#consoleInput {
    width: auto;
    height: 20px;

    padding: 5px;
    margin: 0px;
    margin-left: 2px;
    margin-right: 2px;

    font-family: var(--editor-font);

    background-color: var(--color-console);
    color: var(--color-input);;

    outline: none;

    border-width: 5px;
    border-style: solid;
    border-radius: 3px;
}

.inputDisabled {
    display: none;
    border-color: transparent;
    pointer-events: none;
}

.inputEmpty {
    opacity: 1;
    animation: borderFlash 1s linear infinite;
}

@keyframes borderFlash {
    0% {border-color: #666666;}
    50% {border-color: #aaaaaa;}
    100% {border-color: #666666;}
}

.inputGreen {
    opacity: 1;
    border-color: #88ff88;
}

.inputRed {
    opacity: 1;
    border-color: #ff8888;
}

input[type="number"] {
    text-align: center;

    min-width: 3rem;
    width: auto;
    max-width: 5rem;

    outline: transparent;
    white-space: pre;

    -moz-appearance: textfield;
}

input::-webkit-outer-spin-button,
input::-webkit-inner-spin-button {
  -webkit-appearance: none; 
  margin: 0;
}

input[type="number"]:focus {
    background-color: var(--color-ui-active);
}

.panel :is(button, a,  input) {
    background-color: var(--color-ui);

    border: 0px transparent;
    border-radius: 3px;

    cursor: pointer;

    transition: all 10ms;
}

.run-container button, .zoom-container button {
    width: 1.5em;
    aspect-ratio: 1/1;
}

.options-container a {
    display: flex;

    flex-flow: row nowrap;
    align-items: center;
    justify-content: center;
}

.options-container a div {
    display: flex;

    flex-flow: row wrap;
    align-items: center;
    justify-content: space-evenly;
    gap: 0.5em;

    font-size: inherit;

    padding: 5px;
}

.panel :is(button) {
    margin: 0px;
    padding: 0px 5px;
}

.panel :is(button, a):disabled {
    opacity: 0.5;
}

.panel :is(button, a):not(:disabled):hover {
    background-color: var(--color-ui-hover);
}

.panel :is(button, a):not(:disabled):active {
    background-color: var(--color-ui-active);
}

/* Tooltip */

[tooltip]::after {
    content: attr(tooltip);

    position: absolute;
    display: block;

    max-width: 10em;
    margin-top: 60px;
    margin-left: 2em;
    padding: .25em;

    color: #555;
    background-color: #aaa;
    
    border: 3px solid #555;
    border-radius: 5px;

    font-family: "Trebuchet MS";
    font-size: 16px;
    font-weight: bold;

    opacity: 0;
    pointer-events: none;
    z-index: 9999;

    transition: all 0.1s;
}

[tooltip]:hover::after {
    opacity: 1;
}

/* Square tooltip */

[tooltipS]::after {
    content: attr(tooltipS);

    position: absolute;
    display: block;

    max-width: 10em;
    padding: .25em;

    color: #555;
    background-color: #aaa;
    
    border: 3px solid #555;
    border-radius: 5px;

    font-family: "Trebuchet MS";
    font-size: 16px;
    font-weight: bold;

    opacity: 0;
    pointer-events: none;
    z-index: 9999;

    transition: all 0.1s;
}

[tooltipS]:hover::after {
    opacity: 0.8;
}

/* Phone friendly WIDTH */

@media screen and (max-width: 830px) {
    .options-container :is(button, a) {
        font-size: 3vw;
    }
}

/* Iconify */
@media screen and (max-width: 400px) {
    .options-container button {
        font-size: 0px;
    }

    .options-container a {
        font-size: 0px;
    }
}

/* Phone friendly HEIGHT */

@media screen and (max-height: 800px) {
    #console, .screen-container {
        height: 100px;
        min-height: 100px;
        max-height: 40vh;
    }

    .console-container {
        min-height: 100px;
    }
}

@media screen and (max-height: 600px) {
    #registers {
        font-size: 1.8vh;
    }
}

@media screen and (max-height: 640px) {
    #memory {
        font-size: 1.8vh;
    }
}