:root {
	--w1: #2c48b8;
	--w2: #0c1650;
	--accent: #ffd23d;
	--accent-2: #7ad8ff;
	--bg1: #05071a;
	--bg2: #0c1240;
	--ink: #f4f5ff;
	--ink-dim: #b9bde0;
	--bar-empty: rgba(0, 0, 0, 0.45);
	--frame: #eef0fa;
	--frame-mid: #8d92b8;
	--px: var(--wp--preset--font-family--pixel);
	--txt: var(--wp--preset--font-family--terminal);
	--speed: 1;

	/* game cursors: an arrow, and a pointing hand on anything clickable */
	--cursor: url(../img/cursor-arrow.svg) 0 0, auto;
	--cursor-pointer: url(../img/cursor-hand.svg) 7 1, pointer;
}

* {
	box-sizing: border-box;
}

html,
body {
	margin: 0;
	min-height: 100%;
}

html {
	cursor: var(--cursor);
}

/* a visible focus ring everywhere (forced-colors and low-vision friendly) */
:focus-visible {
	outline: 2px solid var(--accent);
	outline-offset: 2px;
}

body {
	background: var(--bg1);
	color: var(--ink);
	font-family: var(--txt);
	font-size: 24px;
	line-height: 1.1;
	-webkit-font-smoothing: none;
	transition: background-color 0.4s steps(4);
	overflow-x: hidden;
}

a,
button,
label {
	cursor: var(--cursor-pointer);
}

.sr-only {
	position: absolute;
	width: 1px;
	height: 1px;
	overflow: hidden;
	clip: rect(0 0 0 0);
	white-space: nowrap;
}

/* Scrolling checker backdrop, like an SNES menu BG layer */
.kf-app::before,
.kf-page::before {
	content: "";
	position: fixed;
	inset: -64px;
	z-index: -1;
	background: repeating-conic-gradient(var(--bg2) 0 25%, var(--bg1) 0 50%) 0 0 / 32px 32px;
	animation: bgscroll 6s linear infinite;
	opacity: 0.9;
	transition: background 0.4s steps(4);
}

.kf-app::after,
.kf-page::after {
	content: "";
	position: fixed;

	/* behind the windows, over the checker: scanlines on the backdrop only */
	z-index: -1;
	inset: 0;
	background: repeating-linear-gradient(to bottom, rgba(0, 0, 0, 0.28) 0 2px, transparent 2px 4px);
	pointer-events: none;
}

@keyframes bgscroll {

	to {
		transform: translate(32px, 32px);
	}
}

/* Layout */
.screen {
	width: 100%;
	max-width: 1400px;
	margin: 0 auto;
	padding: 20px 16px 28px;
	display: grid;
	gap: 14px;

	/* the stage gets the bigger column, as big as the window height allows */
	grid-template-columns: minmax(0, min(calc((100svh - 214px) * 1.04 + 46px), 53.5%)) minmax(0, 1fr);
	grid-template-rows: auto auto 1fr auto;

	/* header on top; the stage runs the full height beside intro and stats */
	grid-template-areas:
		"header header"
		"portrait intro"
		"portrait status"
		"hint hint";
}


/* SNES window */
.kf-win {
	position: relative;
	background: linear-gradient(180deg, var(--w1), var(--w2));
	border-radius: 10px;
	padding: 18px 22px;
	box-shadow:
		0 0 0 2px #000,
		inset 0 0 0 3px var(--frame),
		inset 0 0 0 5px var(--frame-mid),
		inset 0 0 0 6px #000,
		0 6px 0 2px rgba(0, 0, 0, 0.45);
	transition: background 0.35s steps(5);
	transform-origin: 50% 50%;
}

.kf-win.closing {
	animation: winclose 0.16s steps(4) forwards;
}

.kf-win.opening {
	animation: winopen 0.2s steps(5) forwards;
}

@keyframes winclose {

	to {
		transform: scaleY(0.04);
		filter: brightness(1.6);
	}
}

@keyframes winopen {

	from {
		transform: scaleY(0.04);
		filter: brightness(1.6);
	}

	to {
		transform: none;
	}
}

