/**
 * Total Tools Locator — frontend styles.
 * All colors/sizes come from CSS custom properties written inline by
 * TTL_Shortcode::build_dynamic_css() from the admin Settings screen, with
 * sensible fallbacks here matching the original reference design.
 */
.ttl-locator {
	--ttl-font-heading: "Barlow Condensed", Barlow, sans-serif;
	--ttl-font-body: Barlow, system-ui, sans-serif;
	--ttl-font-size-base: 16px;
	--ttl-font-size-heading: 42px;
	--ttl-font-size-button: 15px;
	--ttl-font-size-loc-title: 16px;
	--ttl-font-size-loc-meta: 13px;
	--ttl-line-height: 1.6;
	--ttl-font-weight-heading: 600;
	--ttl-color-bg: #fff;
	--ttl-color-header-bg: #00464b;
	--ttl-color-header-text: #fff;
	--ttl-color-text: #12232b;
	--ttl-color-text-secondary: #5c6b73;
	--ttl-color-border: #d8e0e2;
	--ttl-color-accent: #e02020;
	--ttl-color-filter-bg: #fff;
	--ttl-color-filter-text: #12232b;
	--ttl-color-filter-active-bg: #00464b;
	--ttl-color-filter-active-text: #fff;
	--ttl-color-search-bg: #fff;
	--ttl-color-search-text: #12232b;
	--ttl-color-search-border: #d8e0e2;
	--ttl-color-town-heading: #12232b;
	--ttl-color-loc-item: #12232b;
	--ttl-color-loc-selected-bg: #f2f8f8;
	--ttl-color-loc-hover-bg: #f7f9f9;
	--ttl-color-footer-bg: #00464b;
	--ttl-color-footer-text: #b9d9db;
	--ttl-filter-padding: 8px 13px;
	--ttl-filter-border-width: 1px;
	--ttl-filter-border-radius: 2px;
	--ttl-filter-font-weight: 500;
	--ttl-filter-gap: 10px;
	--ttl-max-width: 1240px;
	--ttl-layout-gap: 48px;
	--ttl-map-width: 55%;
	--ttl-list-width: 45%;
	--ttl-border-radius: 4px;
	--ttl-section-padding: 24px;
	--ttl-map-height: 640px;

	box-sizing: border-box;
	max-width: var(--ttl-max-width);
	margin: 0 auto;
	background: var(--ttl-color-bg);
	color: var(--ttl-color-text);
	font: 400 var(--ttl-font-size-base)/var(--ttl-line-height) var(--ttl-font-body);
	-webkit-font-smoothing: antialiased;
}

.ttl-locator *,
.ttl-locator *::before,
.ttl-locator *::after {
	box-sizing: border-box;
}

.ttl-locator h1,
.ttl-locator h2,
.ttl-locator h3 {
	font-family: var(--ttl-font-heading);
	font-weight: var(--ttl-font-weight-heading);
	letter-spacing: 0.01em;
	margin: 0;
}

/* Filter bar */
.ttl-bar {
	display: flex;
	flex-wrap: wrap;
	gap: 12px;
	align-items: center;
	border-bottom: 1px solid var(--ttl-color-border);
	background: var(--ttl-color-bg);
	padding: 14px var(--ttl-section-padding);
	position: sticky;
	top: 0;
	z-index: 20;
}

.ttl-chips {
	display: flex;
	flex-wrap: wrap;
	gap: var(--ttl-filter-gap);
	flex: 1 1 auto;
	min-width: 0;
	max-width: 100%;
}

