/**
 * ManIT Post Filter — front end.
 *
 * Everything is scoped under .manit-pf so it cannot leak into the theme.
 * To match the brand, override the custom properties below in
 * Appearance > Customise > Additional CSS. Nothing else needs touching.
 */

.manit-pf {
	--manit-pf-accent: #ba3942;
	--manit-pf-accent-contrast: #fff;
	--manit-pf-focus-ring: rgba( 186, 57, 66, 0.2 );
	--manit-pf-text: inherit;
	--manit-pf-muted: #5b6472;
	--manit-pf-border: #e2e5ea;
	--manit-pf-card-bg: #fff;
	--manit-pf-chip-bg: #f4f6f9;
	--manit-pf-radius: 10px;
	--manit-pf-gap: 24px;
	--manit-pf-columns: 3;
	--manit-pf-shadow: 0 1px 2px rgba( 16, 24, 40, 0.06 ), 0 8px 24px rgba( 16, 24, 40, 0.06 );

	font: inherit;
	color: var( --manit-pf-text );
}

.manit-pf *,
.manit-pf *::before,
.manit-pf *::after {
	box-sizing: border-box;
}

.manit-pf .screen-reader-text {
	position: absolute;
	width: 1px;
	height: 1px;
	margin: -1px;
	padding: 0;
	overflow: hidden;
	clip: rect( 0, 0, 0, 0 );
	white-space: nowrap;
	border: 0;
}

/* Controls
   ------------------------------------------------------------------------ */

.manit-pf__controls {
	margin: 0 0 var( --manit-pf-gap );
	text-align: center;
}

.manit-pf__search {
	position: relative;
	max-width: 560px;
	margin: 0 auto 18px;
}