/* Header: name and contact links on the left, character select on the right */
.kf-header {
	grid-area: header;
	position: relative;
	z-index: 5;
	display: flex;
	align-items: center;
	gap: 16px;
	padding: 8px 16px;
}

.kf-id {
	display: flex;
	align-items: center;
	flex-wrap: wrap;
	gap: 6px 18px;
	margin-right: auto;
}

.name {
	margin: 0;
	font: 20px/1.2 var(--px);
	text-shadow: 3px 3px 0 #000;
}

.tab-list {
	display: flex;
	gap: 10px;
}

/* a tile per class: a live crop of its scene over its name */
.tab {
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 6px;
	text-decoration: none;
	font: 8px/1 var(--px);
	color: var(--ink-dim);
	text-transform: uppercase;
	letter-spacing: 1px;
	text-shadow: 1px 1px 0 #000;
	cursor: var(--cursor-pointer);
}

.face {
	display: block;
	width: 46px;
	height: 46px;
	overflow: hidden;
	background: #000;
	border: 2px solid var(--frame-mid);
	border-radius: 4px;
	box-shadow: 0 0 0 2px #000;
	filter: saturate(0.5) brightness(0.75);
	transition: filter 0.12s steps(2);
}

/* zoomed in on the character: --face is where they stand in the scene */
.face img {
	display: block;
	width: 100%;
	height: 100%;
	object-fit: cover;
	image-rendering: pixelated;
	transform: scale(var(--zoom, 2.6));
	transform-origin: var(--face, 50% 40%);
}

.tab:hover,
.tab:focus-visible,
.tab[aria-selected="true"] {
	color: var(--ink);
}

.tab:hover .face,
.tab:focus-visible .face {
	filter: none;
	border-color: var(--ink);
}

.tab[aria-selected="true"] .face {
	filter: none;
	border-color: var(--accent);
}

.tab[aria-selected="true"] .tab-name {
	color: var(--accent);
}

/* where each class's character sits in its scene */
#tab-developer {
	--face: 30% 35%;
}

#tab-designer {
	--face: 45% 40%;
}

/* show the guitar; the coach tile takes in the student and the bat */
#tab-musician {
	--face: 45% 62%;
	--zoom: 1.7;
}

#tab-coach {
	--face: 30% 60%;
	--zoom: 1.8;
}

/* the class menu replaces the tiles on phones */
.class-menu {
	display: none;
	align-items: center;
	gap: 6px;
	font: 10px/1 var(--px);
	color: var(--accent);
	text-transform: uppercase;
	background: rgba(0, 0, 0, 0.35);
	border: 2px solid var(--accent);
	border-radius: 4px;
	padding: 7px 8px;
	cursor: var(--cursor-pointer);
}

.cursor {
	position: absolute;
	left: 0;
	top: 50%;
	width: 21px;
	height: 14px;
	margin-top: -7px;
	background: url(../img/cursor.svg) no-repeat center / contain;
	image-rendering: pixelated;
	opacity: 0;
}

@keyframes point {

	50% {
		transform: translateX(3px);
	}
}

.sound {
	white-space: nowrap;
	font: 10px/1 var(--px);
	color: var(--ink-dim);
	background: rgba(0, 0, 0, 0.35);
	border: 2px solid var(--frame-mid);
	border-radius: 4px;
	padding: 6px 8px;
	cursor: var(--cursor-pointer);
}

.sound[aria-pressed="true"] {
	color: var(--accent);
	border-color: var(--accent);
}

/* Portrait */
.portrait {
	grid-area: portrait;
	display: flex;
	flex-direction: column;
	gap: 12px;
}

.stage {
	position: relative;
	border-radius: 4px;
	overflow: hidden;
	box-shadow: 0 0 0 3px #000, 0 0 0 5px var(--frame-mid);
	background: #000;

	/* one fixed shape for every scene, so switching never moves the page */
	aspect-ratio: 291 / 280;
}

.stage img,
.stage canvas {
	display: block;
	width: 100%;
	height: 100%;
	object-fit: cover;
	object-position: center bottom;
	image-rendering: pixelated;
	image-rendering: crisp-edges;
}

/* guitar and bass: the player is clickable (swaps the instrument) */
.stage img.swappable {
	cursor: var(--cursor-pointer);
}

