/* Fonts */
@font-face {
    font-family: visitor;
    src: url(./fonts/visitor/visitor1.ttf);
    src: url(./fonts/visitor/visitor2.ttf);
}

:root {
    --text: white;
    --alt-text: rgb(200, 200, 200);
    --link-color: #51a2ff;

    --bg: #171718;
    --overlay-bg: rgba(20, 20, 20, 0.8);

    --border-color: rgba(199, 199, 199, 0.3);
}

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

body {
    max-height: 100vh;
    overflow: hidden;

    background-color: var(--bg);
    color: white;

    margin: 0;
    /* cursor: url(./assets/ui/cursor.png), auto; */
    /* overflow: overlay */
}

/* Button */
button,
input,
*[role="button"] {
    display: inline-block;
    text-decoration: none;

    background-color: rgb(23, 23, 24, 0.8);
    color: white;
    border: none;

    cursor: pointer;
    min-width: 24px;
    text-align: center;
    padding: 2px 4px;

    font-size: 13pt;

    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 8px 18px;
    margin: 0 3px;
    box-shadow: 2px 2px 8px rgba(0, 0, 0, 0.3);

    transition: background-color 0.2s ease;
}
button:hover,
input[type="button"]:hover,
*[role="button"]:hover,
button:focus-visible,
input:focus-visible,
*[role="button"]:focus-visible {
    color: black;
    background-color: white;
    transition-duration: 0.1s;
    z-index: 1;
}

input[type="text"], input[type="number"], select {
    width: 100%;
    max-width: 300px;
    padding: 4px 14px;
    border-radius: 8px;
    cursor: unset;
}
input[type="file"] {
    width: 100%;
    height: 120px;
    margin-bottom: 12px;
}
input[type="file"]:hover {
    filter: brightness(140%);
}
input:disabled {
    border: none;
    box-shadow: none;
    cursor: unset;
    pointer-events: none;
    opacity: 0.7;
}
label.select_label {
    background-color: rgba(255, 255, 255, 0.1);
    border-radius: 6px;
    padding: 5px 0 5px 12px;
}
button p {
    padding: 3px 0 0 6px;
}
a {
    color: var(--link-color);
}


hr {
    border: none;
    height: 1px;
    background-color: var(--border-color);
    margin: 12px 0 12px;
}
.alt_text { color: var(--alt-text); }
.flex { display: flex; }
.fullwidth { width: 100%; }

canvas {
    width: 100%;
    height: 100%;
    /* max-width: 1200px; */
    /* object-fit: contain; */
    /* max-height: 100vh; */
}
h2 { padding-top: 12px; }

table {
    margin-bottom: 12px;
}
table td, table th {
    min-width: 96px;
    padding-right: 12px;
    margin: 0;
}
table * { text-align: left; }


/* Game */
#game {
    position: relative;
    max-height: 100vh;
    aspect-ratio: 1200 / 672;
    margin: 0 auto;
}
.html_menu {
    position: absolute;
    top: 0; right: 0; bottom: 0; left: 0;

    background-color: var(--overlay-bg);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);

    transition-property: opacity;
    transition-duration: 0.1s;
    transition-timing-function: ease;
}
.html_menu > * {
    width: 100%;
    max-width: 600px;
    position: absolute;
}
#game.hide_creation > #creation,
#game.hide_players > #players,
#game.hide_tools > #tools {
    pointer-events: none !important;
    opacity: 0;
}
#game.hide_tools > #tools * { pointer-events: none !important;}
.ui_box {
    top: 0;
    left: 50%;
    transform: translate(-50%, 0);

    background-color: var(--bg);
    height: fit-content;
    max-height: 100%;
    padding: 0 18px 18px;
    border: 1px solid var(--border-color);
    border-top: none;
    border-radius: 0 0 12px 12px;
    box-shadow: 6px 6px 12px rgba(0, 0, 0, 0.3);
    
    transition: transform 0.2s ease;
}
#game.hide_creation #creation .ui_box,
#game.hide_players #players .ui_box {
    transform: translate(-50%, -32px);
}
.pane { display: none; }
.pane:target { display: unset; }

.tabs {
    bottom: 0;
    left: 50%;
    transform: translate(-50%, 0);

    padding-top: 18px;
}
.tabs *[role="button"] {
    border-radius: 9px 9px 0 0;
    margin: 0;
    padding: 6px;
    font-size: 12pt;
    border: none;
    border-bottom: 3px solid transparent;
    color: var(--alt-text);
}
.tabs *[role="button"]:hover {
    border-color: var(--alt-text);
    background-color: rgba(34, 34, 36, 0.8);
    color: var(--text);
}
.tabs *[role="button"].selection {
    z-index: 1;
    background-color: var(--text);
    color: black;
}

