/* =========================================================
   Face Breakout. See inc/breakout.php.
   The game sits in a modal <dialog>, so it renders in the top
   layer above everything, the CRT overlays included. It brings
   its own scanlines.
   Prefix: .bo-
   ========================================================= */

html[data-bo-open] {
	overflow: hidden;
	scrollbar-gutter: stable;
}

.bo-game {
	--bo-bg: #05020a;
	--bo-ink: #d7ffd7;
	--bo-dim: #8fbe8f;
	--bo-lime: #39ff14;
	--bo-magenta: #ff00d4;
	--bo-cyan: #00f0ff;
	--bo-yellow: #ffee00;
	--bo-chrome: #c0c0c0;
	--bo-chrome-dark: #808080;
	--bo-label: 'VT323', 'Courier New', monospace;

	position: fixed;
	inset: 0;
	width: 100%;
	height: 100%;
	max-width: none;
	max-height: none;
	margin: 0;
	padding: 0;
	border: 0;
	overflow: hidden;
	background: var(--bo-bg);
	color: var(--bo-ink);
	font-family: var(--bo-label);
	color-scheme: dark;
}
.bo-game[open] {
	display: flex;
	flex-direction: column;
}
.bo-game::backdrop { background: #05020a; }
.bo-game:focus,
.bo-stage:focus { outline: none; }

.bo-sr {
	position: absolute !important;
	width: 1px; height: 1px;
	padding: 0; margin: -1px;
	overflow: hidden;
	clip: rect(0 0 0 0);
	white-space: nowrap;
	border: 0;
}

/* ---------- HUD ---------- */
.bo-hud {
	display: flex;
	justify-content: center;
	gap: clamp(14px, 4vw, 48px);
	padding: 14px 16px 6px;
	font-size: clamp(18px, 3.2vw, 26px);
	letter-spacing: 0.06em;
	color: var(--bo-lime);
	white-space: nowrap;
}
.bo-hud b {
	font-weight: 400;
	color: var(--bo-yellow);
	text-shadow: -1px 0 var(--bo-magenta), 1px 0 var(--bo-cyan);
}

/* ---------- Stage ---------- */
.bo-stage {
	position: relative;
	flex: 1 1 auto;
	min-height: 0;
	display: flex;
	align-items: center;
	justify-content: center;
	touch-action: none;
	user-select: none;
	-webkit-user-select: none;
	-webkit-touch-callout: none;
}

.bo-canvas {
	display: block;
	image-rendering: pixelated;
	image-rendering: crisp-edges;
	border-left: 1px solid rgba(57, 255, 20, 0.25);
	border-right: 1px solid rgba(57, 255, 20, 0.25);
	/* The RGB split the logo has. Spikes on every hit. */
	filter: drop-shadow(-1px 0 rgba(255, 0, 212, 0.55)) drop-shadow(1px 0 rgba(0, 240, 255, 0.55));
	cursor: none;
}
.bo-stage.is-glitch .bo-canvas {
	filter: drop-shadow(-3px 0 rgba(255, 0, 212, 0.8)) drop-shadow(3px 0 rgba(0, 240, 255, 0.8));
	transform: translateX(2px);
}
.bo-stage.is-shake .bo-canvas { animation: bo-shake 0.5s steps(6) 1; }
@keyframes bo-shake {
	0%   { transform: translate(0, 0); }
	20%  { transform: translate(-6px, 3px); }
	40%  { transform: translate(5px, -4px); }
	60%  { transform: translate(-4px, -2px); }
	80%  { transform: translate(3px, 4px); }
	100% { transform: translate(0, 0); }
}
.bo-stage.is-over .bo-canvas,
.bo-stage.is-still .bo-canvas { cursor: default; }

/* ---------- Words on the stage ---------- */
.bo-prompt,
.bo-toast {
	position: absolute;
	left: 50%;
	top: 66%;
	transform: translate(-50%, -50%);
	margin: 0;
	padding: 4px 10px;
	background: var(--bo-bg);
	color: var(--bo-lime);
	font-size: clamp(18px, 3.4vw, 28px);
	line-height: 1.15;
	text-align: center;
	letter-spacing: 0.05em;
	white-space: nowrap;
	pointer-events: none;
}
.bo-prompt { animation: bo-blink 1.1s steps(2) infinite; }
.bo-prompt[hidden],
.bo-toast[hidden] { display: none; }
.bo-prompt__touch { display: none; }
.bo-game.is-touch .bo-prompt__keys { display: none; }
.bo-game.is-touch .bo-prompt__touch { display: inline; }
.bo-toast { color: var(--bo-yellow); }
@keyframes bo-blink { 50% { opacity: 0.25; } }

/* ---------- Buttons ---------- */
.bo-btn {
	appearance: none;
	padding: 10px 22px 8px;
	border: 2px solid var(--bo-chrome);
	border-right-color: var(--bo-chrome-dark);
	border-bottom-color: var(--bo-chrome-dark);
	border-radius: 0;
	background: var(--bo-chrome);
	color: #000;
	font-family: var(--bo-label);
	font-size: clamp(22px, 4vw, 30px);
	line-height: 1;
	letter-spacing: 0.08em;
	cursor: pointer;
	box-shadow: 4px 4px 0 var(--bo-magenta);
}
.bo-btn:hover { background: var(--bo-yellow); }
.bo-btn:active {
	border-color: var(--bo-chrome-dark) var(--bo-chrome) var(--bo-chrome) var(--bo-chrome-dark);
	transform: translate(2px, 2px);
	box-shadow: 2px 2px 0 var(--bo-magenta);
}
.bo-btn:focus-visible { outline: 3px solid var(--bo-cyan); outline-offset: 4px; }
.bo-btn--big {
	padding: 16px 34px 13px;
	font-size: clamp(30px, 6vw, 46px);
	box-shadow: 6px 6px 0 var(--bo-magenta), -6px -6px 0 var(--bo-cyan);
}

.bo-win,
.bo-still {
	position: absolute;
	inset: 0;
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: 18px;
}
.bo-win[hidden],
.bo-still[hidden] { display: none; }
.bo-win { animation: bo-in 0.35s steps(4) 1; }
@keyframes bo-in {
	from { opacity: 0; transform: scale(0.6); }
	to   { opacity: 1; transform: scale(1); }
}
.bo-still { justify-content: flex-end; padding-bottom: 6%; }
.bo-still__line {
	margin: 0;
	padding: 2px 8px;
	background: var(--bo-bg);
	color: var(--bo-lime);
	font-size: clamp(18px, 3vw, 24px);
}
.bo-still__btns { display: flex; gap: 22px; flex-wrap: wrap; justify-content: center; }

/* ---------- Bottom bar ---------- */
.bo-bar {
	display: flex;
	justify-content: space-between;
	align-items: center;
	padding: 6px 16px 12px;
	padding-bottom: max(12px, env(safe-area-inset-bottom));
}
.bo-link {
	appearance: none;
	padding: 6px 4px;
	border: 0;
	background: none;
	color: var(--bo-dim);
	font-family: var(--bo-label);
	font-size: 20px;
	letter-spacing: 0.05em;
	cursor: pointer;
}
.bo-link:hover { color: var(--bo-yellow); }
.bo-link:focus-visible { outline: 2px solid var(--bo-cyan); outline-offset: 2px; color: var(--bo-yellow); }

/* The skip link is there from the start for keyboards, and fades
   in for everyone else after a few seconds. */
.bo-skip { opacity: 0; transition: opacity 0.6s steps(4); }
.bo-game.is-skippable .bo-skip,
.bo-skip:focus-visible { opacity: 1; }

/* Once the wall is gone, the only thing on screen is the button. */
.bo-game.is-won .bo-bar { visibility: hidden; }

/* ---------- CRT ---------- */
.bo-crt {
	position: absolute;
	inset: 0;
	pointer-events: none;
	background:
		radial-gradient(ellipse at center, rgba(0, 0, 0, 0) 50%, rgba(0, 0, 0, 0.75) 100%),
		repeating-linear-gradient(to bottom, rgba(0, 0, 0, 0.3) 0, rgba(0, 0, 0, 0.3) 1px, rgba(0, 0, 0, 0) 1px, rgba(0, 0, 0, 0) 3px);
}

/* Power off: squash to a line, then to a dot. */
.bo-game.is-off { animation: bo-off 0.5s steps(8) forwards; }
@keyframes bo-off {
	0%   { transform: scale(1, 1);      filter: brightness(1); }
	55%  { transform: scale(1, 0.006);  filter: brightness(3); }
	100% { transform: scale(0, 0.006);  filter: brightness(5); }
}

/* The site switching on afterwards. */
.fp-shell.bo-power-on { animation: bo-on 0.45s steps(5) 1; }
@keyframes bo-on {
	0%   { opacity: 0; transform: scale(1, 0.02); }
	50%  { opacity: 1; transform: scale(1, 1.02); }
	100% { opacity: 1; transform: none; }
}

/* PLAY AGAIN, in the homepage footer. */
.bo-again {
	font-family: var(--gc-font-label, 'VT323', monospace);
	letter-spacing: 0.05em;
	text-decoration: none;
}
.bo-again::before { content: '> '; }

@media (prefers-reduced-motion: reduce) {
	.bo-prompt,
	.bo-win,
	.bo-game.is-off,
	.fp-shell.bo-power-on,
	.bo-stage.is-shake .bo-canvas { animation: none !important; }
	.bo-stage.is-glitch .bo-canvas { transform: none; }
	.bo-skip { transition: none; }
}
