/*
 * MSH AJAX Filter & Search
 * msh-ajax-filter.css
 *
 * Scoped to .msh-ajax-filter-widget so it never leaks into the rest of the page.
 * Uses CSS custom properties so the Elementor style controls can override via
 * inline styles that cascade naturally.
 */

/* ============================================================================
   Root custom properties (defaults – overridden by Elementor style controls)
   ============================================================================ */
.msh-ajax-filter-widget {
	--msh-filter-bg:         #f5f5f5;
	--msh-filter-border:     #d8d8d8;
	--msh-filter-radius:     4px;
	--msh-filter-text:       #333;
	--msh-accent:            #005f8e;   /* MSH-ish blue – adjust to brand */
	--msh-accent-hover:      #00456a;
	--msh-font-size:         14px;
	--msh-transition:        0.2s ease;
}

/* ============================================================================
   Filter bar
   ============================================================================ */
.msh-filter-bar {
	background-color: var( --msh-filter-bg );
	border: 1px solid var( --msh-filter-border );
	border-radius: var( --msh-filter-radius );
	padding: 16px;
	margin-bottom: 24px;
}

.msh-filter-row {
	display: flex;
	flex-wrap: wrap;
	gap: 12px;
	align-items: center;
}

/* Individual filter group */
.msh-filter-group {
	display: flex;
	flex-direction: column;
	flex: 1 1 180px;
	min-width: 160px;
	max-width: 260px;
}

/* Search group is a bit wider */
.msh-filter-group.msh-filter-search {
	flex: 2 1 240px;
	max-width: 340px;
	flex-direction: row;
	align-items: center;
}

/* Sort group */
.msh-filter-group.msh-filter-sort {
	flex: 1 1 160px;
	max-width: 200px;
}

.msh-multiselect-checkbox:focus-visible {
	outline: 2px solid var( --msh-accent );
	outline-offset: 2px;
}

.msh-multiselect-option:has(.msh-multiselect-checkbox:focus-visible) {
	background-color: var( --msh-filter-bg );
}

/* ============================================================================
   Form controls – selects & text inputs
   ============================================================================ */
.msh-filter-bar select,
.msh-filter-bar input[type="text"] {
	width: 100%;
	padding: 8px 12px;
	font-size: var( --msh-font-size );
	color: var( --msh-filter-text );
	background-color: #fff;
	border: 1px solid var( --msh-filter-border );
	border-radius: var( --msh-filter-radius );
	appearance: none;
	-webkit-appearance: none;
	transition: border-color var( --msh-transition ), box-shadow var( --msh-transition );
	line-height: 1.4;
}

/* Custom arrow for selects */
.msh-filter-group:not(.msh-filter-search) {
	position: relative;
}
.msh-filter-group:not(.msh-filter-search)::after {
	content: '';
	position: absolute;
	right: 12px;
	bottom: 12px;
	width: 8px;
	height: 8px;
	border-right: 2px solid var( --msh-filter-text );
	border-bottom: 2px solid var( --msh-filter-text );
	transform: rotate( 45deg );
	pointer-events: none;
}

.msh-ajax-filter-widget .msh-filter-bar select:focus-visible,
.msh-ajax-filter-widget .msh-filter-bar input[type="text"]:focus-visible {
	outline: 2px solid var( --msh-accent );
	outline-offset: 2px;
	border-color: var( --msh-accent );
	box-shadow: 0 0 0 3px rgba( 0, 95, 142, 0.30 );
}
/* Fallback for engines without :focus-visible support */
.msh-ajax-filter-widget .msh-filter-bar select:focus,
.msh-ajax-filter-widget .msh-filter-bar input[type="text"]:focus {
	outline: 2px solid var( --msh-accent );
	outline-offset: 2px;
	border-color: var( --msh-accent );
}

/* Search input – fill remaining space before button */
.msh-filter-group.msh-filter-search input[type="text"] {
	flex: 1;
	border-radius: var( --msh-filter-radius ) 0 0 var( --msh-filter-radius );
	border-right: none;
}

