/**
 * Rek.ai product feed.
 *
 * Deliberately minimal so the Bricks theme keeps control of typography and
 * colours. Everything is scoped to .rekai-feed.
 */

.rekai-feed {
	--rekai-columns: 4;
	--rekai-gap: 1.5rem;
	margin-block: 2.5rem;
}

.rekai-feed--cols-1 { --rekai-columns: 1; }
.rekai-feed--cols-2 { --rekai-columns: 2; }
.rekai-feed--cols-3 { --rekai-columns: 3; }
.rekai-feed--cols-4 { --rekai-columns: 4; }
.rekai-feed--cols-5 { --rekai-columns: 5; }
.rekai-feed--cols-6 { --rekai-columns: 6; }

.rekai-feed--empty {
	display: none;
}

.rekai-feed__title {
	margin-block-end: 1.25rem;
}

.rekai-feed__status {
	display: flex;
	align-items: center;
	justify-content: center;
	min-height: 6rem;
}

.rekai-feed__spinner {
	width: 1.75rem;
	height: 1.75rem;
	border: 2px solid currentColor;
	border-top-color: transparent;
	border-radius: 50%;
	opacity: 0.4;
	animation: rekai-spin 0.8s linear infinite;
}

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

@media (prefers-reduced-motion: reduce) {
	.rekai-feed__spinner {
		animation: none;
	}
}

.rekai-feed__grid.products {
	display: grid;
	grid-template-columns: repeat(var(--rekai-columns), minmax(0, 1fr));
	gap: var(--rekai-gap);
	margin: 0;
	padding: 0;
	list-style: none;
}

/**
 * Neutralise the float based layout WooCommerce applies to loop items.
 *
 * WooCommerce sizes items with fixed percentages (.woocommerce ul.products
 * .columns-2 li.product sets width: 48%) from a selector with higher
 * specificity than anything scoped to this feed. Autoptimize also aggregates
 * and reorders stylesheets on this site, so load order cannot be relied on to
 * settle it either. Inside our own grid the track defines the width, so these
 * declarations are forced.
 */
.rekai-feed__grid.products > li.product {
	width: 100% !important;
	max-width: none !important;
	margin: 0 !important;
	float: none !important;
	clear: none !important;
}

.rekai-feed__grid.products::before,
.rekai-feed__grid.products::after {
	content: none;
}

.rekai-card__inner {
	display: flex;
	flex-direction: column;
	height: 100%;
	gap: 0.75rem;
}

.rekai-card__media {
	position: relative;
	display: block;
	overflow: hidden;
}

/* Covers both card templates so the feed keeps one consistent image shape. */
.rekai-card__media img,
.rekai-feed .rekai-feed__items li.product img {
	display: block;
	width: 100%;
	height: auto;
	aspect-ratio: 4 / 5;
	object-fit: cover;
}

.rekai-card__media img {
	transition: transform 0.3s ease;
}

.rekai-card__media:hover img {
	transform: scale(1.03);
}

@media (prefers-reduced-motion: reduce) {
	.rekai-card__media img,
	.rekai-card__media:hover img {
		transition: none;
		transform: none;
	}
}

.rekai-card__badge {
	position: absolute;
	inset-block-start: 0.5rem;
	inset-inline-start: 0.5rem;
	padding: 0.15em 0.6em;
	font-size: 0.75rem;
	line-height: 1.6;
	text-transform: uppercase;
	letter-spacing: 0.04em;
	color: #fff;
	background: #1a1a1a;
}

.rekai-card__body {
	display: flex;
	flex: 1 1 auto;
	flex-direction: column;
	gap: 0.4rem;
}

.rekai-card__title {
	margin: 0;
	font-size: 1rem;
	line-height: 1.35;
}

.rekai-card__link {
	text-decoration: none;
}

.rekai-card__meta {
	margin: 0;
	font-size: 0.8125rem;
	line-height: 1.4;
	opacity: 0.75;
}

.rekai-card__meta-label {
	font-weight: 600;
}

.rekai-card__excerpt {
	margin: 0;
	font-size: 0.875rem;
	line-height: 1.5;
}

.rekai-card__footer {
	display: flex;
	flex-direction: column;
	align-items: flex-start;
	gap: 0.5rem;
	margin-block-start: auto;
	padding-block-start: 0.5rem;
}

/**
 * Add to cart button.
 *
 * Scoped to the rendered items so the rest of the shop is untouched, and
 * covers both the plugin card and WooCommerce's own loop button. The border
 * colour is left to currentColor so it follows the text through the hover
 * state. Forced because Bricks and WooCommerce both style .button.
 */
.rekai-feed .rekai-feed__items .button,
.rekai-feed .rekai-feed__items .add_to_cart_button,
.rekai-feed .rekai-card__button {
	background: transparent !important;
	border: 1px solid !important;
	border-radius: 40px !important;
	color: #013b47 !important;
	padding: 0.75em 2em !important;
	font-size: 0.75em !important;
	font-weight: 700 !important;
	text-transform: uppercase !important;
	text-decoration: none !important;
	transition: background-color 0.2s ease, color 0.2s ease;
}

.rekai-feed .rekai-feed__items .button:hover,
.rekai-feed .rekai-feed__items .button:focus-visible,
.rekai-feed .rekai-feed__items .add_to_cart_button:hover,
.rekai-feed .rekai-feed__items .add_to_cart_button:focus-visible,
.rekai-feed .rekai-card__button:hover,
.rekai-feed .rekai-card__button:focus-visible {
	background: #013b47 !important;
	border: 1px solid !important;
	color: #fff !important;
}

@media (prefers-reduced-motion: reduce) {
	.rekai-feed .rekai-feed__items .button,
	.rekai-feed .rekai-card__button {
		transition: none;
	}
}

/* repeat() only accepts integers, so the column count is stepped down here. */
@media (max-width: 1024px) {
	.rekai-feed--cols-4,
	.rekai-feed--cols-5,
	.rekai-feed--cols-6 {
		--rekai-columns: 3;
	}
}

@media (max-width: 767px) {
	.rekai-feed--cols-2,
	.rekai-feed--cols-3,
	.rekai-feed--cols-4,
	.rekai-feed--cols-5,
	.rekai-feed--cols-6 {
		--rekai-columns: 2;
	}

	.rekai-feed {
		--rekai-gap: 1rem;
	}
}

/* Two columns are kept all the way down, so only the spacing tightens here. */
@media (max-width: 480px) {
	.rekai-feed {
		--rekai-gap: 0.75rem;
	}

	.rekai-card__title {
		font-size: 0.9375rem;
	}

	.rekai-card__excerpt {
		font-size: 0.8125rem;
	}

	.rekai-card__footer {
		gap: 0.35rem;
	}
}
