/**
 * Find a Cohort (WP-1360).
 * Grid + facet-bar styling for the FacetWP "cohorts" listing. The cards
 * themselves reuse the theme's .card--program / .c1 / .is-style-heading-link-color.
 */

/* Facet bar — the two facets are placed as separate shortcodes/blocks */
.facetwp-facet-cohort_state,
.facetwp-facet-cohort_city {
	display: inline-block;
	vertical-align: top;
	margin: 0 16px 24px 0;
}

.facetwp-facet-cohort_state select,
.facetwp-facet-cohort_city select,
.facetwp-facet-cohort_state .facetwp-dropdown,
.facetwp-facet-cohort_city .facetwp-dropdown {
	appearance: none;
	-webkit-appearance: none;
	-moz-appearance: none;
	width: 250px;
	min-width: 220px;
	padding: 10px;
	padding-left: 35px;
	border: 1px solid var(--wp--preset--color--custom-body-subtle);
	border-radius: 2px;
	outline: none;
	cursor: pointer;
	background-color: transparent;
	background-image: url(../../assets/images/drop.svg);
	background-repeat: no-repeat;
	background-position: 14px center;
	background-size: 12px;
	font-size: 17px;
	line-height: 25px;
	color: var(--wp--preset--color--custom-body-subtle);
}

.facetwp-facet-cohort_state select:focus,
.facetwp-facet-cohort_city select:focus,
.facetwp-facet-cohort_state .facetwp-dropdown:focus,
.facetwp-facet-cohort_city .facetwp-dropdown:focus {
	box-shadow: 0 0 0 1px var(--wp--preset--color--custom-body-subtle);
}

/* On narrow viewports the State/City/Search row — a WordPress flex block set
   to "nowrap" — otherwise forces all three fields into one unbreakable row at
   their full desktop width, pushing later fields off-screen and causing the
   whole page to scroll sideways. Let the row wrap and stack each label +
   field full-width.
   Targeted structurally (":has()" on the flex row that contains the State
   dropdown) rather than via a custom block className — this row gets
   hand-edited/reordered in wp-admin from time to time, which has silently
   dropped a className-based hook before. Order-independent by design (works
   whether it's State/City/Search or Search/State/City, etc). */
@media (max-width: 680px) {
	.wp-block-group.is-nowrap:has(> .facetwp-facet-cohort_state) {
		flex-wrap: wrap !important;
		gap: 0 !important;
	}
	.wp-block-group.is-nowrap:has(> .facetwp-facet-cohort_state) > * {
		flex: 1 1 100% !important;
		margin-right: 0 !important;
	}
	.wp-block-group.is-nowrap:has(> .facetwp-facet-cohort_state) > .wp-block-spacer {
		display: none;
	}
	/* Field titles read as page-heading-sized (32px) at the site's default h3
	   style — appropriately scaled down here since they're really just form
	   labels above compact fields, not section headings. */
	.wp-block-group.is-nowrap:has(> .facetwp-facet-cohort_state) > h3.wp-block-heading {
		font-size: 14px;
		font-weight: 600;
		line-height: 1.3;
		margin: 22px 0 4px;
	}
	.wp-block-group.is-nowrap:has(> .facetwp-facet-cohort_state) > h3.wp-block-heading:first-child {
		margin-top: 0;
	}
	.facetwp-facet-cohort_state,
	.facetwp-facet-cohort_city,
	.facetwp-facet-name_cohort {
		margin: 0;
		width: 100%;
	}
	.facetwp-facet-cohort_state select,
	.facetwp-facet-cohort_city select,
	.facetwp-facet-cohort_state .facetwp-dropdown,
	.facetwp-facet-cohort_city .facetwp-dropdown {
		width: 100%;
		min-width: 0;
	}
	.facetwp-facet-name_cohort .facetwp-input-wrap {
		display: block;
		width: 100%;
	}
	.facetwp-facet-name_cohort .facetwp-search {
		width: 100%;
		box-sizing: border-box;
	}

	/* Space before the form: the intro paragraph's trailing spacer, found by
	   selecting the group whose very next sibling is the filter row's
	   wrapper — structural, not className-based, for the same reason as
	   above. */
	.wp-block-group:has(+ .wp-block-group .facetwp-facet-cohort_state) > .wp-block-spacer:last-child {
		height: 20px !important;
	}

	/* Space after the form: the spacer that sits directly between the filter
	   row and the results grid. */
	.wp-block-group.is-nowrap:has(> .facetwp-facet-cohort_state) + .wp-block-spacer {
		height: 24px !important;
	}
}

/* Results grid — 3 per row, gracefully handles filtered partial rows */
.find-a-cohort__list {
	display: grid;
	grid-template-columns: repeat(3, 1fr);
	column-gap: 24px;
	row-gap: 8px;
	align-items: start;
}
.find-a-cohort__list h5 {
	margin-bottom: 0;
}
@media (max-width: 1023px) {
	.find-a-cohort__list {
		grid-template-columns: repeat(2, 1fr);
	}
}

@media (max-width: 680px) {
	.find-a-cohort__list {
		grid-template-columns: 1fr;
	}
}

/* Uniform image box so every card lines up and the placeholder never looks
   broken — real photos fill it (cover), the placeholder is centered/contained. */
.find-a-cohort__list .card--program figure.wp-block-image {
	margin: 0;
	aspect-ratio: 3 / 2;
	overflow: hidden;
	display: flex;
	align-items: center;
	justify-content: center;
	background-color: #ddd;
}

.find-a-cohort__list .card--program figure.wp-block-image img {
	width: 100%;
	height: 100%;
	object-fit: cover;
	display: block;
}

.find-a-cohort__list .card--program figure.wp-block-image img.is-placeholder {
	width: auto;
	height: 40%;
	object-fit: contain;
	opacity: 0.5;
}

/* Ensure the card body's -40px lift works outside the original wp:columns context */
.find-a-cohort__list .card--program .wp-block-group {
	position: relative;
}

.find-a-cohort__empty {
	grid-column: 1 / -1;
	text-align: center;
	padding: 40px 0;
}