.msh-filter-section-label {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
}
.msh-filter-bar:focus {
    outline: 2px solid #5ab3cc;
    outline-offset: 2px;
}

.msh-filter-sentinel {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
    outline: none !important;  /* ← add this */
}

.msh-filter-sentinel:focus {
    outline: none !important;
}



/* Search button */
.msh-search-btn {
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 8px 14px;
	background-color: var( --msh-accent );
	color: #fff;
	border: 1px solid var( --msh-accent );
	border-radius: 0 var( --msh-filter-radius ) var( --msh-filter-radius ) 0;
	cursor: pointer;
	transition: background-color var( --msh-transition );
	line-height: 1;
}
.msh-search-btn:hover {
	background-color: var( --msh-accent-hover );
}
.msh-search-btn:focus,
.msh-search-btn:focus-visible {
	background-color: var( --msh-accent-hover );
	outline: none;
	box-shadow: none;
}
.msh-search-btn svg {
	display: block;
	pointer-events: none; /* clicks land on the button, never the svg */
}

/* ============================================================================
   Results meta row
   ============================================================================ */
.msh-results-meta {
	display: flex;
	align-items: center;
	gap: 16px;
	margin-bottom: 16px;
	font-size: 13px;
	color: #666;
	min-height: 24px;
}

.msh-results-count {
	font-weight: 500;
}

/* Clear filters button */
.msh-clear-filters {
	background: none;
	border: none;
	color: var( --msh-accent );
	cursor: pointer;
	font-size: 13px;
	padding: 0;
	text-decoration: underline;
	transition: color var( --msh-transition );
}
.msh-clear-filters:hover {
	color: var( --msh-accent-hover );
}

/* ============================================================================
   Loading overlay
   ============================================================================ */
.msh-results-wrapper {
	position: relative;
}

.msh-loading-overlay {
	position: absolute;
	inset: 0;
	background: rgba( 255, 255, 255, 0.75 );
	display: flex;
	align-items: center;
	justify-content: center;
	z-index: 10;
	border-radius: 4px;
	min-height: 120px;
}

/* CSS spinner */
.msh-spinner {
	display: inline-block;
	width: 36px;
	height: 36px;
	border: 4px solid rgba( 0, 95, 142, 0.2 );
	border-top-color: var( --msh-accent );
	border-radius: 50%;
	animation: msh-spin 0.75s linear infinite;
}
@keyframes msh-spin {
	to { transform: rotate( 360deg ); }
}

/* Dim grid while loading */
.msh-is-loading .msh-posts-grid {
	opacity: 0.5;
	pointer-events: none;
	transition: opacity var( --msh-transition );
}

/* ============================================================================
   No results / error messages
   ============================================================================ */
.msh-no-results,
.msh-error {
	grid-column: 1 / -1;
	padding: 32px;
	text-align: center;
	color: #555;
	font-size: 15px;
	background: #fafafa;
	border: 1px dashed #ddd;
	border-radius: 4px;
}
.msh-error {
	color: #b00;
	border-color: #f5c2c7;
	background: #fff3f4;
}

/* ============================================================================
   Pagination
   ============================================================================ */
.msh-pagination {
	margin-top: 32px;
}

.msh-pagination-nav {
	display: flex;
	justify-content: center;
}

.msh-page-numbers {
	display: flex;
	flex-wrap: wrap;
	gap: 6px;
	list-style: none;
	margin: 0;
	padding: 0;
	align-items: center;
}

.msh-page-btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-width: 36px;
	height: 36px;
	padding: 0 8px;
	background: #fff;
	border: 1px solid var( --msh-filter-border );
	border-radius: var( --msh-filter-radius );
	color: var( --msh-filter-text );
	font-size: var( --msh-font-size );
	cursor: pointer;
	transition: background-color var( --msh-transition ), border-color var( --msh-transition ), color var( --msh-transition );
}

