.ht-covers-installs {
	/* Slower than the site-wide default, scoped to this block only. */
	--ht-transition--default: 0.75s;
}

.ht-covers-installs__label {
	display: inline-block;
	background-color: var(--wp--preset--color--green-highlight);
	color: var(--wp--preset--color--contrast);
	padding: var(--wp--preset--spacing--xxs) var(--wp--preset--spacing--s);
	border-radius: var(--ht-radius--xxs);
	font-weight: 700;
	text-transform: uppercase;
}

.ht-covers-installs__title {
	margin-top: var(--wp--preset--spacing--s);
	color: var(--wp--preset--color--contrast);
}

.ht-covers-installs__items {
	display: flex;
	flex-direction: column;
	gap: var(--wp--preset--spacing--s);
	margin-top: var(--wp--preset--spacing--m);
}

.ht-covers-installs__item {
	border-radius: var(--ht-radius--s);
	border: 1px solid var(--wp--preset--color--green-dark-10);
	background-color: var(--wp--preset--color--mono-white);
	cursor: pointer;
	overflow: hidden;
	transition: background-color var(--ht-transition--default) ease,
		border-color var(--ht-transition--default) ease;
}

.ht-covers-installs__item-inner {
	padding: var(--wp--preset--spacing--s);
	box-sizing: border-box;
}

.ht-covers-installs__item-header {
	display: flex;
	align-items: center;
	gap: var(--wp--preset--spacing--xs);
}

.ht-covers-installs__item-icon-image {
	display: block;
	width: 28px;
	height: 28px;
	object-fit: contain;
}

.ht-covers-installs__item-mobile-icon {
	display: none;
}

.ht-covers-installs__item-mobile-icon-image {
	display: block;
	width: 28px;
	height: 28px;
	object-fit: contain;
	transition: filter var(--ht-transition--default) ease;
}

.ht-covers-installs__item-title {
	margin: 0;
	color: var(--wp--preset--color--green-dark-70);
	font-family: var(--headings-font);
	font-weight: 700;
	font-size: var(--wp--preset--font-size--h-3);
	line-height: 0.95;
	/* Titles are expected to stay short (content guideline, not enforced
	   elsewhere); this is a safety net so a too-long one truncates
	   instead of wrapping to 2 lines and jumping the layout. */
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
	transition: color var(--ht-transition--default) ease;
}

.ht-covers-installs__item-body-inner {
	margin-top: var(--wp--preset--spacing--s);
}

.ht-covers-installs__item-description {
	color: var(--wp--preset--color--green-dark-70);
}

.ht-covers-installs__item-links {
	display: flex;
	flex-wrap: wrap;
	gap: var(--wp--preset--spacing--xxs);
	margin-top: var(--wp--preset--spacing--s);
}

.ht-covers-installs__item-links .ht-button {
	margin: 0;
	padding: var(--wp--preset--spacing--xxs) var(--wp--preset--spacing--s);
	font-size: calc(var(--wp--preset--font-size--small) - 1px);
	font-weight: 700;
}

.ht-covers-installs__item-illustration {
	display: none;
}

/* Active item on touch devices/narrow screens: tap toggles this via script.js. */
@media (max-width: 1099px) {

	.ht-covers-installs__item-icon {
		display: none;
	}

	.ht-covers-installs__item-mobile-icon {
		display: block;
	}

	.ht-covers-installs__item-mobile-icon-image {
		filter: opacity(0.7);
	}

	.ht-covers-installs__item--active .ht-covers-installs__item-mobile-icon-image {
		filter: none;
	}

	.ht-covers-installs__item--active {
		background-color: var(--wp--preset--color--primary);
		border-color: var(--wp--preset--color--primary);
	}

	.ht-covers-installs__item--active .ht-covers-installs__item-title {
		color: var(--wp--preset--color--contrast);
	}

	.ht-covers-installs__item-body {
		display: grid;
		grid-template-rows: 0fr;
		transition: grid-template-rows var(--ht-transition--default) ease;
	}

	.ht-covers-installs__item-body-inner {
		overflow: hidden;
	}

	.ht-covers-installs__item--active .ht-covers-installs__item-body {
		grid-template-rows: 1fr;
	}
}

