/* =====================================================================
   MM Blog Grid  ·  v1.1.0
   Change the tokens in .mm-bg below to re-skin the whole module.
   ===================================================================== */

.mm-bg {
	/* Brand tokens ---------------------------------------------------- */
	--mm-ink: #1e3327;          /* headings, active pill, dark UI          */
	--mm-ink-soft: #3d5145;     /* body copy                               */
	--mm-muted: #6d7a71;        /* meta, counts                            */
	--mm-accent: #74bf6e;       /* category tag + focus ring               */
	--mm-surface: #ffffff;      /* card + input background                 */
	--mm-line: #e3e0d6;         /* hairlines and borders                   */
	--mm-shadow: 0 1px 2px rgba(30, 51, 39, .05), 0 12px 28px -18px rgba(30, 51, 39, .35);
	--mm-shadow-lift: 0 2px 4px rgba(30, 51, 39, .06), 0 26px 48px -24px rgba(30, 51, 39, .45);

	/* Layout tokens --------------------------------------------------- */
	--mm-cols: 3;
	--mm-gap: 30px;
	--mm-radius: 20px;
	--mm-radius-sm: 999px;
	--mm-ratio: 16 / 10;
	--mm-title-lines: 3;
	--mm-title-lh: 1.32;

	color: var(--mm-ink-soft);
	font-family: inherit;
	max-width: 1220px;
	margin-inline: auto;
	width: 100%;
	-webkit-font-smoothing: antialiased;
}

.mm-bg *,
.mm-bg *::before,
.mm-bg *::after {
	box-sizing: border-box;
}

.mm-bg__sr {
	position: absolute !important;
	width: 1px;
	height: 1px;
	padding: 0;
	margin: -1px;
	overflow: hidden;
	clip: rect(0 0 0 0);
	white-space: nowrap;
	border: 0;
}

/* ---------------------------------------------------------------------
   Control bar: search + category filters
   ------------------------------------------------------------------ */

.mm-bg__controls {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	justify-content: space-between;
	gap: 18px 24px;
	padding-bottom: 22px;
	border-bottom: 1px solid var(--mm-line);
}

.mm-bg__search {
	position: relative;
	flex: 0 1 340px;
	min-width: 240px;
}

.mm-bg .mm-bg__input {
	width: 100%;
	height: 52px;
	padding: 0 44px 0 46px;
	font: inherit;
	font-size: 15px;
	line-height: 52px;
	color: var(--mm-ink);
	background: var(--mm-surface);
	border: 1px solid var(--mm-line);
	border-radius: var(--mm-radius-sm);
	box-shadow: none;
	transition: border-color .2s ease, box-shadow .2s ease;
	appearance: none;
	-webkit-appearance: none;
}

.mm-bg .mm-bg__input::placeholder {
	color: var(--mm-muted);
	opacity: 1;
}

.mm-bg .mm-bg__input:focus,
.mm-bg .mm-bg__input:focus-visible {
	outline: none;
	border-color: var(--mm-accent);
	box-shadow: 0 0 0 4px rgba(116, 191, 110, .22);
}

.mm-bg__input::-webkit-search-cancel-button {
	display: none;
}

.mm-bg__search-icon {
	position: absolute;
	left: 17px;
	top: 50%;
	width: 19px;
	height: 19px;
	transform: translateY(-50%);
	fill: none;
	stroke: var(--mm-muted);
	stroke-width: 1.8;
	stroke-linecap: round;
	pointer-events: none;
}

.mm-bg .mm-bg__clear {
	position: absolute;
	right: 8px;
	top: 50%;
	transform: translateY(-50%);
	display: grid;
	place-items: center;
	width: 34px;
	height: 34px;
	padding: 0;
	background: transparent;
	border: 0;
	border-radius: 50%;
	cursor: pointer;
	transition: background-color .18s ease;
}

.mm-bg .mm-bg__clear:hover {
	background: rgba(30, 51, 39, .07);
}

.mm-bg__clear[hidden] {
	display: none;
}

