/*
 * Host themes style <button>, <a>, <input> and headings globally, typically at
 * (0,1,1) with :hover at (0,2,1) (Elementor kits, Hello Elementor's reset), and
 * this sheet is enqueued before them. Every rule for those elements is
 * therefore pitched at (0,2,1) or higher, with hover/focus restated, so the
 * widget renders the same in any theme.
 */

.semel-maps-wrap {
	--semel-accent: #f0a868;
	--semel-dark: #1d3050;
	--semel-list-height: 450px;
	/* Mobile: the map sits between the title and the search box. */
	--semel-mobile-map-height: max(160px, 25vh);
	/* Breathing room above the title and below the list (and, on phones, below
	   the map); on desktop the map column carries the same padding so the map
	   starts level with the title and ends level with the list. */
	--semel-column-padding: 60px;
	display: grid;
	grid-template-columns: 1fr 1fr;
	grid-template-rows: auto 1fr;
	grid-template-areas:
		"header map"
		"list map";
	gap: 0 2rem;
	/* Stretch (the default) so the map column runs the full height of the
	   header + list column beside it. */
	align-items: stretch;
}

.semel-maps-header {
	grid-area: header;
	padding-top: var(--semel-column-padding);
	padding-bottom: 1.25rem;
}

.semel-maps-wrap .semel-maps-title {
	margin: 0 0 1.5rem;
	font-size: clamp(1.375rem, 1.1rem + 1vw, 1.75rem);
	font-weight: 700;
	line-height: 1.2;
	color: var(--semel-dark);
}

/* The script hides controls with the hidden attribute; the display rules
   below (e.g. the geolocate button's inline-flex) would otherwise win over
   the browser's [hidden] { display: none }. */
.semel-maps-header [hidden] {
	display: none !important;
}

.semel-maps-search {
	position: relative;
	margin: 0;
}

/* (0,4,1): Elementor's kit "Form Fields" style targets
   input:not([type=button]):not([type=submit]) at (0,3,1), which a plain
   .wrap input.class selector loses to. */
.semel-maps-wrap .semel-maps-search input[type="text"].semel-maps-search-input {
	width: 100%;
	padding: 0.9rem 3rem 0.9rem 1.1rem;
	font-size: 1rem;
	line-height: 1.5;
	color: inherit;
	background: #fff;
	border: 2px solid var(--semel-accent);
	border-radius: 8px;
	box-sizing: border-box;
}

.semel-maps-wrap .semel-maps-search input[type="text"].semel-maps-search-input:focus {
	border-color: var(--semel-accent);
	outline: 2px solid var(--semel-dark);
	outline-offset: 1px;
}

/* Shared reset for the widget's own buttons, hover and focus included. */
.semel-maps-wrap button.semel-maps-search-btn,
.semel-maps-wrap button.semel-maps-geolocate,
.semel-maps-wrap button.semel-maps-reset,
.semel-maps-wrap button.semel-maps-item-name,
.semel-maps-wrap button.semel-maps-search-btn:hover,
.semel-maps-wrap button.semel-maps-geolocate:hover,
.semel-maps-wrap button.semel-maps-reset:hover,
.semel-maps-wrap button.semel-maps-item-name:hover,
.semel-maps-wrap button.semel-maps-search-btn:focus,
.semel-maps-wrap button.semel-maps-geolocate:focus,
.semel-maps-wrap button.semel-maps-reset:focus,
.semel-maps-wrap button.semel-maps-item-name:focus {
	background: transparent;
	border: 0;
	border-radius: 0;
	box-shadow: none;
	color: var(--semel-dark);
	font-family: inherit;
	line-height: 1.4;
	text-transform: none;
	white-space: normal;
}

.semel-maps-wrap button.semel-maps-search-btn:focus-visible,
.semel-maps-wrap button.semel-maps-geolocate:focus-visible,
.semel-maps-wrap button.semel-maps-reset:focus-visible,
.semel-maps-wrap button.semel-maps-item-name:focus-visible {
	outline: 2px solid var(--semel-dark);
	outline-offset: 2px;
}