/* the mosaic transition draws over the scene while it swaps */
.stage canvas {
	position: absolute;
	inset: 0;
}

.stage canvas[hidden] {
	display: none;
}

/* under the stage: AUTO and the scene chips, then the caption on the right */
.stage-bar {
	display: flex;
	align-items: center;
	gap: 6px 12px;
	min-height: 32px;

	/* line up with the stage's outer frame, which is drawn 5px outside its box */
	margin: 0 -5px;
}

.caption {
	flex: 1;
	margin: 0;
	text-align: right;
	font: 10px/1.6 var(--px);
	color: var(--ink);
	text-shadow: 2px 2px 0 #000;
}

.acts {
	display: flex;
	align-items: center;
	gap: 4px;
}

/* single-scene characters keep the row's space, so the panel never moves */
.acts[hidden] {
	display: flex;
	visibility: hidden;
}

.act-list {
	display: flex;
	gap: 4px;
}

.act-chip,
.auto {
	font: 9px/1 var(--px);
	color: var(--ink-dim);
	background: rgba(0, 0, 0, 0.35);
	border: 2px solid var(--frame-mid);
	border-radius: 4px;
	padding: 6px 7px;
	cursor: var(--cursor-pointer);
	text-shadow: 1px 1px 0 #000;
}

.auto {
	margin-right: 20px;
}

.act-chip[aria-pressed="true"],
.auto[aria-pressed="true"] {
	color: #000;
	background: var(--accent);
	border-color: var(--accent);
	text-shadow: none;
}

.act-chip:hover,
.auto:hover {
	color: var(--ink);
	border-color: var(--ink);
}

/* hover or focus GTR / BASS: the rack pops up above the chip */
.act {
	position: relative;
	display: inline-flex;
}

.picker {
	position: absolute;
	z-index: 12;
	bottom: calc(100% + 8px);
	left: 0;
	display: flex;
	align-items: flex-end;
	gap: 4px;
	padding: 8px;
	background: linear-gradient(180deg, var(--w1), var(--w2));
	border-radius: 6px;
	box-shadow: 0 0 0 2px #000, inset 0 0 0 2px var(--frame), 0 4px 0 2px rgba(0, 0, 0, 0.45);
	opacity: 0;
	visibility: hidden;
	transition: opacity 0.12s steps(2), visibility 0s 0.12s;
}

/* a little bridge so the pointer can travel from the chip up into the rack */
.picker::after {
	content: "";
	position: absolute;
	left: 0;
	right: 0;
	top: 100%;
	height: 10px;
}

/* hover, keyboard focus, or (touch screens) a tap on the chip opens it */
.act.is-open .picker,
.act:has(:focus-visible) .picker {
	opacity: 1;
	visibility: visible;
	transition-delay: 0s;
}

@media (hover: hover) {

	.act:hover .picker {
		opacity: 1;
		visibility: visible;
		transition-delay: 0s;
	}
}

.picker button {
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 6px;
	padding: 6px 5px 5px;
	min-width: 44px;
	font: 7px/1 var(--px);
	color: var(--ink-dim);
	text-shadow: 1px 1px 0 #000;
	white-space: nowrap;
	background: rgba(0, 0, 0, 0.35);
	border: 2px solid transparent;
	border-radius: 4px;
	cursor: var(--cursor-pointer);
}

