/**
 * Distributor Locator ([streets_distributor_locator] element / legacy template).
 * Same palette as the Product Finder: primary #cf162e, slate #313d4b, ink #231f20.
 *
 * Layout modifiers (set by the element's Layout option):
 *   .sloc--map-right  list left, map right (default)
 *   .sloc--map-left   map left, list right
 *   .sloc--map-top    map full width above a card grid
 *   .sloc--list-only  no map
 *   .sloc--map-only   no list
 * .sloc--sticky pins the map while the list scrolls (side-by-side only).
 * --sl-map-h (inline) is the desktop map height; --sl-red / --sl-red-dark the accent.
 */

.sloc {
	--sl-red: #cf162e;
	--sl-red-dark: #a81124;
	--sl-slate: #313d4b;
	--sl-ink: #231f20;
	--sl-muted: #6b7784;
	--sl-line: #e2e5e8;
	--sl-panel: #f5f6f7;
	--sl-hi: #fff4f5;
	--sl-radius: 2px;
	--sl-ease: 180ms ease;
	--sl-map-h: 560px;

	clear: both;
	max-width: 1280px;
	margin: 0 auto;
	padding: 40px 24px 72px;
	color: var(--sl-ink);
}

/* Inside a builder column the column supplies width + gutters */
.sloc--embedded {
	max-width: none;
	padding: 0;
}

.sloc-intro {
	max-width: 1280px;
	margin: 0 auto;
	padding: 0 24px;
}

.sloc-notice {
	max-width: 1280px;
	margin: 0 auto 24px;
	padding: 16px 24px;
	border-left: 3px solid #cf162e;
	background: #f5f6f7;
	color: #313d4b;
}

/* ---------- Filter bar ---------- */

.sloc__bar {
	display: grid;
	grid-template-columns: 1fr;
	gap: 16px 20px;
	align-items: end;
	padding: 20px;
	margin: 0 0 24px;
	border: 1px solid var(--sl-line);
	border-radius: var(--sl-radius);
	background: var(--sl-panel);
}

@media (min-width: 720px) {
	.sloc__bar {
		grid-template-columns: 1fr 1fr;
	}
}

@media (min-width: 1200px) {
	.sloc__bar {
		grid-template-columns: minmax(260px, 1.6fr) minmax(150px, 1fr) minmax(180px, 1.1fr) minmax(290px, 1.3fr) auto;
	}
}

.sloc__field {
	min-width: 0;
	margin: 0;
	padding: 0;
	border: 0;
}

.sloc__label {
	display: block;
	margin: 0 0 6px;
	padding: 0;
	font-size: 12px;
	font-weight: 700;
	letter-spacing: 1.5px;
	text-transform: uppercase;
	color: var(--sl-slate);
}

.sloc__field--reset {
	align-self: end;
	padding-bottom: 8px;
}

/* Controls, normalised to one height. The extra selector depth beats Avada's
   form rules (fusion-dynamic-css sizes bare inputs to --form_input_height). */
.sloc__input,
.sloc__select,
.sloc .sloc__bar input.sloc__input,
.sloc .sloc__bar select.sloc__select {
	box-sizing: border-box;
	display: block;
	width: 100%;
	min-width: 0;
	height: 44px;
	margin: 0;
	padding: 0 14px;
	border: 1px solid var(--sl-line);
	border-radius: var(--sl-radius);
	background: #fff;
	color: var(--sl-ink);
	font-family: inherit;
	font-size: 15px;
	line-height: 42px;
	box-shadow: none;
	transition: border-color var(--sl-ease), box-shadow var(--sl-ease);
	-webkit-appearance: none;
	appearance: none;
}

.sloc__select {
	padding-right: 36px;
	background-image: url("data:image/svg+xml;charset=UTF-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' fill='none' stroke='%23313d4b' stroke-width='1.8'/%3E%3C/svg%3E");
	background-repeat: no-repeat;
	background-position: right 14px center;
	cursor: pointer;
}

.sloc__input:focus,
.sloc__select:focus {
	outline: none;
	border-color: var(--sl-slate);
	box-shadow: 0 0 0 3px rgba(49, 61, 75, 0.12);
}

.sloc__input::placeholder {
	color: var(--sl-muted);
	opacity: 1;
}

.sloc__input[type="search"]::-webkit-search-decoration {
	-webkit-appearance: none;
}

