/**
 * Mastex Search — frontend styles.
 * Variables (--mastex-*) are set inline per-page by the shortcode so site
 * admins can tune colours without touching CSS.
 */

.mastex-search {
	--mastex-radius: 12px;
	--mastex-gap: 28px;
	--mastex-shadow: 0 8px 24px rgba(15, 45, 92, 0.08);
	--mastex-shadow-hover: 0 14px 34px rgba(15, 45, 92, 0.14);
	--mastex-text: #4b5563;
	--mastex-muted: #9aa4b2;
	--mastex-border: #e4ebf3;

	background: var(--mastex-page-bg, #eef3f8);
	padding: 48px clamp(16px, 4vw, 48px);
	border-radius: var(--mastex-radius);
	box-sizing: border-box;
}

.mastex-search *,
.mastex-search *::before,
.mastex-search *::after {
	box-sizing: border-box;
}

/* ---------- Search form ---------- */
.mastex-search__form {
	display: flex;
	gap: 10px;
	max-width: 720px;
	margin: 0 auto 36px;
	background: #fff;
	border-radius: 999px;
	padding: 6px 6px 6px 20px;
	box-shadow: var(--mastex-shadow);
	align-items: center;
}

.mastex-search__label {
	flex: 1;
	display: flex;
	align-items: center;
	gap: 10px;
}

.mastex-search__icon {
	width: 20px;
	height: 20px;
	fill: var(--mastex-muted);
	flex-shrink: 0;
}

.mastex-search__form input[type="search"] {
	flex: 1;
	width: 100%;
	border: 0;
	background: transparent;
	font-size: 16px;
	padding: 12px 4px;
	outline: none;
	color: var(--mastex-primary, #0f2d5c);
	font-family: inherit;
}

.mastex-search__form input[type="search"]::placeholder {
	color: var(--mastex-muted);
}

.mastex-search__submit {
	appearance: none;
	border: 0;
	background: var(--mastex-primary, #0f2d5c);
	color: #fff;
	font-weight: 600;
	padding: 12px 26px;
	border-radius: 999px;
	cursor: pointer;
	font-size: 15px;
	transition: transform 0.15s ease, background 0.15s ease;
	font-family: inherit;
}

.mastex-search__submit:hover,
.mastex-search__submit:focus-visible {
	background: color-mix(in srgb, var(--mastex-primary, #0f2d5c) 88%, black);
	transform: translateY(-1px);
}

/* ---------- Meta / filters ---------- */
.mastex-search__meta {
	text-align: center;
	color: var(--mastex-text);
	margin: 0 0 20px;
	font-size: 15px;
}

.mastex-search__meta strong {
	color: var(--mastex-primary, #0f2d5c);
}

.mastex-search__meta em {
	font-style: normal;
	color: var(--mastex-primary, #0f2d5c);
}

.mastex-search__filters {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
	justify-content: center;
	margin: 0 0 28px;
}

.mastex-search__chip {
	display: inline-flex;
	align-items: center;
	padding: 8px 16px;
	border-radius: 999px;
	background: #fff;
	color: var(--mastex-primary, #0f2d5c);
	text-decoration: none;
	font-size: 14px;
	font-weight: 600;
	border: 1px solid var(--mastex-border);
	transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.mastex-search__chip:hover {
	border-color: var(--mastex-primary, #0f2d5c);
}

.mastex-search__chip.is-active {
	background: var(--mastex-primary, #0f2d5c);
	color: #fff;
	border-color: var(--mastex-primary, #0f2d5c);
}

/* ---------- Masonry grid ----------
   CSS multi-column layout: cards flow into columns, each card is kept intact
   with break-inside. Shorter cards (no image) fill gaps beneath taller ones
   so the layout reads as a tight masonry. */
.mastex-search__grid {
	column-count: var(--mastex-cols, 3);
	column-gap: var(--mastex-gap);
}

.mastex-search__grid > .mastex-card {
	break-inside: avoid;
	-webkit-column-break-inside: avoid;
	page-break-inside: avoid;
	margin: 0 0 var(--mastex-gap);
	display: block;
	width: 100%;
}

@media (max-width: 960px) {
	.mastex-search__grid {
		column-count: 2;
	}
}

@media (max-width: 600px) {
	.mastex-search__grid {
		column-count: 1;
	}
	.mastex-search__form {
		flex-direction: column;
		border-radius: var(--mastex-radius);
		padding: 10px;
	}
	.mastex-search__submit {
		width: 100%;
	}
}

/* ---------- Card ---------- */
.mastex-card {
	display: block;
	background: var(--mastex-card-bg, #fff);
	border-radius: var(--mastex-radius);
	overflow: hidden;
	box-shadow: var(--mastex-shadow);
	transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.mastex-card:hover,
.mastex-card:focus-within {
	transform: translateY(-3px);
	box-shadow: var(--mastex-shadow-hover);
}

.mastex-card__media {
	display: block;
	aspect-ratio: 4 / 3;
	background: #f0f4f8;
	overflow: hidden;
	position: relative;
}

.mastex-card__media img,
.mastex-card__img {
	width: 100%;
	height: 100%;
	object-fit: cover;
	display: block;
	transition: transform 0.4s ease;
}

.mastex-card:hover .mastex-card__img {
	transform: scale(1.04);
}

.mastex-card__body {
	padding: 24px 26px 28px;
	display: flex;
	flex-direction: column;
	gap: 10px;
}

.mastex-card__type {
	font-size: 11px;
	text-transform: uppercase;
	letter-spacing: 0.08em;
	color: var(--mastex-muted);
	font-weight: 700;
}

.mastex-card__title {
	margin: 0;
	font-size: 20px;
	line-height: 1.3;
	font-weight: 700;
	color: var(--mastex-primary, #0f2d5c);
}

.mastex-card__title a {
	color: inherit;
	text-decoration: none;
}

.mastex-card__title a:hover,
.mastex-card__title a:focus-visible {
	text-decoration: underline;
	text-underline-offset: 3px;
}

.mastex-card__date {
	margin: 0;
	font-size: 14px;
	font-weight: 700;
	color: var(--mastex-accent, #f7941d);
}

.mastex-card__excerpt {
	margin: 4px 0 0;
	font-size: 15px;
	line-height: 1.55;
	color: var(--mastex-text);
}

.mastex-card__link {
	padding-top: 8px;
	align-self: flex-start;
	text-decoration: none;
	font-weight: 600;
	color: var(--mastex-primary, #0f2d5c);
	font-size: 14px;
	display: inline-flex;
	gap: 6px;
	align-items: center;
	transition: gap 0.15s ease;
}

.mastex-card__link:hover,
.mastex-card__link:focus-visible {
	gap: 10px;
}

/* ---------- Pagination ---------- */
.mastex-search__pagination {
	display: flex;
	flex-wrap: wrap;
	gap: 6px;
	justify-content: center;
	margin-top: 40px;
}

.mastex-search__page {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-width: 40px;
	height: 40px;
	padding: 0 14px;
	border-radius: 8px;
	background: #fff;
	color: var(--mastex-primary, #0f2d5c);
	text-decoration: none;
	font-weight: 600;
	font-size: 14px;
	border: 1px solid var(--mastex-border);
	transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.mastex-search__page:hover {
	border-color: var(--mastex-primary, #0f2d5c);
}

.mastex-search__page.is-active {
	background: var(--mastex-primary, #0f2d5c);
	color: #fff;
	border-color: var(--mastex-primary, #0f2d5c);
}

.mastex-search__page--gap {
	border: 0;
	background: transparent;
	color: var(--mastex-muted);
}

.mastex-search__page--nav {
	padding: 0 16px;
}

/* ---------- Empty / intro ---------- */
.mastex-search__intro,
.mastex-search__empty {
	text-align: center;
	padding: 48px 24px;
	color: var(--mastex-text);
}

.mastex-search__empty-icon {
	width: 72px;
	height: 72px;
	color: var(--mastex-primary, #0f2d5c);
	opacity: 0.7;
	margin-bottom: 14px;
}

.mastex-search__empty-title {
	font-size: 24px;
	color: var(--mastex-primary, #0f2d5c);
	margin: 0 0 8px;
	font-weight: 700;
}

.mastex-search__empty-text {
	margin: 0 auto;
	max-width: 480px;
	font-size: 15px;
	line-height: 1.55;
}

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