/* Desktop: horizontal row that expands the hovered/active card. */
@media (min-width: 1100px) {

	.ht-covers-installs__items {
		flex-direction: row;
		align-items: stretch;
	}

	.ht-covers-installs__item {
		position: relative;
		cursor: default;
		flex-grow: 1;
		flex-basis: 0;
		min-width: 0;
		height: var(--ht-covers-installs-item-height, 340px);
		transition: flex-grow var(--ht-transition--default) ease,
			background-color var(--ht-transition--default) ease,
			border-color var(--ht-transition--default) ease;
	}

	.ht-covers-installs__item-inner {
		display: flex;
		flex-direction: column;
		height: 100%;
		padding: var(--wp--preset--spacing--s);
		box-sizing: border-box;
		position: relative;
	}

	.ht-covers-installs__item-header {
		flex-grow: 1;
		flex-direction: column;
		justify-content: center;
		text-align: center;
	}

	.ht-covers-installs__item-icon-image {
		width: 140px;
		height: 140px;
		margin: 0 auto;
	}

	.ht-covers-installs__item-title {
		font-size: var(--wp--preset--font-size--h-5);
	}

	.ht-covers-installs__item-body {
		display: none;
		opacity: 0;
		max-width: 380px;
		/* Positioned out of the item-inner flex flow so its presence never
		   changes the header's box height mid-transition (it would otherwise
		   squeeze the header while fading in/out). item-inner is the
		   positioned ancestor; absolute offsets are measured from its
		   padding edge (not its content edge), so left/right/top must
		   still add its padding explicitly. --ht-group-top (set by
		   script.js) is the slack space that centers the whole title+body
		   block vertically; the title's real measured height is added on
		   top of that so item-body starts right below the title. */
		position: absolute;
		top: calc(var(--wp--preset--spacing--s) + var(--ht-group-top, 0px) + var(--ht-title-height, 3rem));
		left: var(--wp--preset--spacing--s);
		right: var(--wp--preset--spacing--s);
		/* Closing fades out at half the normal duration (opening keeps the
		   full duration, declared separately below), so less of the
		   clipped-overflow content is visible while it's on its way out. */
		transition: opacity calc(var(--ht-transition--default) / 2) ease,
			display calc(var(--ht-transition--default) / 2) ease allow-discrete;
	}

	.ht-covers-installs__item-links {
		justify-content: flex-start;
	}

	.ht-covers-installs__item-illustration {
		display: flex;
		align-items: flex-end;
		justify-content: center;
		position: absolute;
		right: var(--wp--preset--spacing--s);
		bottom: var(--wp--preset--spacing--xxs);
		width: 240px;
		height: 240px;
		opacity: 0;
		transition: opacity var(--ht-transition--default) ease;
		pointer-events: none;
	}

	.ht-covers-installs__item-illustration-image {
		display: block;
		width: 100%;
		height: 100%;
		object-fit: contain;
		object-position: bottom center;
	}

	/* Expanded state: the active card while the row isn't hovered/focused, or whichever card is. */
	.ht-covers-installs__items:not(:hover):not(:focus-within) .ht-covers-installs__item--active,
	.ht-covers-installs__item:hover,
	.ht-covers-installs__item:focus-within {
		flex-grow: 4;
		background-color: var(--wp--preset--color--primary);
		border-color: var(--wp--preset--color--primary);
	}

	.ht-covers-installs__items:not(:hover):not(:focus-within) .ht-covers-installs__item--active .ht-covers-installs__item-header,
	.ht-covers-installs__item:hover .ht-covers-installs__item-header,
	.ht-covers-installs__item:focus-within .ht-covers-installs__item-header {
		flex-grow: 0;
		flex-direction: row;
		justify-content: flex-start;
		/* Shrink-wrapped to the title's own height, then pushed down by the
		   slack space (set by script.js) so the whole title+body block
		   ends up vertically centered instead of stuck at the top. */
		margin-top: var(--ht-group-top, 0px);
		text-align: left;
	}

	.ht-covers-installs__items:not(:hover):not(:focus-within) .ht-covers-installs__item--active .ht-covers-installs__item-icon,
	.ht-covers-installs__item:hover .ht-covers-installs__item-icon,
	.ht-covers-installs__item:focus-within .ht-covers-installs__item-icon {
		display: none;
	}

	.ht-covers-installs__items:not(:hover):not(:focus-within) .ht-covers-installs__item--active .ht-covers-installs__item-title,
	.ht-covers-installs__item:hover .ht-covers-installs__item-title,
	.ht-covers-installs__item:focus-within .ht-covers-installs__item-title {
		color: var(--wp--preset--color--contrast);
		font-size: var(--wp--preset--font-size--h-3);
	}

	.ht-covers-installs__items:not(:hover):not(:focus-within) .ht-covers-installs__item--active .ht-covers-installs__item-body,
	.ht-covers-installs__item:hover .ht-covers-installs__item-body,
	.ht-covers-installs__item:focus-within .ht-covers-installs__item-body {
		display: block;
		opacity: 1;
		transition: opacity var(--ht-transition--default) ease,
			display var(--ht-transition--default) ease allow-discrete;
	}

	@starting-style {
		.ht-covers-installs__items:not(:hover):not(:focus-within) .ht-covers-installs__item--active .ht-covers-installs__item-body,
		.ht-covers-installs__item:hover .ht-covers-installs__item-body,
		.ht-covers-installs__item:focus-within .ht-covers-installs__item-body {
			opacity: 0;
		}
	}

	.ht-covers-installs__items:not(:hover):not(:focus-within) .ht-covers-installs__item--active .ht-covers-installs__item-illustration,
	.ht-covers-installs__item:hover .ht-covers-installs__item-illustration,
	.ht-covers-installs__item:focus-within .ht-covers-installs__item-illustration {
		opacity: 1;
		pointer-events: auto;
	}
}