/* The Near box has its own locate button where the native clear "x" would sit. */
.sloc__near-input::-webkit-search-cancel-button {
	-webkit-appearance: none;
	display: none;
}

.sloc__input.is-invalid {
	border-color: var(--sl-red);
	box-shadow: 0 0 0 3px rgba(207, 22, 46, 0.14);
}

.sloc__input.is-busy {
	background-image: linear-gradient(90deg, transparent 0, rgba(49, 61, 75, 0.08) 50%, transparent 100%);
	background-size: 200% 100%;
	animation: sloc-busy 1s linear infinite;
}

@keyframes sloc-busy {
	from { background-position: 200% 0; }
	to   { background-position: -200% 0; }
}

/* Near: location input + radius side by side */
.sloc__near {
	display: grid;
	grid-template-columns: minmax(0, 1fr) 112px;
	gap: 8px;
}

@media (max-width: 719px) {
	.sloc__near {
		grid-template-columns: minmax(0, 1fr) 100px;
	}

	.sloc .sloc__bar select.sloc__radius {
		padding-left: 10px;
		padding-right: 28px;
		background-position: right 10px center;
	}
}

.sloc__near-wrap {
	position: relative;
	min-width: 0;
}

.sloc__near-input {
	padding-right: 44px;
}

.sloc__locate {
	position: absolute;
	top: 50%;
	right: 6px;
	display: grid;
	place-items: center;
	width: 32px;
	height: 32px;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: transparent;
	color: var(--sl-slate);
	opacity: 0.7;
	cursor: pointer;
	transform: translateY(-50%);
	transition: opacity var(--sl-ease), background var(--sl-ease);
}

.sloc__locate:hover,
.sloc__locate:focus-visible {
	opacity: 1;
	background: var(--sl-panel);
	outline: none;
}

.sloc__locate.is-busy svg {
	animation: sloc-spin 1s linear infinite;
}

@keyframes sloc-spin {
	to { transform: rotate(360deg); }
}

/* Suggestions list */
.sloc__suggest {
	position: absolute;
	top: calc(100% + 4px);
	left: 0;
	right: 0;
	z-index: 20;
	margin: 0;
	padding: 4px 0;
	list-style: none;
	border: 1px solid var(--sl-line);
	border-radius: var(--sl-radius);
	background: #fff;
	box-shadow: 0 6px 20px rgba(0, 0, 0, 0.12);
}

.sloc__suggest[hidden] {
	display: none;
}

.sloc__suggest li {
	display: flex;
	flex-direction: column;
	gap: 1px;
	padding: 8px 14px;
	cursor: pointer;
	font-size: 14px;
	line-height: 1.3;
}

.sloc__suggest li:hover,
.sloc__suggest li.is-active {
	background: var(--sl-hi);
}

.sloc__suggest-main {
	color: var(--sl-ink);
	font-weight: 600;
}

.sloc__suggest-sec {
	color: var(--sl-muted);
	font-size: 12px;
}

/* Region checkboxes, inline */
.sloc__checks {
	display: flex;
	flex-wrap: wrap;
	gap: 6px 16px;
	min-height: 44px;
	align-items: center;
}

.sloc__check {
	display: inline-flex;
	align-items: center;
	gap: 8px;
	margin: 0;
	font-size: 14px;
	line-height: 1.4;
	font-weight: 400;
	color: var(--sl-ink);
	cursor: pointer;
}

.sloc__check input {
	width: 16px;
	height: 16px;
	margin: 0;
	accent-color: var(--sl-red);
	cursor: pointer;
}

.sloc__check-count {
	color: var(--sl-muted);
}

/* Reset link */
.sloc__reset {
	padding: 0;
	border: 0;
	border-bottom: 1px solid transparent;
	border-radius: 0;
	background: transparent;
	color: var(--sl-red);
	font-size: 13px;
	font-weight: 700;
	letter-spacing: 1px;
	text-transform: uppercase;
	line-height: 1.4;
	cursor: pointer;
	transition: border-color var(--sl-ease);
}

.sloc__reset:hover,
.sloc__reset:focus-visible {
	border-color: var(--sl-red);
	outline: none;
}

.sloc__reset[hidden] {
	display: none;
}

/* ---------- Body: map + list ---------- */

.sloc__body {
	display: grid;
	grid-template-columns: 1fr;
	gap: 24px;
}

