/**
 * ES Category Cards
 * Architecture notes:
 * - Columns via CSS var (--es-cols) + minmax(0,1fr) to avoid overflow.
 * - Card height via padding-top spacer (--es-ratio) NOT aspect-ratio
 *   (aspect-ratio collapses to 0 height inside some grid/theme contexts).
 * - Height guards on wrapper to survive theme flex rules.
 */

.es-cats {
	display: grid;
	grid-template-columns: repeat(var(--es-cols, 3), minmax(0, 1fr));
	column-gap: 24px;
	row-gap: 24px;
	width: 100%;
	height: auto !important;
	align-self: flex-start;
}

.es-cat-card {
	position: relative;
	display: block;
	text-decoration: none;
	overflow: hidden;
	border-radius: 3px;
	height: auto !important;
	align-self: flex-start;
	transition-property: transform, box-shadow;
	transition-duration: 0.4s;
	transition-timing-function: cubic-bezier(0.2, 0.7, 0.2, 1);
}

/* Ratio box: padding-top spacer keeps height stable */
.es-cat-media {
	position: relative;
	display: flex;
	flex-direction: column;
	justify-content: flex-end;
	width: 100%;
	overflow: hidden;
	background-color: #f7f5f2;
}

.es-cat-media::before {
	content: "";
	display: block;
	width: 100%;
	padding-top: var(--es-ratio, 125%);
}

/* Image fills the ratio box */
.es-cat-img {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	object-fit: cover;
	object-position: center;
	display: block;
	transition: transform 0.7s cubic-bezier(0.2, 0.7, 0.2, 1);
	z-index: 1;
}

.es-cat-img--empty {
	background: linear-gradient(150deg, #cabfa9, #a9793a);
}

/* Legibility scrim (configurable via vars) */
.es-cat-scrim {
	position: absolute;
	inset: 0;
	z-index: 2;
	pointer-events: none;
	background: linear-gradient(
		var(--es-scrim-angle, 0deg),
		var(--es-scrim, rgba(30, 25, 22, 0.72)) 0%,
		transparent var(--es-scrim-stop, 68%)
	);
}

/* Content block over the image */
.es-cat-body {
	position: relative;
	z-index: 3;
	display: flex;
	flex-direction: column;
	align-items: flex-start;
	width: 100%;
	padding: 26px 26px 24px;
}

.es-cat-title {
	margin: 0;
	font-family: "Jost", sans-serif;
	font-size: 21px;
	font-weight: 600;
	line-height: 1.15;
	letter-spacing: 0.06em;
	text-transform: uppercase;
	color: #ffffff;
	transition: color 0.3s ease;
}

.es-cat-count {
	display: block;
	margin-top: 4px;
	font-family: "Red Hat Display", sans-serif;
	font-size: 13px;
	color: rgba(255, 255, 255, 0.8);
}

/* Shop Now */
.es-cat-shop {
	display: inline-flex;
	align-items: center;
	gap: 8px;
	font-family: "Jost", sans-serif;
	font-size: 13px;
	font-weight: 600;
	letter-spacing: 0.1em;
	text-transform: uppercase;
	color: #a9793a;
	line-height: 1;
}

.es-cat-shop svg,
.es-cat-shop i {
	width: 15px;
	height: 15px;
	font-size: 15px;
	fill: none;
	stroke: currentColor;
	stroke-width: 2.2;
	stroke-linecap: round;
	stroke-linejoin: round;
	transition: transform 0.3s ease;
}

.es-cat-card:hover .es-cat-shop svg,
.es-cat-card:hover .es-cat-shop i {
	transform: translateX(3px);
}

/* Reveal-on-hover behaviour */
.es-shop-hover .es-cat-shop {
	max-height: 0;
	opacity: 0;
	overflow: hidden;
	margin-top: 0;
	transition: max-height 0.35s ease, opacity 0.35s ease, margin-top 0.35s ease;
}

.es-shop-hover .es-cat-card:hover .es-cat-shop {
	max-height: 40px;
	opacity: 1;
	margin-top: var(--es-shop-gap, 10px);
}

.es-shop-always .es-cat-shop {
	margin-top: var(--es-shop-gap, 10px);
}

/* Editor notice */
.es-cats-notice {
	padding: 20px;
	border: 1px dashed #c9bda9;
	border-radius: 3px;
	background: #faf7f2;
	color: #6b645d;
	font-family: "Red Hat Display", sans-serif;
	font-size: 14px;
	text-align: center;
}

/* Touch devices: always show Shop Now (hover is unreliable) */
@media (hover: none) {
	.es-shop-hover .es-cat-shop {
		max-height: 40px;
		opacity: 1;
		margin-top: var(--es-shop-gap, 10px);
	}
}
