/**
 * Post grid
 *
 * Column count comes from three custom properties set inline by the widget
 * (`--fast-pg-cols`, `--fast-pg-cols-tablet`, `--fast-pg-cols-mobile`), so a
 * three column desktop grid costs nothing on a phone. A `repeat()` fallback
 * value keeps the layout intact if the inline block is ever missing.
 */

.fast-post-grid {
	--fast-pg-cols: 3;
	--fast-pg-cols-tablet: 2;
	--fast-pg-cols-mobile: 1;
	--fast-pg-gap: 24px;
	--fast-pg-radius: 12px;
	--fast-pg-padding: 20px;
	--fast-pg-shadow: 0 1px 2px rgba(16, 24, 40, 0.06), 0 1px 3px rgba(16, 24, 40, 0.1);
	--fast-pg-shadow-hover: 0 12px 24px rgba(16, 24, 40, 0.12);
	--fast-pg-lift: -4px;
	--fast-pg-zoom: 1.06;
	--fast-pg-card-bg: #fff;
	--fast-pg-title-color: inherit;
	--fast-pg-excerpt-color: #667085;
	--fast-pg-meta-color: #98a2b3;
	--fast-pg-badge-bg: #eef2ff;
	--fast-pg-badge-color: #4338ca;
	--fast-pg-button-bg: #4338ca;
	--fast-pg-button-color: #fff;
	--fast-pg-transition: 0.25s cubic-bezier(0.2, 0, 0.2, 1);
}

.fast-post-grid__grid,
.fast-pg__grid {
	display: grid;
	grid-template-columns: repeat(var(--fast-pg-cols, 3), minmax(0, 1fr));
	gap: var(--fast-pg-gap);
	list-style: none;
	margin: 0;
	padding: 0;
}

/**
 * Cards.
 *
 * `min-width: 0` stops a long unbroken word from blowing out the track,
 * which is the classic grid overflow bug.
 */
.fast-post-card {
	position: relative;
	display: flex;
	flex-direction: column;
	min-width: 0;
	background: var(--fast-pg-card-bg);
	border-radius: var(--fast-pg-radius);
	overflow: hidden;
	box-shadow: var(--fast-pg-shadow);
	transition: transform var(--fast-pg-transition),
		box-shadow var(--fast-pg-transition);
}

@media (hover: hover) {
	.fast-post-card:hover {
		transform: translateY(var(--fast-pg-lift));
		box-shadow: var(--fast-pg-shadow-hover);
	}
}

/**
 * The whole card is clickable, but only through real anchors. A pseudo
 * element overlay would swallow text selection inside the excerpt.
 */
.fast-post-card__media {
	display: block;
	overflow: hidden;
	background: #f2f4f7;
}

.fast-post-card__image {
	display: block;
	width: 100%;
	height: auto;
	transition: transform var(--fast-pg-transition);
}

@media (hover: hover) {
	.fast-post-card:hover .fast-post-card__image {
		transform: scale(var(--fast-pg-zoom));
	}
}

.fast-post-card__body {
	display: flex;
	flex: 1 1 auto;
	flex-direction: column;
	gap: 10px;
	padding: var(--fast-pg-padding);
}

.fast-post-card__title {
	margin: 0;
	font-size: var(--fast-pg-title-size, 1.125rem);
	line-height: 1.35;
	color: var(--fast-pg-title-color);
}

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

.fast-post-card__title a:focus-visible {
	outline: 2px solid currentColor;
	outline-offset: 3px;
}

.fast-post-card__excerpt {
	margin: 0;
	font-size: var(--fast-pg-excerpt-size, 0.9375rem);
	line-height: 1.6;
	color: var(--fast-pg-excerpt-color);
}

.fast-post-card__meta {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 6px;
	font-size: 0.8125rem;
	color: var(--fast-pg-meta-color);
}

.fast-post-card__meta-sep {
	opacity: 0.55;
}
.fast-post-card__meta-item {
	white-space: nowrap;
}
.fast-post-card__badges {
	display: flex;
	flex-wrap: wrap;
	gap: 6px;
	padding: 12px var(--fast-pg-padding) 0;
}

.fast-post-card__badge {
	display: inline-block;
	padding: 3px 9px;
	border-radius: 999px;
	background: var(--fast-pg-badge-bg);
	color: var(--fast-pg-badge-color);
	font-size: 0.75rem;
	font-weight: 600;
	line-height: 1.5;
	text-decoration: none;
}

.fast-post-card__button {
	display: inline-flex;
	align-items: center;
	align-self: flex-start;
	gap: 6px;
	margin-top: auto;
	padding: 9px 16px;
	border-radius: calc(var(--fast-pg-radius) / 2);
	background: var(--fast-pg-button-bg);
	color: var(--fast-pg-button-color);
	font-size: 0.875rem;
	font-weight: 600;
	text-decoration: none;
	transition: opacity var(--fast-pg-transition);
}

