* {
    margin: 0;
    padding: 0;
    font-family: IBM Plex Mono, monospace;
}

html, body {
    margin: 0;
    height: 100vh;
    overflow: hidden;
    overscroll-behavior-y: none;
    color: #ffffff;
    background-color: #131313;
}

body {
    display: flex;
}

#sidebar {
    background-color: #131313;
    width: fit-content;
    min-width: 5rem;
    height: 100%;
    border-right: 1px solid #272727;
    padding: .5rem;

    display: flex;
    flex-direction: column;
    gap: 3rem;

    > .logo > img {
        height: 2.5rem;
        display: flex;
        margin-inline: auto;
    }

    > .thingies {
        gap: .5rem;
        display: flex;
        flex-direction: column;
        font-size: .8rem;

        &.settings {
            > .thingy {
                gap: .2rem;

                &[data-settings="brightness"] {
                    position: relative;

                    &::after {
                        position: absolute;
                        content: attr(data-brightness);
                        font-size: .5rem;
                        top: 13px;
                    }
                }

                &[data-settings="modes"] {
                    display: none;
                }

            }
        }

        > .thingy {
            display: flex;
            flex-direction: column;
            align-items: center;
            padding-block: .2rem;
            border-radius: .5rem;
            cursor: pointer;
            transition: background-color .1s ease-in-out;
    
            &.active {
                background-color: #272727;
            }
    
            > img {
                height: 2.4rem;
            }
        }
    }

}

main {
    background-color: #151617;
    flex-grow: 1;
    height: 100%;
    display: grid;
    place-content: center;

    > [data-mode] {
        position: relative;
    }

    > [data-mode="clock"] {
        > .time {
            display: flex;
            align-items: baseline;
            gap: 2rem;
            font-size: 10rem;

            > .second {
                font-size: 5rem;
            }
        }
        > .date {
            display: flex;
            gap: .5rem;
            font-size: 5rem;

            > .weekday {
                margin-left: .5rem;
            }
        }
    }

    > [data-mode="rgb_square"] {
        > .square {
            width: 256px;
            height: 256px;
            background:
                linear-gradient(to top left, #fffb2e, rgba(255, 153, 150, 0), #00b6ff),
                linear-gradient(to top right, #00ff1d, rgba(255, 153, 150, 0), #ff35ff) rgb(146 146 146);
            
            /* rotate this square clockwise infinitely */
            animation: rotate 1.5s linear infinite;
        }
    }

    > [data-mode="draw"] {
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 1rem;

        > div {
            > #drawing-canvas {
                cursor: crosshair;
                width: auto;
            }
        }
        
        > #draw-controls {
            display: flex;
            background-color: #131313;
            padding: .5rem 1rem;
            border-radius: .4rem;
            box-shadow: 0px 5px 20px 0px rgba(0, 0, 0, .2);
            filter: drop-shadow(0px 2px 15px rgba(0, 0, 0, .2));
            border: 1px solid #272727;

            > .dvdr {
                margin-block: auto;
                height: 57%;
                width: 1px;
                background-color: #272727;
                margin-inline: .75rem;
            }

            > .ctrl {
                display: flex;
                flex-direction: column;
                align-items: center;
                gap: .3rem;
                padding: .25rem .75rem;
                border-radius: .3rem;
                cursor: pointer;
                transition: background-color .1s ease-in-out;

                > img {
                    height: 2rem;
                }

                &[data-ctrl="picker"] {
                    > #color-input {
                        height: 2rem;
                        width: 2rem;
                        outline: 1px solid gray;
                        border-radius: .3rem;
                        cursor: pointer;
                        appearance: none;

                        &::-webkit-color-swatch-wrapper {
                            padding: 0;
                        }
                        &::-webkit-color-swatch {
                            border: none;
                        }
                    }
                }

            }
        }

    }

    > [data-mode="gif"],
    > [data-mode="image"] {
        position: relative;
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 1rem;
        
        &[data-has-gif="false"],
        &[data-has-image="false"] {
            > .canvas-and-grid-parent {
                display: none;
            }
            > #gif-remove,
            > #image-remove {
                display: none;
            }
        }
        &[data-has-gif="true"] > label[for="gif-input"],
        &[data-has-image="true"] > label[for="image-input"] {
            height: 4rem;
            width: 15rem;
        }

        &[data-has-gif="loading"] {
            > #gif-remove,
            > #gif-input,
            > label[for="gif-input"] {
                display: none;
            }
            > .loader {
                width: 100%;
                height: 100%;
                display: grid;
                position: absolute;
                place-content: center;
                justify-items: center;
                color: gray;

                > img {
                    width: 3rem;
                }
            }
        }
        > .loader {
            display: none;
        }

        > label[for="gif-input"],
        > label[for="image-input"] {
            width: 50vw;
            height: 30vh;
            display: flex;
            align-items: center;
            justify-content: center;
            border: dashed 1px gray;
            border-radius: 15px;
            background-color: #151617;
            z-index: 2;
            filter: drop-shadow(0px 2px 11px rgba(0, 0, 0, .4));
            cursor: pointer;
        }

        > #gif-remove,
        > #image-remove {
            cursor: pointer;
        }
    }

}

