.cfm-widget {
	--cfm-accent: #1c244b;
	--cfm-heading: #1c244b;
	--cfm-card-bg: #ffffff;
	--cfm-panel-bg: #f7fafc;
	--cfm-checkbox-border: #1c244b;
	--cfm-title-btn-hover-bg: transparent;
	--cfm-title-btn-focus-outline: var(--cfm-accent);
	--cfm-cols-desktop: 3;
	--cfm-cols-tablet: 2;
	--cfm-cols-mobile: 1;
}

.cfm-heading {
	color: var(--cfm-heading);
	font-family: Georgia, 'Times New Roman', serif;
	margin: 0 0 8px;
}

.cfm-intro {
	color: var(--cfm-heading);
	margin: 0 0 32px;
}

.cfm-layout {
	display: grid;
	grid-template-columns: 280px 1fr;
	gap: 32px;
	align-items: start;
}

.cfm-layout--right {
	grid-template-columns: 1fr 280px;
}

.cfm-layout--right .cfm-filters {
	order: 2;
}

.cfm-layout--right .cfm-results {
	order: 1;
}

/* Filter panel */
.cfm-filters {
	background: transparent;
	border: 0;
}

.cfm-filters__mobile-toggle {
	display: none;
	width: 100%;
	background: var(--cfm-accent);
	color: #fff;
	border: 0;
	padding: 12px;
	font-size: 1rem;
	cursor: pointer;
}

.cfm-search {
	margin-bottom: 20px;
}

.cfm-filters__mobile-toggle {
	margin-bottom: 20px;
}

.cfm-filters__mobile-toggle:last-child {
	margin-bottom: 0;
}

.cfm-search__input {
	width: 100%;
	box-sizing: border-box;
	padding: 10px 14px;
	border: 1px solid #ccc;
	background: #fff;
}

/* Active filter chips */
.cfm-active-filters {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 8px;
	margin-bottom: 20px;
}

.cfm-active-filters[hidden] {
	display: none;
}

.cfm-active-filters__label {
	color: var(--cfm-heading);
	font-weight: 600;
}

.cfm-active-filters__list {
	display: contents;
}

.cfm-active-filter {
	display: inline-flex;
	align-items: center;
	gap: 8px;
	background: var(--cfm-chip-bg, rgba(28, 36, 75, 0.12));
	color: var(--cfm-accent);
	padding: 6px 12px;
	max-width: 100%;
}

.cfm-active-filter__text {
	overflow-wrap: anywhere;
}

.cfm-active-filter__remove {
	background: none;
	border: 0;
	padding: 0;
	color: inherit;
	font-size: 1.1em;
	line-height: 1;
	cursor: pointer;
	flex: 0 0 auto;
}

.cfm-active-filter__remove:hover,
.cfm-active-filter__remove:focus {
	opacity: 0.7;
	background: none;
	color: inherit;
}

.cfm-filter-group + .cfm-filter-group {
	margin-top: 20px;
}

.cfm-filter-group__toggle {
	width: 100%;
	display: flex;
	justify-content: space-between;
	align-items: center;
	background-color: transparent;
	background-image: none;
	border: 0;
	border-bottom: 1px solid rgba(0, 0, 0, 0.15);
	padding: 0 0 8px;
	font-weight: 600;
	color: var(--cfm-heading);
	cursor: pointer;
}

.cfm-filter-group__toggle:hover,
.cfm-filter-group__toggle:focus,
.cfm-filter-group__toggle:active {
	background-color: transparent;
	color: var(--cfm-heading);
}

.cfm-filter-group__toggle:focus-visible {
	outline: 2px solid var(--cfm-accent);
	outline-offset: 1px;
}

.cfm-filter-group__icon {
	color: var(--cfm-accent);
	font-weight: 700;
}

.cfm-filter-group__body {
	margin-top: 10px;
	display: flex;
	flex-direction: column;
	gap: 10px;
}

.cfm-filter-group.is-collapsed .cfm-filter-group__body {
	display: none;
}

.cfm-checkbox {
	display: flex;
	align-items: center;
	gap: 8px;
	cursor: pointer;
	min-height: 24px;
}

.cfm-checkbox input[type='checkbox'] {
	position: absolute;
	opacity: 0;
	width: 24px;
	height: 24px;
	margin: 0;
	cursor: pointer;
}

.cfm-checkbox__box {
	width: 20px;
	height: 20px;
	flex: 0 0 auto;
	border: 2px solid var(--cfm-checkbox-border);
	background: #fff;
	position: relative;
}

.cfm-checkbox input[type='checkbox']:checked + .cfm-checkbox__box::after {
	content: '';
	position: absolute;
	inset: 3px;
	background: var(--cfm-checkbox-border);
}

