/**
 * File: /assets/css/frontend/product/product-card.css
 * Purpose: Defines the shared frontend product card layout, actions, badges, and archive card consistency styles.
 *
 * @package SunTechPortal
 */

.stp-product-card,
.stp-product-card *,
.stp-product-card *::before,
.stp-product-card *::after {
	box-sizing: border-box;
}

.stp-product-card {
	--stp-card-primary: #ff5a00;
	--stp-card-primary-dark: #c2410c;
	--stp-card-text: #111827;
	--stp-card-muted: #6b7280;
	--stp-card-border: #e5e7eb;
	--stp-card-border-strong: #d1d5db;
	--stp-card-bg-soft: #f9fafb;
	--stp-card-link: #2563eb;
	--stp-card-link-hover: #1d4ed8;
	--stp-card-rating: #f59e0b;
	--stp-product-card-width: 205px;
	--stp-product-card-height: 330px;

	position: relative;
	z-index: 1;
	display: grid;
	grid-template-rows: 27px 168px 1fr;
	width: var(--stp-product-card-width);
	min-width: var(--stp-product-card-width);
	max-width: var(--stp-product-card-width);
	height: var(--stp-product-card-height);
	min-height: var(--stp-product-card-height);
	min-width: 0;
	padding: 0;
	color: var(--stp-card-text);
	background: #fff;
	border: 0 solid var(--stp-card-border);
	border-radius: 0;
	box-shadow: none;
	overflow: visible;
	transition:
		border-color 0.16s ease,
		box-shadow 0.16s ease,
		transform 0.16s ease;
}

.stp-product-card:hover {
	z-index: 20;
	border-color: var(--stp-card-border-strong);
	box-shadow: 0 0 5px rgba(17, 24, 39, 0.3);
	transform: translateY(-1px);
}

.stp-product-card__catalog-meta {
	position: relative;
	z-index: 5;
	display: flex;
	align-items: center;
	justify-content: flex-start;
	gap: 0;
	min-height: 27px;
	margin: 0;
	padding: 6px 17px 3px;
	background: #fff;
	overflow: hidden;
}

.stp-product-card__category {
	display: block;
	min-width: 0;
	max-width: 100%;
	overflow: hidden;
	color: var(--stp-card-text);
	font-size: 11px;
	font-weight: 600;
	line-height: 1.2;
	letter-spacing: 0.02em;
	text-overflow: ellipsis;
	text-transform: uppercase;
	white-space: nowrap;
}

.stp-product-card__brand {
	display: none !important;
}

.stp-product-card__media {
	position: relative;
	z-index: 1;
	display: flex;
	align-items: center;
	justify-content: center;
	width: 100%;
	height: 168px;
	min-height: 168px;
	max-height: 168px;
	margin: 0;
	padding: 0 17px;
	color: var(--stp-card-muted);
	background: #fff;
	text-decoration: none;
	overflow: hidden;
}

.stp-product-card__media-link {
	position: absolute;
	inset: 0;
	z-index: 1;
	display: flex;
	align-items: center;
	justify-content: center;
	width: 100%;
	height: 100%;
	color: inherit;
	text-decoration: none;
}

.stp-product-card__image,
.stp-product-card__media-link .stp-product-card__image {
	display: block;
	width: 100%;
	height: 100%;
	object-fit: contain;
	object-position: center;
	transform: translateZ(0);
	transition: transform 0.18s ease;
}

.stp-product-card:hover .stp-product-card__image {
	transform: scale(1.025);
}

.stp-product-card__image-placeholder,
.stp-product-card__media-link .stp-product-card__image-placeholder {
	display: grid;
	place-items: center;
	width: 100%;
	height: 100%;
	min-height: 152px;
	background: var(--stp-card-bg-soft);
	border: 1px solid var(--stp-card-border);
}

.stp-product-card__image-placeholder .dashicons {
	width: 42px;
	height: 42px;
	color: var(--stp-card-muted);
	font-size: 42px;
	line-height: 42px;
}

.stp-product-card__badges {
	position: absolute;
	top: 8px;
	left: 10px;
	z-index: 6;
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 5px;
	max-width: calc(100% - 20px);
	pointer-events: none;
}

