/**
 * Case studies index grid.
 *
 * Ported from the <style> block that lived inside a Divi code module on
 * /case-studies/. Class names are unchanged so that any stray rule elsewhere on
 * the site still matches.
 *
 * Everything an editor can change arrives as a custom property set inline on
 * .cpg-wrapper, so this file is static and cacheable. The fallbacks after each
 * var() are the original hardcoded values.
 */

.cpg-wrapper {
	position: relative;
}

/*
 * The original alternated one full-width card with two half-width cards
 * (rowPattern = [1, 2]) using flex rows. A uniform grid replaces it, and the
 * column count is now a setting.
 */
.cpg-grid {
	display: grid;
	grid-template-columns: repeat(var(--cpg-columns, 2), minmax(0, 1fr));
	gap: var(--cpg-gap, 24px);
}

.cpg-card {
	display: block;
	overflow: hidden;
	border-radius: var(--cpg-radius, 8px);
	text-decoration: none;
	color: inherit;
	min-width: 0;
}

/*
 * The fix for the cropped hero images.
 *
 * The original gave this box a fixed height — 420px on the large card, 260px on
 * the small ones. In a two-column row a card is roughly 538px wide, so a 260px
 * box is about 2.07:1 while the photos are about 1.5:1, and background-size:
 * cover then cut roughly 30% off the top and bottom. On the SeePort hero that
 * kept the fireworks and lost the stage and the crowd.
 *
 * Sizing by ratio instead means the height follows the width, so at the default
 * 3 / 2 — the exact ratio of half the hero images and the median of all of them
 * — nothing is cropped at any viewport width.
 */
.cpg-image {
	position: relative;
	width: 100%;
	aspect-ratio: var(--cpg-ratio, 3 / 2);
	border-radius: var(--cpg-radius, 8px);
	background-color: var(--cpg-placeholder-bg, #eee);
	overflow: hidden;
}

.cpg-image__img {
	display: block;
	width: 100%;
	height: 100%;
	object-fit: var(--cpg-fit, cover);
	object-position: center;
}

.cpg-content {
	padding: 16px 4px;
}

.cpg-date {
	font-size: 13px;
	color: var(--cpg-date-color, #888);
	text-transform: uppercase;
	letter-spacing: 0.5px;
}

/*
 * The title had no colour of its own and inherited whatever the surrounding
 * Divi section gave it, which on this page was #333 on a near-black background
 * — 1.54:1, unreadable. It is an explicit setting now.
 */
.cpg-title {
	font-size: 22px;
	margin: 6px 0;
	line-height: 1.3;
	color: var(--cpg-title-color, inherit);
}

.cpg-excerpt {
	font-size: 15px;
	color: var(--cpg-excerpt-color, #555);
}

/* Single column on phones regardless of the column setting. */
@media (max-width: 767px) {
	.cpg-grid {
		grid-template-columns: minmax(0, 1fr);
	}

	.cpg-title {
		font-size: 18px;
	}
}

/* -------------------------------------------------------------------------
 * Pagination
 * ---------------------------------------------------------------------- */

.cpg-pagination {
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 18px;
	margin-top: 32px;
	flex-wrap: wrap;
}

.cpg-page-btn {
	display: inline-block;
	background: var(--cpg-accent, #f15a22);
	color: var(--cpg-accent-text, #fff);
	border: none;
	border-radius: 0;
	padding: 12px 26px;
	font-size: 15px;
	font-weight: 600;
	letter-spacing: 0.3px;
	text-decoration: none;
	cursor: pointer;
	transition: opacity 0.2s ease, background 0.2s ease;
}

/*
 * The original used <button disabled>. These are links now, so that paging
 * works without JavaScript, and the unavailable state is a <span>.
 */
.cpg-page-btn:hover {
	opacity: 0.88;
	color: var(--cpg-accent-text, #fff);
}

.cpg-page-btn[aria-disabled="true"] {
	background: var(--cpg-disabled-bg, #ececec);
	color: var(--cpg-disabled-text, #b0b0b0);
	cursor: default;
	opacity: 1;
}

.cpg-page-info {
	font-size: 14px;
	color: var(--cpg-date-color, #888);
	min-width: 96px;
	text-align: center;
	text-transform: uppercase;
	letter-spacing: 0.5px;
}

/* -------------------------------------------------------------------------
 * Loading state
 * ---------------------------------------------------------------------- */

.cpg-wrapper.cpg-is-loading .cpg-grid {
	opacity: 0.3;
	pointer-events: none;
	transition: opacity 0.2s ease;
}

.cpg-loading-overlay {
	position: absolute;
	inset: 0;
	display: flex;
	align-items: center;
	justify-content: center;
	z-index: 10;
}

.cpg-spinner {
	width: 46px;
	height: 46px;
	border: 4px solid rgba(241, 90, 34, 0.25);
	border-top-color: var(--cpg-accent, #f15a22);
	border-radius: 50%;
	animation: cpg-spin 0.7s linear infinite;
}

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

@media (prefers-reduced-motion: reduce) {
	.cpg-spinner {
		animation-duration: 2.4s;
	}

	.cpg-page-btn {
		transition: none;
	}
}
