/*

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: #000;
    /* Default to crisp pixels. Smoothing a 240x160 framebuffer up to a
       desktop viewport is what makes emulator output look mushy; the
       Smooth Scaling toggle still switches it back. */
    image-rendering: pixelated;
}

/* Hide the pointer only while a game is actually running. */
.playing canvas { 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-controls {
    display: flex;
    padding: 1em;
    position: absolute;
    bottom: 0px;
    left: 0px;
    right: 0px;
}

.touch-controls button {
    display: inline-block;
    -webkit-appearance: none;
    border: 0;
    outline: 0;
    background: #fff;
    opacity: 0.7;
    width: 3em;
    height: 3em;
    line-height: 3em;
    text-align: center;
    cursor: pointer;
    transition: .1s ease;
    margin: .5em;
}

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

.touch-dpad,
.touch-buttons {
    flex-grow: 1;
    text-align: center;
}

.touch-buttons {
    align-self: flex-end;
}

.touch-dpad--up {
    flex-grow: 1;
    width: 100%;
}


/*
|-----------------------------------------
| Touch control visibility
|-----------------------------------------
|
| Previously these were hidden at min-aspect-ratio: 1/1, which removed every
| control the moment a phone was turned landscape - the orientation you would
| actually hold a handheld in. Gate on input type instead of orientation: show
| them wherever the primary pointer is coarse and there is no hover.
*/

.touch-controls { display: none; }

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

@media (hover: none) and (pointer: coarse) {
    .touch-controls {
        display: flex;
        z-index: 300;
        padding: var(--u3, 12px);
        padding-bottom: max(var(--u3, 12px), env(safe-area-inset-bottom));
    }
}

/* Landscape on a handheld: pin the pads to the edges so the screen keeps
   the middle of the viewport instead of being pushed up by a bottom bar. */
@media (hover: none) and (pointer: coarse) and (orientation: landscape) {
    .touch-controls {
        top: 0;
        bottom: 0;
        align-items: center;
        justify-content: space-between;
        pointer-events: none;
    }
    .touch-dpad,
    .touch-buttons { pointer-events: auto; flex-grow: 0; align-self: center; }

    /*
     Markup order is dpad, then Select/Start, then the face buttons. With three
     flex children, space-between parks Select/Start dead centre — on top of the
     game. Pull that group out of the flow and pin it along the bottom edge.

     Addressed by nth-of-type(2), not .touch-buttons:first-of-type: all three
     children are divs, so :first-of-type resolves against the div type and
     matches the dpad, never the Select/Start group.
    */
    .touch-controls > div:nth-of-type(2) {
        position: absolute;
        left: 50%;
        bottom: max(6px, env(safe-area-inset-bottom));
        transform: translateX(-50%);
        display: flex;
        gap: var(--u2, 8px);
    }
    .touch-controls > div:nth-of-type(2) button {
        width: auto;
        min-width: 0;
        height: 34px;
        min-height: 34px;
        padding: 0 14px;
        font-size: 10px;
        letter-spacing: 0.1em;
        opacity: 0.55;
        margin: 0;
    }

    #main { padding: 0 96px; }
}

/* Touch targets must clear 44px however small the screen gets. */
.touch-controls button {
    min-width: 48px;
    min-height: 48px;
    width: 3em;
    height: 3em;
    background: rgba(20, 17, 29, 0.85);
    border: 2px solid #2e2842;
    color: #f2f0ff;
    font-family: ui-monospace, Menlo, monospace;
    font-size: 14px;
    opacity: 0.9;
    margin: 6px;
    transition: background 80ms steps(2, end), transform 80ms steps(2, end);
}

.touch-controls button:active {
    transform: scale(0.94);
    background: #d600ff;
    box-shadow: none;
}
