/* =========================================================================
   layout.css — in-game screen: header, board, info bars, controls, modals.
   Conventions (see also base.css :root tokens):
     - Controls SIZE TO THEIR LABEL (width:auto) so text is never clipped.
     - Spacing comes from a parent's `gap`, never per-item margins.
     - Sizes/colors/radii/shadows come from --tokens, not magic numbers.
   ========================================================================= */

/* ── Header ─────────────────────────────────────────────────────────────── */
header {
	background-color: var(--highlight-color);
	color: white;
	padding: var(--space-3) var(--space-5);
	text-align: center;
}

/* ── Layout containers ──────────────────────────────────────────────────── */
.player-frame {
	margin-top: 0 !important;
	margin-bottom: 0 !important;
	flex: 0 0 auto;
	order: 4;
	width: 100%;
	position: relative;
	background: rgba(245, 245, 245, 0.9);
	display: flex;
	flex-direction: column;
	border-top: 1px solid #ddd;
}

.player-controls-row {
	display: flex;
	flex-direction: row;
	align-items: center;
	justify-content: flex-start;
	gap: var(--space-3);
	padding: var(--space-2) var(--space-3) 0 var(--space-3);
	position: relative;
}

#board-container {
	display: flex;
	flex-direction: column;
	align-items: center;
	margin: 0 auto;
	padding: 0;
	width: 100%;
	max-width: 100%;
}

/* ── Controls: shared look for chips (deck/timer) and buttons ───────────────
   One base rule for the whole family. Each control widens to fit its label
   (no fixed width → no "…" clipping); spacing comes from the parent gap. */
.deck-info,
.timer,
.pass-button,
.redraw-button,
.multiplayer-button,
.spacer,
.menu-button {
	flex: 0 0 auto;
	width: auto;
	min-width: 0;
	height: var(--control-height);
	line-height: calc(var(--control-height) - 12px);
	padding: 6px var(--space-4);
	box-sizing: border-box;

	background: var(--button-bg);
	color: var(--button-text);
	border: none;
	border-radius: var(--radius-pill);
	box-shadow: var(--shadow-sm);

	font-size: 15px;
	font-weight: bold;
	text-align: center;
	white-space: nowrap;          /* one line; control grows instead of clipping */
	transition: background 0.2s, box-shadow 0.2s;
}

/* The clickable members get a pointer + the slight letter-spacing the design
   used, and a consistent hover. (Chips deck-info/timer are not buttons.) */
.pass-button,
.redraw-button,
.multiplayer-button,
.menu-button {
	position: static;
	cursor: pointer;
	letter-spacing: 1px;
}

.pass-button:hover,
.multiplayer-button:hover,
.menu-button:hover {
	background: var(--button-hover);
	box-shadow: var(--shadow-md);
}

/* ── Control variants ───────────────────────────────────────────────────── */

/* Deck chip: secondary info, so a smaller label. */
.deck-info {
	display: inline-block;
	font-size: 11.25px;
}

.deck-info .deck-count {
	color: inherit;
}

/* deck-info is wrapped in a bare <button> (.deck-button); strip the button
   chrome so only the inner chip shows. */
.deck-button {
	display: flex;
	align-items: center;
	justify-content: center;
	flex: 0 0 auto;
	width: auto;
	min-width: 0;
	height: var(--control-height);
	background: none;
	border: none;
	box-shadow: none;
	padding: 0;
	margin: 0;
	font: inherit;
	color: inherit;
	cursor: pointer;
}

/* Timer chip: a small floor so 3:00 ↔ 0:09 doesn't make it jump width. */
.timer {
	min-width: 64px;
}

.timer.active {
	background: var(--button-hover);
	box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
	border: 1px solid rgba(255, 255, 255, 0.4);
	transform: translateY(-1px);
	transition: all 0.2s ease;
}

.timer.low-time {
	background-color: #ff3b30;
	color: white;
	animation: timer-pulse 1s infinite;
}

@keyframes timer-pulse {
	0%   { opacity: 1; }
	50%  { opacity: 0.7; }
	100% { opacity: 1; }
}

/* Redraw chip: compact fixed-width counter sitting beside Pass; distinct
   accent so it reads as a limited resource, dimmed when out of uses. */
.redraw-button {
	width: 48px;
	min-width: 48px;
	max-width: 48px;
	padding: 6px var(--space-2);
	background: var(--redraw-bg);
	letter-spacing: 0;
}

.redraw-button:hover:not(:disabled) {
	background: var(--redraw-hover);
	box-shadow: var(--shadow-md);
}

.redraw-button:disabled {
	opacity: 0.45;
	cursor: not-allowed;
}

/* Danger variant (concede etc.). */
.danger {
	background-color: #d83c3c;
}

