/**
 * Church Directory block styles.
 * Frontend + editor placeholder. All colors via theme.json presets.
 */

/* ─── Wrapper ─────────────────────────────────────────────────────── */
.chl-church-directory {
	font-family: var( --wp--preset--font-family--primary, 'Poppins', sans-serif );
}

.chl-church-directory__heading {
	font-size: var( --wp--preset--font-size--x-large, 2rem );
	font-weight: 700;
	margin: 0 0 0.5rem;
	color: var( --wp--preset--color--contrast );
}

.chl-church-directory__intro {
	font-size: 1rem;
	color: var( --wp--preset--color--muted );
	margin: 0 0 1.5rem;
	max-width: 720px;
}

/* ─── Map shell ──────────────────────────────────────────────────── */
.chl-map-container {
	display: flex;
	border: 1px solid var( --wp--preset--color--outline );
	border-radius: 12px;
	overflow: hidden;
	box-shadow: 0 2px 12px rgba( 0, 0, 0, 0.06 );
}

.chl-sidebar {
	width: 360px;
	min-width: 360px;
	background: var( --wp--preset--color--base, #fff );
	display: flex;
	flex-direction: column;
	border-right: 1px solid var( --wp--preset--color--outline );
	z-index: 10;
}

.chl-sidebar-header {
	padding: 1rem;
	background: var( --wp--preset--color--primary, #7969BC );
}

/* Small uppercase heading above the location picker (matches .chl-clergy-label). */
.chl-city-select-label {
	display: block;
	font-size: 0.625rem;
	font-weight: 600;
	letter-spacing: 0.07em;
	text-transform: uppercase;
	color: rgba( 255, 255, 255, 0.7 );
	margin-bottom: 4px;
}

.chl-city-select-wrap {
	display: flex;
	align-items: center;
	gap: 4px;
	margin-bottom: 0.5rem;
}

.chl-city-select {
	font-family: inherit;
	font-size: 1.25rem;
	font-weight: 600;
	color: #fff;
	background: transparent;
	border: none;
	cursor: pointer;
	appearance: none;
	-webkit-appearance: none;
	padding: 0;
	padding-right: 28px;
	background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='%23ffffff'%3E%3Cpath d='M7 10l5 5 5-5z'/%3E%3C/svg%3E");
	background-repeat: no-repeat;
	background-position: right center;
	background-size: 24px;
	width: 100%;
}

.chl-city-select option {
	color: var( --wp--preset--color--contrast );
	background: var( --wp--preset--color--base );
}

.chl-city-select:focus {
	outline: 2px solid rgba( 255, 255, 255, 0.4 );
	outline-offset: 2px;
}

.chl-clergy-leader {
	display: flex;
	flex-direction: column;
	align-items: flex-start;
	gap: 5px;
	margin: 0;
	line-height: 1.3;
}

.chl-clergy-label {
	font-size: 0.625rem;
	font-weight: 600;
	letter-spacing: 0.07em;
	text-transform: uppercase;
	color: rgba( 255, 255, 255, 0.7 );
}

/* Clergy leader name as a distinct pill so it reads apart from the region. */
.chl-clergy-name {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	padding: 3px 11px 3px 9px;
	border-radius: 100px;
	background: rgba( 255, 255, 255, 0.15 );
	border: 1px solid rgba( 255, 255, 255, 0.28 );
	font-size: 0.8125rem;
	font-weight: 600;
	color: #fff;
}

.chl-clergy-name:empty {
	display: none;
}

.chl-clergy-name::before {
	content: "";
	width: 12px;
	height: 12px;
	flex-shrink: 0;
	background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%23ffffff'%3E%3Cpath d='M12 12a5 5 0 1 0 0-10 5 5 0 0 0 0 10Zm0 2c-4.4 0-8 2.2-8 5v2.5h16V19c0-2.8-3.6-5-8-5Z'/%3E%3C/svg%3E") no-repeat center / contain;
	opacity: 0.85;
}

/* ─── Search row ─────────────────────────────────────────────────── */
.chl-sidebar-search {
	display: flex;
	align-items: center;
	gap: 8px;
	padding: 0.5rem 1rem;
	border-bottom: 1px solid var( --wp--preset--color--outline );
}

.chl-sidebar-search svg {
	width: 20px;
	height: 20px;
	flex-shrink: 0;
	fill: var( --wp--preset--color--muted, #6B6B73 );
}

.chl-sidebar-search input {
	border: none;
	background: transparent;
	font-family: inherit;
	font-size: 0.875rem;
	font-weight: 500;
	color: var( --wp--preset--color--contrast );
	width: 100%;
	outline: none;
}

.chl-sidebar-search input::placeholder {
	color: var( --wp--preset--color--muted );
}

/* ─── Filter pills ───────────────────────────────────────────────── */
.chl-sidebar-filters {
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 0.5rem 1rem;
	border-bottom: 1px solid var( --wp--preset--color--outline );
}

.chl-filter-pills {
	display: flex;
	gap: 0.5rem;
}

.chl-filter-pill {
	font-family: inherit;
	font-size: 0.6875rem;
	font-weight: 500;
	padding: 0.15rem 0.5rem;
	border-radius: 100px;
	cursor: pointer;
	border: 1px solid rgba( 119, 119, 119, 0.4 );
	background: var( --wp--preset--color--base, #fff );
	color: var( --wp--preset--color--muted, #6B6B73 );
	transition: all 0.15s ease;
	line-height: 1.3;
}

.chl-filter-pill.is-active {
	background: var( --wp--preset--color--primary, #7969BC );
	color: var( --wp--preset--color--base, #fff );
	border-color: var( --wp--preset--color--primary, #7969BC );
}

.chl-church-count {
	font-size: 0.6875rem;
	font-weight: 500;
	color: var( --wp--preset--color--muted, #6B6B73 );
}

/* ─── Church list ────────────────────────────────────────────────── */
.chl-sidebar-churches {
	flex: 1;
	overflow-y: auto;
	overscroll-behavior: contain;
}

.chl-sidebar-churches::-webkit-scrollbar {
	width: 6px;
}

.chl-sidebar-churches::-webkit-scrollbar-track {
	background: transparent;
}

.chl-sidebar-churches::-webkit-scrollbar-thumb {
	background: rgba( 121, 105, 188, 0.35 );
	border-radius: 32px;
}

.chl-church-item {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 0.75rem;
	padding: 0.5rem 1rem;
	border-bottom: 1px solid var( --wp--preset--color--outline );
	cursor: pointer;
	transition: background 0.15s ease;
	width: 100%;
	/* Anchors don't inherit the button's border-box default — without this the
	   horizontal padding overflows width:100% and shoves the badge off-screen. */
	box-sizing: border-box;
	background: transparent;
	border-left: none;
	border-right: none;
	border-top: none;
	text-align: left;
	font: inherit;
	color: inherit;
}

.chl-church-item:hover {
	background: var( --wp--preset--color--surface );
}

.chl-church-item.is-selected {
	background: rgba( 121, 105, 188, 0.1 );
	border-left: 3px solid var( --wp--preset--color--primary );
	padding-left: calc( 1rem - 3px );
}

/* Link rows (no map pin) must shed the theme's default anchor styling so they
   read identically to the button rows. text-decoration propagates from the
   <a> to its descendants and can't be undone by the children, so it has to be
   beaten on the anchor itself — hence the scoped specificity + !important. */
.chl-church-directory a.chl-church-item--link,
.chl-church-directory a.chl-church-item--link:hover,
.chl-church-directory a.chl-church-item--link:focus,
.chl-church-directory a.chl-church-item--link:visited {
	text-decoration: none !important;
	color: inherit;
}

a.chl-church-item--link .chl-church-name {
	color: var( --wp--preset--color--contrast );
}

a.chl-church-item--link .chl-church-address {
	color: var( --wp--preset--color--muted );
}

.chl-church-address--profile {
	color: var( --wp--preset--color--primary );
	font-weight: 600;
}

.chl-church-info {
	flex: 1;
	min-width: 0;
}

.chl-church-name {
	font-size: 0.875rem;
	font-weight: 500;
	color: var( --wp--preset--color--contrast );
	line-height: 1.4;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

.chl-church-address {
	font-size: 0.75rem;
	font-weight: 500;
	color: var( --wp--preset--color--muted );
	line-height: 1.3;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

.chl-status-badge {
	font-family: inherit;
	font-size: 0.6875rem;
	font-weight: 500;
	padding: 0.15rem 0.5rem;
	border-radius: 100px;
	white-space: nowrap;
	flex-shrink: 0;
	line-height: 1.3;
}

.chl-status-badge.active-status {
	color: #fff;
	border: 1px solid var( --wp--preset--color--primary, #3E3979 );
	background: var( --wp--preset--color--primary, #3E3979 );
}

.chl-status-badge.affiliate-status {
	/* Gold pill; dark text keeps it legible against the light gold. */
	color: var( --wp--preset--color--contrast, #1A1A1D );
	border: 1px solid #F19A1E;
	background: #F19A1E;
}

.chl-no-results {
	padding: 2rem 1rem;
	text-align: center;
	color: var( --wp--preset--color--muted );
	font-size: 0.875rem;
}

/* ─── Map area ───────────────────────────────────────────────────── */
.chl-map-area {
	flex: 1;
	position: relative;
	min-width: 0;
}

.chl-map {
	width: 100%;
	height: 100%;
	background: var( --wp--preset--color--surface );
}

.chl-map__loading {
	display: flex;
	align-items: center;
	justify-content: center;
	height: 100%;
	color: var( --wp--preset--color--muted );
	font-size: 0.875rem;
}

.chl-church-marker {
	background: transparent !important;
	border: none !important;
}

.chl-church-marker svg {
	filter: drop-shadow( 0 2px 3px rgba( 0, 0, 0, 0.3 ) );
}

/* ─── Leaflet popup overrides ────────────────────────────────────── */
.chl-church-directory .leaflet-popup {
	overflow: visible !important;
}

.chl-church-directory .leaflet-popup-content-wrapper {
	border-radius: 8px !important;
	padding: 0 !important;
	overflow: visible !important;
	box-shadow: 4px 4px 12px rgba( 0, 0, 0, 0.25 ) !important;
}

.chl-church-directory .leaflet-popup-content {
	margin: 0 !important;
	width: 275px !important;
	overflow: visible !important;
}

.chl-church-directory .leaflet-popup-tip-container {
	display: none;
}

.chl-church-directory .leaflet-popup-close-button {
	display: none !important;
}

.chl-popup-card {
	font-family: var( --wp--preset--font-family--primary, 'Poppins', sans-serif );
	position: relative;
	display: flex;
	flex-direction: column;
	gap: 12px;
	padding: 16px;
	background: var( --wp--preset--color--base, #fff );
	border-radius: 8px;
}

.chl-popup-photo {
	width: 100%;
	aspect-ratio: 229 / 140;
	border-radius: 4px;
	background: linear-gradient( 135deg, rgba( 121, 105, 188, 0.3 ) 0%, rgba( 121, 105, 188, 0.6 ) 100% );
	display: flex;
	align-items: center;
	justify-content: center;
	overflow: hidden;
}

.chl-popup-photo img {
	width: 100%;
	height: 100%;
	object-fit: cover;
	display: block;
}

.chl-popup-photo svg {
	width: 40px;
	height: 40px;
	fill: rgba( 255, 255, 255, 0.6 );
}

.chl-popup-close {
	position: absolute;
	top: -10px;
	right: -10px;
	width: 24px;
	height: 24px;
	background: var( --wp--preset--color--base, #fff );
	border: none;
	border-radius: 4px;
	color: var( --wp--preset--color--primary, #7969BC );
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	z-index: 10;
	padding: 0;
	box-shadow: 0 2px 6px rgba( 0, 0, 0, 0.15 );
}

.chl-popup-close svg {
	width: 10px;
	height: 10px;
}

.chl-popup-close:hover {
	background: var( --wp--preset--color--surface );
}

.chl-popup-info {
	display: flex;
	flex-direction: column;
	gap: 2px;
}

.chl-popup-name {
	font-size: 1rem;
	font-weight: 600;
	color: var( --wp--preset--color--contrast );
	line-height: 1.25;
	letter-spacing: -0.15px;
}

.chl-popup-address {
	font-size: 0.75rem;
	font-weight: 500;
	color: var( --wp--preset--color--muted );
	line-height: 1.3;
}

.chl-popup-actions {
	display: flex;
	gap: 8px;
	width: 100%;
}

.chl-popup-action {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 4px;
	white-space: nowrap;
	font-family: inherit;
	font-size: 0.8125rem;
	font-weight: 500;
	letter-spacing: -0.15px;
	box-sizing: border-box;
	padding: 5px 9px;
	border: 1px solid rgba( 121, 105, 188, 0.4 );
	border-radius: 4px;
	background: var( --wp--preset--color--base, #fff );
	color: var( --wp--preset--color--primary, #7969BC );
	text-decoration: none;
	cursor: pointer;
	transition: background 0.15s;
	line-height: 1.4;
}

.chl-church-directory .chl-popup-action,
.chl-church-directory .chl-popup-action:hover {
	color: var( --wp--preset--color--primary, #7969BC );
	text-decoration: none !important;
}

.chl-popup-action:hover {
	background: var( --wp--preset--color--surface );
}

.chl-popup-action-phone {
	flex: 1;
	min-width: 0;
}

.chl-popup-detail {
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 6px;
	width: 100%;
	box-sizing: border-box;
	padding: 8px;
	font-family: inherit;
	font-size: 0.9375rem;
	font-weight: 600;
	letter-spacing: -0.15px;
	line-height: 1.4;
	background: var( --wp--preset--color--primary, #7969BC );
	color: #fff;
	border: none;
	border-radius: 4px;
	cursor: pointer;
	text-decoration: none;
	transition: opacity 0.15s;
}

.chl-church-directory .chl-popup-detail,
.chl-church-directory .chl-popup-detail:hover {
	color: #fff;
	text-decoration: none !important;
}

.chl-popup-detail:hover {
	opacity: 0.9;
}

/* ─── Mobile: stack list under map ───────────────────────────────── */
@media ( max-width: 800px ) {
	.chl-map-container {
		flex-direction: column-reverse;
		height: auto !important;
	}

	.chl-sidebar {
		width: 100%;
		min-width: 0;
		max-height: 360px;
		border-right: none;
		border-top: 1px solid var( --wp--preset--color--outline );
	}

	.chl-map-area {
		min-height: 360px;
		flex: 0 0 360px;
	}
}

/* ─── Editor placeholder ─────────────────────────────────────────── */
.chl-church-directory--editor {
	border: 2px dashed var( --wp--preset--color--outline, #E0DDE8 );
	background: var( --wp--preset--color--surface, #F8F7FC );
	padding: 1rem;
	border-radius: 12px;
}

.chl-church-directory--editor .chl-church-directory__heading {
	margin-top: 0;
}

.chl-church-directory--editor .chl-church-directory__preview {
	display: flex;
	gap: 0;
	border: 1px solid var( --wp--preset--color--outline );
	border-radius: 8px;
	overflow: hidden;
	background: #fff;
	pointer-events: none;
}

.chl-church-directory--editor .chl-church-directory__sidebar {
	width: 280px;
	min-width: 280px;
	background: #fff;
	border-right: 1px solid var( --wp--preset--color--outline );
	display: flex;
	flex-direction: column;
}

.chl-church-directory--editor .chl-church-directory__sidebar-head {
	background: var( --wp--preset--color--primary, #7969BC );
	color: #fff;
	padding: 1rem;
}

.chl-church-directory--editor .chl-church-directory__sidebar-title {
	font-size: 1rem;
	font-weight: 600;
}

.chl-church-directory--editor .chl-church-directory__sidebar-sub {
	font-size: 0.6875rem;
	opacity: 0.8;
	margin-top: 4px;
}

.chl-church-directory--editor .chl-church-directory__sidebar-list {
	list-style: none;
	margin: 0;
	padding: 0;
	flex: 1;
}

.chl-church-directory--editor .chl-church-directory__sidebar-item {
	padding: 0.625rem 1rem;
	border-bottom: 1px solid var( --wp--preset--color--outline );
	display: flex;
	flex-direction: column;
	gap: 4px;
}

.chl-church-directory--editor .chl-church-directory__sidebar-line {
	display: block;
	height: 8px;
	background: var( --wp--preset--color--outline, #E0DDE8 );
	border-radius: 4px;
}

.chl-church-directory--editor .chl-church-directory__sidebar-line--name {
	width: 70%;
}

.chl-church-directory--editor .chl-church-directory__sidebar-line--addr {
	width: 50%;
	background: var( --wp--preset--color--neutral, #F0EFF4 );
}

.chl-church-directory--editor .chl-church-directory__map {
	flex: 1;
	position: relative;
	min-width: 0;
	background: var( --wp--preset--color--surface, #F8F7FC );
}

.chl-church-directory--editor .chl-church-directory__map-bg {
	width: 100%;
	height: 100%;
	display: block;
}

.chl-church-directory--editor .chl-church-directory__map-label {
	position: absolute;
	bottom: 16px;
	left: 50%;
	transform: translateX( -50% );
	background: rgba( 255, 255, 255, 0.96 );
	border: 1px solid var( --wp--preset--color--outline );
	border-radius: 8px;
	padding: 0.5rem 1rem;
	display: flex;
	align-items: center;
	gap: 8px;
	font-size: 0.875rem;
	color: var( --wp--preset--color--contrast );
	box-shadow: 0 2px 8px rgba( 0, 0, 0, 0.08 );
	white-space: nowrap;
}

.chl-church-directory--editor .chl-church-directory__map-label svg {
	width: 18px;
	height: 18px;
	color: var( --wp--preset--color--primary );
}

.chl-church-directory--editor .chl-church-directory__map-label strong {
	font-weight: 600;
}

.chl-church-directory--editor .chl-church-directory__map-label span {
	color: var( --wp--preset--color--muted );
	font-size: 0.8125rem;
}