.msh-page-btn:hover {
	background-color: var( --msh-accent );
	border-color:     var( --msh-accent );
	color: #fff;
}

.msh-page-btn.msh-page-current {
	background-color: var( --msh-accent );
	border-color:     var( --msh-accent );
	color: #fff;
	font-weight: 600;
	cursor: default;
}

.msh-page-btn:focus {
	outline: none;
	box-shadow: 0 0 0 3px rgba( 0, 95, 142, 0.25 );
}

.msh-page-ellipsis {
	color: #999;
	padding: 0 4px;
	line-height: 36px;
}

.msh-prev-btn,
.msh-next-btn {
	font-size: 16px;
}

/* ============================================================================
   Responsive adjustments
   ============================================================================ */
@media ( max-width: 768px ) {
	.msh-filter-row {
		flex-direction: column;
	}

	.msh-filter-group,
	.msh-filter-group.msh-filter-search,
	.msh-filter-group.msh-filter-sort {
		flex: 1 1 100%;
		max-width: 100%;
	}
}

/* ============================================================================
   Screen-reader only utility
   ============================================================================ */
.screen-reader-text {
	position: absolute;
	width: 1px;
	height: 1px;
	padding: 0;
	margin: -1px;
	overflow: hidden;
	clip: rect( 0, 0, 0, 0 );
	white-space: nowrap;
	border: 0;
}

/* ============================================================================
   Featured card — shown only when featured sort is active
   ============================================================================ */

/* Card highlight — subtle top border accent */
.msh-ajax-filter-widget .blog-inner.msh-card-featured {
	position: relative;
	border-top: 3px solid var( --msh-accent );
	box-shadow: 0 2px 12px rgba( 0, 95, 142, 0.10 );
}

/* Featured badge — sits top-left, overlapping the image */
.msh-featured-badge {
	display: inline-flex;
	align-items: center;
	gap: 4px;
	position: absolute;
	top: 10px;
	left: 10px;
	z-index: 2;
	background-color: var( --msh-accent );
	color: #fff;
	font-size: 11px;
	font-weight: 600;
	line-height: 1;
	padding: 4px 8px;
	border-radius: 3px;
	letter-spacing: 0.03em;
	text-transform: uppercase;
	pointer-events: none;
	box-shadow: 0 1px 4px rgba( 0, 0, 0, 0.18 );
}

/* When card has no thumbnail the badge sits above the text instead */
.msh-ajax-filter-widget .blog-inner.msh-card-featured:not(:has(.post-thumb)) .msh-featured-badge {
	position: static;
	display: inline-flex;
	margin-bottom: 8px;
}

/* Star icon inside badge */
.msh-featured-badge svg {
	flex-shrink: 0;
	margin-top: -1px;
}
/* ============================================================================
   Multi-select filter dropdown (Technical Area / Content Type / Country)
   Replaces the native <select> so users can check multiple terms.
   Reuses .msh-filter-group sizing/flex rules already defined above.
   ============================================================================ */

/* Don't double up: the generic select-arrow pseudo-element is for native
   <select> groups only — the multiselect draws its own chevron in the button. */
.msh-filter-group.msh-multiselect::after {
	content: none;
}

.msh-multiselect {
	position: relative;
}

.msh-multiselect-toggle {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 8px;
	width: 100%;
	padding: 8px 12px;
	font-size: var( --msh-font-size );
	font-family: inherit;
	color: var( --msh-filter-text );
	background-color: #fff;
	border: 1px solid var( --msh-filter-border );
	border-radius: var( --msh-filter-radius );
	cursor: pointer;
	line-height: 1.4;
	transition: border-color var( --msh-transition ), box-shadow var( --msh-transition );
}

.msh-multiselect-toggle:hover {
	border-color: var( --msh-accent );
}