.semel-maps-wrap button.semel-maps-search-btn {
	position: absolute;
	top: 50%;
	right: 0.5rem;
	transform: translateY(-50%);
	display: inline-flex;
	align-items: center;
	justify-content: center;
	padding: 0.5rem;
	cursor: pointer;
}

.semel-maps-wrap button.semel-maps-geolocate {
	display: inline-flex;
	align-items: center;
	gap: 0.4rem;
	margin-top: 0.75rem;
	padding: 0.4rem 0;
	font-size: 0.9rem;
	font-weight: 400;
	cursor: pointer;
	text-decoration: underline;
	text-underline-offset: 3px;
}

.semel-maps-filters {
	margin: 1rem 0 0;
	padding: 0;
	border: 0;
}

.semel-maps-filters-legend {
	margin: 0 0 0.5rem;
	padding: 0;
	font-size: 0.9rem;
	font-weight: 700;
	color: var(--semel-dark);
}

.semel-maps-filter-options {
	display: flex;
	flex-wrap: wrap;
	gap: 0.5rem;
}

.semel-maps-filter {
	display: inline-flex;
	align-items: center;
	gap: 0.4rem;
	padding: 0.35rem 0.75rem;
	font-size: 0.9rem;
	line-height: 1.4;
	border: 1px solid rgba(29, 48, 80, 0.25);
	border-radius: 999px;
	cursor: pointer;
}

.semel-maps-filter input {
	margin: 0;
	accent-color: var(--semel-dark);
}

.semel-maps-filter:has(input:checked) {
	background: rgba(240, 168, 104, 0.12);
	border-color: var(--semel-dark);
}

.semel-maps-meta {
	display: flex;
	align-items: baseline;
	justify-content: space-between;
	gap: 1rem;
	margin-top: 1rem;
}

.semel-maps-status {
	margin: 0;
	font-weight: 700;
	color: var(--semel-dark);
}

.semel-maps-wrap button.semel-maps-reset {
	padding: 0;
	font-size: 0.9rem;
	font-weight: 700;
	cursor: pointer;
	text-decoration: underline;
	text-underline-offset: 3px;
	white-space: nowrap;
}

.semel-maps-notice {
	margin: 0.75rem 0 0;
	padding: 0.6rem 0.9rem;
	font-size: 0.9rem;
	background: #fdf3e7;
	border-left: 3px solid var(--semel-accent);
}

.semel-maps-list-col {
	grid-area: list;
	min-width: 0;
	padding-bottom: var(--semel-column-padding);
}

.semel-maps-list {
	list-style: none;
	margin: 0;
	padding: 0 0.75rem 0 0;
	max-height: var(--semel-list-height);
	overflow-y: auto;
	scrollbar-width: thin;
	scrollbar-color: var(--semel-accent) transparent;
}

.semel-maps-list::-webkit-scrollbar {
	width: 6px;
}

.semel-maps-list::-webkit-scrollbar-thumb {
	background: var(--semel-accent);
	border-radius: 3px;
}

/* Always-visible scroll indicator for the list, driven by semel-maps.js.
   Mobile overlay scrollbars auto-hide between scrolls (and iOS ignores
   scrollbar styling entirely), so nothing signals that the list scrolls;
   this bar stays put. Desktop keeps the native thin scrollbar. */
.semel-maps-list-scrollbar,
.semel-maps-list-scrollbar[hidden] {
	display: none;
}

.semel-maps-item {
	display: grid;
	/* Wide enough for LAPPEENRANTA / HÄMEENLINNA in bold caps without a mid-word break. */
	grid-template-columns: minmax(7rem, 9.5rem) 1fr;
	gap: 1.25rem;
	padding: 1.5rem 0.25rem;
	cursor: pointer;
}