.ttl-chip {
	display: inline-flex;
	align-items: center;
	gap: 8px;
	border: var(--ttl-filter-border-width) solid var(--ttl-color-border);
	background: var(--ttl-color-filter-bg);
	color: var(--ttl-color-filter-text);
	font: var(--ttl-filter-font-weight) var(--ttl-font-size-button) var(--ttl-font-body);
	padding: var(--ttl-filter-padding);
	border-radius: var(--ttl-filter-border-radius);
	cursor: pointer;
	transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.ttl-chip .ttl-chip-dot {
	width: 9px;
	height: 9px;
	border-radius: 50%;
	display: block;
	flex: none;
}

.ttl-chip .ttl-chip-count {
	color: var(--ttl-color-text-secondary);
	font-size: 13px;
	font-variant-numeric: tabular-nums;
}

.ttl-chip:hover {
	border-color: var(--ttl-color-header-bg);
}

.ttl-chip.is-on {
	background: var(--ttl-color-filter-active-bg);
	border-color: var(--ttl-color-filter-active-bg);
	color: var(--ttl-color-filter-active-text);
}

.ttl-chip.is-on .ttl-chip-count {
	color: var(--ttl-color-filter-active-text);
	opacity: 0.8;
}

.ttl-chip:focus-visible,
.ttl-search:focus-visible,
.ttl-loc-item:focus-visible,
.ttl-town-heading:focus-visible {
	outline: 3px solid var(--ttl-color-accent);
	outline-offset: 2px;
}

.ttl-search {
	flex: 0 0 250px;
	border: 1px solid var(--ttl-color-search-border);
	border-radius: var(--ttl-filter-border-radius);
	padding: 9px 12px;
	font: 400 16px var(--ttl-font-body);
	background: var(--ttl-color-search-bg);
	color: var(--ttl-color-search-text);
}

.ttl-search-label {
	flex: 0 0 auto;
	display: none; /* Search bar hidden per client request */
}

/* Main layout */
.ttl-main {
	display: grid;
	grid-template-columns: minmax(0, calc(var(--ttl-map-width) - var(--ttl-layout-gap) / 2)) minmax(0, calc(var(--ttl-list-width) - var(--ttl-layout-gap) / 2));
	gap: var(--ttl-layout-gap);
	padding: var(--ttl-section-padding) var(--ttl-section-padding) 0;
}

.ttl-mapcol {
	position: static; /* Map no longer sticks while scrolling, per client request */
	align-self: start;
}

.ttl-map-wrap {
	position: relative;
	width: 100%;
	height: var(--ttl-map-height);
	border-radius: var(--ttl-border-radius);
	overflow: hidden;
	background: #eef3f3;
}

.ttl-map-iframe {
	width: 100%;
	height: 100%;
	display: block;
	border: 0;
}

.ttl-map-iframe[hidden] {
	display: none;
}

.ttl-map-message {
	position: absolute;
	inset: 0;
	margin: 0;
	display: flex;
	align-items: center;
	justify-content: center;
	text-align: center;
	padding: 24px;
	color: var(--ttl-color-text-secondary);
	background: #eef3f3;
}

/* An author-stylesheet `display` on the same selector overrides the
   browser's default `[hidden]{display:none}` UA rule, so this element
   stayed visually on top of the map (covering it with its own opaque
   background) even while JS correctly set the hidden attribute. This
   higher-specificity rule restores the expected hidden behaviour. */
.ttl-map-message[hidden] {
	display: none;
}

/* Count / reset */
.ttl-count {
	display: flex;
	align-items: baseline;
	justify-content: space-between;
	gap: 12px;
	border-bottom: 2px solid var(--ttl-color-text);
	padding-bottom: 8px;
}

.ttl-tally {
	font: var(--ttl-font-weight-heading) 14px var(--ttl-font-heading);
	text-transform: uppercase;
	letter-spacing: 0.06em;
}

.ttl-reset {
	border: 0;
	background: none;
	color: var(--ttl-color-header-bg);
	font: 500 15px var(--ttl-font-body);
	cursor: pointer;
	padding: 0;
	text-decoration: underline;
}

.ttl-reset:hover {
	opacity: 0.75;
}

/* Town + location list */
.ttl-town {
	border-bottom: 1px solid var(--ttl-color-border);
	padding: 18px 0;
	scroll-margin-top: 90px;
}

.ttl-town.is-selected {
	background: var(--ttl-color-loc-selected-bg);
	box-shadow: -14px 0 0 var(--ttl-color-loc-selected-bg), 14px 0 0 var(--ttl-color-loc-selected-bg);
}

.ttl-town-heading {
	margin: 0;
	font-size: 19px;
	color: var(--ttl-color-town-heading);
	text-transform: uppercase;
	display: flex;
	justify-content: space-between;
	align-items: baseline;
	gap: 10px;
	cursor: pointer;
	background: none;
	border: 0;
	width: 100%;
	text-align: left;
	font-family: var(--ttl-font-heading);
	font-weight: var(--ttl-font-weight-heading);
	padding: 0;
}

.ttl-town-heading .ttl-town-region {
	color: var(--ttl-color-text-secondary);
	font-weight: 500;
	font-size: 15px;
	font-family: var(--ttl-font-body);
	text-transform: none;
}

.ttl-town-list {
	list-style: none;
	margin: 10px 0 0;
	padding: 0;
}

.ttl-loc-item {
	display: flex;
	gap: 10px;
	align-items: baseline;
	padding: 7px 6px;
	margin: 0 -6px;
	border-radius: var(--ttl-border-radius);
	cursor: pointer;
	color: var(--ttl-color-loc-item);
	background: none;
	border: 0;
	width: calc(100% + 12px);
	min-width: 0;
	text-align: left;
	font: inherit;
}

.ttl-loc-item:hover,
.ttl-loc-item.is-selected {
	background: var(--ttl-color-loc-hover-bg);
	color: var(--ttl-color-loc-hover-text, #fff);
}

.ttl-loc-item .ttl-loc-dot {
	width: 8px;
	height: 8px;
	border-radius: 50%;
	flex: none;
	margin-top: 8px;
}

.ttl-loc-item .ttl-loc-name {
	font-size: var(--ttl-font-size-loc-title);
}

.ttl-loc-item .ttl-loc-cat {
	color: var(--ttl-color-text-secondary);
	font-size: var(--ttl-font-size-loc-meta);
	margin-left: auto;
	white-space: nowrap;
}

.ttl-loc-item:hover .ttl-loc-cat,
.ttl-loc-item.is-selected .ttl-loc-cat {
	color: var(--ttl-color-loc-hover-text, #fff);
	opacity: 0.85;
}

.ttl-loc-detail {
	list-style: none;
	margin: 2px 0 8px;
	padding: 10px 14px;
	border-left: 3px solid var(--ttl-color-header-bg);
	background: var(--ttl-color-loc-selected-bg);
	border-radius: 0 var(--ttl-border-radius) var(--ttl-border-radius) 0;
}

.ttl-loc-detail p {
	margin: 0 0 6px;
	font-size: var(--ttl-font-size-loc-meta);
	color: var(--ttl-color-text);
	line-height: 1.5;
}

.ttl-loc-detail p:last-of-type {
	margin-bottom: 0;
}

.ttl-loc-detail a {
	color: var(--ttl-color-header-bg);
}

.ttl-loc-detail .ttl-detail-directions {
	display: inline-block;
	margin-top: 8px;
	font-weight: 600;
	text-decoration: none;
}

.ttl-loc-detail .ttl-detail-directions:hover {
	text-decoration: underline;
}

.ttl-none {
	padding: 28px 0;
	color: var(--ttl-color-text-secondary);
}

.ttl-locator .screen-reader-text {
	position: absolute;
	width: 1px;
	height: 1px;
	overflow: hidden;
	clip: rect(1px, 1px, 1px, 1px);
	white-space: nowrap;
}

@media (prefers-reduced-motion: reduce) {
	.ttl-locator * {
		transition: none !important;
	}
}

@media (max-width: 900px) {
	.ttl-bar {
		flex-direction: column;
		flex-wrap: nowrap;
		align-items: stretch;
	}

	/* Responsive filter buttons: wrap onto multiple rows inside the container
	   instead of a horizontal slider, never overflow or overlap. */
	.ttl-chips {
		flex-wrap: wrap;
		overflow: visible;
		min-width: 0;
		max-width: 100%;
		width: 100%;
	}

	.ttl-chip {
		flex: 0 1 auto;
		max-width: 100%;
		min-width: 0;
		white-space: normal;
		text-align: left;
		line-height: 1.3;
		height: auto;
		margin: 0;
		overflow-wrap: anywhere;
	}

	.ttl-search-label {
		order: -1;
		flex: 1 1 auto;
	}

	.ttl-search {
		flex: 1 1 auto;
		width: 100%;
	}

	.ttl-main {
		grid-template-columns: 1fr;
		gap: 24px;
	}

	.ttl-mapcol {
		position: static;
	}

	.ttl-map-wrap {
		height: var(--ttl-map-height);
	}
}

/* Small phones: compact filter buttons so they sit side by side (inline)
   and wrap onto the next line only when a row is full. */
@media (max-width: 600px) {
	.ttl-locator .ttl-bar {
		padding-left: 8px;
		padding-right: 8px;
	}

	.ttl-locator .ttl-chips {
		display: flex;
		flex-direction: row;
		flex-wrap: wrap;
		gap: 5px;
	}

	.ttl-locator .ttl-chip {
		display: inline-flex;
		width: auto;
		flex: 0 0 auto;
		gap: 4px;
		padding: 5px 8px;
		font-size: 12px;
		line-height: 1.25;
	}

	.ttl-locator .ttl-chip .ttl-chip-dot {
		width: 7px;
		height: 7px;
	}

	.ttl-locator .ttl-chip .ttl-chip-count {
		font-size: 11px;
	}
}