.stp-product-card__badge {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-height: 22px;
	padding: 3px 8px;
	color: #fff;
	background: #111827;
	border-radius: 999px;
	box-shadow: 0 1px 2px rgba(15, 23, 42, 0.12);
	font-size: 10px;
	font-weight: 700;
	line-height: 1;
	letter-spacing: 0.03em;
	text-transform: uppercase;
}

.stp-product-card__badge--sale {
	background: var(--stp-card-primary);
}

.stp-product-card__badge--stock {
	color: #111827;
	background: #f3f4f6;
}

.stp-product-card__badge--outofstock {
	color: #fff;
	background: #dc2626;
}

.stp-product-card__badge--onbackorder {
	color: #111827;
	background: #f59e0b;
}

.stp-product-card__body {
	position: relative;
	z-index: 5;
	display: grid;
	grid-template-rows: 42px 28px 38px;
	gap: 6px;
	min-width: 0;
	padding: 4px 17px 10px;
	background: #fff;
	overflow: visible;
}

.stp-product-card__title {
	position: relative;
	z-index: 6;
	height: 42px;
	min-height: 42px;
	max-height: 42px;
	margin: 0;
	color: var(--stp-card-link);
	background: #fff;
	font-size: 14px;
	font-weight: 800;
	line-height: 1.45;
	letter-spacing: 0;
	overflow: hidden;
}

.stp-product-card__title a {
	position: relative;
	z-index: 6;
	display: -webkit-box;
	overflow: hidden;
	color: inherit;
	text-decoration: none;
	-webkit-box-orient: vertical;
	-webkit-line-clamp: 2;
}

.stp-product-card__title a:hover,
.stp-product-card__title a:focus {
	color: var(--stp-card-link-hover);
	text-decoration: underline;
	text-underline-offset: 3px;
	outline: none;
}

.stp-product-card__summary {
	position: relative;
	z-index: 5;
	display: grid;
	grid-template-columns: minmax(0, 1fr) max-content;
	gap: 4px;
	align-items: center;
	min-height: 28px;
	max-height: 28px;
	margin: 0;
	background: #fff;
	overflow: hidden;
}

.stp-product-card__price {
	display: flex;
	flex-wrap: nowrap;
	align-items: baseline;
	gap: 4px;
	min-width: 0;
	max-width: 100%;
	color: var(--stp-card-text);
	font-size: 13px;
	font-weight: 800;
	line-height: 1.2;
	white-space: nowrap;
}

.stp-product-card__price-current {
	flex: 0 1 auto;
	min-width: 0;
	color: var(--stp-card-text);
}

.stp-product-card__price-regular {
	flex: 0 1 auto;
	min-width: 0;
	overflow: hidden;
	color: #dc2626;
	font-size: 11px;
	font-weight: 600;
	text-decoration-thickness: 1px;
	text-overflow: ellipsis;
}

.stp-product-card__rating {
	display: inline-flex;
	align-items: center;
	justify-content: flex-end;
	gap: 1px;
	min-width: max-content;
	color: var(--stp-card-rating);
	font-size: 10px;
	font-weight: 700;
	line-height: 1;
	white-space: nowrap;
}

.stp-product-card__stars {
	display: inline-flex;
	align-items: center;
	gap: 0;
	font-size: 11px;
	letter-spacing: -0.1em;
}

.stp-product-card__star--filled {
	color: var(--stp-card-rating);
}

.stp-product-card__star--empty {
	color: #d1d5db;
}

.stp-product-card__rating-count {
	color: var(--stp-card-rating);
	font-size: 10px;
	font-weight: 700;
}

.stp-product-card__actions {
	position: relative;
	z-index: 5;
	display: grid;
	grid-template-columns: 38px 36px;
	gap: 9px;
	align-items: center;
	justify-content: space-between;
	min-height: 38px;
	max-height: 38px;
	margin: 0;
	background: #fff;
	overflow: visible;
}

