@import url("fontawesome-all.min.css");

.chess-page {
	background: #f4f1ea;
	color: #4d514f;
}

.chess-page .site-header {
	align-items: center;
	background: #263a3a;
	color: #f4f1ea;
	display: flex;
	justify-content: space-between;
	padding: 1.5rem max(5vw, 1.5rem);
}

.chess-page .site-header h1 {
	color: #f4f1ea;
	font-size: 1.35rem;
	margin: 0;
}

.chess-page .site-header h1 i {
	color: #e2a85b;
	margin-right: .45rem;
}

.chess-page .back-link {
	border-bottom: 0;
	color: #f4f1ea;
	font-size: .85rem;
	letter-spacing: .04em;
	text-transform: uppercase;
}

.chess-page .back-link i {
	margin-right: .4rem;
}

.chess-main {
	margin: 0 auto;
	max-width: 1100px;
	padding: 5rem 1.5rem 6rem;
}

.chess-intro {
	max-width: 680px;
}

.chess-intro .eyebrow {
	color: #b56e34;
	font-size: .78rem;
	font-weight: 700;
	letter-spacing: .14em;
	margin-bottom: .9rem;
	text-transform: uppercase;
}

.chess-intro h2 {
	color: #263a3a;
	font-size: clamp(2.1rem, 5vw, 4rem);
	line-height: 1.05;
	margin-bottom: 1rem;
}

.chess-intro p {
	font-size: 1.05rem;
}

.search-panel {
	background: #fffdf8;
	border-left: 4px solid #e2a85b;
	box-shadow: 0 16px 40px rgba(38, 58, 58, .1);
	margin: 2.5rem 0 3rem;
	padding: 1.6rem;
}

.search-fields {
	display: grid;
	gap: 1rem;
	grid-template-columns: minmax(0, 2fr) minmax(10rem, 1fr) minmax(6rem, .5fr) auto;
}

.search-fields label {
	color: #263a3a;
	display: block;
	font-size: .8rem;
	font-weight: 700;
	letter-spacing: .05em;
	margin-bottom: .35rem;
	text-transform: uppercase;
}

.search-fields input,
.search-fields select {
	background: #f4f1ea;
	border: 1px solid #d5d0c5;
	border-radius: 0;
	color: #263a3a;
	height: 3.1rem;
	padding: 0 .8rem;
	width: 100%;
}

.search-fields input:focus,
.search-fields select:focus {
	border-color: #b56e34;
	box-shadow: 0 0 0 2px rgba(181, 110, 52, .2);
	outline: 0;
}

.search-button {
	align-self: end;
	background: #b56e34;
	border: 0;
	color: #fffdf8;
	cursor: pointer;
	font-weight: 700;
	height: 3.1rem;
	padding: 0 1.3rem;
	transition: background .2s ease, transform .2s ease;
}

.search-button:hover,
.search-button:focus {
	background: #8e5026;
	color: #fffdf8;
	transform: translateY(-1px);
}

.results-heading {
	align-items: baseline;
	display: flex;
	justify-content: space-between;
	margin-bottom: 1rem;
}

.results-heading h3 {
	color: #263a3a;
	font-size: 1.55rem;
	margin: 0;
}

#result-count {
	color: #8e8a80;
	font-size: .9rem;
}

.board-preview-panel {
	background: #fffdf8;
	border-left: 4px solid #e2a85b;
	box-shadow: 0 16px 40px rgba(38, 58, 58, .1);
	margin: 0 0 2rem;
	padding: 1.25rem 1.4rem;
}

.board-preview-panel h3 {
	color: #263a3a;
	font-size: 1rem;
	letter-spacing: .08em;
	margin: 0 0 .9rem;
	text-transform: uppercase;
}

.board-editor-controls {
	align-items: end;
	display: flex;
	flex-wrap: wrap;
	gap: .75rem 1rem;
	margin-bottom: 1rem;
}

.board-edit-toggle {
	background: #263a3a;
	border: 0;
	color: #fffdf8;
	cursor: pointer;
	font-weight: 700;
	min-height: 2.75rem;
	padding: 0 .9rem;
}

.board-edit-toggle:hover,
.board-edit-toggle:focus {
	background: #3e5a55;
	color: #fffdf8;
}

.board-editor-controls label {
	color: #263a3a;
	display: block;
	font-size: .75rem;
	font-weight: 700;
	margin-bottom: .3rem;
}

.board-editor-controls select {
	background: #f4f1ea;
	border: 1px solid #d5d0c5;
	color: #263a3a;
	height: 2.75rem;
	min-width: 10rem;
	padding: 0 .7rem;
}

.board-editor-controls select:focus {
	border-color: #b56e34;
	box-shadow: 0 0 0 2px rgba(181, 110, 52, .2);
	outline: 0;
}

.board-workspace {
	align-items: start;
	display: grid;
	gap: 1.5rem;
	grid-template-columns: minmax(0, 360px) 180px;
}

.piece-palette {
	background: #f4f1ea;
	border: 1px solid #d5d0c5;
	display: grid;
	gap: .8rem;
	padding: .75rem;
}

.piece-palette[hidden] {
	display: none;
}

.piece-palette h4,
.piece-group h5 {
	color: #263a3a;
	font-size: .75rem;
	font-weight: 700;
	margin: 0;
	text-transform: uppercase;
}

.piece-group {
	display: grid;
	gap: .35rem;
}

.piece-choice-grid {
	display: grid;
	gap: .3rem;
	grid-template-columns: repeat(3, minmax(0, 1fr));
}

