/* Map Studio (extension package). The modal chrome (backdrop, frame,
   header, close button, scrollbars, selects, labels) comes from the
   editor's own modal design (dsm family) - the dialog mounts inside
   #wpie-root for exactly that reason. Only map-specific parts live here. */

.wpiemap-dialog {
	width: min( 1060px, 96vw );
	height: min( 720px, 92vh );
}

.wpiemap-body {
	display: flex;
	flex: 1;
	min-height: 0;
}

.wpiemap-view {
	position: relative;
	display: grid;
	flex: 1;
	place-items: center;
	min-width: 0;
	background:
		repeating-conic-gradient(
			rgba( 128, 128, 128, 0.07 ) 0 25%,
			transparent 0 50%
		)
		0 0 / 22px 22px;
}

.wpiemap-view canvas {
	background: transparent;
	cursor: grab;
}

.wpiemap-view canvas:active {
	cursor: grabbing;
}

.wpiemap-hint {
	position: absolute;
	bottom: 10px;
	left: 12px;
	font-size: 11px;
	color: var( --ed-text-muted, #9aa1ab );
	pointer-events: none;
}

.wpiemap-empty {
	position: absolute;
	max-width: 300px;
	padding: 14px 18px;
	font-size: 13px;
	line-height: 1.5;
	color: var( --ed-text, #e6e8ee );
	text-align: center;
	pointer-events: none;
	background: var( --ed-panel, #1d2126 );
	border: 1px solid var( --ed-border, #333a44 );
	border-radius: 8px;
	box-shadow: 0 10px 30px rgba( 0, 0, 0, 0.3 );
}

.wpiemap-loading {
	position: absolute;
	top: 12px;
	right: 12px;
	display: none;
	gap: 8px;
	align-items: center;
	padding: 6px 12px;
	font-size: 11px;
	background: var( --ed-panel, #1d2126 );
	border: 1px solid var( --ed-border, #333a44 );
	border-radius: 999px;
}

.wpiemap-loading.on {
	display: flex;
}

.wpiemap-loading::before {
	width: 10px;
	height: 10px;
	content: '';
	border: 2px solid rgba( 128, 128, 128, 0.35 );
	border-top-color: var( --ed-accent, #3b82f6 );
	border-radius: 50%;
	animation: wpiemap-spin 0.8s linear infinite;
}

@keyframes wpiemap-spin {

	to {
		transform: rotate( 360deg );
	}
}

.wpiemap-side {
	display: flex;
	flex: none;
	flex-direction: column;
	gap: 10px;
	width: 332px;
	padding: 12px 14px;
	overflow-x: hidden;
	overflow-y: auto;
	font-size: 12px;
	border-left: 1px solid var( --ed-border, #333a44 );
}

/* The side is a flex column: without this its section cards keep their
   default flex-shrink and get compressed to fit the panel height instead
   of overflowing, so overflow-y: auto never triggers and the scrollbar
   never appears. Pinning the direct children to their natural height lets
   the column overflow and scroll. */
.wpiemap-side > * {
	flex-shrink: 0;
}

/* Sections need air on BOTH sides of their rule, not only above it.
 * With padding on one side only, every heading sat tight under the rule
 * while the block above it kept a full line of space, so the rules read as
 * belonging to the wrong section. */
.wpiemap-section {
	padding-top: 12px;
	margin-top: 12px;
	border-top: 1px solid var( --ed-border, rgba( 128, 128, 128, 0.15 ) );
}

.wpiemap-section:first-child {
	padding-top: 0;
	margin-top: 0;
	border-top: 0;
}

.wpiemap-label {
	display: block;
	margin-bottom: 7px;
}

.wpiemap-card {
	background: var( --ed-panel-alt, rgba( 255, 255, 255, 0.03 ) );
	border: 1px solid var( --ed-border, #333a44 );
	border-radius: 10px;
	overflow: hidden;
}

.wpiemap-card-head {
	display: flex;
	gap: 8px;
	align-items: center;
	padding: 10px 12px 4px;
	font-size: 11px;
	font-weight: 600;
	letter-spacing: 0.04em;
	text-transform: uppercase;
	color: var( --ed-text-dim, #b9c0cc );
}

.wpiemap-card-head svg {
	flex: none;
	opacity: 0.85;
}

.wpiemap-card-body {
	display: flex;
	flex-direction: column;
	gap: 8px;
	padding: 8px 12px 12px;
}

#wpie-root .wpiemap-check {
	display: inline-flex;
	align-items: center;
	gap: 7px;
	cursor: pointer;
}

#wpie-root .wpiemap-check input {
	width: 15px;
	height: 15px;
	accent-color: var( --accent, #3b66ff );
}

.wpiemap-search {
	position: relative;
}

.wpiemap-search input,
.wpiemap-text-row input {
	width: 100%;
	padding: 7px 9px;
	font-size: 12px;
	color: inherit;
	background: var( --ed-bg, #14171c );
	border: 1px solid var( --ed-border, #333a44 );
	border-radius: 6px;
	outline: none;
}

.wpiemap-search input:focus,
.wpiemap-text-row input:focus {
	border-color: var( --ed-accent, #3b82f6 );
}

/* The result list flows, it does not float.
 *
 * It used to be position:absolute over the panel, and an absolutely
 * positioned element is clipped by the nearest ancestor with an overflow
 * other than visible. That ancestor is .wpiemap-side, which scrolls, so
 * the list was cut off at the bottom edge of the panel: the further down
 * the search sat, the fewer results you could see. No z-index fixes that,
 * because nothing is stacked over it; it is simply not drawn.
 *
 * In the flow it pushes the rest of the column down and the panel scrolls
 * to it. It cannot be clipped by anything, at any panel height. */
.wpiemap-results {
	margin: 8px 0 2px;
	overflow: hidden;
	background: var( --ed-panel, #1d2126 );
	border: 1px solid var( --ed-border, #333a44 );
	border-radius: 8px;
}

/* Scoped to #wpie-root, and it has to be.
 *
 * The core resets every button with `#wpie-root button { padding: 0;
 * background: none; ... }` (tokens.css). That selector is an id plus an
 * element and beats any plain class, so a bare `.wpiemap-result` lost its
 * padding - the rows collapsed against the list edge - AND lost its hover
 * background, which looked like the highlight had simply not been written.
 * One reset, two symptoms that look unrelated.
 *
 * Raising the specificity fixes both without a single !important, the same
 * way .wpiemap-check input above does it. Reaching for !important here
 * would have silenced the padding and left the hover dead. */
#wpie-root .wpiemap-result {
	display: block;
	width: 100%;
	padding: 9px 11px;
	color: inherit;
	text-align: left;
	cursor: pointer;
	background: none;
	border: 0;
	/* Hairline between rows, never above the first one. */
	box-shadow: inset 0 1px 0 var( --ed-border, #333a44 );
}

#wpie-root .wpiemap-result:first-child {
	box-shadow: none;
}

#wpie-root .wpiemap-result:hover,
#wpie-root .wpiemap-result:focus-visible {
	background: rgba( 128, 128, 128, 0.14 );
	outline: none;
}

.wpiemap-result strong {
	display: block;
	overflow: hidden;
	font-size: 12.5px;
	font-weight: 600;
	line-height: 1.35;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.wpiemap-result small {
	display: block;
	overflow: hidden;
	font-size: 11px;
	line-height: 1.35;
	color: var( --ed-text-muted, #9aa1ab );
	text-overflow: ellipsis;
	white-space: nowrap;
}

.wpiemap-coords {
	margin-top: 7px;
	font-size: 11px;
	line-height: 1.45;
	color: var( --ed-text-muted, #9aa1ab );
}

.wpiemap-row {
	display: grid;
	grid-template-columns: 78px 1fr auto;
	gap: 8px;
	align-items: center;
	margin: 5px 0;
}

.wpiemap-row > span {
	overflow: hidden;
	white-space: nowrap;
}

.wpiemap-row input[type='range'] {
	width: 100%;
	accent-color: var( --ed-accent, #3b82f6 );
}

.wpiemap-row input[type='color'] {
	width: 30px;
	height: 22px;
	padding: 0;
	cursor: pointer;
	background: none;
	border: 1px solid var( --ed-border, #333a44 );
	border-radius: 5px;
}

.wpiemap-row output {
	min-width: 48px;
	font-size: 11px;
	color: var( --ed-text-muted, #9aa1ab );
	text-align: right;
}

.wpiemap-check {
	display: flex;
	gap: 7px;
	align-items: center;
	margin: 4px 0;
	cursor: pointer;
}

.wpiemap-check input {
	accent-color: var( --ed-accent, #3b82f6 );
}

.wpiemap-check .dim {
	color: var( --ed-text-muted, #9aa1ab );
}

.wpiemap-shaperow {
	margin: 6px 0;
}

.wpiemap-shaperow > span {
	display: block;
	margin-bottom: 6px;
	font-size: 11px;
	color: var( --ed-text-muted, #9aa1ab );
}

/* Full-width five-column grid so all ten shape tiles stay visible in two
   tidy rows; a single non-wrapping flex row overflowed and was clipped by
   the panel's overflow-x: hidden. */
.wpiemap-shapes {
	display: grid;
	grid-template-columns: repeat( 5, 1fr );
	gap: 6px;
	justify-items: center;
}

/* On-map text placement: compact 3x3 alignment grid. */
.wpiemap-anchorrow {
	margin: 6px 0;
}

.wpiemap-anchorrow > span {
	display: block;
	margin-bottom: 6px;
	font-size: 11px;
	color: var( --ed-text-muted, #9aa1ab );
}

.wpiemap-anchors {
	display: grid;
	grid-template-columns: repeat( 3, 1fr );
	gap: 5px;
	max-width: 122px;
}

#wpie-root .wpiemap-anchor {
	display: grid;
	place-items: center;
	height: 30px;
	color: var( --ed-text-muted, #9aa1ab );
	cursor: pointer;
	background: none;
	border: 1px solid var( --ed-border, #333a44 );
	border-radius: 6px;
}

#wpie-root .wpiemap-anchor:hover {
	color: inherit;
}

#wpie-root .wpiemap-anchor.sel {
	color: var( --ed-accent, #3b82f6 );
	border-color: var( --ed-accent, #3b82f6 );
	box-shadow: 0 0 0 1px var( --ed-accent, #3b82f6 );
}

#wpie-root .wpiemap-shape {
	display: grid;
	flex: none;
	place-items: center;
	width: 32px;
	height: 28px;
	color: var( --ed-text-muted, #9aa1ab );
	cursor: pointer;
	background: none;
	border: 1px solid var( --ed-border, #333a44 );
	border-radius: 6px;
}

#wpie-root .wpiemap-shape:hover {
	color: inherit;
}

#wpie-root .wpiemap-shape.sel {
	color: var( --ed-accent, #3b82f6 );
	border-color: var( --ed-accent, #3b82f6 );
	box-shadow: 0 0 0 1px var( --ed-accent, #3b82f6 );
}

.wpiemap-attr {
	margin-top: auto;
	padding-top: 8px;
	font-size: 10px;
	color: var( --ed-text-muted, #9aa1ab );
}

.wpiemap-swatch {
	display: inline-flex;
}

.wpiemap-themes {
	display: grid;
	grid-template-columns: repeat( 5, 1fr );
	gap: 6px;
}

.wpiemap-theme {
	position: relative;
	height: 34px;
	overflow: hidden;
	cursor: pointer;
	border: 1px solid var( --ed-border, #333a44 );
	border-radius: 6px;
}

.wpiemap-theme.sel {
	border-color: var( --ed-accent, #3b82f6 );
	box-shadow: 0 0 0 1px var( --ed-accent, #3b82f6 );
}

#wpie-root .wpiemap-reset {
	padding: 1px 7px;
	font-size: 11px;
	color: var( --ed-text-muted, #9aa1ab );
	cursor: pointer;
	background: none;
	border: 1px solid var( --ed-border, #333a44 );
	border-radius: 5px;
}

#wpie-root .wpiemap-reset:hover {
	color: inherit;
	border-color: var( --ed-accent, #3b82f6 );
}


.wpiemap-pin {
	display: grid;
	grid-template-columns: 1fr auto;
	gap: 6px;
	align-items: center;
	margin-top: 6px;
}

.wpiemap-pin input {
	width: 100%;
	padding: 5px 8px;
	font-size: 12px;
	color: inherit;
	background: var( --ed-bg, #14171c );
	border: 1px solid var( --ed-border, #333a44 );
	border-radius: 6px;
}

.wpiemap-btn {
	padding: 6px 12px;
	font-size: 12px;
	color: inherit;
	cursor: pointer;
	background: rgba( 128, 128, 128, 0.12 );
	border: 1px solid var( --ed-border, #333a44 );
	border-radius: 6px;
}

.wpiemap-btn:hover {
	background: rgba( 128, 128, 128, 0.2 );
}

/* Add pin reads as a real, primary action button (icon + label, accent
   framed, full width) rather than a faint line of text. */
.wpiemap-addpin {
	display: flex;
	gap: 6px;
	align-items: center;
	justify-content: center;
	width: 100%;
	margin-bottom: 8px;
	font-weight: 600;
	color: var( --ed-accent, #3b82f6 );
	background: rgba( 59, 130, 246, 0.12 );
	border-color: var( --ed-accent, #3b82f6 );
}

.wpiemap-addpin:hover {
	background: rgba( 59, 130, 246, 0.2 );
}

.wpiemap-btn:disabled {
	cursor: default;
	opacity: 0.5;
}


.wpiemap-status {
	position: absolute;
	bottom: 14px;
	left: 50%;
	display: none;
	max-width: 78%;
	padding: 7px 14px;
	font-size: 11px;
	line-height: 1.4;
	color: var( --ed-text, #e6e8ee );
	text-align: center;
	pointer-events: none;
	background: var( --ed-panel, #1d2126 );
	border: 1px solid var( --ed-border, #333a44 );
	border-radius: 999px;
	box-shadow: 0 8px 24px rgba( 0, 0, 0, 0.3 );
	transform: translateX( -50% );
}

.wpiemap-status.on {
	display: block;
}

.wpiemap-status.err {
	color: #f28b82;
	border-color: rgba( 242, 139, 130, 0.5 );
}


.wpiemap-text-row {
	margin: 6px 0;
}

.wpiemap-text-row > span {
	display: block;
	margin-bottom: 3px;
	font-size: 11px;
	color: var( --ed-text-muted, #9aa1ab );
}

.wpiemap-var-wrap {
	display: flex;
	gap: 6px;
	align-items: center;
}

.wpiemap-var-wrap input {
	flex: 1;
	min-width: 0;
}

.wpiemap-varhint {
	margin-top: 4px;
	font-size: 10px;
	line-height: 1.45;
	color: var( --ed-text-muted, #9aa1ab );
}

/* v2.0 - foil / gradient swatches for the roads */

.wpiemap-gradrow {
	margin: 6px 0;
}

.wpiemap-gradlbl {
	display: block;
	margin-bottom: 4px;
	font-size: 11px;
	color: var( --ed-text-muted, #9aa1ab );
}

.wpiemap-grads {
	display: flex;
	flex-wrap: wrap;
	gap: 6px;
}

#wpie-root .wpiemap-grad {
	flex: none;
	width: 42px;
	height: 20px;
	font-size: 10px;
	color: var( --ed-text-muted, #9aa1ab );
	cursor: pointer;
	background: none;
	border: 1px solid var( --ed-border, #333a44 );
	border-radius: 5px;
}

#wpie-root .wpiemap-grad.sel {
	color: var( --ed-accent, #3b82f6 );
	border-color: var( --ed-accent, #3b82f6 );
	box-shadow: 0 0 0 1px var( --ed-accent, #3b82f6 );
}
