/**
 * Networld Chess Stylesheet
 *
 * Clean, responsive 8x8 chess board, SVG piece glyphs, promotion dialog,
 * captured pieces trays, and Core 1.0 theme integration.
 *
 * @package Networld_Chess
 */

.networld-chess-wrap {
	width: 100%;
	max-width: 100%;
	margin: 0 auto;
	box-sizing: border-box;
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
	color: var(--networld-text, #f0f4f8);
}

.networld-chess-panel {
	display: none;
	width: 100%;
}

.networld-chess-panel.active {
	display: block;
}

.networld-chess-back-bar {
	margin-bottom: 16px;
}

/* Buttons */
.networld-chess-btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 8px;
	padding: 8px 16px;
	font-size: 14px;
	font-weight: 600;
	border-radius: 6px;
	border: 1px solid transparent;
	cursor: pointer;
	transition: all 0.2s ease;
	text-decoration: none;
	background: var(--networld-primary, #3b82f6);
	color: #fff;
}

.networld-chess-btn:hover:not(:disabled) {
	filter: brightness(1.1);
	transform: translateY(-1px);
}

.networld-chess-btn:disabled {
	opacity: 0.5;
	cursor: not-allowed;
	transform: none;
}

.networld-chess-btn-secondary {
	background: rgba(255, 255, 255, 0.08);
	color: var(--networld-text, #f0f4f8);
	border-color: rgba(255, 255, 255, 0.15);
}

.networld-chess-btn-secondary:hover:not(:disabled) {
	background: rgba(255, 255, 255, 0.14);
}

.networld-chess-btn-danger {
	background: #ef4444;
	color: #fff;
}

.networld-chess-btn-danger:hover:not(:disabled) {
	background: #dc2626;
}

/* Board layout container */
.networld-chess-board-container {
	display: flex;
	flex-direction: column;
	align-items: center;
	width: 100%;
	max-width: 900px;
	margin: 0 auto;
	box-sizing: border-box;
}

.networld-chess-game-layout {
	display: grid;
	grid-template-columns: 1fr;
	gap: 16px;
	width: 100%;
	max-width: 100%;
	box-sizing: border-box;
	min-width: 0;
}

@media (min-width: 820px) {
	.networld-chess-game-layout {
		grid-template-columns: minmax(0, 560px) minmax(240px, 320px);
		align-items: start;
	}
}

/* Board Arena Column */
.networld-chess-arena-col {
	display: flex;
	flex-direction: column;
	align-items: center;
	width: 100%;
	max-width: 100%;
	margin: 0 auto;
	box-sizing: border-box;
	min-width: 0;
}

/* Player Info Bar */
.networld-chess-player-bar {
	display: flex;
	justify-content: space-between;
	align-items: center;
	width: 100%;
	padding: 8px 12px;
	background: rgba(15, 23, 42, 0.65);
	border: 1px solid rgba(255, 255, 255, 0.08);
	border-radius: 8px;
	margin-bottom: 8px;
	box-sizing: border-box;
}

.networld-chess-player-bar.bottom {
	margin-top: 8px;
	margin-bottom: 0;
}

.networld-chess-player-bar.active-turn {
	border-color: #f59e0b;
	box-shadow: 0 0 10px rgba(245, 158, 11, 0.25);
}

.networld-chess-player-meta {
	display: flex;
	align-items: center;
	gap: 10px;
}

.networld-chess-color-indicator {
	width: 18px;
	height: 18px;
	border-radius: 4px;
	border: 2px solid #94a3b8;
	box-sizing: border-box;
}

.networld-chess-color-indicator.white {
	background: #f8fafc;
	border-color: #cbd5e1;
}

.networld-chess-color-indicator.black {
	background: #1e293b;
	border-color: #475569;
}

.networld-chess-player-name {
	font-weight: 600;
	font-size: 15px;
}

.networld-chess-captured-tray {
	display: flex;
	align-items: center;
	gap: 2px;
	min-height: 24px;
	flex-wrap: wrap;
}

.networld-chess-captured-piece {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 19px;
	height: 19px;
	vertical-align: middle;
}

.networld-chess-captured-piece svg {
	width: 100%;
	height: 100%;
	display: block;
}

.networld-chess-advantage {
	font-size: 12px;
	font-weight: 700;
	color: #10b981;
	margin-left: 6px;
}

/* 8x8 Chessboard */
.networld-chess-board-wrapper {
	position: relative;
	width: 100%;
	aspect-ratio: 1 / 1;
	max-width: 560px;
	border-radius: 10px;
	overflow: hidden;
	box-shadow: 0 12px 32px rgba(0, 0, 0, 0.45);
	border: 4px solid #334155;
	box-sizing: border-box;
	user-select: none;
	-webkit-user-select: none;
}

.networld-chess-board-wrapper.loading,
.networld-chess-board-wrapper.disabled {
	opacity: 0.88;
	pointer-events: none;
}

.networld-chess-board {
	display: grid;
	grid-template-columns: repeat(8, 1fr);
	grid-template-rows: repeat(8, 1fr);
	width: 100%;
	height: 100%;
}

/* Squares */
.networld-chess-sq {
	position: relative;
	display: flex;
	align-items: center;
	justify-content: center;
	width: 100%;
	height: 100%;
	box-sizing: border-box;
	cursor: default;
	transition: background-color 0.15s ease;
}

.networld-chess-board-wrapper.interactive .networld-chess-sq {
	cursor: pointer;
}

.networld-chess-sq.light {
	background-color: #edd8b7;
	color: #b58863;
}

.networld-chess-sq.dark {
	background-color: #b58863;
	color: #edd8b7;
}

/* Square Coordinates */
.networld-chess-coord-file,
.networld-chess-coord-rank {
	position: absolute;
	font-size: 11px;
	font-weight: 700;
	line-height: 1;
	pointer-events: none;
	opacity: 0.85;
}

.networld-chess-coord-file {
	bottom: 2px;
	right: 4px;
}

.networld-chess-coord-rank {
	top: 3px;
	left: 4px;
}

/* Square Highlights */
.networld-chess-sq.selected {
	background-color: #cbd5e1 !important;
	box-shadow: inset 0 0 0 3px #3b82f6;
}

.networld-chess-sq.last-move {
	background-color: rgba(254, 240, 138, 0.55) !important;
}

.networld-chess-sq.in-check {
	background-color: #f87171 !important;
	animation: chessCheckPulse 1.4s infinite ease-in-out;
}

@keyframes chessCheckPulse {
	0%, 100% { box-shadow: inset 0 0 12px 4px #dc2626; }
	50% { box-shadow: inset 0 0 20px 8px #ef4444; }
}

/* Legal Move Hints */
.networld-chess-hint-dot {
	width: 28%;
	height: 28%;
	border-radius: 50%;
	background-color: rgba(30, 41, 59, 0.35);
	pointer-events: none;
}

.networld-chess-sq.dark .networld-chess-hint-dot {
	background-color: rgba(255, 255, 255, 0.4);
}

.networld-chess-hint-capture {
	position: absolute;
	inset: 4px;
	border: 3px solid rgba(239, 68, 68, 0.7);
	border-radius: 50%;
	pointer-events: none;
	box-sizing: border-box;
}

/* Pieces */
.networld-chess-piece {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	pointer-events: none;
	display: flex;
	align-items: center;
	justify-content: center;
	z-index: 2;
	transition: transform 0.12s ease;
}

.networld-chess-piece svg {
	width: 84%;
	height: 84%;
	max-width: 58px;
	max-height: 58px;
	display: block;
	pointer-events: none;
}

/* Promotion Modal Overlay */
.networld-chess-promo-overlay {
	position: absolute;
	inset: 0;
	background: rgba(15, 23, 42, 0.85);
	backdrop-filter: blur(4px);
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	z-index: 50;
	border-radius: 10px;
	padding: 16px;
	box-sizing: border-box;
}

.networld-chess-promo-title {
	font-size: 16px;
	font-weight: 700;
	margin-bottom: 16px;
	text-align: center;
	color: #f8fafc;
}

.networld-chess-promo-options {
	display: flex;
	gap: 12px;
	justify-content: center;
}

.networld-chess-promo-btn {
	width: 56px;
	height: 56px;
	border-radius: 8px;
	background: #334155;
	border: 2px solid #475569;
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 4px;
	box-sizing: border-box;
	transition: all 0.15s ease;
	color: #f8fafc;
}

.networld-chess-promo-btn svg {
	width: 100%;
	height: 100%;
	display: block;
	pointer-events: none;
}

.networld-chess-promo-btn:hover {
	background: #3b82f6;
	border-color: #60a5fa;
	transform: scale(1.08);
}

/* Side Panel / Controls Column */
.networld-chess-sidebar {
	display: flex;
	flex-direction: column;
	gap: 16px;
	width: 100%;
	box-sizing: border-box;
}

.networld-chess-card {
	background: rgba(15, 23, 42, 0.65);
	border: 1px solid rgba(255, 255, 255, 0.08);
	border-radius: 10px;
	padding: 16px;
	box-sizing: border-box;
}

.networld-chess-status-banner {
	font-size: 15px;
	font-weight: 600;
	text-align: center;
	padding: 10px 14px;
	border-radius: 6px;
	background: rgba(59, 130, 246, 0.15);
	border: 1px solid rgba(59, 130, 246, 0.3);
	color: #93c5fd;
	margin-bottom: 12px;
}

.networld-chess-status-banner.game-over {
	background: rgba(16, 185, 129, 0.15);
	border-color: rgba(16, 185, 129, 0.3);
	color: #6ee7b7;
}

.networld-chess-status-banner.in-check {
	background: rgba(239, 68, 68, 0.15);
	border-color: rgba(239, 68, 68, 0.3);
	color: #fca5a5;
}

.networld-chess-status-banner.initializing {
	background: rgba(148, 163, 184, 0.15);
	border-color: rgba(148, 163, 184, 0.3);
	color: #cbd5e1;
	animation: chessInitPulse 1.5s infinite ease-in-out;
}

.networld-chess-status-banner.error {
	background: rgba(239, 68, 68, 0.2);
	border-color: #ef4444;
	color: #fca5a5;
}

@keyframes chessInitPulse {
	0%, 100% { opacity: 0.7; }
	50% { opacity: 1; }
}

.networld-chess-error-card {
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 10px;
	padding: 14px;
	background: rgba(239, 68, 68, 0.15);
	border: 1px solid rgba(239, 68, 68, 0.35);
	border-radius: 8px;
	color: #fca5a5;
	text-align: center;
	margin-top: 12px;
	font-size: 13px;
}

/* Move Log / History */
.networld-chess-movelist-header {
	font-size: 13px;
	font-weight: 700;
	text-transform: uppercase;
	letter-spacing: 0.05em;
	color: #94a3b8;
	margin-bottom: 8px;
}

.networld-chess-movelist-scroll {
	max-height: 180px;
	overflow-y: auto;
	padding-right: 6px;
	display: grid;
	grid-template-columns: 36px 1fr 1fr;
	gap: 4px 8px;
	font-family: monospace;
	font-size: 13px;
}

.networld-chess-movelist-scroll::-webkit-scrollbar {
	width: 5px;
}

.networld-chess-movelist-scroll::-webkit-scrollbar-thumb {
	background: rgba(255, 255, 255, 0.2);
	border-radius: 4px;
}

.networld-chess-move-num {
	color: #64748b;
	text-align: right;
}

.networld-chess-move-san {
	padding: 2px 4px;
	border-radius: 3px;
	color: #e2e8f0;
}

.networld-chess-move-san.active {
	background: rgba(59, 130, 246, 0.25);
	color: #93c5fd;
	font-weight: 700;
}

/* Action Buttons Bar */
.networld-chess-actions {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
}

.networld-chess-actions .networld-chess-btn {
	flex: 1 1 calc(50% - 4px);
}

/* Setup Form for PvE & Local */
.networld-chess-setup-row {
	display: flex;
	flex-direction: column;
	gap: 6px;
	margin-bottom: 12px;
}

.networld-chess-setup-label {
	font-size: 13px;
	font-weight: 600;
	color: #cbd5e1;
}

.networld-chess-select {
	padding: 8px 12px;
	background: #1e293b;
	border: 1px solid #475569;
	border-radius: 6px;
	color: #f8fafc;
	font-size: 14px;
	outline: none;
}

.networld-chess-select:focus {
	border-color: #3b82f6;
}

/* Responsive constraints */
@media (max-width: 480px) {
	.networld-chess-card {
		padding: 12px;
	}
	.networld-chess-board-wrapper {
		border-width: 3px;
	}
	.networld-chess-promo-btn {
		width: 46px;
		height: 46px;
		font-size: 26px;
	}
}
