/*

GBA ONLINE;  GBA.JS.ORG;  "Online GameBoy Advance Emulator"
Copyright (C) 2021-present AYVACS
Licensed under the MIT License (view LICENSE.md for more information)

*/


/*
|-----------------------------------------
| Core CSS
|-----------------------------------------
 */

html,
body {
    font-family: Open Sans, Arial, sans-serif;
    height: 100%;
    width: 100%;
    margin: 0;
    padding: 0;
    background: #000;
    overflow: hidden;
    box-sizing: border-box;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    -khtml-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}


/* reset all list items */

ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

#container {
    width: 100%;
    height: 100%;
}

#main {
    position: absolute;
    top: 0px;
    left: 0px;
    right: 0px;
    bottom: 0px;
}


/*
|-----------------------------------------
| Canvas
|-----------------------------------------
|
| Classes are automatically overwritten
| by the filter styles, therefore only
| attributes and id"s can be used.
|
 */

canvas {
    margin: auto;
    display: block;
    padding: 0px;
    background-color: rgb(248, 248, 248);
    cursor: none;
}

canvas.textureSmooth {
    image-rendering: auto;
    image-rendering: optimizeQuality;
    -ms-interpolation-mode: bicubic;
}

canvas.texturePixelated {
    image-rendering: -webkit-optimize-contrast;
    image-rendering: -o-crisp-edges;
    image-rendering: -moz-crisp-edges;
    image-rendering: crisp-edges;
    image-rendering: pixelated;
    -ms-interpolation-mode: nearest-neighbor;
}


/*
|-----------------------------------------
| Messages
|-----------------------------------------
 */

.message {
    background: #6cc27d;
    padding: 1em 2em;
    text-align: center;
    color: #fff;
    bottom: 0px;
    position: fixed;
    left: 0px;
    display: none;
    font-weight: bold;
    vertical-align: bottom;
    font-family: monospace;
    z-index: 1;
}


/*
|-----------------------------------------
| Main Menu
|-----------------------------------------
 */


/* top level menu */

div#menu {
    position: absolute;
    z-index: 1;
    width: 100%;
    height: 0px;
}

.menu {
    position: fixed;
    display: flex;
    flex-wrap: wrap;
    width: 100%;
    background: #fff;
    border-bottom: 1px solid rgba(0, 0, 0, .1);
    transition: .3s ease;
    cursor: pointer;
}


/* auto hide menu while playing */

.playing .menu {
    opacity: 0;
}

.playing .menu:hover {
    opacity: 0.9;
}


/* sub level menu */

.menu ul {
    visibility: hidden;
    opacity: 0;
    position: absolute;
    top: 100%;
    left: 0;
    background-color: rgb(245, 245, 245);
    box-shadow: 0 5px 10px 0 rgba(0, 0, 0, .1);
    transition: .3s ease;
    z-index: 1;
}

li.hide {
    display: none !important;
}


/* bottom level nav */

.menu ul ul {
    top: 0;
    left: 100%;
}

#menu_top li {
    padding: .7em 1em;
}

.menu ul li {
    padding: .3em 1em !important;
}

.menu li {
    white-space: nowrap;
    position: relative;
    cursor: pointer;
}

.menu li:hover {
    /*background: rgba(0,0,0,.1);*/
}


/* show sub nav on hover */

.menu li:hover>ul {
    visibility: visible;
    opacity: 1;
}


/*
|-----------------------------------------
| Touch Controls
|-----------------------------------------
 */

.touch-dpad {
    grid-area: dpad;
}
#touch-a {
    grid-area: a;
}
#touch-b {
    grid-area: b;
}
#touch-r {
    grid-area: r;
    transform-origin: bottom left;
}
#touch-l {
    grid-area: l;
    transform-origin: bottom right;
}
#touch-select {
    grid-area: select;
}
#touch-start {
    grid-area: start;
}

#touch-r, #touch-start {
    justify-self: end;
}

.touch-controls, .touch-dpad {
    --font-size: 0.85rem;
    font-size: 0px;
    touch-action: none;
}
.touch-controls > *, .touch-dpad > * {
    font-size: var(--font-size);
}

.touch-controls {
    display: grid;
    align-items: center;
    justify-content: space-between;
    justify-items: start;
    grid-template-columns: minmax(9em, 100%) auto auto;
    grid-template-areas:
        "l ............ r"
        "dpad b a"
        "select . start";
    padding: calc(1 * var(--font-size));
    position: absolute;
    bottom: 0px;
    left: 0px;
    right: 0px;
}