.cfm-checkbox__count {
	color: #777;
	font-size: 0.85em;
}

/* Results grid */
.cfm-grid {
	display: grid;
	grid-template-columns: repeat(var(--cfm-cols-desktop), 1fr);
	gap: 24px;
	align-items: stretch;
}

/* Cards are server-rendered in repeater order; keep them hidden until the
   frontend JS has filtered/sorted/paginated them client-side, so the visitor
   never sees the raw order flash before it settles. cfm-frontend.js removes
   this class once the first applyFilters() pass has run. */
.cfm-widget.cfm-is-loading .cfm-grid,
.cfm-widget.cfm-is-loading .cfm-pagination {
	display: none;
}

.cfm-card {
	background: var(--cfm-card-bg);
	border: 0;
	display: flex;
	flex-direction: column;
	height: 100%;
}

.cfm-card.is-expanded {
	align-self: start;
	/* Beats the inline height JS freezes on the collapsed cards. */
	height: auto !important;
}

.cfm-card[hidden] {
	display: none;
}

.cfm-card__media {
	display: block;
	width: 100%;
	padding: 0;
	border: 0;
	background: none;
	cursor: pointer;
}

.cfm-card__image {
	display: block;
	width: 100%;
	aspect-ratio: 4 / 3;
	object-fit: cover;
}

.cfm-card__image--placeholder {
	background: #ddd;
}

.cfm-card__body {
	padding: 16px;
	display: flex;
	flex-direction: column;
	gap: 12px;
	flex: 1;
}

.cfm-card__title-btn {
	display: flex;
	justify-content: space-between;
	align-items: flex-start;
	gap: 8px;
	width: 100%;
	background-color: transparent;
	background-image: none;
	color: inherit;
	border: 0;
	padding: 4px;
	margin: -4px;
	text-align: left;
	cursor: pointer;
	border-radius: 2px;
	outline: none;
	box-shadow: none;
}

.cfm-card__title-btn:hover,
.cfm-card__title-btn:focus,
.cfm-card__title-btn:active {
	background-color: var(--cfm-title-btn-hover-bg);
	color: inherit;
}

.cfm-card__title-btn:focus-visible {
	outline: 2px solid var(--cfm-title-btn-focus-outline);
	outline-offset: 1px;
}

.cfm-card__title {
	margin: 0;
	color: var(--cfm-accent);
	font-family: Georgia, 'Times New Roman', serif;
	font-size: 1rem;
}

.cfm-card__expand-icon {
	display: inline-flex;
	align-items: center;
	color: var(--cfm-accent);
	font-size: 1rem;
	font-weight: 700;
	flex: 0 0 auto;
}

.cfm-card__expand-icon i {
	color: currentColor;
}

.cfm-card__expand-icon svg {
	width: 1em;
	height: 1em;
	fill: currentColor;
}

.cfm-card__expand-icon--expanded {
	display: none;
}

.cfm-card.is-expanded .cfm-card__expand-icon--collapsed {
	display: none;
}

.cfm-card.is-expanded .cfm-card__expand-icon--expanded {
	display: inline-flex;
}

.cfm-card__details {
	display: none;
	flex-direction: column;
	gap: 6px;
	font-size: 13px;
	color: var(--cfm-heading);
}

.cfm-card.is-expanded .cfm-card__details {
	display: flex;
}

.cfm-card__detail {
	margin: 0 !important;
	display: flex;
	align-items: flex-start;
	gap: 6px;
}

.cfm-card__detail-text {
	flex: 1;
	min-width: 0;
}

.cfm-card__detail-text strong {
	white-space: nowrap;
}

.cfm-card__description {
	margin: 6px 0 0 !important;
	display: flex;
	align-items: flex-start;
	gap: 6px;
}

.cfm-card__detail-icon {
	flex-shrink: 0;
	color: var(--cfm-field-icon-color, var(--cfm-accent));
	width: 1em;
	height: 1em;
}

.cfm-card__description .cfm-card__detail-icon {
	margin-top: 0.2em;
}

.cfm-card__guia {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	margin-top: 6px;
	color: var(--cfm-accent);
	font-weight: 600;
	text-decoration: none;
}

.cfm-card__guia i {
	color: currentColor;
}

.cfm-card__guia svg {
	width: 1em;
	height: 1em;
	fill: currentColor;
}

.cfm-card__guia:hover,
.cfm-card__guia:focus {
	text-decoration: underline;
}

.cfm-card__cta {
	margin-top: auto;
	display: inline-block;
	text-align: center;
	background: var(--cfm-accent);
	color: #fff;
	text-decoration: none;
	padding: 12px 20px;
	font-weight: 600;
}