.semel-maps-item.is-active {
	background: rgba(240, 168, 104, 0.12);
}

/* Search results: partners that did not match stay listed beneath the
   matches, faded, so the widget keeps its height with few results. */
.semel-maps-item.is-muted {
	opacity: 0.45;
}

.semel-maps-item:not(.is-muted) + .semel-maps-item.is-muted {
	border-top: 1px solid rgba(29, 48, 80, 0.15);
}

.semel-maps-item.is-muted:hover,
.semel-maps-item.is-muted:focus-within,
.semel-maps-item.is-muted.is-active {
	opacity: 1;
}

.semel-maps-item-city {
	font-weight: 700;
	text-transform: uppercase;
	color: var(--semel-dark);
	overflow-wrap: break-word;
}

.semel-maps-item-body {
	min-width: 0;
}

.semel-maps-wrap button.semel-maps-item-name {
	display: block;
	padding: 0;
	font-size: 1.05em;
	font-weight: 700;
	text-align: left;
	cursor: pointer;
}

.semel-maps-wrap button.semel-maps-item-name:hover,
.semel-maps-wrap button.semel-maps-item-name:focus {
	text-decoration: underline;
	text-underline-offset: 3px;
}

.semel-maps-item-address {
	margin: 0.15rem 0 0;
}

.semel-maps-item-distance {
	margin: 0.5rem 0 0;
	font-size: 0.9rem;
	font-weight: 700;
	color: var(--semel-dark);
}

.semel-maps-item-links {
	list-style: none;
	margin: 0;
	padding: 0;
}

.semel-maps-item-links li {
	margin-top: 0.75rem;
}

.semel-maps-wrap .semel-maps-item-links a,
.semel-maps-wrap .semel-maps-item-links a:hover,
.semel-maps-wrap .semel-maps-item-links a:focus {
	color: inherit;
	text-decoration: underline;
	text-underline-offset: 3px;
	overflow-wrap: anywhere;
}

.semel-maps-wrap .semel-maps-item-links a.semel-maps-directions,
.semel-maps-wrap .semel-maps-item-links a.semel-maps-directions:hover,
.semel-maps-wrap .semel-maps-item-links a.semel-maps-directions:focus {
	font-weight: 600;
	color: var(--semel-dark);
}

.semel-maps-map-col {
	grid-area: map;
	min-width: 0;
	padding-top: var(--semel-column-padding);
	padding-bottom: var(--semel-column-padding);
}

.semel-maps-map {
	width: 100%;
	height: 100%;
	min-height: var(--semel-list-height);
	background: #eceae4;
}

.semel-maps-map-placeholder {
	margin: 0;
	padding: 2rem;
	text-align: center;
	color: #666;
}

/* "You are here": the searched/located origin is a pulsing dot with a white
   ring — the familiar own-location mark, and nothing like the teardrop pins
   the asennusliikkeet get. Color comes from the userColor setting via the
   custom property set in semel-maps.js. */