#brightness-dialog > .content {
    font-size: 5rem;
    text-align: center;
    display: flex;
    flex-direction: column;
    margin-bottom: .25rem;
    gap: .5rem;
    width: 15rem;

    > #brightness-mode-switch {
        align-self: center;

        > label {
            font-size: 1rem;
            justify-content: center;
        }
    }

    > #current-brightness-value {
        margin-top: .5rem;
    }

    > input[type="range"] {
        margin: 1rem;
        margin-block: 1rem .5rem;

        &:focus-visible {
            outline: none;
        }
        &:disabled {
            cursor: not-allowed;
            opacity: .5;
        }
    }
}

#info-dialog > .content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;

    > .dvdr {
        height: 1px;
        width: 100%;
        background-color: #272727;
    }

    > .main {
        display: grid;
        grid-template-columns: 10rem auto;
        justify-items: start;
        gap: .5rem 1.5rem;
        min-width: 20rem;
    
        > .info {
            display: contents;
    
            > div:nth-of-type(1) {
                justify-self: end;
            }
        }
    }

    > .device-info {
        display: grid;
        grid-template-columns: auto auto;
        align-items: center;
        gap: .75rem;

        > .info {
            display: grid;
            grid-template-columns: 5rem auto;
            gap: .5rem;

            > img {
                width: 3rem;
                place-self: center;
            }

            > .data {
                display: grid;
                grid-template-columns: 4rem 5rem;
                align-items: center;
                column-gap: .5rem;
                
                > div:nth-of-type(2n-1) {
                    color: #a1a1a1;
                }
                > div:nth-of-type(2n) {
                    justify-self: start;
                }
            }
        }
    }

}





/* yaaahh .. its mobile time */
@media (max-width: 535px) {

    html, body {
        height: auto;
    }

    body {
        flex-direction: column;
    }

    #logo {
        display: block !important;
        position: absolute;
        top: .5rem;
        left: .5rem;
        width: 3rem;
    }

    #sidebar {
        width: 100%;
        height: 4rem;
        position: fixed;
        bottom: 0;
        flex-direction: row;
        justify-content: center;
        border: none;
        margin-bottom: .8rem;
        gap: 1rem;

        > .logo {
            display: none;
        }

        > .thingies {
            flex-direction: row;

            &.settings {
                > [data-settings="modes"] {
                    display: inherit !important;
                }
            }

            &[data-modes]:not([data-modes="open"]) {    
                position: absolute;
                bottom: 5rem;
                opacity: 0;
                pointer-events: none;
                z-index: -1;
                user-select: none;
            }
            &[data-modes] {
                position: absolute;
                bottom: 6rem;
                display: grid;
                grid-template-columns: repeat(4, 1fr);
                width: fit-content;
                justify-content: center;
                background-color: #151617;
                z-index: 2;
                filter: drop-shadow(0px 2px 11px rgba(0, 0, 0, .4));
                padding: .5rem .5rem;
                border-radius: 15px;
                transition: all .2s cubic-bezier(0.89, 0.44, 0.2, 1.61);
            }

            > .thingy {
                width: 5rem;
            }
        }
    }

    main {
        height: calc(100vh - 5rem);
        width: 100%;
        border-bottom-right-radius: 1.5rem;
        border-bottom-left-radius: 1.5rem;

        > [data-mode="clock"] {
            > .time {
                font-size: 8rem;
    
                > .second {
                    font-size: 3rem;
                }
            }
            > .date {
                margin-left: .5rem;
                font-size: 3rem;
            }
        }

        > [data-mode="draw"] {
            > div > #drawing-canvas {
                width: 95%;
            }
        }

        > [data-mode="image"] {
            display: flex;
            flex-direction: column;
            align-items: center;
            gap: 1rem;
            
            > #image-preview-canvas {
                width: 95vw;
            }
    
            > label[for="image-input"] {
                width: 69vw;
                height: 16vh;
            }
    
        }

    }

    #info-dialog > .content {
        > .device-info {
            gap: .5rem;
            font-size: .8rem;

            > .info {
                grid-template-columns: 2.5rem auto;

                > img {
                    width: 2.5rem;
                }
                > .data {
                    grid-template-columns: 3rem 4rem;
                }
            }
        }
    }

}