.touch-controls button {
    position: relative;
    display: inline-block;
    -webkit-appearance: none;
    border: 0;
    outline: 0;
    background: #c7c7c7;
    color: #a9a9a9;
    font-weight: bold;
    width: 3em;
    height: 3em;
    line-height: 3em;
    text-align: center;
    cursor: pointer;
    transition: all .1s ease;
    margin: 0;
    padding: 0;
}
.touch-controls button:focus, .touch-controls button:active {
    -webkit-tap-highlight-color: transparent;
}

.touch-controls button:active,
.touch-controls button.pressed {
    transform: scale(0.95);
    box-shadow: 0 0 10px 0 #000 inset;
}

.touch-dpad button:active:after,
.touch-dpad button.pressed:after {
    transform: scale(0.95);
}

.touch-dpad {
    margin-left: calc(3 * var(--font-size));
    width: calc(9 * var(--font-size));
    height: calc(9 * var(--font-size));
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
}

#touch-up, #touch-down {
    margin-inline: 3em;
}

#touch-up {
    border-radius: 15% 15% 0 0;
    transform-origin: bottom;
}
#touch-right {
    border-radius: 0 15% 15% 0;
    transform-origin: left;
}
#touch-down {
    border-radius: 0 0 15% 15%;
    transform-origin: top;
}

#touch-left {
    border-radius: 15% 0 0 15%;
    transform-origin: right;
}

#touch-up:before, #touch-right:before, #touch-down:before, #touch-left:before {
    width: 100%;
    height: 100%;
    content: " ";
    display: block;
    background: linear-gradient(0deg, #c7c7c7 1%, transparent 50%);
}
#touch-right:before {
    background: linear-gradient(90deg, #c7c7c7 1%, transparent 50%);
}
#touch-down:before {
    background: linear-gradient(180deg, #c7c7c7 1%, transparent 50%);
}
#touch-left:before {
    background: linear-gradient(270deg, #c7c7c7 1%, transparent 50%);
}

#touch-up:after, #touch-right:after, #touch-down:after, #touch-left:after, #center-placeholder:after {
    position: absolute;
    content: " ";
    border-width: 0em 0.7em 1em;
    border-style: solid;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    border-color: transparent transparent #a9a9a9 transparent;
}
#touch-right:after {
    transform: translate(-50%, -50%) rotate(90deg);
}
#touch-down:after {
    transform: translate(-50%, -50%) rotate(180deg);
}
#touch-left:after {
    transform: translate(-50%, -50%) rotate(270deg);
}

#center-placeholder {

}
.touch-controls #center-placeholder:active,
.touch-controls #center-placeholder.pressed {
    transform: none;
    box-shadow: none;
}
#center-placeholder:after {
    border-width: 0;
    border-radius: 50%;
    width: 1.5em;
    height: 1.5em;
    background: #c7c7c7;
    box-shadow: -1px -1px 10px 0px #a9a9a9 inset;
}

#touch-a, #touch-b {
    border-radius: 50%;
    margin: 1em;
}

#touch-r, #touch-l, #touch-select, #touch-start {
    position: relative;
    height: 2em;
    line-height: 2em;
    border-radius: 1em;
}

#touch-r, #touch-l {
    width: 4em;
    border-radius: 0.5em;
}
#touch-r {
    clip-path: polygon(0 0, 100% 0, 100% 100%, 33% 100%, 33% 50%, 0 50%);
}
#touch-l {
    clip-path: polygon(0 0, 100% 0, 100% 50%, 66% 50%, 66% 100%, 0 100%);
}

#touch-select, #touch-start {
    width: auto;
    margin-top: 1em;
    border: 1px solid #7f7f7f80;
    background: transparent;
    color: #7f7f7f80;
    font-weight: normal;
    display: flex;
    justify-content: right;
    align-items: center;
    padding-left: 0.6em;
}
#touch-select:after, #touch-start:after {
    content: "";
    display: inline-block;
    width: 2em;
    height: 2em;
    border-radius: 50%;
    background: white;
    transform-origin: center;
    transform: scale(0.6);
}
.touch-controls #touch-select:active,
.touch-controls #touch-select.pressed,
.touch-controls #touch-start:active,
.touch-controls #touch-start.pressed {
    transform: scale(1);
    box-shadow: 0 0 0 0 #000 inset;
}
.touch-controls #touch-select:active:after,
.touch-controls #touch-select.pressed:after,
.touch-controls #touch-start:active:after,
.touch-controls #touch-start.pressed:after {
    transform: scale(0.57);
    box-shadow: 0 0 10px 0 #000 inset;
}

/* Only show controls on touch screens */
@media (pointer: fine) {
    .touch-controls {
        display: none;
    }
    #main {
        display: flex;
        justify-content: center;
        flex-grow: 1;
        align-items: center;
    }
}