/**
 * SRD Shop Suite — shared product card and grid (SRD_Suite_Product_Card).
 *
 * Every adjustable value is a --srd-card-* custom property, set by the module
 * on its own wrapper (.srd-related, .srd-archive) from its Appearance
 * settings, so each module can look different on the same page.
 */
ul.srd-card-grid {
	display: grid;
	grid-template-columns: repeat(var(--srd-card-cols, 4), minmax(0, 1fr));
	gap: var(--srd-card-gap, 24px);
	margin: 0;
	padding: 0;
	list-style: none;
}

/* Divi's list rules (#left-area ul, .et-l--body ul, .entry-content ul:
   padding 0 0 23px 1em) outweigh the rule above; three IDs of weight and
   !important keep the grid flush. */
ul.srd-card-grid:not(#srd-card):not(#srd-card):not(#srd-card) {
	padding: 0 !important;
}

/* The same for the list items: Divi's li margins (every item but the last)
   make the row stretch the margin-less last card taller than the others,
   leaving an empty strip at the bottom of its body. The grid gap spaces
   the cards. */
ul.srd-card-grid:not(#srd-card):not(#srd-card):not(#srd-card) > li.srd-card {
	margin: 0 !important;
}

@media (max-width: 1380px) {
	ul.srd-card-grid {
		grid-template-columns: repeat(var(--srd-card-cols-l, var(--srd-card-cols, 4)), minmax(0, 1fr));
	}
}

@media (max-width: 980px) {
	ul.srd-card-grid {
		grid-template-columns: repeat(var(--srd-card-cols-t, 3), minmax(0, 1fr));
	}
}

@media (max-width: 767px) {
	ul.srd-card-grid {
		grid-template-columns: repeat(var(--srd-card-cols-mt, var(--srd-card-cols-m, 2)), minmax(0, 1fr));
	}
}

@media (max-width: 579px) {
	ul.srd-card-grid {
		grid-template-columns: repeat(var(--srd-card-cols-m, 2), minmax(0, 1fr));
	}
}