/* also somehow target mobile in landscape */
@media (max-height: 535px) and (orientation: landscape) {

    #logo {
        display: none;
    }

    #sidebar {
        justify-content: center;

        > .logo {
            display: none;
        }

        > .thingies {

            &.settings {
                > [data-settings="modes"] {
                    display: inherit !important;
                }
            }

            &[data-modes]:not([data-modes="open"]) {    
                position: absolute;
                left: 5rem;
                opacity: 0;
                pointer-events: none;
                z-index: -1;
                user-select: none;
            }
            &[data-modes] {
                position: absolute;
                left: 7rem;
                display: grid;
                grid-template-columns: repeat(2, 1fr);
                width: fit-content;
                justify-content: center;
                background-color: #151617;
                z-index: 2;
                filter: drop-shadow(0px 2px 11px rgba(0, 0, 0, .4));
                padding: .5rem .5rem;
                border-radius: 15px;
                transition: all .2s cubic-bezier(0.89, 0.44, 0.2, 1.61);
            }

            > .thingy {
                width: 5rem;
            }
        }
    }

    main {
        > [data-mode="draw"] {
            display: flex;
            flex-direction: row;

            > #draw-controls {
                flex-direction: column;
                height: fit-content;
                margin-block: auto;
                gap: 1rem;
            }
        }
    }

}



dialog[open] {
    background-color: #151617;
    color: #ffffff;
    display: grid;
    place-content: center;
    margin-inline: auto;
    margin-block: auto;
    border: 1px solid #272727;
    border-radius: 1rem;
    
    > .content {
        padding: 1rem;
    }

    &::backdrop {
        background-color: rgba(0, 0, 0, .5);
        backdrop-filter: blur(3px);
    }
}

canvas {
    width: 75vw;
    max-width: 75rem;
    border: 5px solid #272727;
    border-radius: .25rem;
    background-color: black;
    box-shadow: 0px 5px 35px 0px rgba(0, 0, 0, .4);
    filter: drop-shadow(0px 2px 11px rgba(0, 0, 0, .4));
    image-rendering: pixelated;
}

.canvas-and-grid-parent {
    position: relative;
}
canvas + .canvas-grid-overlay {
    top: 5px;
    left: 5px;
    width: calc(100% - 10px);
    height: calc(100% - 14px);
    position: absolute;

    display: grid;
    grid-template-columns: repeat(64, 1fr);
    grid-template-rows: repeat(32, 1fr);

    > div {
        border: 1px solid rgba(255, 255, 255, .07);
        box-sizing: border-box;
    }
}



@keyframes rotate {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}








.f_switch {
    --rows: 1;
    --columns: 2;
    --cell_width: 75px;
    --cell_height: 32px;
    --radius: 5px;
	--border: 4px;
    --speed: .25s;
    --ease: linear(
        0, 0.1641 3.52%, 0.311 7.18%,
        0.4413 10.99%, 0.5553 14.96%,
        0.6539 19.12%, 0.738 23.5%,
        0.8086 28.15%, 0.8662 33.12%,
        0.9078 37.92%, 0.9405 43.12%,
        0.965 48.84%, 0.9821 55.28%,
        0.992 61.97%, 0.9976 70.09%, 1
    );

	display: grid;
	grid-auto-flow: row;
    outline: 1px solid hsl(0 0% 100% / .1);
	border-radius: var(--radius);
	grid-template-columns: repeat(var(--columns), var(--cell_width));
    grid-template-rows: repeat(var(--rows), var(--cell_height));
	position: relative;
    padding: var(--border);
    gap: var(--border);
    width: fit-content;
    box-sizing: border-box;

    --col: 0;
    --row: 0;

    &:has(:checked:nth-of-type(1)) {
        --col: mod((1 - 1), var(--columns));
        --row: calc(round(down, (1 - 1) / var(--columns)))
    }
    
    &:has(:checked:nth-of-type(2)) {
        --col: mod((2 - 1), var(--columns));
        --row: calc(round(down, (2 - 1) / var(--columns)))
    }

    > label {
        font-size: 1rem;
        padding-left: .1rem;
        cursor: pointer;
        text-align: center;
        height: 100%;
        display: flex;
        border-radius: calc(var(--radius) - var(--border));
        justify-items: start;
        align-items: center;
        padding-inline: .6rem;
        color: hsl(0 0% 100% / calc(.5 + var(--highlight, 0)));
        transition: background-color, color;
        transition-duration: .25s;
        transition-timing-function: var(--ease, ease);
        user-select: none;
    }

    &:not(:has(:checked))::after {
        background-color: transparent;
    }
    &::after {
        pointer-events: none;
        content: "";
        background: hsl(0 0% 100%);
        position: absolute;
        border-radius: 4px;
        mix-blend-mode: difference;

        width: var(--cell_width);
        height: var(--cell_height);

        translate:
            calc( var(--col) * 100% + (var(--border) * (var(--col, 0) + 1)) )
            calc( var(--row) * 100% + (var(--border) * (var(--row, 0) + 1)) )
        ;

        transition: translate, outline-color, background-color;
        transition-duration: var(--speed);
        transition-timing-function: var(--ease, ease);
        outline: 2px solid transparent;
    }

    > input {
        position: absolute;
        width: 1px;
        height: 1px;
        padding: 0;
        margin: -1px;
        overflow: hidden;
        clip: rect(0, 0, 0, 0);
        white-space: nowrap;
        border-width: 0;
    }

    :checked + label { --highlight: 1; }
    :disabled + label { cursor: not-allowed; }
}
