/* COLORS  */
.pc .ram {
    background-color: var(--color-ram);
    color: var(--color-ram-text);
}

.pc .cu {
    background-color: var(--color-cu);
    color: var(--color-cu-text);
}

.pc .alu {
    background-color: var(--color-alu);
    color: var(--color-alu-text);
}

.pc .section h1.header {
    background-color: var(--color-header);
    color: var(--color-header-text);
}


/* TABLE COLORS */
.pc .ram .scroller table thead.head th {
    background-color: var(--color-table-ram-head);
    color: var(--color-table-ram-head-text);
}

.pc .cu .scroller table thead.head th {
    background-color: var(--color-table-cu-head);
    color: var(--color-table-cu-head-text);
}

.pc .scroller table tr td {
    background-color: var(--color-table-row);
    color: var(--color-table-text);
    border-bottom: 1px solid var(--color-table-border);
}

.pc .scroller table tr:nth-child(even) td{
    background-color: var(--color-table-row-alt);
}

.pc .scroller table tr.empty td {
    color: var(--color-table-text-empty);
}

.pc .ram .scroller table tr.current td {
    background-color: var(--color-table-ram-highlight);
    color: var(--color-table-ram-highlight-text);
}

.pc .cu .scroller table tr.current td {
    background-color: var(--color-table-cu-highlight);
    color: var(--color-table-cu-highlight-text);
}


.pc button,
.pc .button{
    text-transform: none !important;
    font-weight: 600;
    height: 2.5em;
    line-height: 1em;
    margin: 0;
    margin-bottom: .5em;
    vertical-align: top;
    padding: 0.25em 2em;
    font-size: 0.75em;
}

/* CONTROLS COLORS */
.pc .controls .checker::before {
    border: 1px solid var(--color-controls-button-border);
}

.pc .controls .checker.checked::before {
    color: var(--color-controls-button-text);
}



/* FORMATTING STUFF */

.pc {
    /*height: 400px;
    height: 99vh;*/

    box-sizing: border-box;

    padding: 1em;

    display: grid;
    grid-template-columns: auto auto auto;
    /* grid-template-columns: max-content auto max-content; */
    gap: 9px;
}

.pc .grid-fullwidth{
    grid-column: 1 / span 3;
}

.pc .pc-main {
    width: 100%;
    grid-column: 1 / span 3;
}

.pc .pc-main > div {
    /*height: 400px;
    height: 99vh;*/
    width: 100%;

    box-sizing: border-box;

    padding: 1em 0;

    display: grid;
    grid-template-columns: auto auto auto;
    /* grid-template-columns: max-content auto max-content; */
    gap: 9px;
}

.pc .section {
    min-height: 25em;
    max-height: calc(80vh - 8em);
    min-width: 20%;

    box-sizing: border-box;
    padding: 2.5em 1em 1em 1em;

    display: flex;
    flex-direction: column;

    position: relative;
    /*top: 0;
    left: 0;*/
}

.pc .section h1.header {
    font-size: 1.2em;
    position: absolute;
    top: 3px;
    left: 4px;
    padding: 3px;
}

.pc .row {
    display: flex;
    justify-content: space-evenly;
}

.pc .scroller {
    overflow-x: auto;
    overflow-y: scroll;

    /*position: relative;*/

    /* max-height: 60%; */
    padding: 0;
    box-sizing: border-box;

    width: 100%;
    margin: 1em 0 0 0;
}

/*.pc .scroller:last-child {
    margin-bottom: -1em;
}*/

.pc .scroller table {
    margin: 0;
}

.pc .scroller table thead.head {
    position: sticky;
    top: -2px;
    left: 0;
    /*height: 1em;*/
    /*padding: 1em;*/
    font-size: .8em;

    transition: 0.2s;
}

.pc .scroller table thead th {
    position: -webkit-sticky;
    position: sticky;
    top: 0;
    width: min-content;
}
.pc .scroller table thead th:last-child {
    width: max-content;
}

.pc .scroller table thead.head.shrunk {
    /*height: .5rem;*/
    /*font-size: .8em;*/
}

.pc .scroller table thead.head th {
    padding: .2em 3px;
    transition: 0.2s;
    text-align: center;
    /*border: 1px solid black !important;*/
}

.pc .scroller table thead.head.shrunk th {
    /*padding-top: .2em;
    padding-bottom: .2em;*/
}

.pc .scroller table .num {
    text-align: right;
    white-space: nowrap;
}

.pc .scroller table td {
    padding: 6px 3px;
    vertical-align: baseline;
    /*border: 1px solid black !important;*/
}

