/*
 * AHCS Location Finder
 *
 * Selectors use two classes (.ahcs-lf .ahcs-lf__x) so theme and Elementor
 * global button/input styles don't override the finder. Colors, corners and
 * heights come from custom properties set by the Style tab.
 */

.ahcs-lf {
	--ahcs-lf-accent: #0e5a8a;
	--ahcs-lf-on-accent: #fff;
	--ahcs-lf-radius: 12px;
	--ahcs-lf-map-h: 520px;
	--ahcs-lf-map-h-mobile: 420px;
	--ahcs-lf-ink: #17212b;
	--ahcs-lf-muted: #5b6774;
	--ahcs-lf-line: rgba(23, 33, 43, 0.12);
	--ahcs-lf-surface: #fff;
	--ahcs-lf-ring: color-mix(in srgb, var(--ahcs-lf-accent) 22%, transparent);
	--ahcs-lf-inner-radius: max(0px, calc(var(--ahcs-lf-radius) - 5px));

	display: grid;
	grid-template-columns: minmax(0, 1fr);
	gap: 16px;
	width: 100%;
	max-width: 100%;
	box-sizing: border-box;
	font-family: inherit;
	color: var(--ahcs-lf-ink);
	text-align: left;
}

.ahcs-lf [hidden] {
	display: none !important;
}

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

.ahcs-lf > * {
	min-width: 0;
}

.ahcs-lf .ahcs-lf-icon {
	flex: none;
	width: 18px;
	height: 18px;
}

.ahcs-lf .ahcs-lf__sr-only {
	position: absolute !important;
	width: 1px;
	height: 1px;
	overflow: hidden;
	clip-path: inset(50%);
	white-space: nowrap;
}

/* ---------- Search ---------- */

.ahcs-lf .ahcs-lf__search {
	display: grid;
	gap: 8px;
	justify-self: start;
	width: 100%;
	max-width: 600px;
	margin: 0;
	padding: 0;
}

.ahcs-lf--width-full .ahcs-lf__search {
	max-width: none;
}

.ahcs-lf--align-center .ahcs-lf__search {
	justify-self: center;
}

.ahcs-lf--align-right .ahcs-lf__search {
	justify-self: end;
}

.ahcs-lf .ahcs-lf__label {
	display: block;
	margin: 0;
	padding: 0;
	font-size: 15px;
	font-weight: 600;
	line-height: 1.3;
	color: var(--ahcs-lf-ink);
}

