/**
 * Hebrew Kids Maze Game – RTL styles
 *
 * @package HebrewKidsMazeGame
 */

/* CSS variables – primary color overridden via wp_add_inline_style */
:root {
	--hkm-primary: #4a90d9;
	--hkm-primary-dark: #2f6fad;
	--hkm-secondary: #81c784;
	--hkm-accent: #ffd54f;
	--hkm-danger: #e63946;
	--hkm-bg: #f5f7fb;
	--hkm-card-bg: #ffffff;
	--hkm-text: #1a2b3c;
	--hkm-text-muted: #5a6b7c;
	--hkm-border: #d8e2ef;
	--hkm-radius: 16px;
	--hkm-shadow: 0 8px 32px rgba(26, 43, 60, 0.12);
	--hkm-font: "Segoe UI", Tahoma, Arial, sans-serif;
	--hkm-btn-min-height: 48px;
	--hkm-focus-ring: 0 0 0 3px rgba(74, 144, 217, 0.45);
}

/* Wrapper & card */
.hkm-game-wrapper {
	direction: rtl;
	text-align: right;
	font-family: var(--hkm-font);
	color: var(--hkm-text);
	max-width: 720px;
	margin: 1.5rem auto;
	padding: 0 1rem;
	box-sizing: border-box;
}

.hkm-game-card {
	background: var(--hkm-card-bg);
	border: 1px solid var(--hkm-border);
	border-radius: var(--hkm-radius);
	box-shadow: var(--hkm-shadow);
	padding: 1.25rem 1.5rem 1.5rem;
	box-sizing: border-box;
}

.hkm-noscript {
	padding: 1rem;
	background: #fff3cd;
	border: 1px solid #ffc107;
	border-radius: 8px;
	text-align: center;
}

/* Header */
.hkm-header {
	margin-bottom: 1rem;
	text-align: center;
}

.hkm-title {
	margin: 0;
	font-size: clamp(1.35rem, 4vw, 1.85rem);
	color: var(--hkm-primary-dark);
	font-weight: 700;
}

.hkm-subtitle {
	margin: 0 0 1rem;
	font-size: 1.15rem;
	text-align: center;
	color: var(--hkm-text);
}

.hkm-intro {
	text-align: center;
	font-size: 1.1rem;
	color: var(--hkm-text-muted);
	margin: 0 0 1.25rem;
}

/* HUD */
.hkm-hud {
	display: flex;
	flex-wrap: wrap;
	gap: 0.5rem 1rem;
	justify-content: center;
	padding: 0.75rem 1rem;
	background: var(--hkm-bg);
	border-radius: 12px;
	margin-bottom: 1rem;
	font-size: 0.95rem;
	font-weight: 600;
}

.hkm-hud-item {
	white-space: nowrap;
}

.hkm-hidden {
	display: none !important;
}

/* Screen areas */
.hkm-screen {
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 1rem;
}

/* Buttons */
.hkm-btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-height: var(--hkm-btn-min-height);
	padding: 0.6rem 1.25rem;
	font-size: 1rem;
	font-weight: 600;
	font-family: inherit;
	border: 2px solid transparent;
	border-radius: 12px;
	cursor: pointer;
	transition: background 0.15s ease, transform 0.15s ease, border-color 0.15s ease;
	background: var(--hkm-bg);
	color: var(--hkm-text);
	touch-action: manipulation;
	-webkit-tap-highlight-color: transparent;
}

.hkm-btn:hover {
	background: #e8eef6;
}

.hkm-btn:focus-visible {
	outline: none;
	box-shadow: var(--hkm-focus-ring);
}

.hkm-btn:active {
	transform: scale(0.97);
}

.hkm-btn-primary {
	background: var(--hkm-primary);
	color: #fff;
	border-color: var(--hkm-primary-dark);
}

.hkm-btn-primary:hover {
	background: var(--hkm-primary-dark);
}

.hkm-btn-secondary {
	background: var(--hkm-secondary);
	color: #1b3d1c;
	border-color: #5a9e5c;
}

.hkm-btn-ghost {
	background: transparent;
	border-color: var(--hkm-border);
	color: var(--hkm-text-muted);
}

.hkm-btn-icon {
	min-height: 42px;
	padding: 0.45rem 0.9rem;
	font-size: 0.9rem;
}

.hkm-btn-disabled,
.hkm-btn:disabled {
	opacity: 0.55;
	cursor: not-allowed;
}

/* Difficulty grid */
.hkm-difficulty-grid {
	display: grid;
	grid-template-columns: repeat(3, 1fr);
	gap: 0.75rem;
	width: 100%;
	max-width: 420px;
}

.hkm-btn-difficulty {
	flex-direction: column;
	padding: 1rem 0.5rem;
	font-size: 1.1rem;
}

.hkm-diff-easy {
	border-color: #81c784;
}

.hkm-diff-medium {
	border-color: #ffb74d;
}

.hkm-diff-hard {
	border-color: #e57373;
}

.hkm-btn-difficulty.hkm-selected {
	background: var(--hkm-primary);
	color: #fff;
	border-color: var(--hkm-primary-dark);
}

/* Level grid */
.hkm-level-grid {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(68px, 1fr));
	gap: 0.6rem;
	width: 100%;
	max-width: 520px;
}

