html, body {
    margin: 0;
    padding: 0;
    overflow: hidden;
}
* {
    box-sizing: border-box;
}

body {
    width: 100vw;
    height: 100vh;
}

.modal-alert, .modal-confirm, .modal-prompt {
    font: 1rem arial;
    box-shadow: 0 0 10px black;

    input {
        font: 1rem arial;

    }
}
/* --  color picker  -- */

m20colorpickerfield {
    display: inline-flex;
    inline-size: 85px;
    block-size: 22px;
    border: 2px outset buttonface;
    border-radius: 5px;
    background-color: red;
    padding: 2px;
}
[data-component-name="m20colorpicker"] {

    --hue: 0;
    --saturation: 100%;
    --lightness: 50%;
    --opacity: 1;
    --initial-hsla: hsla(var(--hue), var(--saturation), var(--lightness), var(--opacity));

    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    width: 310px;
    height: 310px;
    padding: 10px;
    background-color: hsl(180, 50%, 95%);

    div {display: inline-block;}

    [data-component-element="centerarea"] {

        margin: 0 10px;
        position: relative;

        [data-component-element="revertwrapper"], [data-component-element="setwhiteblackwrapper"], [data-component-element="eyedropperwrapper"], [data-component-element="randomizewrapper"] {

            position: absolute;
            filter: drop-shadow(1px 1px 1px black);
            width: 60px;
            height: 60px;

            * {
                padding: 4px;
                width: 60px;
                height: 60px;
                position: absolute;
                color: white;
                font-weight: 900;
                cursor: pointer;
                filter: drop-shadow(1px 1px 1px white);

            }
            [data-component-element="revertbutton"] {

                background-color: var(--initial-hsla);
                width: 60px;
                height: 60px;
                mask: radial-gradient(100px at 95px 95px, #0000 99%, #000);
            }
            [data-component-element="setwhitebutton"] {

                right: 0;
                background-color: white;
                clip-path: polygon(100% 100%, 100% 5%, 5% 100%);
                mask: radial-gradient(100px at -35px 95px, #0000 99%, #000);
            }
            [data-component-element="setblackbutton"] {

                right: 0;
                background-color: black;
                clip-path: polygon(0 0, 95% 0, 0 95%);
                mask: radial-gradient(100px at -35px 95px, #0000 99%, #000);
            }
            [data-component-element="eyedropperbutton"] {

                display: flex;
                align-items: flex-end;
                background-color: hsla(var(--hue), var(--saturation), var(--lightness), 1);
                width: 60px;
                height: 60px;
                mask: radial-gradient(100px at 95px -35px, #0000 99%, #000);
            }
            [data-component-element="randomizebutton"] {

                display: flex;
                align-items: flex-end;
                justify-content: right;
                /* background-color: hsla(var(--hue), var(--saturation), var(--lightness), 1); */
                background-image:
                linear-gradient(-45deg, hsla(0, 0%, 70%, 1) 20%, hsla(0, 0%, 50%, 0) 60%, hsla(0, 0%, 30%, 1) 100%),
                    linear-gradient(45deg, hsla(0, 100%, 50%, 1) 0%,
                    hsla( 60, 100%, 50%, 1) 16.66%,  hsla(120, 100%, 50%, 1)  33.33%,
                    hsla(180, 100%, 50%, 1) 50.00%,  hsla(240, 100%, 50%, 1)  66.66%,
                    hsla(300, 100%, 50%, 1) 83.33%,  hsla(360, 100%, 50%, 1) 100.00%)
                ;
                width: 60px;
                height: 60px;
                mask: radial-gradient(100px at -35px -35px, #0000 99%, #000);
            }
        }
        [data-component-element="setwhiteblackwrapper"],[data-component-element="randomizewrapper"] {
            right: 0;
            filter: drop-shadow(-1px 1px 1px black);
        }
        [data-component-element="eyedropperwrapper"],[data-component-element="randomizewrapper"] {
            bottom: 0;
            filter: drop-shadow(1px -1px 1px black);
        }
        [data-component-element="randomizewrapper"] {

            filter: drop-shadow(-1px -1px 1px black);
        }

        [data-component-element="huelightnessdisplay"] {
            position: relative;
            border-radius: 40%;
            display: flex;
            /* background-color: red; */
        }
        [data-component-element="huelightnessdisplaycircle"] {
            position: relative;
            width: 200px;
            aspect-ratio: 1;
            border-radius: 50%;
            padding: 0;
            cursor: crosshair;
            background-image:
                radial-gradient(circle at center,  hsla(0, 0%, 100%, var(--opacity)) 3%,  transparent 35.35%,   hsla(0, 100%, 0%, var(--opacity)) 68.7%),
                conic-gradient(from 0deg at center,  hsla(0, var(--saturation), 50%, var(--opacity)) 0%,
                    hsla( 60, var(--saturation), 50%, var(--opacity)) 16.66%,  hsla(120, var(--saturation), 50%, var(--opacity))  33.33%,
                    hsla(180, var(--saturation), 50%, var(--opacity)) 50.00%,  hsla(240, var(--saturation), 50%, var(--opacity))  66.66%,
                    hsla(300, var(--saturation), 50%, var(--opacity)) 83.33%,  hsla(360, var(--saturation), 50%, var(--opacity)) 100.00%
                    )
                    /* conic-gradient(from 0deg at center, hsl(0, var(--saturation), 50%) 0%, hsl(60, var(--saturation), 50%) 17%, hsl(120, var(--saturation), 50%) 33%, hsl(180, var(--saturation), 50%) 50%, hsl(240, var(--saturation), 50%) 67%, hsl(300, var(--saturation), 50%) 83%, hsl(0, var(--saturation), 50%) 100%) */
            ;
            &::after {
                width: 100%;
                aspect-ratio: 1;
                border-radius: 50%;
                /* content: ""; */
                z-index: -1;
                position: relative;
                display: block;
                background-image:
                    linear-gradient(45deg, #eee 25%, transparent 25%, transparent 75%, #eee 75%, #eee),
                    linear-gradient(45deg, #eee 25%, transparent 25%, transparent 75%, #eee 75%, #eee);
                background-size: 8px 8px;
                background-position: 0 0, 4px 4px;
            }

            [data-component-element="huelightnessdisplaycirclethumb"] {
                position: absolute;
                left: 50%;
                top: 25%;
                translate: -50% -50%;
                width: 13px;
                height: 13px;
                border-radius: 50%;
                border: 2px outset white;
                background-color: transparent;
                background-color: hsla(var(--hue), var(--saturation), var(--lightness), var(--opacity));
                cursor: default;

            }
        }
    }

    input[type=range][data-component-element="opacityselector"] {
        /* width: auto;
        height: 190px; */
        background-image:
            linear-gradient(45deg, #eee 25%, transparent 25%, transparent 75%, #eee 75%, #eee),
            linear-gradient(45deg, #eee 25%, transparent 25%, transparent 75%, #eee 75%, #eee);
        background-size: 8px 8px;
        background-position: 0 0, 4px 4px;
        &::-webkit-slider-runnable-track {
            width: 16px;
            height: 100%;
            background: linear-gradient(180deg, transparent 0%, hsl(var(--hue), var(--saturation), var(--lightness)) 100%);
        }
        &::-webkit-slider-thumb {
            height: 8px;
            width: 18px;
            margin-left: -1px;
        }
    }
    input[type=range] {
        -webkit-appearance: none;
        writing-mode: vertical-lr;
        rotate: 180deg;
        padding: 0;
        height: 190px;
        /* margin: 10px 0; */
        /* width: 100%; */
    }
    input[type=range]:focus {
        outline: none;
    }
    input[type=range]::-webkit-slider-runnable-track {
        width: 16px;
        height: 100%;
        cursor: pointer;
        box-shadow: 0px 0px 10px #000, 0px 0px 5px #fff;
        border-radius: 2px;
        background: linear-gradient(180deg, hsl(var(--hue), 0%, var(--lightness)) 0%, hsl(var(--hue), 100%, var(--lightness)) 100%);
    }
    input[type=range]::-webkit-slider-thumb {
        box-shadow: 0px 0px 4px #000000, 0px 0px 2px #fff;
        border: 1px solid #FFF;
        border-radius: 2px;
        height: 8px;
        width: 18px;
        background: #FFF0;
        cursor: pointer;
        -webkit-appearance: none;
        margin-top: -1px;
    }
    /* input[type=range]:focus::-webkit-slider-runnable-track {
        background: #ac51b5;
    } */
    [data-component-element="palletearea"] {
        display: flex;
        flex-wrap: wrap;
        justify-content: center;
        gap: 5px;
        width: 265px;
        padding: 10px;
        background-color: hsl(180, 50%, 95%);

        [data-component-element="palletetile"] {
            width: 30px;
            height: 30px;
            border: 1px solid black;
            cursor: pointer;
            border-radius: 5px;
        }
    }
    [data-component-element="cancelbutton"], [data-component-element="confirmbutton"] {
        position: absolute;
        width: 36px;
        height: 36px;
        margin: 3px;
        cursor: pointer;
        display: grid;
        /* border: 1px solid black; */
        border-radius: 50%;
        background-color: #f50000;
        bottom: 8px;
        left: 8px;
        font-size: 20px;
    }
    [data-component-element="confirmbutton"] {
        background-color: #00f500;
        left: unset;
        right: 8px;
    }
    input[type=range]::-moz-range-track {
        width: 100%;
        height: 12.8px;
        cursor: pointer;
        animate: 0.2s;
        box-shadow: 0px 0px 0px #000000, 0px 0px 0px #0d0d0d;
        background: #ac51b5;
        border-radius: 25px;
        border: 0px solid #000101;
    }
    input[type=range]::-moz-range-thumb {
        box-shadow: 0px 0px 0px #000000, 0px 0px 0px #0d0d0d;
        border: 0px solid #000000;
        height: 20px;
        width: 39px;
        border-radius: 7px;
        background: #65001c;
        cursor: pointer;
    }
}


/* --- */


@starting-style {
    .interaction-notification[open] {
        bottom: 5%;
        opacity: 0;
        transform: scaleY(0) scaleX(0);
        transition:
            opacity 0.7s ease-out
        ;
    }
}
.interaction-notification {
    background-color: transparent;
    border: none;
    z-index: 2;

    bottom: 5%;
    opacity: 0;
    transform: scaleY(0) scaleX(0);

    transition:
        opacity 0.3s ease-out,
        transform 0.3s ease-out,
        bottom 0.5s ease-out,
        overlay 0.7s ease-out allow-discrete,
        display 0.7s ease-out allow-discrete;

    &[open] {
        bottom: 10%;
        opacity: 1;
        transform: scaleY(1) scaleX(1);
    }
    &:focus-visible {
        outline: none;
    }
    div {
        position: relative;
        padding: 0;
        box-sizing: border-box;

        div {
            background-color: #f5f5f5f5;
            border: 2px solid #ffd700;

            &:nth-child(1) {
                left: calc(50% - 20px);
                background-color: #f5f5f5;
                border-bottom: none;
                border-radius: 50%;
                padding: 5px;
                width: max-content;
                z-index: 2;

                img {
                    width: 40px;
                    height: 40px;
                }
            }
            &:nth-child(2) {
                width: fit-content;
                max-width: 100%;
                top: -10px;
                border-radius: 15px;
                padding-top: 5px;
                text-align: center;

                * {
                    padding: 0.5rem;
                    margin: 0;
                }
                h2 {
                    font-size: 1.2rem;
                    padding-bottom: 0;
                }
            }
        }
    }
}

.disabled {
    opacity: 0.5;
}
#drawcanvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: white;
    border: 1px solid black;
}

#saveload>div, #canvasconfig>div {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    align-items: center;

    .fakebutton {

        padding: 1px 6px;
        display: inline-flex;
        justify-content: center;
        align-items: center;
        cursor: pointer;
        border: 2px outset buttonborder;
        background-color: buttonface;
    }
}
#menuarea {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 170px;
    background-color: #f1f1f1AA;
    z-index: 1;
    display: grid;
    grid-template-columns: 1fr;
    grid-template-rows: 50px 1fr;
    font-size: 12px;

    ul {
        width: 100%;
        height: 100%;
        display: flex;
        justify-content: space-between;
        align-items: center;
        list-style-type: none;
        margin: 0;
        padding: 0;
        border: 1px solid black;
    }
    .menuoption {
        width: 25%;
        display: flex;
        justify-content: space-evenly;

        img:active {
            background-color: #AFA;
        }
    }
    input {
        margin: 0;
        width: 80%;
        margin-left: 10%;
    }
}
#brushcontrols {
    width: 100%;
    height: 100%;
    display: grid;
    grid-template-columns: 2fr 3fr 2fr;
    grid-template-rows: 1fr 1fr 1fr;
    grid-template-areas:
        "brushpreview brushsize brushcolor"
        "brushpreview brushhard brushpreset"
        "brushpreview brushopacity brushsave"
    ;
    align-items: center;
    justify-content: center;

    & > *:nth-child(1) {
        grid-area: brushpreview;
    }
    & > *:nth-child(2) {
        grid-area: brushsize;
    }
    & > *:nth-child(3) {
        grid-area: brushhard;
    }
    & > *:nth-child(4) {
        grid-area: brushopacity;
    }
    & > *:nth-child(5) {
        grid-area: brushcolor;
    }
    & > *:nth-child(6) {
        grid-area: brushpreset;
    }
    & > *:nth-child(7) {
        grid-area: brushsave;
    }
}
.hidden {
    display: none;
}
input[name="brushslottoggle"]:checked + li {
    background-color: #AFA;
}
#brushconrolsdisplaytoggle:checked ~ #menuarea {
    height: 40px;
    grid-template-rows: 1fr;

    #brushcontrols {
        display: none;
    }
}
dialog {
    padding: 0;
    border-radius: 15px;

    > * {
        padding: 2rem;
    }
}
svg {
    width: 100%; aspect-ratio: 1;
}
/* MEDIA QUERY FOR LANDSCAPE */
@media screen and (orientation: landscape) {
    #menuarea {
        position: absolute;
        height: 100%;
        width: 170px;
        background-color: #f1f1f1f1;
        z-index: 1;
        display: grid;
        grid-template-rows: 1fr;
        grid-template-columns: 50px 1fr;

        ul {
            display: flex;
            flex-direction: column;
            list-style-type: none;
            margin: 0;
            padding: 0;
            border: 1px solid black;
        }
        .menuoption {
            width: auto;
            height: 25%;
            display: flex;
            flex-direction: column;
            justify-content: space-evenly;
        }
    }
    #brushcontrols {
        display: grid;
        grid-template-columns: 1fr;
        grid-template-rows: repeat(7, min-content);
        grid-template-rows: 35% 10% 10% 10% 10% 10% 10%;
        grid-template-areas:
            "brushpreview"
            "brushsize"
            "brushhard"
            "brushopacity"
            "brushcolor"
            "brushpreset"
            "brushsave"
        ;
        align-content: space-evenly;
    }
    #brushconrolsdisplaytoggle:checked ~ #menuarea {
        width: 40px;
        height: 100%;
        grid-template-columns: 1fr;
    }
}