@charset "UTF-8";

@font-face {
	font-family: 'NotoSansSymbols2';
	src: url('../../lib/fonts/NotoSansSymbols2-Regular.ttf') format('truetype');
}

:root {
	--red-color: #d43d3d;
	--black-color: #333;
}

.one.chessboard {
	--min-cell-len: 60px;
	--line-color: #333;
	--line-stroke-width: 1px; /* 定义棋盘线条的粗细 */
	grid-template-rows: repeat(10, var(--min-cell-len));
	grid-template-columns: repeat(9, var(--min-cell-len));
	background-color: antiquewhite;
	position: relative;
	height: fit-content; /* 避免被拉伸 */
}

.dual-view .one.chessboard {
	--min-cell-len: 55px;
}

.one.chessboard .cell {
	position: relative;
	display: flex;
	justify-content: center;
	align-items: center;
}

.one.chessboard .cell .texture {
	position: absolute;
	width: 100%;
	height: 100%;
	z-index: 1;
	background-image: url('棋盘纹理-十字.svg'); /* 默认所有内部格子使用十字交叉 */
	stroke-width: var(--line-stroke-width); /* 通过CSS变量控制线条粗细 */
	background-size: 100% 100%; /* 确保SVG缩放以填充 */
	background-repeat: no-repeat;
}

/* -------------边框线------------ */
.one.chessboard .row-1 .texture,
.one.chessboard .row-6 .texture {
	background-image: url('棋盘纹理-顶边.svg');
}

.one.chessboard .row-10 .texture,
.one.chessboard .row-5 .texture {
	background-image: url('棋盘纹理-底边.svg');
}

.one.chessboard .col-1 .texture {
	background-image: url('棋盘纹理-左边.svg');
}

.one.chessboard .col-9 .texture {
	background-image: url('棋盘纹理-右边.svg');
}

/* -------------角------------- */
.one.chessboard .row-1.col-1 .texture {
	background-image: url('棋盘纹理-角.svg');
}

.one.chessboard .row-1.col-9 .texture {
	background-image: url('棋盘纹理-角.svg');
	rotate: 90deg;
}

.one.chessboard .row-10.col-1 .texture {
	background-image: url('棋盘纹理-角.svg');
	rotate: -90deg;
}

.one.chessboard .row-10.col-9 .texture {
	background-image: url('棋盘纹理-角.svg');
	rotate: 180deg;
}

/* -------九宫格、炮位、兵卒位------- */
.one.chessboard .九宫 .texture::after,
.one.chessboard .炮位.cell .texture::before,
.one.chessboard .兵卒位.cell .texture::before,
.one.chessboard .炮位 .texture::after,
.one.chessboard .兵卒位 .texture::after {
	position: absolute;
	width: 100%;
	height: 100%;
	display: block;
}

.one.chessboard .row-1.col-4 .texture::after,
.one.chessboard .row-8.col-4 .texture::after {
	content: url('棋盘纹理-半斜线.svg');
	rotate: 180deg;
}

.one.chessboard .row-1.col-6 .texture::after,
.one.chessboard .row-8.col-6 .texture::after {
	content: url('棋盘纹理-半斜线.svg');
	rotate: -90deg;
}

.one.chessboard .row-3.col-4 .texture::after,
.one.chessboard .row-10.col-4 .texture::after {
	content: url('棋盘纹理-半斜线.svg');
	rotate: 90deg;
}

.one.chessboard .row-3.col-6 .texture::after,
.one.chessboard .row-10.col-6 .texture::after {
	content: url('棋盘纹理-半斜线.svg');
}

/* 窝心 */
.one.chessboard .row-2.col-5 .texture::after,
.one.chessboard .row-9.col-5 .texture::after {
	content: url('棋盘纹理-交叉.svg');
}

.one.chessboard .炮位.cell .texture::before,
.one.chessboard .兵卒位.cell .texture::before {
	content: url('棋盘纹理-左花.svg');
}

.one.chessboard .炮位.cell .texture::after,
.one.chessboard .兵卒位.cell .texture::after {
	content: url('棋盘纹理-右花.svg');
}

.one.chessboard .兵卒位.cell.col-1 .texture::before,
.one.chessboard .兵卒位.cell.col-9 .texture::after {
	content: none;
}

/* ============================棋子======================== */
.unit.display {
	position: relative;
	z-index: 10;
	width: 90%;
	height: 90%;
	border-radius: 50%;
	display: flex;
	justify-content: center;
	align-items: center;
	font-family: 'NotoSansSymbols2', sans-serif;
	font-size: calc(var(--min-cell-len) * 0.7);
	cursor: pointer;
	box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
	background-color: #f0f0f0;
	border: 1px solid #888;
	color: var(--black-color);
	user-select: none;
}

.unit.display.red {
	background-color: #fdd;
	border-color: var(--red-color);
	color: var(--red-color);
}

.one.chessboard .selected.unit.display {
	outline: 3px solid #007bff;
	box-shadow: 0 0 10px #007bff;
}

/* 非棋盘内的棋子展示（选中预览 / 杀敌记录 / 棋子库）：无格子约束，用固定尺寸覆盖基类 90%，避免 flex 下被拉满一行 */
.selected.unit.preview .unit.display,
.record-piece .unit.display,
.piece.palette .unit.display {
	width: 45px;
	height: 45px;
	min-width: 45px;
	min-height: 45px;
	max-width: 45px;
	max-height: 45px;
	flex: none;
	font-size: calc(45px * 0.7);
}

/* 统一用伪元素实现提示图标 */
.one.chessboard .cell.movable::after,
.one.chessboard .cell.attack::before,
.one.chessboard .cell.attack::after,
.one.chessboard .cell.blocked::before,
.one.chessboard .cell.blocked::after {
	content: '';
	position: absolute;
	z-index: 20;
	pointer-events: none;
	box-sizing: border-box;
}

/* 可移动 */
.one.chessboard .cell.movable::after {
	width: 40%;
	height: 40%;
	top: 30%;
	left: 30%;
	background-color: rgba(40, 167, 69, 0.5);
	border-radius: 50%;
}

/* 攻击 */
.one.chessboard .cell.attack::before,
.one.chessboard .cell.attack::after {
	width: 60%;
	height: 15%;
	top: 42.5%;
	left: 20%;
	background-color: rgba(255, 0, 0, 0.7);
	border-radius: 2px;
}

.one.chessboard .cell.attack::before {
	transform: rotate(45deg);
}

.one.chessboard .cell.attack::after {
	transform: rotate(-45deg);
}

/* 阻挡 */
.one.chessboard .cell.blocked::after { /* 圆圈 */
	width: 60%;
	height: 60%;
	top: 20%;
	left: 20%;
	border-radius: 50%;
	border: 4px solid rgba(220, 53, 69, 0.9);
	background-color: rgba(255, 255, 255, 0.3);
}

.one.chessboard .cell.blocked::before { /* 斜线 */
	width: 70%;
	height: 15%;
	top: 42.5%;
	left: 15%;
	background-color: rgba(220, 53, 69, 0.9);
	transform: rotate(45deg);
	border-radius: 2px;
}

/* 小视图（如右侧栏「交换视角」）棋盘：格子放大以便看清，整盘随侧栏加宽 */
.reversed-board-in-sidebar .one.chessboard {
	--min-cell-len: 36px;
}