.msh-multiselect-toggle:focus-visible {
	outline: 2px solid var( --msh-accent );
	outline-offset: 2px;
	border-color: var( --msh-accent );
	box-shadow: 0 0 0 3px rgba( 0, 95, 142, 0.30 );
}

.msh-multiselect-label {
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.msh-multiselect-count {
	flex-shrink: 0;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-width: 18px;
	height: 18px;
	padding: 0 5px;
	font-size: 11px;
	font-weight: 700;
	line-height: 1;
	color: #fff;
	background-color: var( --msh-accent );
	border-radius: 999px;
}

.msh-multiselect-chevron {
	flex-shrink: 0;
	color: var( --msh-filter-text );
	transition: transform var( --msh-transition );
}

.msh-multiselect-toggle[aria-expanded="true"] .msh-multiselect-chevron {
	transform: rotate( 180deg );
}

/* Dropdown panel */
.msh-multiselect-panel {
	position: absolute;
	top: calc( 100% + 4px );
	left: 0;
	z-index: 20;
	width: max( 100%, 240px );
	max-height: 320px;
	display: flex;
	flex-direction: column;
	background-color: #fff;
	border: 1px solid var( --msh-filter-border );
	border-radius: var( --msh-filter-radius );
	box-shadow: 0 8px 24px rgba( 0, 0, 0, 0.12 );
	overflow: hidden;
}

.msh-multiselect-search {
	padding: 8px;
	border-bottom: 1px solid var( --msh-filter-border );
}

.msh-multiselect-search-input {
	width: 100%;
	padding: 6px 10px;
	font-size: var( --msh-font-size );
	border: 1px solid var( --msh-filter-border );
	border-radius: var( --msh-filter-radius );
}

.msh-multiselect-search-input:focus-visible {
	outline: 2px solid var( --msh-accent );
	outline-offset: 1px;
	border-color: var( --msh-accent );
}

.msh-multiselect-options {
	margin: 0;
	padding: 4px 0;
	list-style: none;
	overflow-y: auto;
}

.msh-multiselect-option label {
	display: flex;
	align-items: center;
	gap: 8px;
	padding: 8px 12px;
	font-size: var( --msh-font-size );
	color: var( --msh-filter-text );
	cursor: pointer;
	transition: background-color var( --msh-transition );
}

.msh-multiselect-option label:hover {
	background-color: var( --msh-filter-bg );
}

.msh-multiselect-checkbox {
	flex-shrink: 0;
	width: 16px;
	height: 16px;
	accent-color: var( --msh-accent );
	cursor: pointer;
}

.msh-multiselect-option-name {
	flex: 1;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.msh-multiselect-option-count {
	flex-shrink: 0;
	font-size: 12px;
	color: #767676;
}

/* ============================================================================
   Active-filter pills row — "Clear All ×  Term Name ×  Term Name ×"
   ============================================================================ */
.msh-active-filters {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 8px;
	margin-top: 12px;
}

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

.msh-clear-all-pill,
.msh-filter-pill {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	padding: 6px 12px;
	font-size: 13px;
	font-weight: 500;
	line-height: 1.2;
	background-color: #fff;
	border: 1px solid var( --msh-accent );
	border-radius: 999px;
	color: var( --msh-accent );
	cursor: pointer;
	transition: background-color var( --msh-transition ), color var( --msh-transition );
	white-space: nowrap;
}

.msh-clear-all-pill:hover,
.msh-filter-pill:hover {
	background-color: var( --msh-accent );
	color: #fff;
}

.msh-clear-all-pill:focus-visible,
.msh-filter-pill:focus-visible {
	outline: 2px solid var( --msh-accent );
	outline-offset: 2px;
}

.msh-clear-all-pill {
	font-weight: 600;
	border-style: dashed;
}

.msh-filter-pill svg,
.msh-clear-all-pill svg {
	flex-shrink: 0;
}

/* Mobile: stack the multiselect panel to full width so it doesn't overflow */
@media ( max-width: 480px ) {
	.msh-multiselect-panel {
		width: 100%;
	}
}