.picker svg {
	display: block;
	height: 44px;
	width: auto;
	shape-rendering: crispedges;
	filter: drop-shadow(1px 1px 0 #000);
}

.picker button:hover,
.picker button:focus-visible {
	color: var(--ink);
	border-color: var(--ink);
}

.picker button[aria-pressed="true"] {
	color: #000;
	background: var(--accent);
	border-color: var(--accent);
	text-shadow: none;
}

/* AUTO is a mode, not a scene: green when it's on */
.auto[aria-pressed="true"],
.auto[aria-pressed="true"]:hover {
	background: #3ddc6a;
	border-color: #b8ffcc;
}

.equip .equip-btn {
	font: inherit;
	color: var(--accent);
	background: none;
	border: 0;
	padding: 0;
	text-align: left;
	cursor: var(--cursor-pointer);
	text-shadow: 2px 2px 0 #000;
	text-decoration: underline dotted;
	text-underline-offset: 4px;
}

.gear-menu {
	position: fixed;
	z-index: 20;
	left: 50%;
	top: 50%;
	transform: translate(-50%, -50%);
	width: min(520px, calc(100vw - 32px));
	max-height: calc(100vh - 32px);
	overflow: auto;
}

.gear-menu[hidden] {
	display: none;
}

.gear-menu ul {
	list-style: none;
	margin: 10px 0 0;
	padding: 0;
}

.gear-menu li button {
	position: relative;
	display: block;
	width: 100%;
	text-align: left;
	font: 22px/1.2 var(--txt);
	color: var(--ink);
	background: none;
	border: 0;
	padding: 6px 6px 6px 30px;
	cursor: var(--cursor-pointer);
	text-shadow: 2px 2px 0 #000;
}

.gear-menu li button[aria-selected="true"] {
	color: var(--accent);
}

.gear-menu li button:hover .cursor,
.gear-menu li button:focus-visible .cursor,
.gear-menu li button[aria-selected="true"] .cursor {
	opacity: 1;
	animation: point 0.5s steps(2) infinite;
}

/* Status */
.kf-status {
	grid-area: status;
	display: flex;
	flex-direction: column;
	gap: 10px;
}

/* every class is in the page; the active one is the window's content */
.kf-status .panel {
	display: contents;
}

.kf-app [hidden]:not(.acts) {
	display: none !important;
}

.who {
	display: flex;
	justify-content: space-between;
	align-items: flex-start;
	gap: 12px;
	margin-bottom: 8px;
}

.class-title {
	margin: 0;
	font: 16px/1.3 var(--px);
	color: var(--ink);
	text-transform: uppercase;
	text-shadow: 3px 3px 0 #000;
}

.class-title .job {
	font: 26px/1 var(--txt);
	color: var(--accent);
	text-transform: none;
	text-shadow: 2px 2px 0 #000;
}

.lv {
	font: 26px/1 var(--px);
	color: var(--ink);
	text-shadow: 3px 3px 0 #000;
	white-space: nowrap;
}

.lv small {
	font-size: 10px;
	color: var(--accent-2);
	margin-right: 6px;
}

.vitals {
	display: grid;
	grid-template-columns: repeat(2, minmax(0, 1fr));
	gap: 6px 18px;
}

.vital {
	display: grid;
	grid-template-columns: auto 1fr;
	align-items: baseline;
	gap: 0 8px;
}

.vital .k {
	font: 12px/1 var(--px);
	color: var(--accent-2);
	text-shadow: 2px 2px 0 #000;
}

.vital .v {
	justify-self: end;
	font-size: 26px;
	text-shadow: 2px 2px 0 #000;
}

.vital .n {
	grid-column: 1 / -1;
	font-size: 18px;
	color: var(--ink-dim);
}

.vital .bar,
.exp .bar {
	grid-column: 1 / -1;
}

.bar {
	position: relative;
	height: 8px;
	background: var(--bar-empty);
	box-shadow: 0 0 0 2px #000;
	margin-top: 4px;
}

.bar i {
	position: absolute;
	inset: 0 auto 0 0;
	width: calc(var(--v, 0) * 100%);
	background: linear-gradient(180deg, #fff 0 25%, var(--c, var(--accent)) 25% 75%, rgba(0, 0, 0, 0.35) 75%);
	transition: width 0.7s steps(14);
}

.exp {
	grid-column: 1 / -1;
	display: grid;
	grid-template-columns: auto 1fr;
	gap: 0 8px;
	align-items: center;
	font: 10px/1 var(--px);
	color: var(--accent-2);
}

.exp .bar {
	grid-column: auto;
	margin: 0;
}

.kf-label {
	margin: 4px 0 2px;
	font: 10px/1 var(--px);
	color: var(--accent-2);
	text-transform: uppercase;
	letter-spacing: 1px;
	text-shadow: 2px 2px 0 #000;
}

.stats {
	list-style: none;
	margin: 0;
	padding: 0;
	display: grid;
	gap: 2px;
}

.stats li {
	display: grid;
	grid-template-columns: 9.5em 1fr 2.2em;
	align-items: center;
	gap: 10px;
	text-shadow: 2px 2px 0 #000;
}

.stats b {
	font-weight: 400;
	text-align: right;
	color: var(--ink);
}

/* segmented stat meter */
.meter {
	height: 10px;
	background: repeating-linear-gradient(90deg, var(--bar-empty) 0 8px, transparent 8px 10px);
	position: relative;
}

.meter i {
	position: absolute;
	inset: 0 auto 0 0;
	width: calc(var(--v, 0) * 1%);
	background: repeating-linear-gradient(90deg, var(--accent) 0 8px, transparent 8px 10px);
	transition: width 0.8s steps(10);
	filter: drop-shadow(0 2px 0 rgba(0, 0, 0, 0.5));
}

.cols {
	display: grid;
	grid-template-columns: repeat(2, minmax(0, 1fr));
	gap: 8px 22px;
}

.equip {
	margin: 0;
	display: grid;
	grid-template-columns: auto 1fr;
	gap: 2px 10px;
	text-shadow: 2px 2px 0 #000;
}

.equip dt {
	color: var(--ink-dim);
}

.equip dd {
	margin: 0;
}

.abilities {
	list-style: none;
	margin: 0;
	padding: 0;
	text-shadow: 2px 2px 0 #000;
}

.abilities li::before {
	content: "✦ ";
	color: var(--accent);
}

/* Intro: the class, its level and what it's about */
.kf-intro {
	grid-area: intro;
}

.kf-intro .bio {
	position: relative;
	margin: 0;
	font-size: 28px;
	line-height: 1.15;
	text-shadow: 2px 2px 0 #000;
}

/* while it types, the full text keeps the box's size but can't be seen */
.bio.is-typing .bio-full {
	color: transparent;
	text-shadow: none;
}

.bio-typed {
	position: absolute;
	inset: 0;
}

.more {
	position: absolute;
	right: 18px;
	bottom: 12px;
	font-size: 16px;
	color: var(--accent);
	animation: bob 0.6s steps(2) infinite;
}

@keyframes bob {

	50% {
		transform: translateY(3px);
	}
}

/* Contact icons, next to the name */
.links ul {
	position: relative;
	list-style: none;
	margin: 0;
	padding: 0;
	display: flex;
	gap: 10px;
}

.links a {
	display: block;
	padding: 2px;
	color: var(--icon, var(--ink-dim));
}

/* brand colors (GitHub is white on dark; Instagram, YouTube are in the svg) */
.links a[data-key="mail"] {
	--icon: #ff9a4a;
}

.links a[data-key="github"] {
	--icon: #fff;
}

.links a[data-key="linkedin"] {
	--icon: #0a66c2;
}

.links a[data-key="chain"] {
	--icon: #ffd23d;
}

/* a little SNES text box under the icon */
.links a::after {
	content: attr(data-tip);
	position: absolute;
	z-index: 15;
	top: calc(100% + 8px);
	left: 0;
	padding: 6px 9px;
	white-space: nowrap;
	font: 9px/1.4 var(--px);
	color: var(--ink);
	text-shadow: 1px 1px 0 #000;
	background: var(--w2);
	border-radius: 4px;
	box-shadow: 0 0 0 2px #000, inset 0 0 0 2px var(--frame);
	pointer-events: none;
	opacity: 0;
	visibility: hidden;
}

.links a:hover::after,
.links a:focus-visible::after {
	opacity: 1;
	visibility: visible;
}

.links svg {
	display: block;
	height: 18px;
	width: auto;
	shape-rendering: crispedges;

	/* on the svg, not the link, so the tooltip positions against the whole row */
	filter: drop-shadow(2px 2px 0 #000);
}

.links a:hover svg,
.links a:focus-visible svg {
	filter: drop-shadow(2px 2px 0 #000) brightness(1.35);
	transform: translateY(-1px);
}

.hint {
	grid-area: hint;
	margin: 0;
	text-align: center;
	font: 9px/1 var(--px);
	color: var(--ink-dim);
	opacity: 0.7;
}

@media (max-width: 860px) {

	body {
		font-size: 22px;
	}

	/* phones: who you are, the stage, what you do, then the stats */
	.screen {
		grid-template-columns: minmax(0, 1fr);
		grid-template-areas:
			"header"
			"portrait"
			"intro"
			"status";
		padding-top: 12px;
	}

	.kf-header {
		gap: 10px;
		padding: 10px 12px;
	}

	.name {
		font-size: 14px;
	}

	.kf-id {
		gap: 8px 12px;
	}

	.class-menu {
		display: inline-flex;
	}

	/* the class list drops down from the class menu */
	.tab-list {
		display: none;
		position: absolute;
		z-index: 20;
		top: calc(100% + 8px);
		right: 8px;
		flex-direction: column;
		gap: 4px;
		padding: 8px;
		background: linear-gradient(180deg, var(--w1), var(--w2));
		border-radius: 6px;
		box-shadow: 0 0 0 2px #000, inset 0 0 0 2px var(--frame), 0 4px 0 2px rgba(0, 0, 0, 0.45);
	}

	.tab-list.is-open {
		display: flex;
	}

	.tab {
		flex-direction: row;
		gap: 10px;
		padding: 4px 10px 4px 4px;
		font-size: 10px;
	}

	.face {
		width: 36px;
		height: 36px;
	}

	/* just the note on phones; its highlight shows when sound is on */
	.sound {
		padding: 6px 8px;
	}

	.sound span {
		display: none;
	}

	.hint {
		display: none;
	}

	.class-title {
		font-size: 13px;
	}

	.class-title .job {
		font-size: 22px;
	}

	.lv {
		font-size: 20px;
	}

	.kf-intro .bio {
		font-size: 24px;
	}

	.stats li {
		grid-template-columns: 7.5em 1fr 2em;
	}

	/* no hover on phones, so no tooltips */
	.links a::after {
		display: none;
	}
}

@media (max-width: 520px) {

	.cols,
	.vitals {
		grid-template-columns: minmax(0, 1fr);
	}
}

@media (prefers-reduced-motion: reduce) {

	.kf-app::before,
	.kf-page::before {
		animation: none;
	}

	.kf-win.closing,
	.kf-win.opening {
		animation-duration: 0.01s;
	}
}

@media (max-width: 600px) {

	/* the rack spans the button row instead of hanging off one chip */
	.acts {
		position: relative;
	}

	.act {
		position: static;
	}

	.picker {
		right: 0;
		flex-wrap: wrap;
		justify-content: center;
	}

	/* chips on one line, the scene line under them */
	.stage-bar {
		flex-wrap: wrap;
	}

	.caption {
		flex-basis: 100%;
		min-height: 3.2em;
	}
}

/* Other pages (404): one window in the middle of the backdrop */
.kf-404 {
	display: grid;
	place-items: center;
	min-height: 100svh;
	padding: 16px;
}

.kf-404 .kf-win {
	display: grid;
	gap: 16px;
	max-width: 520px;
	padding: 28px 32px;
	text-align: center;
}

.kf-404 p {
	margin: 0;
}

.kf-404 h1 {
	margin: 0;
	font: 20px/1.2 var(--px);
	text-shadow: 3px 3px 0 #000;
}

.kf-404 .wp-block-buttons {
	justify-content: center;
}

.kf-404 .wp-block-button__link {
	font: 10px/1 var(--px);
	color: #000;
	background: var(--accent);
	border-radius: 4px;
}

/* desktop: the screen sits in the middle of the window */
@media (min-width: 861px) {

	body {
		min-height: 100svh;
		display: flex;
		flex-direction: column;
		justify-content: center;
	}
}

@media (min-width: 861px) and (max-height: 960px) {

	/* no hint row (so no empty gap); a little extra bottom for the drop shadow */
	.screen {
		grid-template-rows: auto auto 1fr;
		grid-template-areas:
			"header header"
			"portrait intro"
			"portrait status";
		padding: 16px 16px 22px;
		gap: 10px;
	}

	.kf-win {
		padding: 14px 20px;
	}

	.kf-intro .bio {
		font-size: 24px;
	}

	.hint {
		display: none;
	}

	.kf-status {
		font-size: 22px;
		gap: 8px;
	}
}

/* very short windows: the right column's text shrinks a touch so it fits */
@media (min-width: 861px) and (max-height: 740px) {

	.kf-intro .bio {
		font-size: 21px;
	}

	.kf-status {
		font-size: 20px;
		gap: 6px;
	}
}