.danger:hover {
	background-color: #a32a2a;
}

/* Game-over: grey everything out, kill active/low-time emphasis. */
.game-over {
	background-color: #888 !important;
	color: #eee !important;
	box-shadow: none !important;
	opacity: 0.75;
	transition: all 0.3s ease;
	border: 1px solid #777 !important;
}

.timer.game-over.active {
	background-color: #888 !important;
	transform: none !important;
	border: 1px solid #777 !important;
}

.timer.game-over.low-time {
	animation: none;
	background-color: #888 !important;
}

/* ── Info bars (above/below board) ──────────────────────────────────────────
   Fixed gap + wrap safety net so the row can never overflow the board width,
   however many controls it holds. */
.opponent-info,
.player-info {
	display: flex;
	justify-content: center;
	align-items: center;
	flex-wrap: wrap;
	gap: var(--space-2);
	width: var(--board-size);
	max-width: 100%;
	margin: var(--space-1) 0;
	padding: 6px var(--space-3);
	background: rgba(245, 245, 245, 0.9);
	border: 1px solid #ddd;
	border-radius: var(--radius-panel);
	box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.opponent-info {
	background: rgba(220, 220, 220, 0.9);
}

#white-player { background-color: var(--white-panel-bg); }
#black-player { background-color: var(--black-panel-bg); }

/* Mirror order when playing as black. */
.timer-bar.reversed { flex-direction: row-reverse; }

.opponent-info.reversed,
.player-info.reversed { flex-direction: row-reverse; }

/* ── Timer bar ──────────────────────────────────────────────────────────── */
.timer-bar {
	width: 100%;
	display: flex;
	justify-content: center;
	margin: 0;
	padding: 0;
	background: #f0f0f0;
}

/* ── Status frame ───────────────────────────────────────────────────────── */
#status-frame {
	width: var(--board-size);
	max-width: 100%;
	margin-bottom: var(--space-2);
	padding: 10px var(--space-3);
	background-color: #f9f9f9;
	border: 1px solid #ddd;
	border-radius: var(--radius-panel);
	box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
	text-align: center;
}

#status-message {
	font-weight: 600;
	font-size: 16px;
	color: #333;
}

/* ── Chessboard ─────────────────────────────────────────────────────────── */
#chessboard {
	width: var(--board-size);
	height: var(--board-size);
	border: 2px solid #333;
	margin: 0 auto !important;
}

#chessboard.active-white { border: 4px solid #ffffff !important; }
#chessboard.active-black { border: 4px solid #000000 !important; }

.highlight-square {
	background: #ffe680 !important;
}

.check-highlight {
	background-color: rgba(255, 0, 0, 0.4) !important;
	box-shadow: inset 0 0 5px 3px rgba(255, 0, 0, 0.8) !important;
}

/* Centered "PASS" overlay flashed on the board. */
.pass-indicator {
	position: absolute;
	top: 50%;
	left: 50%;
	transform: translate(-50%, -50%);
	padding: var(--space-3) var(--space-5);
	background-color: rgba(0, 0, 0, 0.7);
	color: white;
	font-size: 32px;
	font-weight: bold;
	text-transform: uppercase;
	border-radius: 8px;
	z-index: 1000;
	opacity: 0;
	visibility: hidden;
	transition: opacity 0.2s ease;
}

/* ── Modals (game options, concede, game over) ──────────────────────────── */
.small-modal {
	width: 300px;
	max-width: 90%;
}

.modal-header {
	display: flex;
	justify-content: space-between;
	align-items: center;
	padding: var(--space-3) var(--space-4);
	background-color: #333;
	color: white;
	border-top-left-radius: 8px;
	border-top-right-radius: 8px;
}

.modal-header h3 {
	margin: 0;
	font-size: 18px;
}

.modal-body {
	display: flex;
	flex-direction: column;
	gap: var(--space-2);
	padding: var(--space-5);
}

.close-modal {
	color: white;
	font-size: 24px;
	cursor: pointer;
}

.close-modal:hover {
	color: #ccc;
}

.button-row {
	display: flex;
	gap: var(--space-3);
	margin-top: var(--space-3);
}

.button-row > * {
	flex: 1 1 0;          /* equal-width buttons that fill the row */
}

/* ── Mobile tweaks ──────────────────────────────────────────────────────── */
@media (max-width: 768px) {
	#status-frame {
		padding: 6px var(--space-3);
		margin-bottom: var(--space-1);
	}

	#status-message {
		font-size: 14px;
	}

	.timer-bar.reversed .white-timer { order: 2; }
	.timer-bar.reversed .black-timer { order: 1; }
	.timer-bar.reversed .spacer      { order: 0; }
}
/* Contains AI-generated edits. */