.pc .scroller table tr td:first-child {
    padding: 12px 8px;
}

.pc .scroller table tr.empty td:first-child {
    padding: 3px 8px;
}

.pc .cu .scroller table tr.empty select {
    padding: 3px 8px;
    height: min-content;
}

.pc .scroller table tr td :last-child {
    margin: 0;
}

.pc .scroller tr:first-child td {
    padding-top: 1.5rem !important;
}

/*.pc .ram .comment {
    padding: 12px 5px;
}*/

.pc .scroller table tbody button:last-child {
    text-decoration: none;
    text-transform: none;
    height: max-content;
    line-height: 2em;
    font-weight: normal;
    font-size: inherit;
    padding: 0px 10px;
}

th.address {
    width: 5rem;
    padding-left: 8px;
    text-align: right;
}

.pc input[type=number] {
    margin: 0 .5em 0 0;
    padding: 0 .25em;
    height: 2.5rem;
    line-height: 1em;
}

.pc input[type=number].instruction {
    width: 4.5em !important;
    margin-left: auto;
    margin-right: 0;
}

.pc input[type=number].address {
    width: 6em !important;
}

.pc .cu input[type=number].address {
    width: 100% !important;
    align-self: end;
    margin-left: auto;
    margin-right: 0;
}


/* CONTROLS */
.pc .controls > :not(:last-child) {
    margin-right: 0.75em;
}

.pc .controls .checker {
    display: inline-flex;
    align-items: center;
    padding-left: 3em;
}

.pc .controls .checker label {
    display: inline;
    /*font-size: 0.8em;*/
    white-space: initial;
    white-space: break-spaces;
    text-transform: none;
    width: 6em;
    width: min-content;
    vertical-align: middle;
    line-height: .9em;

    margin: 0;

    cursor: pointer;
}

.pc .controls input[type=checkbox]{
    display: none;
    margin-left: -1em;
    margin-right: 1em;
    opacity: 0;
    z-index: 0;
}

.pc .controls .checker::before{
    content: "✔";
    display: inline-block;
    width: 2rem;
    height: 2rem;
    color: rgba(0,0,0,0);
    border-radius: 4px;
    vertical-align: middle;
    margin: 0 .5em 0 -1em;

    line-height: 1.8rem;
    font-size: 1.4em;

    box-sizing: border-box;
}

/* END CONTROLS */

/* RAM */

.pc .ram .scroller {
    /* height: 100%; */
    /* padding: 0.2em; */
    box-sizing: border-box;
}

.pc .ram .scroller table {
    width: 100%;
}

.pc .ram input {
    background-color: var(--color-table-ram-select);
    color: var(--color-table-ram-select-text);
    border-color: var(--color-table-ram-select-border);
}

.pc .ram table tr td:nth-child(2){
    text-align: center;
}

.pc .ram .scroller table tbody tr:last-child button{
    background-color: var(--color-table-ram-select);
    color: var(--color-table-ram-select-text);
    border-color: var(--color-table-ram-button-border);
    width: 9.5em;
    height: 2.5rem;
    padding: 2px 1px;
    line-height: 1em;
}

.pc .ram .ram-entry:last-child {
    margin-right: 0 !important;
}

.pc .ram .comment input{
    border: none;
    margin: 0;
    font-size: .8em;
    width: 100%;
    padding: 0;
}


/* CONTROL UNIT */

.pc .cu p {
    margin: 0 0 .2em 0;
}

.pc .cu .scroller table {
    width: 100%;
}

.pc .cu .action-area {
    display: grid;
    grid-template-columns: 1fr min-content 0.5fr;
    grid-row-gap: 0.5em;
    grid-column-gap: 0.5em;
}

.pc .cu .input-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin: 0 0 .5em 0;
}

.pc .cu .input-row:last-child {
    margin: 0;
}

.pc .cu input {
    color: var(--color-cu-text);
    border-color: var(--color-cu-text);
    background-color: transparent;
}

.pc .cu input[type=number] {
    width: 100%;
}

.pc .cu label {
    display: inline;
    margin-bottom: 0;
}

.pc .cu select{
    margin: 0;
    width: 100%;

    background-color: var(--color-table-cu-select);
    color: var(--color-table-cu-select-text);
    border: 1px solid var(--color-table-cu-select-border);
}

.pc .cu .scroller table tbody tr:last-child button {
    background-color: var(--color-table-cu-select);
    color: var(--color-table-cu-select-text);
    border: 1px solid var(--color-table-cu-button-border);

    width: 100%;
    height: min-content;
    padding: 3px 15px;
    text-align: left;
}