/* Gamepad screen */
#players {
    background-color: rgba(155, 155, 155, 0.8);
}
#players > .ui_box {
    background-color: #e6e8eb;
    color: black;
    box-shadow: 6px 6px 12px rgba(0, 0, 0, 0.15);
    top: 50%;
    transform: translate(-50%, -50%);
    border-radius: 12px;
    max-width: 900px;
}
#players h2 {
    font-size: 22pt;
    margin: 20px 20px 0 20px;
    border-bottom: 1px solid gray;
}
#players .players_slot {
    width: 100%;
    margin: 0 8px;
    padding: 12px;

    display: flex;
    justify-content: center;
    align-items: center;
    flex-direction: column;
}
#players .players_slot > .box {
    width: 100%;
    padding: 12px;
    background-color: rgb(214, 214, 214);
    border-radius: 9px;
    box-shadow: inset 0 0 32px rgba(0, 0, 0, 0.15);
    aspect-ratio: 1 / 1;

    display: flex;
    justify-content: center;
    align-items: center;
    flex-direction: column;
}
#players .players_slot.inactive {
    filter: brightness(80%);
}
#players .players_slot img {
    width: 85%;
}
.vibrate { animation: vibrate 0.05s linear infinite alternate; }
@keyframes vibrate {
    0% { transform: translateX(-5px); }
    100% { transform: translateX(5px); }
}
#players .players_slot figcaption {
    text-align: center;
    background-color: #e6e8eb;
    display: inline-block;
    width: 32px;
    height: 32px;
    padding-top: 5px;
    border-radius: 100%;
}
#players .players_slot input {
    width: 100%;
    margin-top: 6px;
}
#players .character {
    margin-top: 24px;
    width: 48px !important;
    height: 48px !important;
    filter: drop-shadow(3px 3px 3px rgba(0, 0, 0, 0.3));
    animation: bounce_in 0.8s;
}
@keyframes bounce_in {
    0% { transform: translateY(-48px); }
    50% { transform: translateY(8px); }
    60% { transform: translateY(-6px); }
    75% { transform: translateY(3px); }
    100% { transform: translateY(0px); }
}



/* Loader */
#loader {
    position: absolute;
    background-color: rgb(80, 80, 80);
    top: 0; right: 0; bottom: 0; left: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: 0.2s opacity ease;
    pointer-events: none;
}
#loader img {
    width: 96px;
    image-rendering: initial;
    animation: spinner 3s linear infinite;
    opacity: 1;
}
@keyframes spinner {
    to { transform: rotate(360deg); }
}




/* Old tools */
#tools {
    /* background-color: rgb(20, 20, 20); */
    /* border: 1px solid rgb(65, 65, 65); */
    /* border-radius: 6px; */
    /* width: fit-content; */
    /* margin: 4px; */
    /* padding: 8px; */
    background-color: transparent;
    backdrop-filter: unset;
    pointer-events: none;
}
#tools > .container {
    background-color: var(--overlay-bg);
    backdrop-filter: blur(24px);
    /* color: black; */
    width: 80%;
    max-width: unset;
    max-height: 80%;
    padding: 0 24px 32px;
    overflow: auto;
    
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    border-radius: 0 0 9px 9px;
    pointer-events: all;
}
#tools > .container .tabs { position: absolute; }
#tools img {
    /* width: 48px; */
    /* height: 54px; */
    /* object-fit: cover; */
    min-width: 44px;
    min-height: 44px;
    padding: 0px;
    border: 4px solid transparent;
    border-bottom-width: 8px;
    transition: transform 0.1s ease-out;
    border-radius: 6px;
    background-color: rgba(255, 255, 255, 0.1);
    box-shadow: none;
}
#tools img:hover {
    transform: scale(1.25, 1.25);
    background-color: white;
}
#tools img.selection {
    border-color: white;
    border-radius: 4px;
    background-color: rgba(255, 255, 255, 1);
    /* padding: 2px; */
    transform: scale(1.25, 1.25);
    animation: float 2s ease-in-out infinite;
}
@keyframes float {
    0% { transform: translateY(0px) scale(1.25, 1.25); }
    50%   { transform: translateY(4px) scale(1.25, 1.25); }
    100% { transform: translateY(0px) scale(1.25, 1.25); }
}

/* Touch controls */
.controls {
    position: sticky;
    justify-content: center;

    bottom: 6px; left: 12px; right: 12px;
    background-color: rgb(48, 48, 48);
    border: 1px solid rgb(82, 82, 82);
    border-radius: 8px;

    width: auto;
    padding: 12px 0;
    margin-top: 24px;
    margin-left: auto;

    visibility: hidden !important;
}
body.show_controls .controls { visibility: visible !important; }
.controls .column {
    margin: 0 16px;
}


.controls 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 button:hover,
.controls button:focus-visible {
    opacity: 1;
}
.controls button:active {
    opacity: 0.8;
    transform: scale(0.9, 0.9);
}

/* Dpad */
.controls .column {
    padding: 16px;
    width: 128px;
    height: 128px;
    position: relative;
}
.controls 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 button:nth-of-type(1) {
    top: 0;
    left: 50%;
    transform: translateX(-50%) rotate(180deg);
}
.controls .column button:nth-of-type(2) {
    left: 0;
    top: 50%;
    transform: translateY(-50%) rotate(90deg);
}
.controls .column button:nth-of-type(3) {
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
}
.controls .column button:nth-of-type(4) {
    right: 0;
    top: 50%;
    transform: translateY(-50%) rotate(-90deg);
}


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

/* Desktop layout */
@media only screen and (min-width: 600px) {
    .controls {
        left: unset;
        width: fit-content;
    }
}
