@import url("https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap");

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    overflow: hidden;
    background-color: black;
    font-family: "Inter";
    touch-action: none;
    /* safari user-select needs vendor prefixes :/ */
    -webkit-touch-callout: none;
    -webkit-tap-highlight-color: transparent;
    -moz-user-select: -moz-none;
    -webkit-user-select: none;
    -ms-user-select: none;
    user-select: none;
    -webkit-text-size-adjust: none;
    text-size-adjust: none;
}

#loading-anim {
    --scale: 8;
    --frames: 8;
    --width: 28px;
    --height: 13px;

    width: calc(100vw + 1px);
    /* the actual model sometimes appears below otherwise */
    height: calc(100svh + 5px);
    position: absolute;
    z-index: 1;
    background-color: black;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    transition: opacity 0.5s;

    &.inactive {
        opacity: 0;
        pointer-events: none;
    }
}

#loading-logo {
    position: absolute;
    width: 100vw;
    image-rendering: crisp-edges;
    z-index: 0;
    opacity: 0.03;
}

#loading-bar {
    width: calc((var(--width) - 2px) * var(--scale));
    height: calc(var(--scale) * 1px);
    background-color: #33302d;
    z-index: 1;

    #loading-inner {
        background-color: #c7c7c7;
        width: 0%;
        height: 100%;
    }
}

#frames {
    width: calc(var(--width) * var(--scale));
    height: calc(var(--height) * var(--scale));
    overflow-y: hidden;
}

#frames-strip {
    animation: loading-animation 1.2s steps(var(--frames)) infinite;
    /* firefox, for some reason */
    will-change: transform;
}

#frames img {
    display: block;
    width: calc(var(--width) * var(--scale));
    image-rendering: crisp-edges;
}

@keyframes loading-animation {
    to {
        translate: 0 calc(-1 * var(--height) * var(--frames) * var(--scale));
    }
}

#old {
    color: #333;
    position: absolute;
    bottom: 0.75em;

    a {
        color: inherit;
    }
}

#render {
    height: 100svh;
    width: 100vw;
}

#drawing-wrap {
    position: absolute;
    top: 0;
    left: 0;
    pointer-events: none;
}

#drawing {
    pointer-events: all;
    cursor: crosshair;
    opacity: 0;
}

#ui-anchor {
    transform-style: preserve-3d;
    height: 110px;
    pointer-events: none !important;
}

#ui {
    display: flex;
    justify-content: space-between;
    width: 1920px;
    align-items: center;
    transform-style: preserve-3d;
    backface-visibility: hidden;
}

.island {
    display: flex;
    align-items: center;
    gap: 0.3em;
    box-shadow: inset 0 0 0 2px #ffffff33;
    backdrop-filter: blur(3px) brightness(0.6);
    color: white;
    padding: 0 0.5em;
    height: 3.2em;
    border-radius: 5em;
    /* render at a higher size, then 3d downscale, for sharper text */
    font-size: 32px;
}

.island > * {
    pointer-events: all;
}

#toolbar {
    padding: 0.25em 0.5em;
}

#infobar {
    gap: 0.8em;
}

#status-text {
    font-size: 1.5em;
    margin-right: 0.3em;
}

#status-color {
    font-size: 1.5em;
    width: 0.8em;
    height: 0.8em;
    border-radius: 1em;
    margin-right: 0.3em;
    background-color: #cccc00;
    margin-left: 0.3em;
}

#status-color.online {
    background-color: #00cc00;
}

#status-color.offline {
    background-color: #cc0000;
}

.bar {
    background-color: #ffffff33;
    width: 2px;
    margin: 0 0.5em;
}

button {
    background-color: transparent;
    border: none;
    font-size: 1.5em;
    padding: 0.2em 0.3em;
    border-radius: 5em;
    cursor: pointer;
    color: inherit;
    transition: color 0.2s;
    font-family: inherit;

    /* &.active {
        background-color: #ffffff22;
    } */
}

#send:disabled {
    color: #888888;
    cursor: not-allowed;
}

#send.success {
    color: #00cc00;
}

button div {
    height: 1em;
    width: 1em;
    border-radius: 1em;
}

.black div {
    background-color: black;
}

.red div {
    background-color: #bb0000;
}

.eraser {
    display: flex;
    align-items: center;
    justify-content: center;
}

.small div {
    background-color: white;
    height: 0.3em;
    width: 0.3em;
    margin: 0.35em;
}

.medium div {
    background-color: white;
    height: 0.6em;
    width: 0.6em;
    margin: 0.2em;
}

.large div {
    background-color: white;
    height: 0.9em;
    width: 0.9em;
    margin: 0.05em;
}

.dither-button img {
    width: 0.9em;
    display: block;
    image-rendering: crisp-edges;
}

#infobar button {
    display: flex;
    align-items: center;
    justify-content: center;
}

svg {
    width: 1em;
    height: 1em;
    scale: 1.2;
    display: block;
}

#dropdowns {
    display: flex;
    font-size: 36px;
    transform-style: preserve-3d;
    pointer-events: none !important;
}

/* optimally some sort of similar spacing layout as the main UI would be controlling the position of
the dropdowns but i find it unnecessarily complicated */
body:has(#status-color.online) #dropdowns {
    translate: -0.42px 0;
}

body:has(#status-color.offline) #dropdowns {
    translate: -0.17px 0;
}

/* this is a little cursed but i got no better idea */
body:has(#color-pick:hover) #color-dropdown,
body:has(#tool-pick:hover) #tool-dropdown,
body:has(#thickness-pick:hover) #thickness-dropdown,
body:has(#dither-pick:hover) #dither-dropdown,
.dropdown-hover:hover {
    opacity: 1;
    pointer-events: all;
}

.dropdown-hover {
    color: white;
    opacity: 0;
    /* i would love to add an opacity transition but it seems like all browsers have unilaterally
    agreed that animating opacity with a backdrop filter is too hard of a task */
    display: flex;
    transform-style: preserve-3d;
    height: min-content;
}

.dropdown {
    display: flex;
    flex-direction: column;
    backdrop-filter: blur(3px) brightness(0.6);
    box-shadow: inset 0 0 0 2px #ffffff33;
    padding: 0.25em 0;
    border-radius: 5em;
    margin-top: 1.7em;
}

.dropdown button:hover {
    background-image: radial-gradient(circle, #ffffff22 0%, #ffffff22 65%, transparent 65%);
}

.dropdown-active > :not(.active) {
    display: none;
}

dialog {
    margin: auto;
    font-size: 1.5em;
    width: 40em;
    padding: 1em;
    background-color: #cec4bb;
    border-radius: 0.5em;

    .dotted {
        text-decoration: dotted underline;
    }

    .close-dialog {
        position: absolute;
        top: 0em;
        right: 0.25em;
        background-color: transparent !important;
        outline: none;
    }
}

/* no dropdowns on mouseless devices */
@media (pointer: coarse) {
    .dropdown-hover {
        opacity: 0 !important;
        pointer-events: none !important;
    }
}

@media (max-width: 600px) {
    .island {
        font-size: 40px;
        translate: 0 -0.8em;
    }

    dialog {
        rotate: 90deg;
        max-height: 90vw;
        max-width: 90svh;
        margin: 0;
        left: 50%;
        top: 50%;
        translate: -50% -50%;
        font-size: 1em;
    }
}

/* firefox ui backdrop filter fallback, since i couldn't get it working there. sad :( */
@supports (-moz-appearance: none) {
    .island,
    .dropdown {
        background-color: rgba(0, 0, 0, 0.45);
    }
}
