/**
 * Magnetic Poetry Board styles.
 *
 * Everything is scoped under .magpo so the plugin is safe to drop into any theme.
 * Layout positions (left/top/transform) are set inline by the JS; this file styles
 * the board surface, the magnet tiles and the controls.
 *
 * IMPORTANT — theme isolation: the tiles and control are real <button>s, and host
 * themes routinely style `button` with high-specificity selectors (e.g. BeSafeWI
 * uses `button:not(.owl-dot, ...)`, specificity 0,1,1, which beats a single class).
 * To stay theme-agnostic we reset the tiles' *cosmetic* properties with !important.
 * Positioning/interaction props (position, left, top, transform, cursor) are left
 * WITHOUT !important so the drag JS keeps full control of them.
 */

.magpo {
	/* Full width of the container by default; optionally capped + centered when a
	   max-width is configured (--magpo-maxw is only emitted when set). */
	width: 100%;
	max-width: var(--magpo-maxw, none);
	margin: 2rem auto;
	box-sizing: border-box;
}

.magpo *,
.magpo *::before,
.magpo *::after {
	box-sizing: border-box;
}

.magpo__title {
	margin: 0 0 0.75rem;
	text-align: center;
}

/* Visually-hidden instruction line (still read by screen readers). */
.magpo__sr {
	position: absolute;
	width: 1px;
	height: 1px;
	padding: 0;
	margin: -1px;
	overflow: hidden;
	clip: rect(0 0 0 0);
	white-space: nowrap;
	border: 0;
}

.magpo__board {
	position: relative;
	width: 100%;
	/* Height is admin-settable per breakpoint via custom props (see media queries). */
	height: var(--magpo-h-d, 460px);
	padding: 0;
	background: #000;
	border-radius: 10px;
	box-shadow: 0 24px 48px rgba(0, 0, 0, 0.28);
	overflow: hidden;
}

/* --- Magnet tiles: cosmetic reset (beats host-theme button styles) --- */
.magpo .magpo__tile {
	display: inline-block !important;
	margin: 0 !important;
	padding: 0.4em 0.7em !important;
	min-width: 0 !important;
	max-width: none !important;
	width: auto !important;
	height: auto !important;
	font-family: inherit !important;
	font-size: 15px !important;
	font-weight: 700 !important;
	line-height: 1 !important;
	letter-spacing: normal !important;
	text-transform: none !important;
	text-decoration: none !important;
	text-align: center !important;
	text-shadow: none !important;
	white-space: nowrap !important;
	color: #111 !important;
	background: #fff !important;
	border: 0 !important;
	border-radius: 4px !important;
	box-shadow: 0 3px 6px rgba(0, 0, 0, 0.35), 0 1px 2px rgba(0, 0, 0, 0.4) !important;
	/* positioning + interaction — NOT !important (the JS owns these) */
	position: absolute;
	left: 0;
	top: 0;
	cursor: grab;
	user-select: none;
	-webkit-user-select: none;
	touch-action: none; /* let touch-punch drive the drag; empty board areas still scroll */
	will-change: left, top, transform;
}

.magpo .magpo__tile:hover,
.magpo .magpo__tile:focus {
	/* neutralize theme :hover recolor; keep the tile's own look */
	color: #111 !important;
	background: #fff !important;
}

.magpo .magpo__tile:active {
	cursor: grabbing;
}

.magpo .magpo__tile--anchor,
.magpo .magpo__tile--anchor:hover,
.magpo .magpo__tile--anchor:focus {
	color: #fff !important;
	background: var(--magpo-anchor, #0497ff) !important;
}

.magpo .magpo__tile:focus-visible {
	outline: 3px solid #ffd400 !important;
	outline-offset: 2px;
}

/* --- Controls (Shuffle / Reset) --- */
.magpo__controls {
	display: flex;
	gap: 0.5rem;
	justify-content: center;
	margin-top: 0.75rem;
}

.magpo .magpo__btn {
	display: inline-block !important;
	min-width: 0 !important;
	margin: 0 !important;
	padding: 0.5em 1.1em !important;
	font-family: inherit !important;
	font-size: inherit !important;
	font-weight: 600 !important;
	line-height: 1.2 !important;
	letter-spacing: normal !important;
	text-transform: none !important;
	text-decoration: none !important;
	color: #111 !important;
	background: transparent !important;
	border: 1px solid #111 !important;
	border-radius: 999px !important;
	box-shadow: none !important;
	cursor: pointer;
}

.magpo .magpo__btn:hover,
.magpo .magpo__btn:focus {
	color: #111 !important;
	background: rgba(0, 0, 0, 0.06) !important;
	border-color: #111 !important;
}

/* Tablet height (≤1024px). */
@media (max-width: 1024px) {
	.magpo__board {
		height: var(--magpo-h-t, 560px);
	}
}

/* Mobile height + smaller tiles (≤640px). */
@media (max-width: 640px) {
	.magpo__board {
		height: var(--magpo-h-m, 720px);
	}

	.magpo .magpo__tile {
		font-size: 13px !important;
		padding: 0.35em 0.6em !important;
	}
}