.pc .cu .scroller table tr td:first-child {
    padding: 12px 12px 12px 8px;
}

.pc .cu button,
.pc .cu .button {
    height: 2.5rem;
    box-sizing: border-box;

    color: var(--color-cu-text);
    border-color: var(--color-cu-text);
    background-color: transparent;
    margin-bottom: 0;
}

.pc .modal .download-button {
    display: block;
    margin-bottom: 2em;
    padding: 2px 15px;
    font-weight: normal;
    font-size: inherit;
    height: min-content;
    line-height: 1.6;
}

.pc .action-button {
    width: 8em;
    padding: 4px;
}

.pc .cu .input-group button {
    width: 10em;
}

/* ALU */
.pc .alu input, .pc .alu .button, .pc .alu button{
    color: var(--color-alu-text);
    border-color: var(--color-alu-text);
    background-color: transparent;
}

.pc .alu input {
    width: 100%;
}

.pc .alu button {
    margin-right: 1em;
}

.pc .alu button:last-child {
    margin-right: 0;
}

.pc .alu .button-group-alu__2-elements {
    display: grid;
    grid-template-columns: 1fr 1fr;
}

.pc .alu .button-group-alu__4-elements {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr 1fr;
}

/* BUSSES */

.pc .databus,
.pc .addressbus{
    /*position: relative;*/
    text-align: left;

    margin: 0;
    padding: .75em .5em;
}
.pc .databus .label,
.pc .addressbus .label {
    /* position: absolute; */
    /* left: .5em; */
    margin-right: 1em;
}

.pc .addressbus input {
    color: var(--color-addressbus-text);
    border-color: var(--color-addressbus-text);
    background-color: var(--color-addressbus);
}

.pc .databus input {
    color: var(--color-databus-text);
    border-color: var(--color-databus-text);
    background-color: var(--color-databus);
}

.pc .addressbus {
    margin-bottom: 2em;

    background-color: var(--color-addressbus);
    color: var(--color-addressbus-text);
}

.pc .databus {
    margin-top: 2em;

    background-color: var(--color-databus);
    color: var(--color-databus-text);
}

/* ARROWS */
.pc .arrow-line {
    display: flex;
    justify-content: space-around;

    height: 0;
    width: 100%;
}

.pc .arrow {
    width: 3rem;
    height: 5rem;

    --transformation: translate(0, -2rem);
    transform: var(--transformation);
    -moz-transform: var(--transformation);
    -webkit-transform: var(--transformation);
    -o-transform: var(--transformation);

    color: var(--color-arrow-text);
    background-color: var(--color-arrow);

    /* Arrow Label */
    display: flex;
    justify-content: center;
    align-items: center;

    z-index: 100;
}

.pc .arrow > :nth-child(1) {
    /* Arrow Label Field */
    color: var(--color-arrow-text) !important;
    background-color: var(--color-arrow) !important;
    border-color: var(--color-arrow-text) !important;

    
    padding: 2px 10px;
    margin: 0;
}

.pc .arrow * {
    z-index: 1000;

    /* Arrow Label Text */
    color: var(--color-arrow-text) !important;
    font-size: 1rem !important;
    line-height: 1.1em !important;
    font-weight: 600 !important;
    text-transform: none !important;
    white-space: normal !important;
    height: min-content !important;
}

.pc .arrow :nth-child(2) {
    /* Arrow Head */
    height: 0;
    width: 0;

    border-left:    2.5rem solid transparent;
    border-right:   2.5rem solid transparent;
    border-top:     2rem solid transparent;
    border-bottom:  2rem solid var(--color-arrow);

    position: absolute;
    left: -1rem;
    bottom: 5rem;
}


.pc .arrow-line.top {
    position: absolute;
    top: 0;
}

.pc .arrow-line.bottom {
    position: absolute;
    bottom: 0;
}


.pc .arrow-line.top .arrow.up {
    --transformation: translate(0, -2.5rem);
}
.pc .arrow-line.bottom .arrow.up {
    --transformation: translate(0, -0.5rem);
}


.pc .arrow-line.top .arrow.down {
    --transformation: translate(0, -4.5rem) rotate(180deg);
}
.pc .arrow-line.bottom .arrow.down {
    --transformation: translate(0, -2.5rem) rotate(180deg);
}
.pc .arrow-line.top .arrow.down :nth-child(1) {
    --transformation: rotate(180deg);

    transform: var(--transformation);
    -moz-transform: var(--transformation);
    -webkit-transform: var(--transformation);
    -o-transform: var(--transformation);
}

