/*
 * The fullscreen view (single-fullscreen.php). Loaded on that view only.
 * js/app-view.js places the game; css/screen-fit.css, the kit's page lock, is
 * added on phones only.
 */

/* Nothing scrolls, on any device: the game is the page. No body margin, so
   the "Go back" bar starts at the top and its height is all the game leaves
   for it (js/app-view.js reads that height). */
html,
body.im3d-app-view {
	overflow: hidden;
}

body.im3d-app-view {
	margin: 0;
}

/* The "Go back" bar is printed when wp_is_mobile() says desktop, but the phone
   test is the browser's: a phone the server missed hides it (the ✕ is the
   phone's way out). */
html.im3d-phone #gamecntmt {
	display: none;
}

/* Phones: Android's pull-to-refresh is not stopped by the kit's position:
   fixed. Here, not in the kit's lock, so it holds from the first paint. */
html.im3d-phone,
html.im3d-phone body {
	overscroll-behavior: none;
}

/* The kit's rule for the game element. Its stylesheet is phone-only here, so
   desktops get the rule from this file. */
.im3d-app-view .screen-fit-game {
	display: block;
	border: 0;
	margin: 0;
}

/* The way out, on a phone: there is no "Go back" bar there. Small and faint,
   top-right inside the safe area, above the game, the cover and the kit's
   rotate overlay (z-index 10000), so a phone held the wrong way can still
   leave. Fainter still after 3 s without a touch (js/app-view.js). */
.im3d-app-exit {
	display: none;
}

html.im3d-phone .im3d-app-exit {
	position: fixed;
	top: 8px;
	right: 8px;
	top: calc(8px + env(safe-area-inset-top));
	right: calc(8px + env(safe-area-inset-right));
	z-index: 10001;
	display: flex;
	align-items: center;
	justify-content: center;
	width: 36px;
	height: 36px;
	border-radius: 50%;
	background: #000;
	color: #fff;
	font: 20px/1 system-ui, sans-serif;
	text-decoration: none;
	opacity: .35;
	transition: opacity .4s;
	-webkit-tap-highlight-color: transparent;
}

html.im3d-phone .im3d-app-exit.im3d-app-exit-faint {
	opacity: .15;
}

/* The kit's rotate overlay is navy; here it is the same black as the bars
   and the cover, so turning into and out of it shows no change of colour. */
html.im3d-phone .screen-fit-rotate {
	background: #000;
}

/* The cover, on a phone: the loading screen (logo and progress bar), then
   "Tap to play", then a black layer over the game whenever the screen changes
   (js/app-view.js sets data-state). Shown by CSS from the first paint, before
   any script; never on a desktop. Above the game, below the ✕ and the kit's
   rotate overlay. */
.im3d-app-cover {
	display: none;
}

html.im3d-phone .im3d-app-cover {
	position: fixed;
	top: 0;
	right: 0;
	bottom: 0;
	left: 0;
	inset: 0;
	z-index: 9000;
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	background: #000;
	opacity: 1;
	-webkit-tap-highlight-color: transparent;
}

/* Playing: out of the way, fading over 120ms. */
html.im3d-phone .im3d-app-cover[data-state=playing] {
	opacity: 0;
	pointer-events: none;
	transition: opacity 120ms;
}

/* Changing: up at once, black only. */
html.im3d-phone .im3d-app-cover[data-state=changing] {
	opacity: 1;
	transition: none;
}

.im3d-app-logo {
	display: block;
	max-width: 60vw;
	max-height: 30vh;
	margin-bottom: 24px;
}

.im3d-app-cover[data-state=playing] .im3d-app-logo,
.im3d-app-cover[data-state=changing] .im3d-app-logo {
	visibility: hidden;
}

/* No progress is known (Ruffle gives none here): a stripe that runs across. */
.im3d-app-progress {
	position: relative;
	overflow: hidden;
	width: 50vw;
	max-width: 240px;
	height: 4px;
	border-radius: 2px;
	background: #222;
	display: none;
}

.im3d-app-cover[data-state=loading] .im3d-app-progress {
	display: block;
}

.im3d-app-progress::before {
	content: "";
	position: absolute;
	top: 0;
	bottom: 0;
	left: 0;
	width: 40%;
	background: #fff;
	-webkit-animation: im3d-app-progress 1.2s ease-in-out infinite;
	animation: im3d-app-progress 1.2s ease-in-out infinite;
}

@-webkit-keyframes im3d-app-progress {
	from { -webkit-transform: translateX(-100%); transform: translateX(-100%); }
	to { -webkit-transform: translateX(250%); transform: translateX(250%); }
}

@keyframes im3d-app-progress {
	from { -webkit-transform: translateX(-100%); transform: translateX(-100%); }
	to { -webkit-transform: translateX(250%); transform: translateX(250%); }
}

.im3d-app-tap {
	display: none;
}

html.im3d-phone .im3d-app-cover[data-state=ready] .im3d-app-tap {
	display: block;
	padding: 14px 32px;
	border: 0;
	border-radius: 28px;
	background: #fff;
	color: #000;
	font: 600 18px/1 system-ui, sans-serif;
	cursor: pointer;
	-webkit-appearance: none;
	appearance: none;
}

/* A Flash game still downloading after 15 s (js/app-view.js sets data-slow):
   say so under the bar, instead of a "Tap to play" that could not start it. */
.im3d-app-slow {
	display: none;
}

html.im3d-phone .im3d-app-cover[data-slow="1"][data-state=loading] .im3d-app-slow {
	display: block;
	margin-top: 14px;
	color: #bbb;
	font: 15px/1.3 system-ui, sans-serif;
	text-align: center;
}

/* No game to play (MyArcade refused it): the logo only, no progress bar and
   no "Tap to play". The ✕ stays above the cover. */
html.im3d-phone .im3d-app-cover[data-state=empty] .im3d-app-progress,
html.im3d-phone .im3d-app-cover[data-state=empty] .im3d-app-tap {
	display: none;
}
