/*
 * Township listing map.
 *
 * The two overlay colours live here rather than in map.js so the palette can
 * be retuned against the basemap without touching behaviour. --ss-map-home is
 * the listing's own township and the pin; --ss-map-other is every other
 * township. Two roles, deliberately: a distinct hue per township would fight
 * the map style and imply the colours mean something.
 */

.ss-map-wrap {
	--ss-map-home:    #FF5A5F;   /* coral -- this listing's township, and the pin */
	--ss-map-other:   #1B6480;   /* every other township in the same county */
	--ss-map-outline: #6B7A85;   /* a neighbouring county, drawn as one faint line */

	position: relative;   /* the hover hint is positioned against this */
	display: flex;
	flex-direction: column;
	gap: 1rem;
}

.ss-map {
	width: 100%;
	border-radius: 4px;
	overflow: hidden;
	background: #e9e6da;   /* shown while tiles load, not a transparent gap */
}

/* ---------- township labels on the map ---------- */

.ss-map-label {
	font: 600 11px/1.2 system-ui, -apple-system, "Segoe UI", sans-serif;
	color: #2b2f2c;
	white-space: nowrap;
	text-align: center;
	pointer-events: none;
	/* No pill or box: a halo keeps the label legible over any basemap colour
	   without adding another rectangle to a map already full of shapes. */
	text-shadow:
		0 0 3px #fff, 0 0 3px #fff, 0 0 3px #fff, 0 0 6px #fff;
}

.ss-map-label.is-home {
	color: var(--ss-map-home);
	font-size: 12px;
}


/* ---------- hover hint ---------- */

/*
 * A plain div, not an InfoWindow. InfoWindows render above the map controls,
 * so one opening near the pan/zoom cluster eats clicks meant for the buttons
 * underneath. pointer-events:none means this can never intercept anything.
 */
.ss-map-tip {
	position: absolute;
	z-index: 5;
	pointer-events: none;
	transform: translate(14px, -50%);
	max-width: 15rem;
	padding: 0.45rem 0.6rem;
	border-radius: 4px;
	background: rgba(255, 255, 255, 0.97);
	box-shadow: 0 1px 2px rgba(0, 0, 0, 0.18), 0 4px 12px rgba(0, 0, 0, 0.12);
	font: 400 12.5px/1.45 system-ui, -apple-system, "Segoe UI", sans-serif;
	color: #1a1f1c;
	white-space: nowrap;
}

.ss-map-tip.is-flipped {
	transform: translate(calc(-100% - 14px), -50%);
}

.ss-map-tip[hidden] {
	display: none;
}

.ss-map-tip strong {
	font-weight: 600;
}

/* ---------- scale switcher ---------- */

.ss-map-views {
	display: flex;
	margin: 10px 0 0 10px;
	border-radius: 4px;
	overflow: hidden;
	box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
	background: #fff;
}

.ss-map-views button {
	appearance: none;
	border: 0;
	border-right: 1px solid rgba(0, 0, 0, 0.12);
	background: #fff;
	padding: 0.42rem 0.7rem;
	font: 500 12px/1 system-ui, -apple-system, "Segoe UI", sans-serif;
	color: #3c4043;
	cursor: pointer;
}

.ss-map-views button:last-child {
	border-right: 0;
}

.ss-map-views button:hover {
	background: #f1f1f1;
}

.ss-map-views button:focus-visible {
	outline: 2px solid var(--ss-map-other);
	outline-offset: -2px;
}

/* ---------- bordering townships ---------- */

/*
 * Everything here is scoped under .ss-map-wrap and styles its own classes
 * rather than bare `li` / `a`, so a theme's list and link rules do not have
 * to be fought with !important -- and so nothing here leaks outward either.
 *
 * Each item is a stack: name, then one metadata line. No flex row, because a
 * theme setting flex-wrap or display on `li` can reorder one, which is
 * exactly what happened to the first version of this.
 */

.ss-map-wrap .ss-map-borders__title {
	font-size: 0.9rem;
	font-weight: 600;
	letter-spacing: 0.01em;
	margin: 0 0 0.6rem;
}

.ss-map-wrap .ss-map-borders__list {
	list-style: none;
	margin: 0;
	padding: 0;
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(9.5rem, 1fr));
	gap: 0.1rem 1.5rem;
}

.ss-map-wrap .ss-map-borders__item {
	display: block;
	margin: 0;
	padding: 0.45rem 0;
	border-top: 1px solid rgba(0, 0, 0, 0.08);
}

.ss-map-wrap .ss-map-borders__link {
	display: block;
	font-size: 0.95rem;
	font-weight: 500;
	line-height: 1.25;
	text-decoration: none;
	border-bottom: 0;
}

.ss-map-wrap .ss-map-borders__link:hover,
.ss-map-wrap .ss-map-borders__link:focus-visible,
.ss-map-wrap .ss-map-borders__link.is-hover {
	color: var(--ss-map-home);
	text-decoration: underline;
	text-underline-offset: 2px;
}

.ss-map-wrap .ss-map-borders__link:focus-visible {
	outline: 2px solid var(--ss-map-other);
	outline-offset: 2px;
	border-radius: 2px;
}

/*
 * County qualifier and count on one muted line. The county only appears when
 * the neighbour sits in a different one -- without it "Fishing Creek" is
 * ambiguous across Granville and Warren.
 */
.ss-map-wrap .ss-map-borders__meta {
	display: block;
	margin-top: 0.1rem;
	font-size: 0.76rem;
	line-height: 1.35;
	opacity: 0.62;
	font-variant-numeric: tabular-nums;
}

@media (prefers-reduced-motion: reduce) {
	.ss-map-wrap * {
		transition: none !important;
		animation: none !important;
	}
}