.hkm-level-cell {
	display: flex;
	flex-direction: column;
	align-items: stretch;
	justify-content: center;
	min-height: 64px;
	min-width: 68px;
	padding: 0.35rem 0.3rem 0.3rem;
	border: 2px solid var(--hkm-border);
	border-radius: 12px;
	background: var(--hkm-bg);
	cursor: pointer;
	font-family: inherit;
	transition: border-color 0.15s ease, background 0.15s ease;
	box-sizing: border-box;
}

.hkm-level-cell:hover:not(:disabled) {
	border-color: var(--hkm-primary);
	background: #e8f2fc;
}

.hkm-level-cell:focus-visible {
	outline: none;
	box-shadow: var(--hkm-focus-ring);
}

.hkm-level-cell.hkm-locked {
	opacity: 0.45;
	cursor: not-allowed;
	background: #eceff3;
}

.hkm-level-inner {
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: 0.15rem;
	width: 100%;
}

.hkm-level-num {
	display: block;
	font-size: 1.05rem;
	font-weight: 700;
	line-height: 1.1;
}

.hkm-level-stars {
	display: flex;
	flex-direction: row;
	justify-content: center;
	align-items: center;
	gap: 1px;
	width: 100%;
	line-height: 1;
	direction: ltr;
}

.hkm-level-star {
	display: flex;
	align-items: center;
	justify-content: center;
	flex: 0 0 8px;
	width: 8px;
	height: 8px;
	color: var(--hkm-accent);
}

.hkm-level-star svg {
	display: block;
	width: 8px;
	height: 8px;
}

/* Canvas */
.hkm-canvas-wrap {
	width: 100%;
	display: flex;
	justify-content: center;
	margin-bottom: 0.75rem;
	touch-action: none;
}

.hkm-canvas-wrap canvas {
	display: block;
	border-radius: 12px;
	border: 3px solid var(--hkm-border);
	background: #f8f4e8;
	max-width: 100%;
}

/* Toolbar */
.hkm-toolbar {
	display: flex;
	flex-wrap: wrap;
	gap: 0.5rem;
	justify-content: center;
	margin-bottom: 0.75rem;
}

/* D-pad controls */
.hkm-controls {
	display: flex;
	justify-content: center;
	margin-top: 0.5rem;
}

.hkm-dpad {
	display: grid;
	grid-template-columns: repeat(3, 56px);
	grid-template-rows: repeat(3, 56px);
	gap: 6px;
	direction: ltr; /* keep spatial layout consistent */
}

.hkm-dpad-btn {
	min-height: 56px;
	width: 56px;
	padding: 0;
	font-size: 1.35rem;
	border-radius: 12px;
	background: var(--hkm-primary);
	color: #fff;
	border-color: var(--hkm-primary-dark);
}

.hkm-dpad-up { grid-column: 2; grid-row: 1; }
.hkm-dpad-left { grid-column: 1; grid-row: 2; }
.hkm-dpad-right { grid-column: 3; grid-row: 2; }
.hkm-dpad-down { grid-column: 2; grid-row: 3; }

.hkm-dpad-btn:hover {
	background: var(--hkm-primary-dark);
}

/* Modal */
.hkm-modal {
	position: fixed;
	inset: 0;
	z-index: 100000;
	display: flex;
	align-items: center;
	justify-content: center;
	background: rgba(26, 43, 60, 0.55);
	padding: 1rem;
	box-sizing: border-box;
}

.hkm-modal-content {
	background: var(--hkm-card-bg);
	border-radius: var(--hkm-radius);
	padding: 1.5rem 1.75rem;
	max-width: 400px;
	width: 100%;
	text-align: center;
	box-shadow: var(--hkm-shadow);
	direction: rtl;
}

.hkm-modal-title {
	margin: 0 0 0.75rem;
	font-size: 1.5rem;
	color: var(--hkm-primary-dark);
}

.hkm-lose-title {
	color: var(--hkm-danger);
}

.hkm-stars-display {
	font-size: 1.5rem;
	color: var(--hkm-accent);
	letter-spacing: 2px;
}

.hkm-modal-actions {
	display: flex;
	flex-direction: column;
	gap: 0.6rem;
	margin-top: 1.25rem;
}

.hkm-modal-actions .hkm-btn {
	width: 100%;
}

/* Responsive */
@media (min-width: 600px) {
	.hkm-modal-actions {
		flex-direction: row;
		flex-wrap: wrap;
		justify-content: center;
	}

	.hkm-modal-actions .hkm-btn {
		width: auto;
		flex: 1 1 auto;
		min-width: 120px;
	}
}

@media (max-width: 480px) {
	.hkm-game-card {
		padding: 1rem;
	}

	.hkm-difficulty-grid {
		grid-template-columns: 1fr;
	}

	.hkm-level-grid {
		grid-template-columns: repeat(auto-fill, minmax(62px, 1fr));
	}

	.hkm-level-cell {
		min-width: 62px;
		min-height: 60px;
		padding: 0.3rem 0.25rem 0.25rem;
	}

	.hkm-level-star,
	.hkm-level-star svg {
		width: 7px;
		height: 7px;
		flex-basis: 7px;
	}

	.hkm-dpad {
		grid-template-columns: repeat(3, 52px);
		grid-template-rows: repeat(3, 52px);
	}

	.hkm-dpad-btn {
		min-height: 52px;
		width: 52px;
	}
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
	.hkm-btn {
		transition: none;
	}

	.hkm-btn:active {
		transform: none;
	}

	.hkm-level-cell {
		transition: none;
	}
}