@media (hover: hover) {
	.fast-post-card__button:hover {
		opacity: 0.9;
	}
}

.fast-post-card__button:focus-visible {
	outline: 2px solid currentColor;
	outline-offset: 2px;
}

.fast-pg__pagination {
	display: flex;
	justify-content: center;
	margin-top: calc(var(--fast-pg-gap) * 1.5);
}

.fast-pg__pagination .page-numbers {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-width: 40px;
	height: 40px;
	margin: 0 4px;
	padding: 0 12px;
	border-radius: 8px;
	background: var(--fast-pg-card-bg);
	color: inherit;
	text-decoration: none;
}

.fast-pg__pagination .current {
	background: var(--fast-pg-button-bg);
	color: var(--fast-pg-button-color);
}

.fast-pg__load-more {
	display: inline-flex;
	align-items: center;
	gap: 8px;
	padding: 11px 26px;
	border: 0;
	border-radius: 999px;
	background: var(--fast-pg-button-bg);
	color: var(--fast-pg-button-color);
	font: inherit;
	font-size: 0.9375rem;
	font-weight: 600;
	cursor: pointer;
	transition: opacity var(--fast-pg-transition);
}

.fast-pg__load-more:hover {
	opacity: 0.92;
}

.fast-pg__load-more:focus-visible {
	outline: 2px solid currentColor;
	outline-offset: 2px;
}

/**
 * Busy state.
 *
 * `cursor: progress` plus a dimmed look gives the feedback without needing a
 * spinner element in the markup.
 */
.fast-pg__load-more.is-loading {
	opacity: 0.7;
	cursor: progress;
	pointer-events: none;
}

.fast-pg__empty {
	grid-column: 1 / -1;
	margin: 0;
	padding: 32px;
	text-align: center;
	color: var(--fast-pg-meta-color);
}

/**
 * Entry animation for cards added over AJAX.
 *
 * The class is removed on `animationend`, so this runs once per card and
 * cannot replay later.
 */
@keyframes fast-pg-enter {
	from {
		opacity: 0;
		transform: translateY(10px);
	}

	to {
		opacity: 1;
		transform: none;
	}
}

.fast-post-card.is-appended {
	animation: fast-pg-enter 0.35s cubic-bezier(0.2, 0, 0.2, 1) both;
}

@media (prefers-reduced-motion: reduce) {
	.fast-post-card,
	.fast-post-card__image,
	.fast-post-card__button,
	.fast-pg__load-more {
		transition-duration: 0.01ms;
	}

	.fast-post-card:hover {
		transform: none;
	}

	.fast-post-card.is-appended {
		animation: none;
	}
}

/* Breakpoints match the Elementor defaults rather than hardcoding device
   widths, so the control values in the panel are the single source of truth. */
@media (max-width: 1024px) {
	.fast-pg__grid {
		grid-template-columns: repeat(var(--fast-pg-cols-tablet, 2), minmax(0, 1fr));
	}
}

@media (max-width: 767px) {
	.fast-pg__grid {
		grid-template-columns: repeat(var(--fast-pg-cols-mobile, 1), minmax(0, 1fr));
	}
}

.fast-post-grid--list .fast-pg__grid,
.fast-post-grid--classic .fast-pg__grid {
	grid-template-columns: 1fr;
}

.fast-post-grid--list .fast-post-card,
.fast-post-grid--compact .fast-post-card {
	flex-direction: row;
	align-items: stretch;
}

.fast-post-grid--list .fast-post-card__media {
	flex: 0 0 36%;
	max-width: 280px;
}

.fast-post-grid--list .fast-post-card__image,
.fast-post-grid--compact .fast-post-card__image,
.fast-post-grid--overlay .fast-post-card__image,
.fast-post-grid--mosaic .fast-post-card--featured .fast-post-card__image {
	height: 100%;
	object-fit: cover;
}

.fast-post-grid--list .fast-post-card__badges {
	position: absolute;
	top: 12px;
	left: 12px;
	padding: 0;
	z-index: 1;
}

.fast-post-grid--classic .fast-post-card__title {
	font-size: 1.5rem;
}

.fast-post-grid--classic .fast-post-card__image {
	width: 100%;
	max-height: 420px;
	object-fit: cover;
}

.fast-post-grid--magazine .fast-post-card--featured {
	grid-column: 1 / -1;
	display: grid;
	grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr);
	grid-template-areas: "media body";
}

.fast-post-grid--magazine .fast-post-card--featured .fast-post-card__media {
	grid-area: media;
	min-height: 280px;
}

.fast-post-grid--magazine .fast-post-card--featured .fast-post-card__body {
	grid-area: body;
	justify-content: center;
}