.stp-product-card__wishlist,
.stp-product-card__compare,
.stp-product-card__button {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	margin: 0;
	text-decoration: none;
	cursor: pointer;
	transition:
		color 0.16s ease,
		background-color 0.16s ease,
		border-color 0.16s ease,
		opacity 0.16s ease,
		box-shadow 0.16s ease,
		transform 0.16s ease;
}

.stp-product-card__wishlist {
	position: relative;
	width: 38px;
	height: 38px;
	min-height: 38px;
	color: var(--stp-card-text);
	background: transparent;
	border: 0;
	border-radius: 0;
	font-size: 21px;
	font-weight: 500;
	line-height: 1;
	justify-self: start;
}

.stp-product-card__wishlist:hover,
.stp-product-card__wishlist:focus,
.stp-product-card__wishlist.is-added {
	color: var(--stp-card-primary);
	background: transparent;
	outline: none;
}

.stp-product-card__wishlist[hidden],
.stp-product-card__wishlist.is-hidden,
.stp-product-card__wishlist-icon[hidden],
.stp-product-card__compare[hidden],
.stp-product-card__compare.is-hidden,
.stp-product-card__compare-icon[hidden] {
	display: none !important;
}

.stp-product-card__wishlist span {
	display: block;
	line-height: 1;
	transform: translateY(-1px);
}

.stp-product-card__wishlist-icon,
.stp-product-card__compare-icon {
	display: block;
	width: 21px;
	height: 21px;
	object-fit: contain;
	pointer-events: none;
}

.stp-product-card__wishlist.is-loading,
.stp-product-card__compare.is-loading,
.stp-product-card.is-loading .stp-product-card__button--primary {
	pointer-events: none;
	opacity: 0.75;
}

.stp-product-card__button {
	width: 36px;
	min-width: 36px;
	height: 36px;
	min-height: 36px;
	padding: 0;
	border-radius: 999px;
	font-size: 0;
	font-weight: 800;
	line-height: 1;
	text-align: center;
	white-space: nowrap;
	justify-self: end;
}

.stp-product-card__button--primary {
	color: #fff;
	background: var(--stp-card-compare-bg, var(--stp-card-primary));
	border: 1px solid var(--stp-card-compare-bg, var(--stp-card-primary));
}