.cfm-card__cta:hover,
.cfm-card__cta:focus {
	opacity: 0.9;
	color: #fff;
}

.cfm-empty {
	grid-column: 1 / -1;
	text-align: center;
	color: var(--cfm-heading);
	padding: 40px 0;
}

/* Pagination */
.cfm-pagination {
	margin-top: 32px;
	text-align: center;
}

.cfm-pagination__load-more {
	background: var(--cfm-accent);
	color: #fff;
	border: 0;
	padding: 12px 28px;
	cursor: pointer;
	font-weight: 600;
}

.cfm-pagination__numbers {
	display: inline-flex;
	gap: 8px;
}

.cfm-pagination__page {
	background: #fff;
	border: 1px solid var(--cfm-accent);
	color: var(--cfm-accent);
	min-width: 36px;
	min-height: 36px;
	cursor: pointer;
}

.cfm-pagination__page.is-active {
	background: var(--cfm-accent);
	color: #fff;
}

.cfm-loading {
	text-align: center;
	padding: 20px 0;
	color: var(--cfm-heading);
}

.cfm-loading__spinner {
	display: inline-block;
	width: 16px;
	height: 16px;
	border: 2px solid var(--cfm-accent);
	border-top-color: transparent;
	border-radius: 50%;
	animation: cfm-spin 0.6s linear infinite;
	margin-right: 8px;
	vertical-align: middle;
}

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

/* Horizontal filters layout: filter bar above the results, filters and search
   laid out in a row, each filter group opening as a floating dropdown instead
   of pushing the content below it down. */
.cfm-layout--horizontal {
	display: block;
}

.cfm-layout--horizontal .cfm-filters {
	width: 100%;
	margin-bottom: 32px;
}

.cfm-layout--horizontal .cfm-search {
	margin-bottom: 20px;
}

.cfm-layout--horizontal .cfm-filters__body {
	display: flex;
	flex-wrap: wrap;
	align-items: flex-start;
	gap: 16px 24px;
}

.cfm-layout--horizontal .cfm-active-filters {
	flex-basis: 100%;
	margin-bottom: 0;
}

.cfm-layout--horizontal .cfm-filter-group {
	position: relative;
	flex: 0 0 auto;
}

.cfm-layout--horizontal .cfm-filter-group + .cfm-filter-group {
	margin-top: 0;
}

.cfm-layout--horizontal .cfm-filter-group__toggle {
	border-bottom: 0;
	white-space: nowrap;
	gap: 10px;
}

.cfm-layout--horizontal .cfm-filter-group__body {
	position: absolute;
	top: 100%;
	left: 0;
	z-index: 10;
	margin-top: 8px;
	min-width: 220px;
	max-height: 320px;
	overflow-y: auto;
	background: var(--cfm-panel-bg);
	border: 1px solid var(--cfm-accent);
	padding: 14px;
}

.cfm-layout--horizontal .cfm-filter-group.is-collapsed .cfm-filter-group__body {
	display: none;
}

/* Tablet */
@media (max-width: 991px) {
	.cfm-layout {
		grid-template-columns: 1fr;
	}

	.cfm-grid {
		grid-template-columns: repeat(var(--cfm-cols-tablet), 1fr);
	}

	.cfm-filters__mobile-toggle {
		display: block;
	}

	.cfm-filters__body {
		display: none;
	}

	.cfm-filters.is-open .cfm-filters__body {
		display: block;
		margin-top: 16px;
	}

	/* Below the mobile-toggle breakpoint, horizontal filters fall back to the
	   same stacked accordion as vertical instead of a row of dropdowns. */
	.cfm-layout--horizontal .cfm-filters__body {
		display: none;
		flex-wrap: nowrap;
	}

	.cfm-layout--horizontal .cfm-filters.is-open .cfm-filters__body {
		display: flex;
		flex-direction: column;
	}

	.cfm-layout--horizontal .cfm-filter-group {
		width: 100%;
	}

	.cfm-layout--horizontal .cfm-filter-group__toggle {
		border-bottom: 1px solid rgba(0, 0, 0, 0.15);
		width: 100%;
		justify-content: space-between;
	}

	.cfm-layout--horizontal .cfm-filter-group__body {
		position: static;
		margin-top: 10px;
		max-height: none;
		overflow-y: visible;
		border: 0;
		padding: 0;
		background: none;
	}
}

/* Mobile */
@media (max-width: 600px) {
	.cfm-grid {
		grid-template-columns: repeat(var(--cfm-cols-mobile), 1fr);
	}

	.cfm-checkbox,
	.cfm-filter-group__toggle {
		min-height: 44px;
	}
}