.manit-pf__search-input {
	width: 100%;
	padding: 14px 46px 14px 18px;
	font: inherit;
	line-height: 1.4;
	color: inherit;
	background: var( --manit-pf-card-bg );
	border: 1px solid var( --manit-pf-border );
	border-radius: 999px;
	box-shadow: none;
	transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.manit-pf__search-input:focus {
	outline: none;
	border-color: var( --manit-pf-accent );
	box-shadow: 0 0 0 3px var( --manit-pf-focus-ring );
}

.manit-pf__search-icon {
	position: absolute;
	top: 50%;
	right: 18px;
	width: 16px;
	height: 16px;
	margin-top: -9px;
	border: 2px solid var( --manit-pf-muted );
	border-radius: 50%;
	pointer-events: none;
}

.manit-pf__search-icon::after {
	content: "";
	position: absolute;
	top: 12px;
	left: 11px;
	width: 7px;
	height: 2px;
	background: var( --manit-pf-muted );
	transform: rotate( 45deg );
}

.manit-pf__chips {
	display: flex;
	flex-wrap: wrap;
	justify-content: center;
	gap: 8px;
	margin: 0 0 14px;
}

.manit-pf__chip {
	position: relative;
	display: inline-flex;
	align-items: center;
	padding: 8px 16px;
	font-size: 0.9em;
	line-height: 1.2;
	color: inherit;
	background: var( --manit-pf-chip-bg );
	border: 1px solid var( --manit-pf-border );
	border-radius: 999px;
	cursor: pointer;
	transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

/* Hover hints at the colour the chip turns once it is on. */
.manit-pf__chip:hover {
	color: var( --manit-pf-accent );
	border-color: var( --manit-pf-accent );
}

.manit-pf__chip.is-active:hover {
	color: var( --manit-pf-accent-contrast );
}

.manit-pf__chip.is-active {
	color: var( --manit-pf-accent-contrast );
	background: var( --manit-pf-accent );
	border-color: var( --manit-pf-accent );
}

.manit-pf__chip-input {
	position: absolute;
	width: 1px;
	height: 1px;
	margin: 0;
	opacity: 0;
}

.manit-pf__chip-input:focus-visible + .manit-pf__chip-label {
	outline: 2px solid var( --manit-pf-accent );
	outline-offset: 4px;
}

.manit-pf__actions {
	display: flex;
	flex-wrap: wrap;
	justify-content: center;
	gap: 10px;
}

.manit-pf__submit,
.manit-pf__more {
	padding: 11px 26px;
	font: inherit;
	font-size: 0.95em;
	color: var( --manit-pf-accent-contrast );
	background: var( --manit-pf-accent );
	border: 0;
	border-radius: 999px;
	cursor: pointer;
	transition: opacity 0.15s ease;
}

.manit-pf__submit:hover,
.manit-pf__more:hover {
	opacity: 0.88;
}

.manit-pf__more[disabled] {
	opacity: 0.6;
	cursor: default;
}

.manit-pf__reset {
	padding: 11px 12px;
	font: inherit;
	font-size: 0.9em;
	color: var( --manit-pf-muted );
	text-decoration: underline;
	background: none;
	border: 0;
	cursor: pointer;
}

/* Results
   ------------------------------------------------------------------------ */

.manit-pf__count {
	margin: 0 0 16px;
	font-size: 0.88em;
	color: var( --manit-pf-muted );
	text-align: center;
}

.manit-pf__count:empty {
	margin: 0;
}

.manit-pf__grid {
	display: grid;
	gap: var( --manit-pf-gap );
	grid-template-columns: repeat(
		auto-fill,
		minmax(
			max( 240px, calc( ( 100% - ( var( --manit-pf-columns ) - 1 ) * var( --manit-pf-gap ) ) / var( --manit-pf-columns ) ) ),
			1fr
		)
	);
	transition: opacity 0.15s ease;
}

.manit-pf.is-loading .manit-pf__grid {
	opacity: 0.5;
}

.manit-pf__card {
	position: relative;
	display: flex;
	flex-direction: column;
	overflow: hidden;
	background: var( --manit-pf-card-bg );
	border: 1px solid var( --manit-pf-border );
	border-radius: var( --manit-pf-radius );
	box-shadow: var( --manit-pf-shadow );
	transition: transform 0.18s ease, box-shadow 0.18s ease;
}

.manit-pf__card:hover {
	transform: translateY( -3px );
	box-shadow: 0 2px 4px rgba( 16, 24, 40, 0.07 ), 0 14px 32px rgba( 16, 24, 40, 0.1 );
}

.manit-pf__media {
	position: relative;
	aspect-ratio: 16 / 9;
	overflow: hidden;
	background: var( --manit-pf-chip-bg );
}

.manit-pf__image {
	display: block;
	width: 100%;
	height: 100%;
	object-fit: cover;
}

.manit-pf__image--empty {
	background: linear-gradient( 135deg, var( --manit-pf-chip-bg ), var( --manit-pf-border ) );
}

.manit-pf__body {
	display: flex;
	flex: 1;
	flex-direction: column;
	padding: 18px 20px 20px;
}

.manit-pf__meta {
	margin: 0 0 8px;
	font-size: 0.8em;
	color: var( --manit-pf-muted );
	text-transform: uppercase;
	letter-spacing: 0.04em;
}

.manit-pf__title {
	margin: 0 0 10px;
	font-size: 1.12em;
	line-height: 1.35;
}

.manit-pf__link {
	color: inherit;
	text-decoration: none;
}

/* Makes the whole card clickable while the real link stays the title. */
.manit-pf__link::after {
	content: "";
	position: absolute;
	inset: 0;
}

.manit-pf__card:hover .manit-pf__link {
	color: var( --manit-pf-accent );
}

.manit-pf__excerpt {
	margin: 0 0 16px;
	font-size: 0.92em;
	line-height: 1.6;
	color: var( --manit-pf-muted );
}

.manit-pf__readmore {
	margin-top: auto;
	font-size: 0.88em;
	font-weight: 600;
	color: var( --manit-pf-accent );
}

.manit-pf__empty,
.manit-pf__error {
	margin: 32px 0;
	color: var( --manit-pf-muted );
	text-align: center;
}

.manit-pf__error {
	color: #b32d2e;
}

.manit-pf__sentinel {
	width: 100%;
	height: 1px;
}

.manit-pf__footer {
	margin-top: 32px;
	text-align: center;
}

/* Once JavaScript is running, the Filter button is redundant. */
.manit-pf.is-enhanced .manit-pf__submit {
	display: none;
}

@media ( prefers-reduced-motion: reduce ) {

	.manit-pf__card,
	.manit-pf__grid,
	.manit-pf__search-input {
		transition: none;
	}

	.manit-pf__card:hover {
		transform: none;
	}
}
