/* ============================================================
   SPW Location: front-end styles

   Colours come from the site's Bricks palette variables, with
   fallbacks so the widget still looks right on a site that does
   not define them. Colours set in Settings > SPW Location > Colours
   are printed inline after this file and win over the palette.
   Override any token on .spw-location, e.g.
     .spw-location { --spw-loc-accent: #0b5; }

   Token                    Palette variable     Fallback
   --spw-loc-text           --primary            #1e1e1c
   --spw-loc-muted          --primary-l-4        #70706f
   --spw-loc-border         --primary-l-9        #d6d6d6
   --spw-loc-surface        --primary-l-10       #ebebea
   --spw-loc-bg             --white              #ffffff
   --spw-loc-accent         --tertiary           #344e41
   --spw-loc-on-accent      --white              #ffffff
   --spw-loc-pin-property   --secondary          #c4a87a
   --spw-loc-pin-property-dot  follows --spw-loc-on-accent
   --spw-loc-pin-place         follows --spw-loc-accent
   --spw-loc-pin-place-text    follows --spw-loc-on-accent
   --spw-loc-placeholder    --secondary-l-10     #faf7f3
   --spw-loc-hover          --secondary-l-10     #faf7f3

   Map pins are SVG: override with
     .spw-poi-pin svg path { fill: ... }   .spw-poi-pin svg text { fill: ... }
   ============================================================ */

