/**
 * Case Studies front-end styles.
 *
 * @package SH_Case_Studies
 */

.sh-cs {
	/* Sampled from the reference design; override here to use exact brand values. */
	--sh-cs-color-1: #00785f;
	--sh-cs-color-2: #0e6486;
	--sh-cs-color-3: #0b3b6b;
	--sh-cs-radius: 8px;
	--sh-cs-gap: 30px;

	box-sizing: border-box;
	width: 100%;
}

.sh-cs *,
.sh-cs *::before,
.sh-cs *::after {
	box-sizing: inherit;
}

/* -------------------------------------------------------------------------
 * Search
 * ---------------------------------------------------------------------- */

.sh-cs__search {
	margin: 0 0 var(--sh-cs-gap);
}

.sh-cs__search-field {
	position: relative;
	max-width: 720px;
	margin: 0 auto;
}

.sh-cs__search-icon {
	position: absolute;
	top: 50%;
	left: 16px;
	width: 20px;
	height: 20px;
	transform: translateY(-50%);
	color: #6b7280;
	pointer-events: none;
}

.sh-cs__search-input {
	width: 100%;
	margin: 0;
	padding: 14px 46px 14px 46px;
	border: 1px solid #d1d5db;
	border-radius: 999px;
	background: #fff;
	color: #111827;
	font-size: 16px;
	line-height: 1.4;
	transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.sh-cs__search-input:focus {
	border-color: var(--sh-cs-color-2);
	box-shadow: 0 0 0 3px rgba(10, 106, 145, 0.15);
	outline: none;
}

.sh-cs__search-input::-webkit-search-cancel-button {
	cursor: pointer;
}

/* Spinner shown inside the field while a search request is in flight. */
.sh-cs__search-spinner {
	position: absolute;
	top: 50%;
	right: 16px;
	display: none;
	width: 18px;
	height: 18px;
	margin-top: -9px;
	border: 2px solid #d1d5db;
	border-top-color: var(--sh-cs-color-2);
	border-radius: 50%;
	animation: sh-cs-spin 0.7s linear infinite;
}

.sh-cs.is-searching .sh-cs__search-spinner {
	display: block;
}

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

.sh-cs__grid {
	display: grid;
	grid-template-columns: repeat(3, minmax(0, 1fr));
	gap: var(--sh-cs-gap);
	align-items: stretch;
}

.sh-cs__grid--cols-1 { grid-template-columns: minmax(0, 1fr); }
.sh-cs__grid--cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.sh-cs__grid--cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }

@media (max-width: 980px) {
	.sh-cs__grid,
	.sh-cs__grid--cols-3,
	.sh-cs__grid--cols-4 {
		grid-template-columns: repeat(2, minmax(0, 1fr));
	}
}

@media (max-width: 640px) {
	.sh-cs__grid,
	.sh-cs__grid--cols-2,
	.sh-cs__grid--cols-3,
	.sh-cs__grid--cols-4 {
		grid-template-columns: minmax(0, 1fr);
	}
}

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

.sh-cs-card {
	display: flex;
	flex-direction: column;
	padding: 40px;
	border-radius: var(--sh-cs-radius);
	background: var(--sh-cs-color-1);
	color: #fff;
	animation: sh-cs-fade-in 0.35s ease both;
}

.sh-cs-card--color-1 { background: var(--sh-cs-color-1); }
.sh-cs-card--color-2 { background: var(--sh-cs-color-2); }
.sh-cs-card--color-3 { background: var(--sh-cs-color-3); }

.sh-cs-card__icon {
	margin: 0 auto 28px;
	line-height: 0;
	text-align: center;
}

.sh-cs-card__icon svg {
	width: 68px;
	height: 68px;
}

/*
 * Themes commonly set `color` on every element via a `*` rule, which beats
 * inheritance and leaves currentColor dark. Paint the shapes directly.
 */
.sh-cs-card__icon svg,
.sh-cs-card__icon svg circle,
.sh-cs-card__icon svg path {
	color: #fff;
	stroke: #fff;
	fill: none;
}

.sh-cs-card__title {
	margin: 0 0 22px;
	color: #fff;
	font-size: 26px;
	font-weight: 700;
	line-height: 1.15;
}

.sh-cs-card__description {
	margin: 0 0 24px;
	color: rgba(255, 255, 255, 0.95);
	font-size: 17px;
	line-height: 1.7;

	/* Keep cards visually even; full text stays in the DOM. */
	display: -webkit-box;
	-webkit-line-clamp: 5;
	line-clamp: 5;
	-webkit-box-orient: vertical;
	overflow: hidden;
}

.sh-cs-card__description > *:last-child {
	margin-bottom: 0;
}

/*
 * Sits directly under the summary rather than pinned to the card bottom,
 * matching the reference design.
 */
.sh-cs-card__download {
	color: #fff;
	font-size: 17px;
	font-weight: 400;
	line-height: 1.5;
	text-decoration: underline;
	text-underline-offset: 3px;
	align-self: flex-start;
}

.sh-cs-card__download:hover,
.sh-cs-card__download:focus {
	color: #fff;
	opacity: 0.8;
}

/* -------------------------------------------------------------------------
 * States
 * ---------------------------------------------------------------------- */

.sh-cs__empty {
	margin: 24px 0 0;
	color: #4b5563;
	font-size: 16px;
}

.sh-cs__sentinel {
	width: 100%;
	height: 1px;
}

.sh-cs__loader {
	display: flex;
	justify-content: center;
	padding: 28px 0 8px;
}

.sh-cs__loader[hidden] {
	display: none;
}

.sh-cs__spinner {
	width: 28px;
	height: 28px;
	border: 3px solid #d1d5db;
	border-top-color: var(--sh-cs-color-2);
	border-radius: 50%;
	animation: sh-cs-spin 0.7s linear infinite;
}

.sh-cs.is-searching .sh-cs__grid {
	opacity: 0.45;
	transition: opacity 0.15s ease;
}

.sh-cs__status {
	position: absolute;
	width: 1px;
	height: 1px;
	margin: -1px;
	padding: 0;
	overflow: hidden;
	clip: rect(0, 0, 0, 0);
	white-space: nowrap;
	border: 0;
}

/* Fallback when the theme does not define this helper. */
.sh-cs .screen-reader-text {
	position: absolute !important;
	width: 1px;
	height: 1px;
	margin: -1px;
	padding: 0;
	overflow: hidden;
	clip: rect(0, 0, 0, 0);
	white-space: nowrap;
	border: 0;
}

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

@keyframes sh-cs-fade-in {
	from { opacity: 0; transform: translateY(8px); }
	to   { opacity: 1; transform: none; }
}

@media (prefers-reduced-motion: reduce) {
	.sh-cs-card {
		animation: none;
	}

	.sh-cs__spinner,
	.sh-cs__search-spinner {
		animation-duration: 2s;
	}
}