.mm-bg__clear svg {
	width: 15px;
	height: 15px;
	fill: none;
	stroke: var(--mm-ink);
	stroke-width: 2;
	stroke-linecap: round;
}

.mm-bg__filters {
	display: flex;
	flex-wrap: wrap;
	gap: 10px;
	flex: 1 1 auto;
	justify-content: flex-end;
}

.mm-bg .mm-bg__pill {
	display: inline-flex;
	align-items: center;
	gap: 8px;
	height: 42px;
	padding: 0 18px;
	font: inherit;
	font-size: 14px;
	font-weight: 500;
	color: var(--mm-ink);
	background: transparent;
	border: 1px solid var(--mm-line);
	border-radius: var(--mm-radius-sm);
	cursor: pointer;
	white-space: nowrap;
	transition: background-color .2s ease, color .2s ease, border-color .2s ease, transform .2s ease;
}

.mm-bg .mm-bg__pill:hover {
	border-color: var(--mm-ink);
	transform: translateY(-1px);
}

.mm-bg .mm-bg__pill.is-active {
	background: var(--mm-ink);
	border-color: var(--mm-ink);
	color: #fff;
}

.mm-bg .mm-bg__pill:focus-visible {
	outline: 2px solid var(--mm-accent);
	outline-offset: 2px;
}

.mm-bg__pill-count {
	font-size: 12px;
	font-weight: 500;
	color: var(--mm-muted);
	transition: color .2s ease;
}

.mm-bg__pill.is-active .mm-bg__pill-count {
	color: rgba(255, 255, 255, .68);
}

/* ---------------------------------------------------------------------
   Status line
   ------------------------------------------------------------------ */

.mm-bg .mm-bg__status {
	margin: 18px 0 26px;
	font-size: 14px;
	color: var(--mm-muted);
	min-height: 1.4em;
}

/* ---------------------------------------------------------------------
   Grid
   ------------------------------------------------------------------ */

.mm-bg__grid {
	display: grid;
	grid-template-columns: repeat(var(--mm-cols), minmax(0, 1fr));
	gap: var(--mm-gap);
	align-items: stretch;
	/* Holds the page height steady while a new query loads. */
	transition: min-height .25s ease;
}

/* ---------------------------------------------------------------------
   Card
   ------------------------------------------------------------------ */

.mm-bg .mm-card {
	position: relative;
	display: flex;
	flex-direction: column;
	height: 100%;
	background: var(--mm-surface);
	border: 1px solid var(--mm-line);
	border-radius: var(--mm-radius);
	box-shadow: var(--mm-shadow);
	overflow: hidden;
	transition: transform .28s cubic-bezier(.2, .7, .3, 1), box-shadow .28s ease, border-color .28s ease;
}

.mm-bg .mm-card:hover {
	transform: translateY(-5px);
	box-shadow: var(--mm-shadow-lift);
	border-color: rgba(30, 51, 39, .16);
}

.mm-card__link {
	position: absolute;
	inset: 0;
	z-index: 2;
	border-radius: inherit;
	text-decoration: none;
}

.mm-card__link:focus-visible {
	outline: 3px solid var(--mm-accent);
	outline-offset: 3px;
}

