/* Fonts */
@font-face {
    font-family: Wackily;
    src: url(assets/fonts/Wackily.ttf);
}
@font-face {
    font-family: OpenDyslexic;
    src: url(assets/fonts/OpenDyslexic/OpenDyslexic-Regular.otf);
}

:root {
    --lg: #bcc0c4;
}

/* Universal */
* {
    box-sizing: border-box;
    image-rendering: pixelated;
    touch-action: manipulation;
    user-select: none;
    -webkit-user-select: none;
    -webkit-user-drag: none;
    margin: 0;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    font-weight: unset;
}

body {
    margin: 0;
    background-color: rgb(8, 8, 8);
    color: white;

    height: 100vh;
    width: 100vw;
    overflow: hidden;
}
#game {
    position: relative;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);

    max-width: 100%;
    max-height: 100vh;
    aspect-ratio: 16 / 9;
    /* aspect-ratio: 4 / 3; */
}
canvas {
    width: 100%;
    height: 100%;
}
#create_level * {
    font-family: Wackily;
    font-size: 48px;
}
#create_level h2 { font-size: 64px; color: white; }
#create_level {
    position: absolute;
    top:0;right:0;bottom:0;left:0;
    background-color: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(24px);
    color: var(--lg);
    padding: 32px;

    visibility: hidden;
}
#create_level.visible { visibility: visible; }
#create_level label { color: white; }
#create_level input {
    background-color: transparent;
    color: var(--lg);
    border: 6px solid ;
}
#create_level input:focus {
    background-color: white;
    color: black;
}
#create_level button { width: 100%; margin: 4px; }



/* Error */
body.body_error_in #game {
    transition: all 0.35s ease;
    overflow-y: hidden;
    transform: translate(-50%, -50%) scale(0.8, 0.8);
    border-radius: 18px;
}
.overlay {
    position: absolute;
    z-index: 2;
    top:0;right:0;bottom:0;left:0;
    background-color: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(6px);
    animation: overlay-in 0.35s ease backwards;
}
@keyframes overlay-in {
    from { opacity: 0; transform: scale(1.15, 1.15); }
}
.error {
    --error-color: #ff8080;
    padding: 64px;
}
.error h3 {
    font-size: 26pt;
    color: white;
    font-weight: bold;
}
.error #error_list {
    overflow-x: hidden;
    overflow-y: auto;
    max-height: calc(100vh - 336px);
}
.error .error_info {
    color: var(--error-color);
    border-left: 6px solid var(--error-color);
    padding-left: 24px;
    font-size: 16pt;
    margin-bottom: 12px;
}
.error img {
    margin-top: 24px;
    width: 600px;
    max-width: 100%;
    border: 1px solid rgba(255, 255, 255, 0.3);
}
.error button {
    font-size: 14pt;
}
.error button.close {
    float: right;
    font-size: 48pt;
    background-color: transparent;
    color: white;
    margin-top: -24px;
}


/* Debug */
#dev {
    position: absolute;
    top:0;left:0;right:0;bottom:0;
    /* background-color: rgba(66, 66, 66, 0.25); */
    /* backdrop-filter: blur(8px); */

    pointer-events: none;
    opacity: 0;
    transform: translateY(-16px);
    transition-property: opacity, transform;
    transition-duration: 0.1s;
    transition-timing-function: ease;
}
#dev:target {opacity:1;transform: translateY(0px);}
#dev > div {
    background-color: rgba(66, 66, 66, 0.25);
    backdrop-filter: blur(12px);
    border: 1px solid rgb(66, 66, 66, 0.5);
    border-radius: 6px;
    padding: 8px 12px;
    margin: 16px;
}
#dev:target > div {pointer-events: all;}
#tools {
    position: absolute;
    top:0;
    width: calc(100% - 400px);
}
#entities {
    position: absolute;
    right:0;top:0;
    width: 360px;
    max-height: 60vh;
    overflow: auto;
}
#entities > div {
    background-color: rgba(66, 66, 66, 0.25);
    backdrop-filter: blur(12px);
    border: 1px solid rgb(66, 66, 66, 0.5);
    border-radius: 6px;
    padding: 3px 12px;
    margin: 5px 0;
}
#entities > div > button {
    float: right;
    background-color: transparent;
    color: white;
    text-decoration: underline;
}
#entities > div > button:hover { opacity: 1; text-decoration: none; }
table tr > * {
    border-bottom: 1px solid rgba(129, 129, 129, 0.5);
}
table tr, table td {
    width: 100%;
}
#entities td {text-align: right;}
button {
    background-color: rgb(170, 170, 170);
    padding: 4px 16px;
    margin-bottom: 4px;
    border-radius: 6px;
    border: none;
    font-size: 11pt;
    font-weight: bold;
    opacity: 0.5;
    cursor: pointer;
}
button:hover,
button:focus-visible {
    opacity: 0.9;
}
p {
    font-weight: bold;
    font-size: 12pt;
    padding-top: 3px;
}
#version {
    position: absolute; bottom:6px; right:6px;
    padding: 6px 14px;
    /* background-color: red; */
    border-radius: 32px;
    opacity: 0.6;
    cursor: pointer;
}
#version:hover {
    background-color: rgba(51, 51, 51, 0.6);
    content: "X";
    color: transparent;
    opacity: 1;
}
#version:hover::after {
    position: absolute;
    top:50%;left:50%;
    transform: translate(-50%, -50%);
    content: "Hide";
    color: white;
}









/* Touch controls */
.flex { display: flex; }
.controls {
    position: absolute;
    left: 24px; right: 24px;
    z-index: 99;

    bottom: 6px; left: 12px; right: 12px;
    padding: 12px 0;
}
body.show_controls .controls { visibility: visible !important; }
.controls .column {
    margin: 0 16px;
    background-color: rgb(48, 48, 48);
    border: 1px solid rgb(82, 82, 82);
    border-radius: 8px;
}


.controls div[data-button] {
    position: absolute;
    width: 36px;
    height: 36px;

    background-color: white;
    border: none;
    border-radius: 0 0 3px 3px;
    opacity: 0.5;

    /* transform-origin: top; */

    transition-property: background-color;
    transition-duration: 0.3s;
    transition-timing-function: cubic-bezier(0.075, 0.82, 0.165, 1);
}
.controls div[data-button]:hover,
.controls div[data-button]:focus-visible {
    opacity: 1;
}
.controls div[data-button]:active {
    opacity: 0.8;
    transform: scale(0.9, 0.9);
}

/* Dpad */
.controls .column {
    padding: 16px;
    width: 128px;
    height: 128px;
    position: relative;
}
.controls .column:nth-of-type(2) {margin-left: auto;}
.controls div[data-button] > svg {
    fill: white;
    position: absolute;
    bottom: 100%;
    left: 0;

    padding: 0;
    margin: 0;

    transition: fill 0.3s cubic-bezier(0.075, 0.82, 0.165, 1);
    opacity: 0.7;
}

/* Button positioning */
.controls .column div[data-button]:nth-of-type(1) {
    top: 0;
    left: 50%;
    transform: translateX(-50%) rotate(180deg);
}
.controls .column div[data-button]:nth-of-type(2) {
    left: 0;
    top: 50%;
    transform: translateY(-50%) rotate(90deg);
}
.controls .column div[data-button]:nth-of-type(3) {
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
}
.controls .column div[data-button]:nth-of-type(4) {
    right: 0;
    top: 50%;
    transform: translateY(-50%) rotate(-90deg);
}


/* Button pad */
.controls .buttonpad div[data-button] {
    border-radius: 50%;
    width: 46px;
    height: 46px;
}