@media (min-width: 1000px) {
	.sloc__body {
		grid-template-columns: minmax(0, 7fr) minmax(0, 5fr);
		gap: 32px;
	}

	.sloc__map {
		order: 2;
	}

	.sloc__results {
		order: 1;
	}

	/* Map left, list right */
	.sloc--map-left .sloc__body {
		grid-template-columns: minmax(0, 5fr) minmax(0, 7fr);
	}

	.sloc--map-left .sloc__map {
		order: 1;
	}

	.sloc--map-left .sloc__results {
		order: 2;
	}

	/* Map above list: one column, results as a card grid */
	.sloc--map-top .sloc__body,
	.sloc--list-only .sloc__body,
	.sloc--map-only .sloc__body {
		grid-template-columns: 1fr;
	}

	.sloc--map-top .sloc__map {
		order: 1;
	}

	.sloc--map-top .sloc__results {
		order: 2;
	}
}

/* Map-only: the list block is removed from flow */
.sloc--map-only .sloc__results[hidden] {
	display: none;
}

.sloc__map {
	position: relative;
	border: 1px solid var(--sl-line);
	border-radius: var(--sl-radius);
	overflow: hidden;
	background: var(--sl-panel);
}

@media (min-width: 1000px) {
	/* after the base rule so it wins: pinned while the list scrolls */
	.sloc--sticky .sloc__map {
		position: sticky;
		top: 120px;
		align-self: start;
	}
}

.sloc__canvas {
	width: 100%;
	height: var(--sl-map-h, 560px);
}

/* Shorter on phones so the list is reachable without a long scroll. */
@media (max-width: 999px) {
	.sloc__canvas {
		height: 62vw;
		min-height: 280px;
		max-height: 440px;
	}
}

/* Hide the empty map box entirely when the script could not load Google. */
.sloc.is-map-failed .sloc__map {
	display: none;
}

/* "Search this area" toggle, laid over the map's top-left corner */
.sloc__area {
	position: absolute;
	top: 12px;
	left: 12px;
	z-index: 2;
	padding: 9px 14px;
	border: 0;
	border-radius: var(--sl-radius);
	background: #fff;
	color: var(--sl-slate);
	font-size: 12px;
	font-weight: 700;
	letter-spacing: 1px;
	text-transform: uppercase;
	box-shadow: 0 1px 4px rgba(0, 0, 0, 0.25);
	cursor: pointer;
	transition: background var(--sl-ease), color var(--sl-ease);
}

.sloc__area[hidden] {
	display: none;
}

.sloc__area:hover,
.sloc__area.is-on {
	background: var(--sl-red);
	color: #fff;
}

/* Google's info window */
.gm-style .gm-style-iw-c {
	padding: 0 !important;
	border-radius: var(--sl-radius, 2px);
}

.gm-style .gm-style-iw-d {
	overflow: auto !important;
}

/* ---------- Results ---------- */

.sloc__toolbar {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 16px;
	padding: 0 0 12px;
	margin-bottom: 4px;
	border-bottom: 1px solid var(--sl-line);
}

.sloc__count {
	font-size: 13px;
	font-weight: 700;
	letter-spacing: 1px;
	text-transform: uppercase;
	color: var(--sl-slate);
}

.sloc__list {
	display: grid;
	grid-template-columns: 1fr;
	gap: 0;
}

/* Stacked layouts get a card grid instead of a single column */
@media (min-width: 720px) {
	.sloc--map-top .sloc__list,
	.sloc--list-only .sloc__list {
		grid-template-columns: repeat(2, minmax(0, 1fr));
		gap: 16px;
	}

	.sloc--map-top .sloc__card--list,
	.sloc--list-only .sloc__card--list {
		border: 1px solid var(--sl-line);
		border-radius: var(--sl-radius);
	}

	.sloc--map-top .sloc__card--list.is-active,
	.sloc--map-top .sloc__card--list.is-hover,
	.sloc--list-only .sloc__card--list.is-active,
	.sloc--list-only .sloc__card--list.is-hover {
		box-shadow: inset 0 0 0 1px var(--sl-red);
		border-color: var(--sl-red);
	}
}

@media (min-width: 1000px) {
	.sloc--map-top .sloc__list,
	.sloc--list-only .sloc__list {
		grid-template-columns: repeat(3, minmax(0, 1fr));
	}
}