.spw-location {
	--spw-loc-text: var(--primary, #1e1e1c);
	--spw-loc-muted: var(--primary-l-4, #70706f);
	--spw-loc-border: var(--primary-l-9, #d6d6d6);
	--spw-loc-surface: var(--primary-l-10, #ebebea);
	--spw-loc-bg: var(--white, #ffffff);
	--spw-loc-accent: var(--tertiary, #344e41);
	--spw-loc-on-accent: var(--white, #ffffff);
	--spw-loc-pin-property: var(--secondary, #c4a87a);
	--spw-loc-pin-property-dot: var(--spw-loc-on-accent);
	--spw-loc-pin-place: var(--spw-loc-accent);
	--spw-loc-pin-place-text: var(--spw-loc-on-accent);
	--spw-loc-placeholder: var(--secondary-l-10, #faf7f3);
	--spw-loc-hover: var(--secondary-l-10, #faf7f3); /* Light enough for muted text to keep 4.5:1 contrast. */
	--spw-loc-error: #9c3d2e; /* The only token not tied to the Bricks palette. */
	--spw-loc-radius: 4px;
	--spw-loc-map-height: 380px;
	--spw-loc-map-height-mobile: 260px;

	font-family: inherit;
	font-size: 15px;
	line-height: 1.4;
	color: var(--spw-loc-text);
	background: var(--spw-loc-bg);
	border: 1px solid var(--spw-loc-border);
	border-radius: var(--spw-loc-radius);
	overflow: hidden;
}

.spw-location *,
.spw-location *::before,
.spw-location *::after {
	box-sizing: border-box;
}

/* ── Map ─────────────────────────────────────────────────────── */
.spw-location__map {
	width: 100%;
	height: var(--spw-loc-map-height);
	display: block;
	background: var(--spw-loc-placeholder);
}

/* The map needs JavaScript; hide the empty box when it is not running or fails. */
.spw-location:not(.is-enhanced) .spw-location__map,
.spw-location--no-map .spw-location__map {
	display: none;
}

@media (max-width: 640px) {
	.spw-location__map {
		height: var(--spw-loc-map-height-mobile);
	}
}

/* Google's info window is always white, so its text stays a fixed dark colour
   rather than following --spw-loc-text (which could be light on a dark theme). */
.spw-map-info {
	font-family: inherit;
	font-size: 13px;
	line-height: 1.5;
	color: #1e1e1c;
	max-width: 220px;
}

/* ── Tabs ────────────────────────────────────────────────────── */
.spw-location__tabs-wrap {
	border-top: 1px solid var(--spw-loc-border);
}

.spw-location__tab-nav {
	display: flex;
	overflow-x: auto;
	scrollbar-width: thin; /* Visible so overflowing tabs can be found with a mouse. */
	border-bottom: 1px solid var(--spw-loc-border);
	background: var(--spw-loc-surface);
}

.spw-location__tab-nav::-webkit-scrollbar {
	height: 4px;
}

.spw-location__tab-nav::-webkit-scrollbar-thumb {
	background: var(--spw-loc-border);
	border-radius: 2px;
}

/* Tabs only work with JavaScript; without it every panel is shown in turn. */
.spw-location:not(.is-enhanced) .spw-location__tab-nav {
	display: none;
}

.spw-location__tab-btn {
	display: flex;
	align-items: center;
	gap: 6px;
	padding: 13px 18px;
	margin: 0;
	border: 0;
	border-bottom: 2px solid transparent;
	border-radius: 0;
	background: none;
	font-family: inherit;
	font-size: 13px;
	font-weight: 500;
	line-height: 1;
	letter-spacing: 0.01em;
	color: var(--spw-loc-text);
	cursor: pointer;
	white-space: nowrap;
	transition: color 0.15s ease, border-color 0.15s ease;
}

.spw-location__tab-btn svg {
	flex-shrink: 0;
	opacity: 0.7;
}

.spw-location__tab-btn:hover {
	color: var(--spw-loc-accent);
}

.spw-location__tab-btn:hover svg,
.spw-location__tab-btn.is-active svg {
	opacity: 1;
}

.spw-location__tab-btn.is-active {
	color: var(--spw-loc-accent);
	border-bottom-color: var(--spw-loc-accent);
	font-weight: 600;
}

.spw-location__tab-btn:focus-visible {
	outline: 2px solid var(--spw-loc-accent);
	outline-offset: -3px;
}

/* ── Panels ──────────────────────────────────────────────────── */
.spw-location.is-enhanced .spw-location__tab-panel {
	display: none;
	min-height: 120px;
}

.spw-location.is-enhanced .spw-location__tab-panel.is-active {
	display: block;
}

.spw-location__tab-panel:focus-visible {
	outline: 2px solid var(--spw-loc-accent);
	outline-offset: -2px;
}

.spw-location__panel-title {
	margin: 0;
	padding: 14px 20px 4px;
	font-size: 14px;
	font-weight: 600;
	color: var(--spw-loc-text);
}

/* With tabs available the heading is for screen readers only. */
.spw-location__sr-only,
.spw-location.is-enhanced .spw-location__panel-title {
	position: absolute;
	width: 1px;
	height: 1px;
	padding: 0;
	margin: -1px;
	overflow: hidden;
	clip: rect(0, 0, 0, 0);
	white-space: nowrap;
	border: 0;
}

/* ── Results ─────────────────────────────────────────────────── */
.spw-location__results {
	list-style: none;
	margin: 0;
	padding: 0;
}

.spw-location__result-item {
	display: flex;
	align-items: center;
	gap: 14px;
	margin: 0;
	padding: 14px 20px;
	border-bottom: 1px solid var(--spw-loc-border);
	transition: background 0.12s ease;
}

.spw-location__result-item:last-child {
	border-bottom: 0;
}

.spw-location__result-item:hover {
	background: var(--spw-loc-hover);
}

.spw-location__result-num {
	display: flex;
	align-items: center;
	justify-content: center;
	flex-shrink: 0;
	width: 26px;
	height: 26px;
	border-radius: 50%;
	background: var(--spw-loc-accent);
	color: var(--spw-loc-on-accent);
	font-size: 11px;
	font-weight: 700;
	line-height: 1;
}

.spw-location__result-info {
	flex: 1;
	min-width: 0;
	display: flex;
	flex-direction: column;
	gap: 2px;
}

.spw-location__result-name {
	display: block;
	font-size: 14px;
	font-weight: 600;
	color: var(--spw-loc-text);
	overflow-wrap: anywhere; /* Full names wrap rather than being cut off. */
}

.spw-location__result-meta,
.spw-location__result-address {
	display: block;
	font-size: 12px;
	color: var(--spw-loc-muted);
	overflow-wrap: anywhere;
}

.spw-location__result-meta {
	color: var(--spw-loc-text);
}

.spw-location__result-links {
	display: block;
	font-size: 12px;
	color: var(--spw-loc-muted);
}

.spw-location__result-links a {
	color: var(--spw-loc-accent);
	text-decoration: underline;
	text-underline-offset: 2px;
}

.spw-location__result-dist {
	flex-shrink: 0;
	display: flex;
	flex-direction: column;
	align-items: flex-end;
	gap: 2px;
	text-align: right;
}

.spw-location__dist-badge {
	font-size: 13px;
	font-weight: 700;
	letter-spacing: 0.01em;
	color: var(--spw-loc-accent);
}

.spw-location__walk-time {
	font-size: 11px;
	color: var(--spw-loc-muted);
	white-space: nowrap;
}

/* ── Messages ────────────────────────────────────────────────── */
.spw-location__empty,
.spw-location__pending {
	margin: 0;
	padding: 28px 20px;
	font-size: 13px;
	color: var(--spw-loc-muted);
}

.spw-location__pending {
	border-top: 1px solid var(--spw-loc-border);
}

.spw-location__credit {
	margin: 0;
	padding: 10px 20px;
	border-top: 1px solid var(--spw-loc-border);
	font-size: 11px;
	line-height: 1.5;
	color: var(--spw-loc-muted);
}

.spw-location__credit a {
	color: inherit;
	text-decoration: underline;
}

/* ── Small screens ───────────────────────────────────────────── */
@media (max-width: 480px) {
	.spw-location__tab-btn {
		padding: 11px 14px;
		font-size: 12px;
	}

	.spw-location__result-item {
		padding: 12px 14px;
		gap: 10px;
	}

	.spw-location__result-name {
		font-size: 13px;
	}

	.spw-location__walk-time {
		display: none;
	}
}

@media (prefers-reduced-motion: reduce) {
	.spw-location__tab-btn,
	.spw-location__result-item {
		transition: none;
	}
}