.piece-choice,
.piece-erase {
	align-items: center;
	appearance: none;
	 aspect-ratio: 1;
	background: #fffdf8;
	border: 1px solid #d5d0c5;
	color: #263a3a;
	cursor: pointer;
	display: flex;
	font-size: 1.55rem;
	justify-content: center;
	min-width: 0;
	padding: 0;
}

.piece-choice:hover,
.piece-choice:focus-visible {
	border-color: #b56e34;
	outline: 2px solid rgba(181, 110, 52, .3);
	outline-offset: 1px;
}

.piece-choice[aria-pressed="true"] {
	background: #e9dfcf;
	border-color: #b56e34;
	box-shadow: inset 0 0 0 1px #b56e34;
}

.piece-erase {
	 aspect-ratio: auto;
	background: #fff5f2;
	color: #a33d2d;
	font-size: 1rem;
	min-height: 2.75rem;
}

.piece-erase[aria-pressed="true"] {
	background: #a33d2d;
	border-color: #a33d2d;
	color: #fffdf8;
}

.chess-board {
	display: grid;
	gap: .25rem;
	max-width: 360px;
	width: 100%;
}

.board-turn {
	color: #263a3a;
	font-size: .75rem;
	font-weight: 700;
	letter-spacing: .04em;
	margin-bottom: .5rem;
	text-transform: uppercase;
}

.board-grid {
	display: grid;
	grid-template-columns: 1.25rem repeat(8, minmax(0, 1fr));
	gap: .25rem;
	align-items: center;
	max-width: 360px;
}

.board-corner,
.board-file,
.board-rank {
	align-items: center;
	color: #5a5f5d;
	display: flex;
	font-size: .75rem;
	justify-content: center;
	line-height: 1;
	min-height: 1.4rem;
}

.board-file,
.board-rank {
	font-size: .7rem;
}

.chess-square {
	aspect-ratio: 1;
	align-items: center;
	appearance: none;
	border: 0;
	display: flex;
	font-size: clamp(1.2rem, 2vw, 2rem);
	justify-content: center;
	min-width: 0;
	padding: 0;
}

.chess-board.is-editing .chess-square {
	cursor: pointer;
}

.chess-square:focus-visible {
	outline: 3px solid #263a3a;
	outline-offset: -3px;
}

.chess-square.light {
	background: #f0e9dd;
}

.chess-square.dark {
	background: #b88a5d;
}

.chess-square .piece {
	line-height: 1;
}

.board-error {
	background: #f4f1ea;
	color: #263a3a;
	padding: 1rem;
}

.game-list {
	display: flex;
	flex-direction: column;
	gap: 1rem;
}

.game-card {
	background: #fffdf8;
	border-top: 3px solid #263a3a;
	padding: 1.25rem;
	transition: box-shadow .2s ease, transform .2s ease;
}

.compact-game-card {
	display: flex;
	flex-direction: row;
	flex-wrap: nowrap;
	gap: .7rem;
	padding: .9rem 1rem;
	align-items: center;
	justify-content: flex-start;
	white-space: nowrap;
	overflow: hidden;
	width: 100%;
	max-width: 100%;
}

.compact-game-card .match-index,
.compact-game-card .players,
.compact-game-card .result,
.compact-game-card .match-date,
.compact-game-card .move-label,
.compact-game-card a {
	flex-shrink: 0;
	white-space: nowrap;
}

.compact-game-card .match-index {
	color: #8e8a80;
	font-size: .85rem;
	min-width: 1.8rem;
}

.compact-game-card .players {
	color: #4d514f;
	font-size: 1rem;
}

.compact-game-card .match-date,
.compact-game-card .move-label {
	color: #8e8a80;
	font-size: .8rem;
}

.compact-game-card .result {
	background: #e9dfcf;
	color: #8e5026;
	font-family: "Source Code Pro", monospace;
	font-size: .8rem;
	padding: .22rem .45rem;
}

.compact-game-card a {
	font-size: .8rem;
}

.game-card:hover {
	box-shadow: 0 10px 24px rgba(38, 58, 58, .1);
	transform: translateY(-2px);
}

.game-card header {
	align-items: start;
	display: flex;
	gap: 1rem;
	justify-content: space-between;
}

.game-card h4 {
	color: #263a3a;
	font-size: 1.1rem;
	line-height: 1.25;
	margin: 0;
}

.game-card .result {
	background: #e9dfcf;
	color: #8e5026;
	font-family: "Source Code Pro", monospace;
	font-size: .8rem;
	padding: .2rem .45rem;
}

.game-card .players {
	color: #4d514f;
	font-size: .95rem;
	margin: .8rem 0 .55rem;
}

.game-card .players strong {
	color: #263a3a;
}

.game-card .meta {
	border-top: 1px solid #e8e3da;
	color: #8e8a80;
	font-size: .78rem;
	padding-top: .65rem;
}

.empty-state {
	background: #fffdf8;
	border: 1px dashed #c9c1b5;
	color: #77756f;
	padding: 2rem;
	text-align: center;
}

.empty-state i {
	color: #e2a85b;
	font-size: 2rem;
	margin-bottom: .75rem;
}

.empty-state p {
	margin: 0;
}

.api-response {
	background: #fffdf8;
	border-left: 3px solid #263a3a;
	color: #263a3a;
	overflow-x: auto;
	padding: 1rem;
	white-space: pre-wrap;
	word-break: break-word;
}

@media screen and (max-width: 680px) {
	.chess-main {
		padding-top: 3.5rem;
	}

	.search-fields,
	.game-list {
		grid-template-columns: 1fr;
	}

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

	.piece-palette {
		grid-template-columns: repeat(2, minmax(0, 1fr));
		max-width: 360px;
	}

	.piece-palette h4,
	.piece-erase {
		grid-column: 1 / -1;
	}

	.search-button {
		width: 100%;
	}
}