/* Reset theme rules aimed at ul.products li.product (floats, widths). */
ul.srd-card-grid li.srd-card {
	position: relative;
	display: flex;
	flex-direction: column;
	float: none;
	width: auto;
	margin: 0;
	padding: var(--srd-card-padding-top, 0) var(--srd-card-padding-right, 0) var(--srd-card-padding-bottom, 0) var(--srd-card-padding-left, 0);
	list-style: none;
	background: var(--srd-card-bg, transparent);
	border: var(--srd-card-border-width, 0) var(--srd-card-border-style, solid) var(--srd-card-border-color, #e2e2e2);
	border-radius: var(--srd-card-radius, 0);
	box-shadow: var(--srd-card-shadow, none);
	text-align: var(--srd-card-text-align, left);
	overflow: hidden;
}

.srd-card::before {
	display: none;
}

/* Positioning box for the sale flash and Product Badge strips. */
.srd-card__image {
	position: relative;
	display: block;
	margin: 0 0 12px;
	overflow: hidden;
	border-radius: var(--srd-card-image-radius, 0);
}

/* Image Aspect Ratio unset = auto, the image's own shape (nothing cropped).
   Object Fit: cover crops to that shape; contain shows the whole image. */
.srd-card__image img {
	display: block;
	width: 100%;
	height: auto;
	margin: 0;
	aspect-ratio: var(--srd-card-image-ratio, auto);
	object-fit: var(--srd-card-image-fit, cover);
}

/* Hover overlay: transparent (invisible) until Image Overlay Background
   Color is set. Fades in while the pointer is anywhere on the card. */
.srd-card__image::after {
	content: "";
	position: absolute;
	inset: 0;
	z-index: 1;
	background-color: var(--srd-card-overlay-bg, transparent);
	opacity: 0;
	transition: opacity var(--srd-card-overlay-duration, 300ms) ease;
	pointer-events: none;
}

.srd-card:hover .srd-card__image::after,
.srd-card__image:focus-visible::after {
	opacity: var(--srd-card-overlay-opacity, 0.3);
}

@media (prefers-reduced-motion: reduce) {
	.srd-card__image::after {
		transition: none;
	}
}

/* Sale flash stays above the overlay (Product Badge strips already sit
   higher, at z-index 9). */
.srd-card__image .onsale {
	z-index: 2;
}

/* Title, price, button…: fills the card below the image, so the button can
   sit at the bottom. In a list layout it is the right-hand column. */
.srd-card__body {
	display: flex;
	flex: 1 1 auto;
	flex-direction: column;
	min-width: 0;
	padding: var(--srd-card-body-padding-top, 0) var(--srd-card-body-padding-right, 0) var(--srd-card-body-padding-bottom, 0) var(--srd-card-body-padding-left, 0);
	background: var(--srd-card-body-bg, transparent);
}

.srd-card__credits {
	margin: 0 0 3px;
	font-size: 14px;
	opacity: 0.8;
}

/* The block holding the title link. The link itself stays inline, like
   the category links, so a theme's link effect drawn as a background (an
   underline that grows on hover) follows each line of text instead of
   spanning the whole block. Font size and line height sit here too: the
   lines' height comes from this block, not from the theme's list (Divi's
   ul: 26px). */
.srd-card__heading {
	margin: 0 0 6px;
	font-size: var(--srd-card-title-size, 16px);
	font-weight: var(--srd-card-title-weight, 600);
	line-height: 1.35;
}

/* No transition of its own: the theme's link transition (which animates
   its hover effect) stays in force. */
a.srd-card__title {
	display: inline;
	color: var(--srd-card-title-color, inherit);
	font-size: inherit;
	font-weight: inherit;
	line-height: inherit;
	text-decoration: none;
}

/* Hover Color falls back to the normal color, so unset = no change. */
a.srd-card__title:hover,
a.srd-card__title:focus-visible {
	color: var(--srd-card-title-hover-color, var(--srd-card-title-color, inherit));
}

.srd-card__category {
	margin: 0 0 5px;
	color: var(--srd-card-category-color, #888);
	font-size: var(--srd-card-category-size, 14px);
}

.srd-card__category a {
	color: inherit;
	text-decoration: none;
}

.srd-card__category a:hover,
.srd-card__category a:focus-visible {
	color: var(--srd-card-category-hover-color, inherit);
}

/* The short description belongs to list layouts only. */
.srd-card__excerpt {
	display: none;
	margin: 0 0 12px;
}

.srd-card__rating {
	margin: 0 0 6px;
}

.srd-card__rating .star-rating {
	float: none;
	display: inline-block;
	margin: 0;
}

.srd-card__price {
	margin: 0 0 12px;
	color: var(--srd-card-price-color, inherit);
	font-size: var(--srd-card-price-size, inherit);
}

/* Footer (button and any later actions) sits at the bottom so footers line
   up across a row. Button Text Align moves the inline-block button across;
   unset, it follows the card's Text Align. */
.srd-card__footer {
	margin-top: auto;
	text-align: var(--srd-card-button-align, inherit);
}

/* Button Placement: After the text (.srd-cards--button-after on the module
   wrapper). The same gap under the text in every card. */
.srd-cards--button-after .srd-card__footer {
	margin-top: 8px;
}

.srd-card__button .button {
	display: inline-block;
	margin: 0;
}

/* Button Style: Plugin. WooCommerce's loop button with .srd-card__btn in
   place of the theme's .button, so this is its whole design; the Button
   settings override it. :not(#srd-card) gives ID weight, so theme link
   rules (a { color }, often under an ID) don't recolor it. */
.srd-card__button .srd-card__btn:not(#srd-card) {
	position: relative;
	display: inline-block;
	box-sizing: border-box;
	margin: 0;
	padding: 10px 20px;
	border: 0;
	border-radius: 4px;
	background-color: #222;
	color: #fff;
	font-size: 14px;
	font-weight: 600;
	line-height: 1.3;
	text-align: center;
	text-decoration: none;
	cursor: pointer;
	transition: background-color 0.2s ease, color 0.2s ease, opacity 0.2s ease;
}

.srd-card__button .srd-card__btn:not(#srd-card):hover,
.srd-card__button .srd-card__btn:not(#srd-card):focus-visible {
	background-color: #444;
	color: #fff;
}

.srd-card__button .srd-card__btn:not(#srd-card):focus-visible {
	outline: 2px solid currentColor;
	outline-offset: 2px;
}

/* AJAX add to cart: WooCommerce adds .loading while it works and .added
   when done (its own spinner and tick are drawn only on .button). */
.srd-card__button .srd-card__btn.loading:not(#srd-card) {
	padding-right: 2.6em;
	opacity: 0.7;
	pointer-events: none;
}

.srd-card__button .srd-card__btn.loading::after {
	content: "";
	position: absolute;
	top: 50%;
	right: 0.9em;
	width: 1em;
	height: 1em;
	margin-top: -0.5em;
	box-sizing: border-box;
	border: 2px solid currentColor;
	border-right-color: transparent;
	border-radius: 50%;
	animation: srd-card-spin 0.7s linear infinite;
}

.srd-card__button .srd-card__btn.added::after {
	content: "\2713";
	margin-left: 0.5em;
}

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

@media (prefers-reduced-motion: reduce) {
	.srd-card__button .srd-card__btn.loading::after {
		animation-duration: 2s;
	}
}

.srd-card__button .added_to_cart {
	display: block;
	margin-top: 8px;
}

/* Product Badge in the same corner as the sale flash: stack below it. */
.srd-card__image .onsale ~ .srd-badge-strip--top-left {
	top: calc(var(--srd-strip-inset, 0px) + 14px + 48px);
}

/* Button Display: Slide up on hover (.srd-cards--slide on the module
   wrapper). The footer hangs just below the card text, clipped by the
   card; on hover / keyboard focus the text slides up by --srd-card-reveal
   and the footer fades in where the text was. Only for devices that can
   hover: on touch screens the button stays in place, always visible. */
@media (hover: hover) {
	.srd-cards--slide ul.srd-card-grid li.srd-card {
		overflow: hidden;
	}

	.srd-cards--slide .srd-card__body {
		position: relative;
		z-index: 3;
		background: var(--srd-card-body-bg, var(--srd-card-bg, #fff));
		transition: transform var(--srd-card-transition, 300ms) ease;
	}

	/* The footer hangs below the body's box, so it repeats the body's
	   background and side / bottom padding to read as part of it: full body
	   width, button lined up with the text. */
	.srd-cards--slide .srd-card__footer {
		position: absolute;
		top: 100%;
		right: 0;
		left: 0;
		margin: 0;
		padding: 8px var(--srd-card-body-padding-right, 0) var(--srd-card-body-padding-bottom, 0) var(--srd-card-body-padding-left, 0);
		background: var(--srd-card-body-bg, var(--srd-card-bg, #fff));
		opacity: 0;
		transition: opacity var(--srd-card-transition, 300ms) ease;
	}

	/* The "View cart" link after an AJAX add sits beside the button, not
	   below it, so it stays inside the revealed strip. */
	.srd-cards--slide .srd-card__button .added_to_cart {
		display: inline-block;
		margin: 0 0 0 12px;
	}

	.srd-cards--slide li.srd-card:hover .srd-card__body,
	.srd-cards--slide li.srd-card:focus-within .srd-card__body {
		transform: translateY(calc(-1 * var(--srd-card-reveal, 52px)));
	}

	.srd-cards--slide li.srd-card:hover .srd-card__footer,
	.srd-cards--slide li.srd-card:focus-within .srd-card__footer {
		opacity: 1;
	}
}

@media (prefers-reduced-motion: reduce) {
	.srd-cards--slide .srd-card__body,
	.srd-cards--slide .srd-card__footer {
		transition: none;
	}
}