.stp-product-card__button--primary:hover,
.stp-product-card__button--primary:focus {
	color: var(--stp-card-qv-color, #fff);
	background: var(--stp-card-primary-dark);
	border-color: var(--stp-card-primary-dark);
	outline: none;
}

.stp-product-card__button .stp-add-to-cart__icon {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 18px;
	height: 18px;
	line-height: 1;
}

.stp-product-card__button .stp-add-to-cart__icon img,
.stp-product-card__button .stp-add-to-cart__icon svg {
	display: block;
	width: 18px;
	height: 18px;
	object-fit: contain;
}

.stp-product-card__button .stp-add-to-cart__icon svg {
	fill: currentColor;
}

.stp-product-card__button .stp-add-to-cart__text {
	position: absolute;
	width: 1px;
	height: 1px;
	padding: 0;
	margin: -1px;
	overflow: hidden;
	clip: rect(0, 0, 0, 0);
	white-space: nowrap;
	border: 0;
}

.stp-product-card__quick-view {
	position: absolute;
	top: calc(50% - 54px);
	left: 50%;
	z-index: 9;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-width: 112px;
	min-height: 36px;
	margin: 0;
	padding: 8px 13px;
	color: var(--stp-card-qv-color, #ffffff);
	background: var(--stp-card-qv-bg, var(--stp-card-primary));
	border: 1px solid var(--stp-card-qv-bg, var(--stp-card-primary));
	border-radius: 25px;
	box-shadow: 0 10px 22px rgba(15, 23, 42, 0.16);
	font-size: 12px;
	font-weight: 900;
	line-height: 1.15;
	text-align: center;
	cursor: pointer;
	opacity: 0;
	transform: translate(-50%, 8px) scale(0.96);
	transition:
		opacity 0.16s ease,
		transform 0.16s ease,
		background-color 0.16s ease,
		border-color 0.16s ease;
}

.stp-product-card__media:hover .stp-product-card__quick-view {
	opacity: 1;
	transform: translate(-50%, 0) scale(1);
}

.stp-product-card__quick-view:hover,
.stp-product-card__quick-view:focus-visible {
	color: var(--stp-card-qv-color, #ffffff);
	background: var(--stp-card-primary-dark);
	border-color: var(--stp-card-primary-dark);
	outline: none;
}

.stp-product-card__compare {
	position: absolute;
	top: calc(50% + 18px);
	left: 50%;
	z-index: 4;
	width: 42px;
	height: 42px;
	min-height: 42px;
	color: var(--stp-card-compare-color, #ffffff);
	background: var(--stp-card-compare-bg, var(--stp-card-primary));
	border: 1px solid var(--stp-card-compare-bg, var(--stp-card-primary));
	border-radius: 999px;
	opacity: 0;
	transform: translate(-50%, -50%) scale(0.94);
}

.stp-product-card__media:hover .stp-product-card__compare {
	opacity: 1;
	transform: translate(-50%, -50%) scale(1);
}

.stp-product-card__compare:hover,
.stp-product-card__compare:focus-visible,
.stp-product-card__media:hover .stp-product-card__compare.is-added {
	color: var(--stp-card-compare-color, #ffffff);
	background: var(--stp-card-primary-dark);
	border-color: var(--stp-card-primary-dark);
	outline: none;
}

.stp-product-card__compare-icon {
	width: 20px;
	height: 20px;
	filter: brightness(0) invert(1);
}

.stp-product-card__quick-view:focus:not(:focus-visible),
.stp-product-card__compare:focus:not(:focus-visible),
.stp-product-card__wishlist:focus:not(:focus-visible),
.stp-product-card__button:focus:not(:focus-visible),
.stp-product-card__title a:focus:not(:focus-visible) {
	outline: none;
}

.stp-product-card__quick-view:focus-visible,
.stp-product-card__compare:focus-visible,
.stp-product-card__wishlist:focus-visible,
.stp-product-card__button:focus-visible,
.stp-product-card__title a:focus-visible {
	outline: 2px solid var(--stp-card-primary);
	outline-offset: 2px;
}

.stp-product-card--fallback {
	padding: 14px;
}

.stp-product-archive,
.stp-product-archive__content,
.stp-product-archive__main,
.stp-product-archive__grid-wrap,
.stp-product-archive__grid {
	overflow: visible;
}

.stp-product-archive__grid:not([data-view="list"]) > .stp-product-card {
	width: var(--stp-product-card-width, 205px) !important;
	min-width: var(--stp-product-card-width, 205px) !important;
	max-width: var(--stp-product-card-width, 205px) !important;
	height: var(--stp-product-card-height, 330px) !important;
	min-height: var(--stp-product-card-height, 330px) !important;
	grid-template-rows: 27px 168px 1fr !important;
	overflow: visible !important;
}

.stp-product-archive__grid:not([data-view="list"]) .stp-product-card__catalog-meta {
	min-height: 27px !important;
	padding: 6px 17px 3px !important;
}

.stp-product-archive__grid:not([data-view="list"]) .stp-product-card__media {
	height: 168px !important;
	min-height: 168px !important;
	max-height: 168px !important;
	padding: 0 17px !important;
}

.stp-product-archive__grid:not([data-view="list"]) .stp-product-card__body {
	grid-template-rows: 42px 28px 38px !important;
	gap: 6px !important;
	padding: 4px 17px 10px !important;
}

.stp-product-archive__grid:not([data-view="list"]) .stp-product-card__title {
	height: 42px !important;
	min-height: 42px !important;
	max-height: 42px !important;
	font-size: 14px !important;
	line-height: 1.45 !important;
}

.stp-product-archive__grid:not([data-view="list"]) .stp-product-card__summary {
	grid-template-columns: minmax(0, 1fr) max-content !important;
	gap: 4px !important;
	min-height: 28px !important;
	max-height: 28px !important;
}

.stp-product-archive__grid:not([data-view="list"]) .stp-product-card__actions {
	display: grid !important;
	grid-template-columns: 38px 36px !important;
	gap: 9px !important;
	align-items: center !important;
	justify-content: space-between !important;
	min-height: 38px !important;
	max-height: 38px !important;
}

.stp-product-archive__grid[data-view="list"] .stp-product-card {
	width: 100%;
	max-width: none;
	height: auto;
	min-height: 0;
	grid-template-rows: auto;
}

.stp-product-archive__grid[data-view="list"] .stp-product-card__media,
.stp-product-archive__grid[data-view="list"] .stp-product-card__image {
	border-radius: 10px !important;
}

.stp-product-archive__grid[data-view="list"] .stp-product-card__body {
	display: grid !important;
	grid-template-columns: minmax(0, 1fr) max-content !important;
	grid-template-rows: auto auto !important;
	column-gap: 17px !important;
	row-gap: 8px !important;
	align-content: center !important;
	padding: 34px 17px 17px !important;
}

.stp-product-archive__grid[data-view="list"] .stp-product-card__title {
	grid-column: 1 !important;
	grid-row: 1 !important;
}

.stp-product-archive__grid[data-view="list"] .stp-product-card__summary {
	display: contents !important;
}

.stp-product-archive__grid[data-view="list"] .stp-product-card__price {
	grid-column: 1 !important;
	grid-row: 2 !important;
}

.stp-product-archive__grid[data-view="list"] .stp-product-card__rating {
	grid-column: 2 !important;
	grid-row: 1 !important;
	align-self: end !important;
	justify-self: end !important;
}

.stp-product-archive__grid[data-view="list"] .stp-product-card__actions {
	grid-column: 2 !important;
	grid-row: 2 !important;
	align-self: start !important;
	justify-self: end !important;
	max-width: none !important;
}

.stp-wishlist-toast,
.stp-compare-toast {
	--stp-toast-bg: #16a34a;
	--stp-toast-color: #ffffff;
	position: fixed;
	z-index: 999999;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	max-width: min(92vw, 360px);
	padding: 12px 16px;
	color: var(--stp-toast-color);
	background: var(--stp-toast-bg);
	border-radius: 999px;
	box-shadow: none;
	font-size: 13px;
	font-weight: 800;
	line-height: 1.35;
	text-align: center;
	opacity: 0;
	pointer-events: none;
	transform: translateY(8px);
	transition:
		opacity 0.18s ease,
		transform 0.18s ease;
}

.stp-wishlist-toast.is-visible,
.stp-compare-toast.is-visible {
	opacity: 1;
	transform: translateY(0);
}

.stp-wishlist-toast--center,
.stp-compare-toast--center {
	top: 50%;
	left: 50%;
	transform: translate(-50%, calc(-50% + 8px));
}

.stp-wishlist-toast--center.is-visible,
.stp-compare-toast--center.is-visible {
	transform: translate(-50%, -50%);
}

.stp-wishlist-toast--top-left,
.stp-compare-toast--top-left {
	top: 24px;
	left: 24px;
}

.stp-wishlist-toast--top-right,
.stp-compare-toast--top-right {
	top: 24px;
	right: 24px;
}

.stp-wishlist-toast--bottom-left,
.stp-compare-toast--bottom-left {
	bottom: 24px;
	left: 24px;
}

.stp-wishlist-toast--bottom-right,
.stp-compare-toast--bottom-right {
	right: 24px;
	bottom: 24px;
}

@media (hover: none) {
	.stp-product-card__quick-view,
	.stp-product-card__compare {
		opacity: 0;
	}
}

@media screen and (max-width: 520px) {
	.stp-wishlist-toast,
	.stp-compare-toast {
		border-radius: 14px;
		font-size: 13px;
	}

	.stp-wishlist-toast--top-left,
	.stp-wishlist-toast--top-right,
	.stp-wishlist-toast--bottom-left,
	.stp-wishlist-toast--bottom-right,
	.stp-compare-toast--top-left,
	.stp-compare-toast--top-right,
	.stp-compare-toast--bottom-left,
	.stp-compare-toast--bottom-right {
		right: 14px;
		left: 14px;
	}
}

/* Product card stock-label removal and sold-state CTA treatment. */
.stp-product-card__badge--stock {
	display: none !important;
}

.stp-product-card__actions {
	grid-template-columns: 38px minmax(36px, max-content);
}

.stp-product-card__button.is-out-of-stock,
.stp-product-card__button.stp-add-to-cart--out-of-stock {
	width: 46px;
	min-width: 46px;
	height: 30px;
	min-height: 30px;
	padding: 0 7px;
	color: #ffffff;
	background: #ef4444;
	border-color: #ef4444;
	border-radius: 999px;
	box-shadow: none;
	font-size: 10px;
	font-weight: 900;
	line-height: 1;
	letter-spacing: 0;
	text-transform: none;
	cursor: not-allowed;
	opacity: 1;
	pointer-events: none;
}

.stp-product-card__button.is-out-of-stock:hover,
.stp-product-card__button.is-out-of-stock:focus,
.stp-product-card__button.stp-add-to-cart--out-of-stock:hover,
.stp-product-card__button.stp-add-to-cart--out-of-stock:focus {
	color: #ffffff;
	background: #ef4444;
	border-color: #ef4444;
	box-shadow: none;
	transform: none;
}

.stp-product-card__button.is-out-of-stock .stp-add-to-cart__icon,
.stp-product-card__button.stp-add-to-cart--out-of-stock .stp-add-to-cart__icon {
	display: none !important;
}

.stp-product-card__button.is-out-of-stock::before,
.stp-product-card__button.stp-add-to-cart--out-of-stock::before {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 100%;
	content: "Sold";
	font-size: 10px;
	font-weight: 900;
	line-height: 1;
	white-space: nowrap;
}

.stp-product-archive__grid:not([data-view="list"]) .stp-product-card__actions {
	grid-template-columns: 38px minmax(36px, max-content) !important;
}

.stp-product-archive__grid:not([data-view="list"]) > .stp-product-card {
	--stp-product-card-width: 100%;
	width: 100% !important;
	min-width: 0 !important;
	max-width: 100% !important;
}

/* Product card fixed dimension lock for shop/archive grids.
 * Prevents card resizing at different browser zoom levels while keeping internal style consistent.
 */
.stp-product-archive__grid:not([data-view="list"]) > .stp-product-card {
	--stp-product-card-width: 205px;
	--stp-product-card-height: 330px;
	width: 205px !important;
	min-width: 205px !important;
	max-width: 205px !important;
	height: 330px !important;
	min-height: 330px !important;
	max-height: 330px !important;
	grid-template-rows: 27px 168px 1fr !important;
	padding: 0 !important;
	overflow: visible !important;
}

.stp-product-archive__grid:not([data-view="list"]) > .stp-product-card .stp-product-card__catalog-meta {
	height: 27px !important;
	min-height: 27px !important;
	max-height: 27px !important;
	padding: 6px 17px 3px !important;
}

.stp-product-archive__grid:not([data-view="list"]) > .stp-product-card .stp-product-card__media {
	height: 168px !important;
	min-height: 168px !important;
	max-height: 168px !important;
	padding: 0 17px !important;
}

.stp-product-archive__grid:not([data-view="list"]) > .stp-product-card .stp-product-card__body {
	height: 135px !important;
	min-height: 135px !important;
	max-height: 135px !important;
	grid-template-rows: 42px 28px 38px !important;
	gap: 6px !important;
	padding: 4px 17px 10px !important;
}

.stp-product-archive__grid:not([data-view="list"]) > .stp-product-card .stp-product-card__title {
	height: 42px !important;
	min-height: 42px !important;
	max-height: 42px !important;
	font-size: 14px !important;
	line-height: 1.45 !important;
}

.stp-product-archive__grid:not([data-view="list"]) > .stp-product-card .stp-product-card__summary {
	height: 28px !important;
	min-height: 28px !important;
	max-height: 28px !important;
}

.stp-product-archive__grid:not([data-view="list"]) > .stp-product-card .stp-product-card__actions {
	height: 38px !important;
	min-height: 38px !important;
	max-height: 38px !important;
}