.sloc__card {
	position: relative;
	display: grid;
	grid-template-columns: minmax(0, 1fr) auto;
	grid-template-areas:
		"head head"
		"place map"
		"contact map";
	gap: 4px 16px;
	padding: 18px 16px;
	border-bottom: 1px solid var(--sl-line);
	background: #fff;
	transition: background var(--sl-ease), box-shadow var(--sl-ease);
}

.sloc__card.is-hidden {
	display: none;
}

.sloc__card:last-child {
	border-bottom: 0;
}

.sloc__card.is-active,
.sloc__card.is-hover {
	background: var(--sl-hi);
	box-shadow: inset 3px 0 0 var(--sl-red);
}

.sloc__card-head {
	grid-area: head;
	display: flex;
	align-items: baseline;
	justify-content: space-between;
	gap: 12px;
}

.sloc__card-title {
	margin: 0;
	font-size: 17px;
	line-height: 1.3;
	font-weight: 700;
	color: var(--sl-slate);
}

.sloc__card-distance {
	flex: none;
	font-size: 12px;
	font-weight: 700;
	letter-spacing: 0.5px;
	color: var(--sl-red);
	white-space: nowrap;
}

.sloc__card-distance[hidden] {
	display: none;
}

.sloc__card-place {
	grid-area: place;
	margin: 0;
	font-size: 14px;
	color: var(--sl-ink);
}

.sloc__card-address {
	display: block;
}

.sloc__card-contact {
	grid-area: contact;
	display: flex;
	flex-wrap: wrap;
	gap: 2px 16px;
	margin: 0;
	padding: 0;
	list-style: none;
	font-size: 14px;
}

.sloc__card-contact a {
	color: var(--sl-slate);
	text-decoration: none;
	border-bottom: 1px solid var(--sl-line);
	transition: color var(--sl-ease), border-color var(--sl-ease);
}

.sloc__card-contact a:hover {
	color: var(--sl-red);
	border-color: var(--sl-red);
}

.sloc__card-map {
	grid-area: map;
	align-self: start;
	padding: 8px 12px;
	border: 1px solid var(--sl-line);
	border-radius: var(--sl-radius);
	background: #fff;
	color: var(--sl-slate);
	font-size: 12px;
	font-weight: 700;
	letter-spacing: 1px;
	text-transform: uppercase;
	white-space: nowrap;
	cursor: pointer;
	transition: background var(--sl-ease), color var(--sl-ease), border-color var(--sl-ease);
}

/* No map without JS / Google: the button has nothing to do. */
.sloc:not(.is-map-ready) .sloc__card-map {
	display: none;
}

.sloc__card-map:hover,
.sloc__card-map:focus-visible {
	background: var(--sl-slate);
	border-color: var(--sl-slate);
	color: #fff;
	outline: none;
}

/* Marker pop-up variant */
.sloc__card--marker {
	display: block;
	min-width: 220px;
	max-width: 280px;
	padding: 14px 16px;
	border: 0;
	font-family: inherit;
}

.sloc__card--marker .sloc__card-title {
	font-size: 15px;
	padding-right: 20px;
}

.sloc__card--marker .sloc__card-place,
.sloc__card--marker .sloc__card-contact {
	font-size: 13px;
	margin-top: 4px;
}

.sloc__card--marker .sloc__card-contact {
	display: block;
}

.sloc__card-directions {
	display: inline-block;
	margin-top: 10px;
	font-size: 12px;
	font-weight: 700;
	letter-spacing: 1px;
	text-transform: uppercase;
	color: var(--sl-red, #cf162e);
	text-decoration: none;
}

.sloc__card-directions:hover {
	text-decoration: underline;
}

.sloc__empty {
	padding: 32px 16px;
	margin: 0;
	text-align: center;
	color: var(--sl-muted);
}

.sloc__empty[hidden] {
	display: none;
}

/* ---------- Pager (show more) ---------- */

.sloc__pager {
	margin-top: 24px;
	text-align: center;
}

.sloc__more {
	display: inline-block;
	padding: 13px 28px;
	border: 2px solid var(--sl-slate);
	border-radius: var(--sl-radius);
	background: transparent;
	color: var(--sl-slate);
	font-size: 13px;
	font-weight: 700;
	letter-spacing: 1.5px;
	text-transform: uppercase;
	cursor: pointer;
	transition: background var(--sl-ease), color var(--sl-ease);
}

.sloc__more[hidden] {
	display: none;
}

.sloc__more:hover,
.sloc__more:focus-visible {
	background: var(--sl-slate);
	color: #fff;
	outline: none;
}