.semel-maps-user-marker {
	position: relative;
	width: 18px;
	height: 18px;
	border-radius: 50%;
	background: var(--semel-user-color, #1a73e8);
	border: 3px solid #fff;
	box-shadow: 0 1px 4px rgba(0, 0, 0, 0.45);
}

.semel-maps-user-marker::before {
	content: "";
	position: absolute;
	/* Over the border box, so the ripple starts at the dot's edge. */
	top: -3px;
	right: -3px;
	bottom: -3px;
	left: -3px;
	border-radius: 50%;
	background: var(--semel-user-color, #1a73e8);
	animation: semel-maps-user-pulse 2.4s ease-out infinite;
	pointer-events: none;
}

@keyframes semel-maps-user-pulse {
	0% {
		transform: scale(1);
		opacity: 0.5;
	}
	70%, 100% {
		transform: scale(2.75);
		opacity: 0;
	}
}

@media (prefers-reduced-motion: reduce) {
	.semel-maps-user-marker::before {
		animation: none;
		opacity: 0;
	}
}

/* Pin info card used on mobile (in flow, below the map); desktop keeps the
   Mapbox popup, so the card never renders there. */
.semel-maps-card,
.semel-maps-card[hidden] {
	display: none;
}

/* --- Mapbox chrome ------------------------------------------------------- */
/* Restores Mapbox GL's own control and popup styling where a host theme's
   global button rules would otherwise repaint them. Values mirror mapbox-gl.css. */

.semel-maps-wrap .mapboxgl-map {
	font-family: inherit;
}

.semel-maps-wrap .mapboxgl-ctrl-group button,
.semel-maps-wrap .mapboxgl-ctrl-group button:hover,
.semel-maps-wrap .mapboxgl-ctrl-group button:focus {
	width: 29px;
	height: 29px;
	padding: 0;
	border: 0;
	color: inherit;
	font: inherit;
}

.semel-maps-wrap .mapboxgl-ctrl-group button {
	background-color: transparent;
}

.semel-maps-wrap .mapboxgl-ctrl-group button:hover {
	background-color: rgba(0, 0, 0, 0.05);
}

.semel-maps-wrap .mapboxgl-ctrl-group button + button,
.semel-maps-wrap .mapboxgl-ctrl-group button + button:hover,
.semel-maps-wrap .mapboxgl-ctrl-group button + button:focus {
	border-top: 1px solid #ddd;
}

.semel-maps-wrap button.mapboxgl-ctrl-attrib-button,
.semel-maps-wrap button.mapboxgl-ctrl-attrib-button:hover,
.semel-maps-wrap button.mapboxgl-ctrl-attrib-button:focus {
	width: 24px;
	height: 24px;
	padding: 0;
	border: 0;
	border-radius: 12px;
	background-color: rgba(255, 255, 255, 0.5);
}

.semel-maps-wrap .mapboxgl-ctrl-attrib.mapboxgl-compact-show button.mapboxgl-ctrl-attrib-button {
	background-color: rgba(0, 0, 0, 0.05);
}

/* Room on the right so a long name never runs under the close button. */
.semel-maps-wrap .mapboxgl-popup-content {
	padding: 0.75rem 2.25rem 0.9rem 0.9rem;
}

.semel-maps-wrap button.mapboxgl-popup-close-button,
.semel-maps-wrap button.mapboxgl-popup-close-button:hover,
.semel-maps-wrap button.mapboxgl-popup-close-button:focus {
	position: absolute;
	top: 0;
	right: 0;
	width: auto;
	height: auto;
	padding: 0.15rem 0.55rem 0.3rem;
	border: 0;
	border-radius: 0 3px 0 0;
	font-family: inherit;
	font-size: 1.25rem;
	font-weight: 400;
	line-height: 1;
	cursor: pointer;
}

.semel-maps-wrap button.mapboxgl-popup-close-button {
	background-color: transparent;
	color: #555;
}

.semel-maps-wrap button.mapboxgl-popup-close-button:hover,
.semel-maps-wrap button.mapboxgl-popup-close-button:focus {
	background-color: rgba(0, 0, 0, 0.05);
	color: #000;
}

.semel-maps-popup {
	font-size: 0.85rem;
	line-height: 1.5;
}

.semel-maps-wrap .semel-maps-popup a,
.semel-maps-wrap .semel-maps-popup a:hover,
.semel-maps-wrap .semel-maps-popup a:focus {
	color: var(--semel-dark);
}

.semel-maps-badge {
	display: inline-block;
	padding: 0.1rem 0.5rem;
	font-size: 0.75rem;
	font-weight: 700;
	border-radius: 999px;
	vertical-align: 1px;
}

.semel-maps-badge.is-open {
	background: #e2f3e6;
	color: #1e7d32;
}

.semel-maps-badge.is-closed {
	background: #f3e3e3;
	color: #a42828;
}

@media (max-width: 900px) {
	.semel-maps-wrap {
		--semel-column-padding: 60px;
		/* About two rows of the list at a time. */
		--semel-list-height: 380px;
		display: flex;
		flex-direction: column;
		gap: 0;
		/* The header box dissolves below (display: contents), so its top
		   padding lives here — and still applies when there is no title. */
		padding-top: var(--semel-column-padding);
	}

	/* The map markup sits after the list, shared with desktop. Dissolving the
	   header makes its children direct flex items of the wrap, so the map
	   column can be ordered in between the title and the search box. */
	.semel-maps-header {
		display: contents;
	}

	.semel-maps-wrap .semel-maps-title {
		order: 0;
	}

	.semel-maps-map-col {
		order: 1;
		/* The desktop title/list alignment padding. */
		padding: 0;
		margin-bottom: 1.5rem;
	}

	.semel-maps-search {
		order: 2;
	}

	.semel-maps-wrap button.semel-maps-geolocate {
		order: 3;
	}

	.semel-maps-filters {
		order: 4;
	}

	.semel-maps-meta {
		order: 5;
	}

	.semel-maps-notice {
		order: 6;
	}

	.semel-maps-list-col {
		order: 7;
		/* The dissolved header's bottom padding. Margin, not padding: the
		   scroll indicator track aligns to the column's padding box. */
		margin-top: 1.25rem;
	}

	.semel-maps-map {
		height: var(--semel-mobile-map-height);
		min-height: 0;
	}

	.semel-maps-card {
		display: block;
		position: relative;
		margin-top: 0.75rem;
		padding: 0.9rem 2.5rem 1rem 1rem;
		background: #fff;
		border: 1px solid rgba(29, 48, 80, 0.15);
		border-radius: 8px;
		box-shadow: 0 6px 18px rgba(29, 48, 80, 0.15);
	}

	.semel-maps-card[hidden] {
		display: none;
	}

	/* The popup body reads small on a phone; the card has room. */
	.semel-maps-card .semel-maps-popup {
		font-size: 0.95rem;
	}

	.semel-maps-wrap button.semel-maps-card-close,
	.semel-maps-wrap button.semel-maps-card-close:hover,
	.semel-maps-wrap button.semel-maps-card-close:focus {
		position: absolute;
		top: 0.3rem;
		right: 0.3rem;
		padding: 0.25rem 0.6rem 0.4rem;
		border: 0;
		border-radius: 6px;
		background: transparent;
		box-shadow: none;
		color: #555;
		font-family: inherit;
		font-size: 1.4rem;
		font-weight: 400;
		line-height: 1;
		cursor: pointer;
	}

	.semel-maps-wrap button.semel-maps-card-close:hover,
	.semel-maps-wrap button.semel-maps-card-close:focus {
		background: rgba(0, 0, 0, 0.05);
		color: #000;
	}

	.semel-maps-wrap button.semel-maps-card-close:focus-visible {
		outline: 2px solid var(--semel-dark);
		outline-offset: 2px;
	}

	.semel-maps-list {
		padding-right: 0.75rem;
		/* The custom indicator replaces the native overlay scrollbar. */
		scrollbar-width: none;
	}

	.semel-maps-list::-webkit-scrollbar {
		display: none;
	}

	.semel-maps-list-col {
		position: relative;
	}

	.semel-maps-list-scrollbar {
		display: block;
		position: absolute;
		top: 0;
		right: 0;
		/* The column's bottom padding, so the track ends level with the list. */
		bottom: var(--semel-column-padding);
		width: 4px;
		border-radius: 2px;
		background: rgba(29, 48, 80, 0.15);
	}

	.semel-maps-list-scrollbar-thumb {
		position: absolute;
		left: 0;
		right: 0;
		border-radius: 2px;
		background: var(--semel-accent);
	}
}
