:root {
    --menu: orange;
    --menu-reuna: darkorange;
    --sync-ok: lightgreen;
    --sync-error: red;
}
* {
    box-sizing: border-box;
}
:nth-child(1) {
  --index: 1;
}
:nth-child(2) {
  --index: 2;
}
:nth-child(3) {
  --index: 3;
}
:nth-child(4) {
  --index: 4;
}
:nth-child(5) {
  --index: 5;
}
:nth-child(6) {
  --index: 6;
}
:nth-child(7) {
  --index: 7;
}
:nth-child(8) {
  --index: 8;
}
:nth-child(9) {
  --index: 9;
}
:nth-child(10) {
  --index: 10;
}
:nth-child(11) {
  --index: 11;
}
:nth-child(12) {
  --index: 12;
}
:nth-child(13) {
  --index: 13;
}
:nth-child(14) {
  --index: 14;
}
:nth-child(15) {
  --index: 15;
}
:nth-child(16) {
  --index: 16;
}
:nth-child(17) {
  --index: 17;
}
:nth-child(18) {
  --index: 18;
}
:nth-child(19) {
  --index: 19;
}
:nth-child(20) {
  --index: 20;
}
:nth-child(21) {
  --index: 21;
}
:nth-child(22) {
  --index: 22;
}
:nth-child(23) {
  --index: 23;
}
:nth-child(24) {
  --index: 24;
}
:nth-child(25) {
  --index: 25;
}
:nth-child(26) {
  --index: 26;
}
:nth-child(27) {
  --index: 27;
}
:nth-child(28) {
  --index: 28;
}
:nth-child(29) {
  --index: 29;
}
:nth-child(30) {
  --index: 30;
}

html {
    height: 100%;
}
body {
    margin: 0;
    height: 100%;
    overflow: hidden;
    background-color: white;
}

a {
    text-decoration: none;
}
ul {
    list-style: none;
    white-space: nowrap;
    margin: 0;
    padding: 0;
}
h2 {
    margin: 0 0;
    text-align: center;
    font-weight: lighter;
    font-size: medium;
    line-height: 1.4rem;
    font-variant: small-caps;
    white-space: nowrap;
    background-color: lightgray;

    span {
        padding: 0 0.5rem;
    }
}
label {
    white-space: nowrap;
    display: flex;
}
iframe {
    width: 100%;
    height: calc(100% - 1.5rem);
    border: 0;
    flex-grow: 1;
}

header {
    position: absolute;
    z-index: 99;
    padding-top: 1.6rem;
    width: 4rem;
    height: 0;
    overflow: hidden;
    background: var(--menu);
    opacity: 0.75;
    border-radius: 0 0 10px 0;

    &:hover {
        width: auto;
        overflow: visible;
        background: transparent;
        opacity: 1;
    }

    .iframe {
        display: none;
    }
    h2 {
        border-radius: 5px;
        padding: 2px;
        margin: 1px;
    }

    fieldset {
        width: 7rem;
        padding: 0;
        border: 0;

        &:hover .content {
            display: flex;
            margin-left: 6.5rem;
            margin-top: calc(-2rem + 1px);
            border-radius: 10px;
        }

        legend {
            padding: 3px 3px 8px 3px;
            background: var(--menu);
            border-radius: 0 0 10px 0;
            border-top: 1px solid var(--menu-reuna);
            width: 100%;
        }
        section label {
            border-top: 1px solid var(--menu-reuna);
        }
    }

    .content {
        display: none;
        
        position: absolute;
        flex-direction: column;
        background: var(--menu);
        padding: 0.5rem 0.5rem 0.5rem 0.5rem;
        text-align: right;
    }

    .layouts {
        table {
            width: 3rem;
            margin: 1px 0;
            margin-right: 0.5rem;
            height: 1.5rem;
            border-collapse: collapse;
        }
        td {
            border: 1px solid gray;
            background: white;
            border-style: dotted dotted;
        }
        .rows td {
            border-style: solid dotted;
        }
        .cols td {
            border-style: dotted solid;
        }
    }
}

.content> label, h2 {
    &:hover {
        background-color: gainsboro;
    }
}

input[name="layout"] {
    display: none;
}

select[name="refresh"]:invalid {
    color: lightgray;
}

.actions {
    display: none;
    float: right;
    a, button {
        vertical-align: text-top;
    }
    select {
        padding: 0;
        border: none;
        vertical-align: top;
    }
    button {
        background: transparent;
        border: none;
    }
    > * {
        padding: 0 0.5rem;
        opacity: 0.7;
        &:hover {
            color: white;
            opacity: 1;
        }
    }
    input[name="sync"] {
        opacity: 0.5;
        &:checked {
            opacity: 1;
            accent-color: var(--sync-ok);
        }
    }
}