.fast-post-grid--magazine .fast-post-card--featured .fast-post-card__badges {
	position: absolute;
	top: 12px;
	left: 12px;
	z-index: 1;
	padding: 0;
}

.fast-post-grid--magazine .fast-post-card--featured .fast-post-card__image {
	height: 100%;
	object-fit: cover;
}

.fast-post-grid--magazine .fast-post-card--featured .fast-post-card__title {
	font-size: 1.75rem;
}

.fast-post-grid--overlay .fast-post-card {
	min-height: 280px;
	color: #fff;
}

.fast-post-grid--overlay .fast-post-card__media,
.fast-post-grid--overlay .fast-post-card__media--empty {
	position: absolute;
	inset: 0;
}

.fast-post-grid--overlay .fast-post-card__media--empty {
	background: #1f2937;
}

.fast-post-grid--overlay .fast-post-card__image {
	width: 100%;
}

.fast-post-grid--overlay .fast-post-card__badges {
	position: absolute;
	top: 12px;
	left: 12px;
	z-index: 2;
	padding: 0;
}

.fast-post-grid--overlay .fast-post-card__body {
	position: relative;
	z-index: 1;
	margin-top: auto;
	color: #fff;
	background: linear-gradient(180deg, transparent, rgba(15, 23, 42, 0.82));
}

.fast-post-grid--overlay .fast-post-card__title,
.fast-post-grid--overlay .fast-post-card__excerpt,
.fast-post-grid--overlay .fast-post-card__meta {
	color: #fff;
}

.fast-post-grid--overlay .fast-post-card__button {
	background: #fff;
	color: #111827;
}

.fast-post-grid--compact .fast-post-card {
	box-shadow: none;
	border-radius: 0;
	border-bottom: 1px solid #eaecf0;
	background: transparent;
}

.fast-post-grid--compact .fast-post-card:hover {
	transform: none;
	box-shadow: none;
}

.fast-post-grid--compact .fast-post-card__media {
	flex: 0 0 96px;
	max-width: 96px;
}

.fast-post-grid--compact .fast-post-card__body {
	padding: 10px 4px 10px 14px;
}

.fast-post-grid--compact .fast-post-card__title {
	font-size: 1rem;
}

.fast-post-grid--compact .fast-post-card__excerpt,
.fast-post-grid--compact .fast-post-card__button,
.fast-post-grid--compact .fast-post-card__badges {
	display: none;
}

.fast-post-grid--mosaic .fast-post-card--featured {
	grid-column: span 2;
	grid-row: span 2;
}

.fast-post-grid--mosaic .fast-post-card--featured .fast-post-card__media {
	flex: 1 1 auto;
	min-height: 0;
}

.fast-post-grid--mosaic .fast-post-card--featured .fast-post-card__title {
	font-size: 1.5rem;
}

@media (max-width: 767px) {
	.fast-post-grid--list .fast-post-card,
	.fast-post-grid--compact .fast-post-card,
	.fast-post-grid--magazine .fast-post-card--featured {
		display: flex;
		flex-direction: column;
		grid-template-columns: 1fr;
	}

	.fast-post-grid--list .fast-post-card__media,
	.fast-post-grid--compact .fast-post-card__media {
		flex: none;
		max-width: none;
	}

	.fast-post-grid--mosaic .fast-post-card--featured {
		grid-column: auto;
		grid-row: auto;
	}
}

.fast-post-grid--equal .fast-pg__grid {
	align-items: stretch;
}

.fast-post-grid--equal .fast-post-card {
	height: 100%;
}

.fast-post-grid--ratio .fast-post-card__media,
.fast-post-grid--ratio .fast-post-card__media--empty {
	position: relative;
	display: block;
	aspect-ratio: var(--fast-pg-image-ratio, 16 / 9);
	height: auto;
	min-height: 0;
	overflow: hidden;
	background: #eef0f3;
}

.fast-post-grid--ratio .fast-post-card__image {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	max-height: none;
	object-fit: var(--fast-pg-image-fit, cover);
	object-position: var(--fast-pg-image-pos, center);
}

.fast-post-grid--overlay.fast-post-grid--ratio .fast-post-card {
	aspect-ratio: var(--fast-pg-image-ratio, 16 / 9);
	min-height: 0;
}

.fast-post-grid--overlay.fast-post-grid--ratio .fast-post-card__media,
.fast-post-grid--overlay.fast-post-grid--ratio .fast-post-card__media--empty {
	position: absolute;
	inset: 0;
	aspect-ratio: auto;
	height: 100%;
}

.fast-post-grid--list.fast-post-grid--ratio .fast-post-card__media,
.fast-post-grid--compact.fast-post-grid--ratio .fast-post-card__media {
	align-self: stretch;
}