.pc .arrow-line.bottom .arrow.down :nth-child(1) {
    --transformation: rotate(180deg);
    
    transform: var(--transformation);
    -moz-transform: var(--transformation);
    -webkit-transform: var(--transformation);
    -o-transform: var(--transformation);
}


/* MODALS */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    z-index: 1000;

    box-sizing: border-box;
    width: 100vw;
    height: 100vh;

    display: flex;
    align-items: center;
    justify-content: center;
}
.modal.hidden {
    display: none;
}

.modal-card {
    z-index: 1500;
    display: block;
    width: 40em;
    min-width: 45vw;
    min-height: 5em;
    position: relative;
    box-sizing: border-box;

    padding: 2.5em 2em 1em 2em;

    background-color: var(--color-modal);
    color: var(--color-modal-text);
}

.modal > :first-child {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;

    background-color: var(--color-modal-shadow);
}

.modal .modal-close {
    position: absolute;
    top: .5em;
    right: .5em;

}

.modal .modal-close::before {
    content: "❌";
    cursor: pointer;
}

.modal .scroller table {
    width: 100%;
}

.input-group > *{
    margin-right: 0.5em !important;
}
.input-group :last-child {
    margin-right: 0;
}


@media(max-width: 1000px){
    .pc{
        grid-template-rows: auto max-content auto;
        justify-items: center;
        /*overflow-x: hidden;*/
    }

    .pc .section {
        grid-column: 2;
        width: 100%;

        min-height: 25rem;
        max-height: 50rem;
    }

    .pc .controls {
        text-align: center;
    }

    .pc .grid-fullwidth.grid-addressbus,
    .pc .grid-fullwidth.grid-databus {
        --width: 5rem;
        --text-height: 32rem;
        --margin-side: 3rem;

        width: var(--width);
        box-sizing: border-box;
        grid-row: 1 / span 3;

        position: relative;
        padding-bottom: calc(var(--text-height) - var(--width));
    }

    .pc .grid-fullwidth.grid-addressbus {
        grid-column: 1;

        background-color: var(--color-addressbus);
        color: var(--color-addressbus-text);

        justify-self: flex-end;
        margin-right: var(--margin-side);
    }
    .pc .grid-fullwidth.grid-databus {
        grid-column: 3;

        background-color: var(--color-databus);
        color: var(--color-databus-text);

        justify-self: flex-start;
        margin-left: var(--margin-side);
    }



    .pc .grid-fullwidth.grid-addressbus > *,
    .pc .grid-fullwidth.grid-databus > * {
        position: sticky;
        top: 6em;
        left: 0;
        margin: 0;
        box-sizing: border-box;

        height: var(--width);
        width: var(--text-height);

        --transformation: rotate(-90deg) translate( calc(var(--width) / 2 - 50%), calc( 50% - var(--text-height) / 2));
        transform: var(--transformation);
        -moz-transform: var(--transformation);
        -webkit-transform: var(--transformation);
        -o-transform: var(--transformation);

        background-color: transparent;

        padding-right: 1em;
        text-align:  right;
    }

    .pc .grid-fullwidth.grid-databus > * {
        float: right;
        --transformation:  rotate(-90deg) translate( calc(var(--width) / 2 - 50%), calc( -50% + var(--text-height) / 2));
    }

    .pc .grid-fullwidth.grid-addressbus input,
    .pc .grid-fullwidth.grid-databus input {
        margin-right: 0;
    }

    .pc .controls.grid-fullwidth {
        grid-column: 1 / span 3;

        position: sticky;
        top: 0;
        z-index: 1000;
        background-color: var(--color-body);
        margin: -1rem;
        padding: 1rem;
        border-bottom: 1px solid var(--color-controls-button-border);
        width: 100%;
    }

    .pc .arrow-line {
        width: 0;
        height: 100%;

        flex-direction: column;
    }

    .pc .arrow-line.top {
        left: 0;
    }

    .pc .arrow-line.bottom {
        right: 0;
    }

    .pc .arrow-line.top .arrow.up {
        --transformation: rotate(-90deg) translate(0, -2.85rem);
    }
    .pc .arrow-line.bottom .arrow.up {
        --transformation: rotate(-90deg) translate(0, 0.75rem);
    }


    .pc .arrow-line.top .arrow.down {
        --transformation: rotate(90deg) translate(0, 4.5rem);
    }
    .pc .arrow-line.bottom .arrow.down {
        --transformation: rotate(90deg) translate(0, 0.1rem);
    }

    .pc .alu {
        text-align: center;
    }

}


@media(max-width: 800px){
    .pc .cu .input-row {
        display: block;
        padding-left: 2rem;
    }

    .pc .cu .input-row label {
        display: block;
    }
}