.mm-card__media {
	position: relative;
	aspect-ratio: var(--mm-ratio);
	overflow: hidden;
	background: linear-gradient(135deg, #eef1ec 0%, #dfe6df 100%);
}

.mm-bg .mm-card__media .mm-card__img {
	width: 100%;
	height: 100%;
	object-fit: cover;
	display: block;
	margin: 0;
	border-radius: 0;
	transition: transform .5s cubic-bezier(.2, .7, .3, 1);
}

.mm-bg .mm-card:hover .mm-card__img {
	transform: scale(1.045);
}

.mm-card__placeholder {
	position: absolute;
	inset: 0;
	display: grid;
	place-items: center;
	font-size: 54px;
	font-weight: 600;
	color: rgba(30, 51, 39, .18);
}

.mm-card__tag {
	position: absolute;
	left: 14px;
	bottom: 14px;
	z-index: 1;
	display: inline-block;
	max-width: calc(100% - 28px);
	padding: 6px 13px;
	font-size: 12.5px;
	font-weight: 500;
	line-height: 1.35;
	color: var(--mm-ink);
	background: rgba(255, 255, 255, .93);
	backdrop-filter: blur(6px);
	-webkit-backdrop-filter: blur(6px);
	border-radius: var(--mm-radius-sm);
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.mm-card__body {
	display: flex;
	flex-direction: column;
	flex: 1 1 auto;
	padding: 24px 24px 20px;
	min-width: 0;
}

/*
 * Title clamp is written defensively: themes often re-declare `display` on
 * headings, which silently kills -webkit-line-clamp and lets a third line
 * spill over the excerpt. The max-height + overflow pair keeps the box honest
 * even if the clamp is overridden.
 */
.mm-bg .mm-card .mm-card__title {
	display: -webkit-box !important;
	-webkit-box-orient: vertical;
	-webkit-line-clamp: var(--mm-title-lines);
	line-clamp: var(--mm-title-lines);
	overflow: hidden;
	margin: 0 0 10px;
	padding: 0;
	font-size: 20px;
	line-height: var(--mm-title-lh);
	font-weight: 600;
	color: var(--mm-ink);
	letter-spacing: normal;
	overflow-wrap: break-word;
	word-break: break-word;
	hyphens: auto;
	min-height: calc(2 * var(--mm-title-lh) * 1em);
	max-height: calc(var(--mm-title-lines) * var(--mm-title-lh) * 1em);
	transition: color .2s ease;
}

.mm-bg .mm-card:hover .mm-card__title {
	color: #16261d;
}

.mm-bg .mm-card .mm-card__excerpt {
	display: -webkit-box !important;
	-webkit-box-orient: vertical;
	-webkit-line-clamp: 3;
	line-clamp: 3;
	overflow: hidden;
	margin: 0 0 20px;
	padding: 0;
	font-size: 15px;
	line-height: 1.62;
	color: var(--mm-ink-soft);
	max-height: calc(3 * 1.62em);
	overflow-wrap: break-word;
}

.mm-card__meta {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 12px;
	margin-top: auto;
	padding-top: 16px;
	border-top: 1px solid var(--mm-line);
	font-size: 13px;
	color: var(--mm-muted);
}

/* Entrance — cards fade in once, staggered by JS. */
.mm-card.mm-card--enter {
	opacity: 0;
	transform: translateY(14px);
}

.mm-card.mm-card--in {
	opacity: 1;
	transform: none;
	transition: opacity .45s ease, transform .45s cubic-bezier(.2, .7, .3, 1),
		box-shadow .28s ease, border-color .28s ease;
}

/* ---------------------------------------------------------------------
   Skeletons
   ------------------------------------------------------------------ */

.mm-skeleton {
	border: 1px solid var(--mm-line);
	border-radius: var(--mm-radius);
	background: var(--mm-surface);
	overflow: hidden;
	box-shadow: var(--mm-shadow);
}

.mm-skeleton__media {
	aspect-ratio: var(--mm-ratio);
}

.mm-skeleton__body {
	padding: 24px;
}

.mm-skeleton__line {
	height: 13px;
	border-radius: 7px;
	margin-bottom: 12px;
}

.mm-skeleton__line:nth-child(1) { width: 85%; height: 18px; }
.mm-skeleton__line:nth-child(2) { width: 62%; height: 18px; margin-bottom: 20px; }
.mm-skeleton__line:nth-child(3) { width: 100%; }
.mm-skeleton__line:nth-child(4) { width: 92%; }
.mm-skeleton__line:nth-child(5) { width: 45%; margin-bottom: 0; }

.mm-skeleton__media,
.mm-skeleton__line {
	background: linear-gradient(90deg, #eeece6 25%, #f7f6f2 37%, #eeece6 63%);
	background-size: 400% 100%;
	animation: mm-shimmer 1.35s ease-in-out infinite;
}

@keyframes mm-shimmer {
	0%   { background-position: 100% 50%; }
	100% { background-position: 0 50%; }
}

/* ---------------------------------------------------------------------
   Empty state, notice, footer
   ------------------------------------------------------------------ */

.mm-bg__empty {
	grid-column: 1 / -1;
	display: grid;
	place-items: center;
	min-height: 280px;
	padding: 48px 28px;
	text-align: center;
	background: var(--mm-surface);
	border: 1px dashed var(--mm-line);
	border-radius: var(--mm-radius);
}

.mm-bg .mm-bg__empty p {
	margin: 0;
	font-size: 16px;
	color: var(--mm-muted);
	max-width: 46ch;
}

.mm-bg__foot {
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 14px;
	margin-top: 44px;
}

.mm-bg .mm-bg__notice {
	margin: 0;
	font-size: 14px;
	color: #a2412f;
}

.mm-bg__notice[hidden] {
	display: none;
}

.mm-bg .mm-bg__more {
	display: inline-flex;
	align-items: center;
	gap: 10px;
	height: 52px;
	padding: 0 34px;
	font: inherit;
	font-size: 15px;
	font-weight: 500;
	color: #fff;
	background: var(--mm-ink);
	border: 1px solid var(--mm-ink);
	border-radius: var(--mm-radius-sm);
	cursor: pointer;
	transition: background-color .22s ease, transform .22s ease, opacity .22s ease;
}

.mm-bg .mm-bg__more:hover {
	background: #16261d;
	transform: translateY(-2px);
}

.mm-bg .mm-bg__more:focus-visible {
	outline: 2px solid var(--mm-accent);
	outline-offset: 3px;
}

.mm-bg .mm-bg__more[disabled] {
	opacity: .6;
	cursor: default;
	transform: none;
}

.mm-bg__more[hidden] {
	display: none;
}

.mm-bg__spinner {
	display: none;
	width: 16px;
	height: 16px;
	border: 2px solid rgba(255, 255, 255, .35);
	border-top-color: #fff;
	border-radius: 50%;
	animation: mm-spin .7s linear infinite;
}

.mm-bg__more.is-loading .mm-bg__spinner {
	display: block;
}

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

/* ---------------------------------------------------------------------
   Responsive
   ------------------------------------------------------------------ */

@media (max-width: 1024px) {
	.mm-bg {
		--mm-cols: 2;
		--mm-gap: 24px;
	}

	.mm-bg__controls {
		flex-direction: column;
		align-items: stretch;
	}

	.mm-bg__search {
		flex: 1 1 auto;
	}

	.mm-bg__filters {
		justify-content: flex-start;
	}
}

@media (max-width: 782px) {
	.mm-bg__filters {
		flex-wrap: nowrap;
		overflow-x: auto;
		padding-bottom: 4px;
		margin-inline: -4px;
		padding-inline: 4px;
		scrollbar-width: none;
		-webkit-overflow-scrolling: touch;
	}

	.mm-bg__filters::-webkit-scrollbar {
		display: none;
	}
}

@media (max-width: 600px) {
	.mm-bg {
		--mm-cols: 1;
		--mm-gap: 20px;
		--mm-radius: 18px;
	}

	.mm-bg .mm-bg__status {
		margin: 16px 0 20px;
	}

	.mm-card__body {
		padding: 20px 20px 18px;
	}

	.mm-bg .mm-card .mm-card__title {
		font-size: 18px;
	}

	.mm-bg__foot {
		margin-top: 34px;
	}

	.mm-bg .mm-bg__more {
		width: 100%;
		justify-content: center;
	}
}

/* ---------------------------------------------------------------------
   Motion preferences
   ------------------------------------------------------------------ */

@media (prefers-reduced-motion: reduce) {
	.mm-bg *,
	.mm-bg *::before,
	.mm-bg *::after {
		animation-duration: .01ms !important;
		animation-iteration-count: 1 !important;
		transition-duration: .01ms !important;
	}

	.mm-card.mm-card--enter {
		opacity: 1;
		transform: none;
	}
}