main {
    height: 100%;

    .actions {
        display: flex;
    }

    input[name="fullscreen"] {
        margin-right: 0.5rem;
    }

    &:has(input[name="fullscreen"]:checked) {
        grid-template-rows: 1fr;
        grid-template-columns: 1fr;

        section {
            display: none;
        }
    }

    section[data-id="_placeholder_"] {
        display: none;
    }
    &:not(:has([data-id]:not([data-id="_placeholder_"]))) section[data-id="_placeholder_"] {
        display: block;
    }

    section {
        margin: 3px;
        border: 1px solid black;
        border-radius: 5px;
        overflow: hidden;
        display: flex;
        flex-direction: column;

        &:has(input[name="fullscreen"]:checked) {
            display: block;
        }

        .carousel {
            display: none;
            position: absolute;
            bottom: 0.5rem;
            background-color: white;
            width: 1rem;
            height: 1rem;
            border-style: solid;
            border-width: 2px;
            border-color: black;
            border-radius: 1rem;
            left: calc(50% + 1rem + 1.8rem*var(--section-index));

            :target & {
                background: radial-gradient(black 0%, black 50%, white 50%);
            }
            
            transition: opacity 1s, transform 0.5s, background-color 250.0ms ease 0.0s;
            opacity: 1;
            @starting-style {
                opacity: 0;
                transform: translateY(1.5em);
            }
        }

        &:nth-child(1 of section[id]):nth-last-child(1 of section[id]),
        &:nth-child(1 of section[id]):nth-last-child(1 of section[id]) ~ section {
            .carousel {
                margin-left: -8rem;
            }
        }
        &:nth-child(1 of section[id]):nth-last-child(2 of section[id]),
        &:nth-child(1 of section[id]):nth-last-child(2 of section[id]) ~ section {
            .carousel {
                margin-left: -9rem;
            }
        }
        &:nth-child(1 of section[id]):nth-last-child(3 of section[id]),
        &:nth-child(1 of section[id]):nth-last-child(3 of section[id]) ~ section {
            .carousel {
                margin-left: -10rem;
            }
        }
        &:nth-child(1 of section[id]):nth-last-child(4 of section[id]),
        &:nth-child(1 of section[id]):nth-last-child(4 of section[id]) ~ section {
            .carousel {
                margin-left: -11rem;
            }
        }
        &:nth-child(1 of section[id]):nth-last-child(5 of section[id]),
        &:nth-child(1 of section[id]):nth-last-child(5 of section[id]) ~ section {
            .carousel {
                margin-left: -12rem;
            }
        }
        &:nth-child(1 of section[id]):nth-last-child(6 of section[id]),
        &:nth-child(1 of section[id]):nth-last-child(6 of section[id]) ~ section {
            .carousel {
                margin-left: -13rem;
            }
        }
        &:nth-child(1 of section[id]):nth-last-child(7 of section[id]),
        &:nth-child(1 of section[id]):nth-last-child(7 of section[id]) ~ section {
            .carousel {
                margin-left: -14rem;
            }
        }
        &:nth-child(1 of section[id]):nth-last-child(8 of section[id]),
        &:nth-child(1 of section[id]):nth-last-child(8 of section[id]) ~ section {
            .carousel {
                margin-left: -15rem;
            }
        }
        &:nth-child(1 of section[id]):nth-last-child(9 of section[id]),
        &:nth-child(1 of section[id]):nth-last-child(9 of section[id]) ~ section {
            .carousel {
                margin-left: -16rem;
            }
        }
        &:nth-child(1 of section[id]):nth-last-child(10 of section[id]),
        &:nth-child(1 of section[id]):nth-last-child(10 of section[id]) ~ section {
            .carousel {
                margin-left: -17rem;
            }
        }
        &:nth-child(1 of section[id]):nth-last-child(11 of section[id]),
        &:nth-child(1 of section[id]):nth-last-child(11 of section[id]) ~ section {
            .carousel {
                margin-left: -18rem;
            }
        }
        &:nth-child(1 of section[id]):nth-last-child(12 of section[id]),
        &:nth-child(1 of section[id]):nth-last-child(12 of section[id]) ~ section {
            .carousel {
                margin-left: -19rem;
            }
        }
        &:nth-child(1 of section[id]):nth-last-child(13 of section[id]),
        &:nth-child(1 of section[id]):nth-last-child(13 of section[id]) ~ section {
            .carousel {
                margin-left: -20rem;
            }
        }
    }
    
    h2:has(input[name="sync"]:checked) {
        &:has(input[name="connection"]:not([value=""])) {
            background-color: var(--sync-error);
        }
        &:has(input[name="connection"]:not([value=""]):checked) {
            background-color: var(--sync-ok);
        }
    }
}

@media (max-width: 800px) {
    /* Hide menu for small main Kali */
    #connection[value=""] ~ header {
        display: none;
    }
}
#connection:not([value=""]) {
    /* Hide menu for nested Kali */
    ~ header {
        display: none;
    }
    ~ main section:nth-child(1 of section[id]) {
        margin-left: 0;
    }
}

.trash {
    display: none;
    margin: 0.1rem 0.1rem;
    padding: 0.1rem;
    font-size: 2rem;
    border: 1px dotted black;
    border-radius: 5px;
    background: darkseagreen;
    width: min-content;

    * {
        display: none;
    }
}
.moving {
    header {
        width: auto;
        height: auto;
    }
    main {
        margin-left: 3rem;
    }
    .trash {
        display: block;
    }
}