.ahcs-lf .ahcs-lf__bar {
	display: flex;
	flex-wrap: nowrap;
	align-items: center;
	gap: 4px;
	min-height: 56px;
	padding: 5px 5px 5px 16px;
	background: var(--ahcs-lf-surface);
	border: 1px solid var(--ahcs-lf-line);
	border-radius: var(--ahcs-lf-radius);
	box-shadow: 0 1px 2px rgba(23, 33, 43, 0.06);
	transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.ahcs-lf .ahcs-lf__bar:focus-within {
	border-color: var(--ahcs-lf-accent);
	box-shadow: 0 0 0 4px var(--ahcs-lf-ring);
}

.ahcs-lf .ahcs-lf__bar-icon {
	width: 20px;
	height: 20px;
	color: var(--ahcs-lf-muted);
}

.ahcs-lf .ahcs-lf__input,
.ahcs-lf .ahcs-lf__input:focus {
	flex: 1 1 120px;
	width: 100%;
	min-width: 0;
	height: 40px;
	margin: 0;
	padding: 0 6px;
	border: 0;
	border-radius: 0;
	background: transparent;
	box-shadow: none;
	outline: none;
	font: inherit;
	font-size: 16px;
	line-height: 1;
	letter-spacing: 0.01em;
	color: var(--ahcs-lf-ink);
}

.ahcs-lf .ahcs-lf__input::placeholder {
	color: var(--ahcs-lf-muted);
	opacity: 1;
}

.ahcs-lf .ahcs-lf__clear {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	flex: none;
	width: 36px;
	height: 36px;
	margin: 0;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: transparent;
	color: var(--ahcs-lf-muted);
	box-shadow: none;
	cursor: pointer;
}

.ahcs-lf .ahcs-lf__clear:hover,
.ahcs-lf .ahcs-lf__clear:focus {
	background: rgba(23, 33, 43, 0.06);
	color: var(--ahcs-lf-ink);
}

.ahcs-lf .ahcs-lf__radius {

	/* flex: none isn't enough on its own to keep this compact: with
	   flex-basis auto, a theme's generic "select { width: 100%; }" reset
	   (common in form styling) still wins as the basis. Pin width/max-width
	   explicitly, !important to stay correct regardless of theme load order. */
	flex: none;
	width: auto !important;
	max-width: 75px !important;
	height: 36px;
	margin: 0 2px;
	padding: 0 22px 0 10px;
	border: 1px solid var(--ahcs-lf-line);
	border-radius: 999px;
	background:
		transparent
		url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' width='14' height='14' fill='none' stroke='%235b6774' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E")
		no-repeat right 6px center;
	color: var(--ahcs-lf-ink);
	font: inherit;
	font-size: 13px;
	line-height: 1;
	appearance: none;
	cursor: pointer;
}

.ahcs-lf .ahcs-lf__radius:focus-visible {
	outline: 2px solid var(--ahcs-lf-accent);
	outline-offset: 1px;
}

.ahcs-lf .ahcs-lf__button,
.ahcs-lf .ahcs-lf__button:hover,
.ahcs-lf .ahcs-lf__button:focus {
	flex: none;
	height: 40px;
	margin: 0;
	padding: 0 24px;
	border: 0;
	border-radius: var(--ahcs-lf-inner-radius);
	background: var(--ahcs-lf-accent);
	color: var(--ahcs-lf-on-accent);
	box-shadow: none;
	font: inherit;
	font-size: 15px;
	font-weight: 600;
	line-height: 1;
	letter-spacing: 0.01em;
	text-transform: none;
	text-decoration: none;
	cursor: pointer;
}

.ahcs-lf .ahcs-lf__button:hover {
	filter: brightness(0.92);
}

.ahcs-lf .ahcs-lf__button:active {
	filter: brightness(0.85);
}

.ahcs-lf button:focus-visible,
.ahcs-lf a:focus-visible {
	outline: 2px solid var(--ahcs-lf-accent);
	outline-offset: 2px;
}

.ahcs-lf .ahcs-lf__status {
	display: flex;
	flex-wrap: wrap;
	align-items: baseline;
	gap: 2px 12px;
	margin: 0;
	padding: 0 2px;
	font-size: 14px;
	line-height: 1.45;
	color: var(--ahcs-lf-muted);
}

.ahcs-lf .ahcs-lf__status[data-tone="success"] .ahcs-lf__status-text {
	font-weight: 600;
	color: var(--ahcs-lf-ink);
}

.ahcs-lf .ahcs-lf__status[data-tone="warning"] .ahcs-lf__status-text {
	color: #9a3412;
}

.ahcs-lf .ahcs-lf__reset,
.ahcs-lf .ahcs-lf__reset:hover,
.ahcs-lf .ahcs-lf__reset:focus {
	margin: 0;
	padding: 0;
	border: 0;
	background: none;
	box-shadow: none;
	color: var(--ahcs-lf-accent);
	font: inherit;
	font-weight: 600;
	text-decoration: underline;
	text-underline-offset: 3px;
	text-transform: none;
	cursor: pointer;
}

/* ---------- Map ---------- */

.ahcs-lf .ahcs-lf__map-wrap {
	position: relative;
	overflow: hidden;
	border: 1px solid var(--ahcs-lf-line);
	border-radius: var(--ahcs-lf-radius);
	background: #e9eef2;
	isolation: isolate;
}

.ahcs-lf .ahcs-lf__map {
	width: 100%;
	height: var(--ahcs-lf-map-h);
}

.ahcs-lf .ahcs-lf__admin-notice {
	margin: 0;
	padding: 12px 16px;
	border-left: 4px solid #d63638;
	border-radius: 4px;
	background: #fcf0f1;
	font-size: 14px;
}

.ahcs-lf .ahcs-lf__empty {
	margin: 0;
	color: var(--ahcs-lf-muted);
}

/* Search floating on the map (desktop). On phones it sits above the map. */
@media (min-width: 641px) {

	.ahcs-lf--search-overlay {
		grid-template-areas: "stack";
	}

	.ahcs-lf--search-overlay > .ahcs-lf__search,
	.ahcs-lf--search-overlay > .ahcs-lf__map-wrap {
		grid-area: stack;
	}

	.ahcs-lf.ahcs-lf--search-overlay > .ahcs-lf__search {
		z-index: 2;
		align-self: start;
		width: calc(100% - 32px);
		max-width: 520px;
		margin: 16px;
		padding: 16px;
		background: var(--ahcs-lf-surface);
		border-radius: calc(var(--ahcs-lf-radius) + 4px);
		box-shadow: 0 10px 30px rgba(23, 33, 43, 0.16), 0 1px 3px rgba(23, 33, 43, 0.08);
	}

	.ahcs-lf--search-overlay.ahcs-lf--width-full > .ahcs-lf__search {
		max-width: none;
	}

	.ahcs-lf--search-overlay .ahcs-lf__bar {
		box-shadow: none;
	}
}

@media (max-width: 640px) {

	.ahcs-lf .ahcs-lf__map {
		height: var(--ahcs-lf-map-h-mobile);
	}

	.ahcs-lf .ahcs-lf__search {
		max-width: none;
	}

	.ahcs-lf .ahcs-lf__button {
		padding: 0 18px;
	}

	.ahcs-lf .ahcs-lf__radius {
		padding: 0 18px 0 8px;
		font-size: 12px;
	}
}

/* ---------- Location details (map popup and fallback list) ---------- */

.ahcs-lf .ahcs-lf-card {
	min-width: 220px;
	max-width: 280px;
	font-family: inherit;
	font-size: 14px;
	line-height: 1.45;
	color: var(--ahcs-lf-ink);
}

.ahcs-lf .ahcs-lf-card__name {
	margin: 0 0 12px;
	padding: 0;
	font-family: inherit;
	font-size: 16px;
	font-weight: 600;
	line-height: 1.3;
	letter-spacing: 0;
	text-transform: none;
	color: var(--ahcs-lf-ink);
}

.ahcs-lf .ahcs-lf-card__row {
	display: grid;
	grid-template-columns: 18px 1fr;
	gap: 10px;
	align-items: start;
	margin: 0 0 8px;
}

.ahcs-lf .ahcs-lf-card__row .ahcs-lf-icon {
	margin-top: 1px;
	color: var(--ahcs-lf-muted);
}

.ahcs-lf .ahcs-lf-card__row a {
	color: inherit;
	text-decoration: none;
}

.ahcs-lf .ahcs-lf-card__row a:hover {
	color: var(--ahcs-lf-accent);
	text-decoration: underline;
	text-underline-offset: 2px;
}

.ahcs-lf .ahcs-lf-card__directions,
.ahcs-lf .ahcs-lf-card__directions:hover,
.ahcs-lf .ahcs-lf-card__directions:focus {
	display: flex;
	align-items: center;
	justify-content: center;
	height: 40px;
	margin-top: 14px;
	padding: 0 16px;
	border-radius: var(--ahcs-lf-inner-radius);
	background: var(--ahcs-lf-accent);
	color: var(--ahcs-lf-on-accent);
	font-size: 14px;
	font-weight: 600;
	text-decoration: none;
}

.ahcs-lf .ahcs-lf-card__directions:hover {
	filter: brightness(0.92);
}

/* Google Maps info window */
.ahcs-lf .gm-style .gm-style-iw-c {
	padding: 16px 16px 4px !important;
	border-radius: var(--ahcs-lf-radius);
	box-shadow: 0 10px 30px rgba(23, 33, 43, 0.18);
}

.ahcs-lf .gm-style .gm-style-iw-ch {
	padding-top: 2px;
}

.ahcs-lf .gm-style .gm-style-iw-ch .ahcs-lf-card__name {
	margin: 0;
}

.ahcs-lf .gm-style .gm-style-iw-d {
	overflow: auto !important;
	padding-bottom: 12px;
}

.ahcs-lf .gm-style .gm-style-iw-d .ahcs-lf-card {
	padding-top: 8px;
}

/* Mapbox popup */
.ahcs-lf .mapboxgl-popup-content {
	padding: 18px 18px 16px;
	border-radius: var(--ahcs-lf-radius);
	box-shadow: 0 10px 30px rgba(23, 33, 43, 0.18);
}

.ahcs-lf .mapboxgl-popup-close-button {
	top: 6px;
	right: 6px;
	width: 28px;
	height: 28px;
	border-radius: 50%;
	font-size: 20px;
	color: var(--ahcs-lf-muted);
}

/* Listing grid - the primary content in "list"/"both" modes, and the
   fallback content in "map" mode if the map can't actually be shown.
   Fixed column counts per breakpoint (1 phone / 2 tablet / 3 desktop),
   not auto-fill/auto-fit - that sized columns purely off available width,
   which could land on any column count depending on the page's layout;
   this is a deliberate, predictable count instead, per explicit request. */
.ahcs-lf .ahcs-lf__list {
	display: grid;
	grid-template-columns: 1fr;
	gap: 16px;
}

@media (min-width: 641px) {

	.ahcs-lf .ahcs-lf__list {
		grid-template-columns: repeat(2, 1fr);
	}
}

@media (min-width: 1025px) {

	.ahcs-lf .ahcs-lf__list {
		grid-template-columns: repeat(3, 1fr);
	}
}

.ahcs-lf .ahcs-lf__list .ahcs-lf-card {
	max-width: none;
	padding: 20px;
	border-radius: var(--ahcs-lf-radius);
	background: var(--ahcs-lf-surface);
	font-family: inherit;
	font-size: var(--ahcs-lf-list-font-size, 16px);
	font-weight: var(--ahcs-lf-list-text-weight, 400);
	transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

/* Title size is its own independent control (Style tab's "Title font
   size"), not derived from the grid's own text size - family is inherited
   from .ahcs-lf-card above; weight is its own control too. */
.ahcs-lf .ahcs-lf__list .ahcs-lf-card__name {
	font-size: var(--ahcs-lf-list-title-font-size, 18px);
	font-weight: var(--ahcs-lf-list-title-weight, 600);
}

/* Card design presets (Style tab's "Card design") - like Typography above,
   these only ever touch the listing grid; a card cloned into a map popup
   keeps its plain, fixed style regardless of theme. "Classic" (the
   default) needs no rules here at all - it's today's existing look,
   unchanged. Title and icon color are overridden explicitly below because
   both already set their own color rather than inheriting it. */
.ahcs-lf--card-gradient .ahcs-lf__list .ahcs-lf-card {
	background: linear-gradient(180deg, #04a49c 0%, #e9f8f9 150%);
	border-color: transparent;
	color: #fff;
}

.ahcs-lf--card-gradient .ahcs-lf__list .ahcs-lf-card__name,
.ahcs-lf--card-gradient .ahcs-lf__list .ahcs-lf-card__row .ahcs-lf-icon {
	color: #fff;
}

.ahcs-lf--card-soft .ahcs-lf__list .ahcs-lf-card {
	border: none;
	border-left: 4px solid var(--ahcs-lf-accent);
	background: color-mix(in srgb, var(--ahcs-lf-accent) 8%, #fff);
}

.ahcs-lf--card-soft .ahcs-lf__list .ahcs-lf-card__name {
	color: var(--ahcs-lf-accent);
}

.ahcs-lf--card-bordered .ahcs-lf__list .ahcs-lf-card {
	border: 2px solid var(--ahcs-lf-accent);
}

.ahcs-lf--card-bordered .ahcs-lf__list .ahcs-lf-card__name,
.ahcs-lf--card-bordered .ahcs-lf__list .ahcs-lf-card__row .ahcs-lf-icon {
	color: var(--ahcs-lf-accent);
}

/* "Get directions" never shows in the grid card - the map popup (opened
   by clicking the card) is where it lives. This used to be scoped to
   .ahcs-lf--map-ready only, which caused a visible flash on load: the
   grid renders immediately from PHP, before the map finishes its async
   setup and JS adds that class, so the button was visible for a moment
   and then disappeared once the class landed. Hiding it unconditionally
   here removes that flash - the grid is never the map, so the link
   never belongs there, regardless of load timing or map state. */
.ahcs-lf__list .ahcs-lf-card__directions {
	display: none;
}

/* Only when a map actually exists to select the card onto - see the
   ahcs-lf--map-ready class added in location-finder.js. Otherwise (list
   mode, or the map failed to load) the card has nowhere new to send a
   click, so it shouldn't look clickable. */
.ahcs-lf--map-ready .ahcs-lf__list .ahcs-lf-card {
	cursor: pointer;
}

/* Subtle elevation on hover/click - no accent ring or outline, just a soft
   shadow lifting the card a little. */
.ahcs-lf--map-ready .ahcs-lf__list .ahcs-lf-card:hover,
.ahcs-lf--map-ready .ahcs-lf__list .ahcs-lf-card:focus-within {
	box-shadow: 0 4px 14px rgba(23, 33, 43, 0.12);
	outline: none;
}

/* Pagination - only shown once there's more than one page (toggled via
   JS's `hidden` attribute, same pattern as the search status/reset
   button above). Only the listing grid paginates; the map always shows
   every matching pin regardless of the current page. */
.ahcs-lf .ahcs-lf__pagination {
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 16px;
	margin-top: 24px;
}

.ahcs-lf .ahcs-lf__page-prev,
.ahcs-lf .ahcs-lf__page-next {
	height: 36px;
	margin: 0;
	padding: 0 18px;
	border: 1px solid var(--ahcs-lf-line);
	border-radius: var(--ahcs-lf-inner-radius);
	background: var(--ahcs-lf-surface);
	color: var(--ahcs-lf-ink);
	font: inherit;
	font-size: 14px;
	font-weight: 600;
	cursor: pointer;
}

.ahcs-lf .ahcs-lf__page-prev:hover:not(:disabled),
.ahcs-lf .ahcs-lf__page-next:hover:not(:disabled) {
	border-color: var(--ahcs-lf-accent);
	color: var(--ahcs-lf-accent);
}

.ahcs-lf .ahcs-lf__page-prev:disabled,
.ahcs-lf .ahcs-lf__page-next:disabled {
	opacity: 0.4;
	cursor: default;
}

.ahcs-lf .ahcs-lf__page-info {
	color: var(--ahcs-lf-muted);
	font-size: 14px;
}

@media (prefers-reduced-motion: reduce) {

	.ahcs-lf .ahcs-lf__bar,
	.ahcs-lf .ahcs-lf__list .ahcs-lf-card {
		transition: none;
	}
}
