/**
 * SP Trending Products - front-end styles.
 * Inherits theme font; colours from CSS variables injected inline.
 */

.sptp-section {
	width: 100%;
	margin: 0 auto;
	font-family: inherit;
}

.sptp-heading {
	font-family: inherit;
	font-size: 30px;
	font-weight: 800;
	line-height: 1.15;
	margin: 0 0 22px;
	color: inherit;
}

/* ---- Filter pills ---- */
.sptp-pills {
	display: flex;
	flex-wrap: wrap;
	gap: 12px;
	margin-bottom: 28px;
}

.sptp-pill {
	font-family: inherit;
	font-size: 15px;
	font-weight: 600;
	cursor: pointer;
	padding: 10px 22px;
	border-radius: 999px;
	border: 1px solid rgba(0, 0, 0, 0.18);
	background: transparent;
	color: inherit;
	white-space: nowrap;
	transition: background 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}

.sptp-pill:hover {
	border-color: var(--sptp-primary, #3C0008);
}

.sptp-pill.is-active {
	background: var(--sptp-primary, #3C0008);
	color: var(--sptp-accent, #F5F5DC);
	border-color: var(--sptp-primary, #3C0008);
}

/* ---- Panels ---- */
.sptp-panel {
	display: none;
}

.sptp-panel.is-active {
	display: block;
}

/* ---- Product grid ---- */
.sptp-grid {
	display: grid;
	gap: 24px 18px;
	/* grid-template-columns injected inline per instance/breakpoint */
}

.sptp-card {
	display: flex;
	flex-direction: column;
	text-align: center;
}

/* Media wrapper holds the image plus hover controls */
.sptp-card-media {
	position: relative;
	margin-bottom: 12px;
}

.sptp-section .sptp-card-img {
	display: block;
	position: relative;
	border-radius: 12px;
	overflow: hidden;
	background: #f3f3f3;
	aspect-ratio: auto !important;
}

.sptp-section .sptp-card-img img {
	width: 100% !important;
	height: auto !important;
	max-width: 100% !important;
	object-fit: fill !important;
	display: block;
	transition: transform 0.3s ease, opacity 0.4s ease;
}

/* Main image defines the natural height (no crop, keeps 960x1280 ratio) */
.sptp-section .sptp-card-img .sptp-img-main {
	position: relative;
	z-index: 1;
}

/* Second image sits on top, hidden until hover */
.sptp-section .sptp-card-img .sptp-img-hover {
	position: absolute !important;
	inset: 0 !important;
	width: 100% !important;
	height: 100% !important;
	object-fit: cover !important;
	opacity: 0;
	z-index: 2;
}

.sptp-card-img.has-hover:hover .sptp-img-hover {
	opacity: 1;
}

.sptp-card-img.has-hover:hover .sptp-img-main {
	opacity: 0;
}

/* Subtle zoom still applies on cards without a second image */
.sptp-card-img:not(.has-hover):hover img {
	transform: scale(1.04);
}

/* ---- Quick view (eye) icon ---- */
.sptp-quickview {
	position: absolute;
	top: 12px;
	right: 12px;
	z-index: 3;
	width: 38px;
	height: 38px;
	display: inline-flex !important;
	align-items: center;
	justify-content: center;
	border-radius: 50%;
	background: #fff;
	color: var(--sptp-primary, #3C0008);
	box-shadow: 0 2px 8px rgba(0, 0, 0, 0.18);
	text-decoration: none !important;
	opacity: 0;
	transform: translateY(-6px);
	transition: opacity 0.25s ease, transform 0.25s ease, background 0.2s ease, color 0.2s ease;
	pointer-events: none;
}

.sptp-quickview svg {
	display: block;
	width: 18px;
	height: 18px;
}

.sptp-card-media:hover .sptp-quickview {
	opacity: 1;
	transform: translateY(0);
	pointer-events: auto;
}

.sptp-quickview:hover {
	background: var(--sptp-primary, #3C0008);
	color: var(--sptp-accent, #F5F5DC);
}

/* ---- Add to cart button ---- */
.sptp-addcart {
	position: absolute;
	left: 50%;
	bottom: 14px;
	transform: translate(-50%, 10px);
	z-index: 3;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	font-family: inherit;
	font-size: 14px;
	font-weight: 600;
	white-space: nowrap;
	padding: 11px 22px;
	border-radius: 999px;
	background: var(--sptp-primary, #3C0008);
	color: var(--sptp-accent, #F5F5DC);
	text-decoration: none !important;
	box-shadow: 0 3px 12px rgba(0, 0, 0, 0.22);
	opacity: 0;
	transition: opacity 0.25s ease, transform 0.25s ease;
	pointer-events: none;
}

.sptp-card-media:hover .sptp-addcart {
	opacity: 1;
	transform: translate(-50%, 0);
	pointer-events: auto;
}

.sptp-addcart:hover {
	opacity: 0.92;
}

.sptp-addcart.is-loading { opacity: 0.75; }
.sptp-addcart.is-added { background: #2e7d32 !important; color: #fff !important; }

/* WooCommerce appends a "View cart" link after AJAX add — hide it inside the
   card so it doesn't overlap the floating button. Cart still updates in header. */
.sptp-section .added_to_cart,
.sptp-section a.added_to_cart,
.sptp-section .wc-forward,
.sptp-card .added_to_cart,
.sptp-card-media .added_to_cart {
	display: none !important;
	visibility: hidden !important;
	position: absolute !important;
	width: 0 !important;
	height: 0 !important;
	overflow: hidden !important;
	pointer-events: none !important;
}

/* When WooCommerce marks it added */
.sptp-addcart.added {
	opacity: 1;
	transform: translate(-50%, 0);
	pointer-events: auto;
}

.sptp-addcart.loading {
	opacity: 0.7;
}

/* Touch devices: show controls always (no hover) */
@media (hover: none) {
	/* No hover on touch: hide the quick-view icon, and show the add-to-cart
	   as a clean full-width button below the image, contained in its own card. */
	.sptp-card-media {
		display: flex;
		flex-direction: column;
	}
	.sptp-quickview {
		display: none !important;
	}
	.sptp-addcart {
		position: static !important;
		left: auto !important;
		right: auto !important;
		bottom: auto !important;
		top: auto !important;
		transform: none !important;
		opacity: 1 !important;
		visibility: visible !important;
		pointer-events: auto !important;
		margin: 10px 0 0 !important;
		width: 100% !important;
		max-width: 100% !important;
		box-sizing: border-box !important;
		box-shadow: none !important;
	}
}

.sptp-card-title {
	font-family: inherit;
	font-size: 15px;
	font-weight: 500;
	line-height: 1.35;
	color: inherit;
	text-decoration: none !important;
	margin-bottom: 6px;
}

.sptp-card-title:hover {
	opacity: 0.8;
}

.sptp-card-price {
	font-family: inherit;
	font-size: 14px;
	font-weight: 600;
	color: inherit;
	opacity: 0.85;
}

.sptp-card-price del { opacity: 0.5; font-weight: 400; margin-right: 6px; }
.sptp-card-price ins { text-decoration: none; }

/* ---- View all ---- */
.sptp-viewall-wrap {
	display: flex;
	justify-content: center;
	margin-top: 34px;
}

.sptp-viewall {
	display: inline-flex;
	align-items: center;
	gap: 10px;
	font-family: inherit;
	font-size: 15px;
	font-weight: 600;
	color: inherit;
	text-decoration: none !important;
	padding: 13px 30px;
	border-radius: 999px;
	border: 1.5px solid rgba(0, 0, 0, 0.65);
	transition: background 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}

.sptp-viewall:hover {
	background: var(--sptp-primary, #3C0008);
	color: var(--sptp-accent, #F5F5DC);
	border-color: var(--sptp-primary, #3C0008);
}

.sptp-viewall-icon { font-size: 18px; line-height: 1; }

/* ---- Responsive ---- */
@media (max-width: 1024px) {
	.sptp-heading { font-size: 26px; }
}

@media (max-width: 600px) {
	.sptp-heading { font-size: 22px; }
	.sptp-pill { font-size: 14px; padding: 8px 16px; }
	.sptp-card-title { font-size: 14px; }
	.sptp-grid { gap: 18px 12px; }

	/* Stack image + button inside each card; hide hover-only quick view. */
	.sptp-card-media {
		display: flex;
		flex-direction: column;
	}
	.sptp-quickview { display: none !important; }
	.sptp-addcart {
		position: static !important;
		left: auto !important;
		right: auto !important;
		top: auto !important;
		bottom: auto !important;
		transform: none !important;
		opacity: 1 !important;
		visibility: visible !important;
		pointer-events: auto !important;
		margin: 10px 0 0 !important;
		width: 100% !important;
		max-width: 100% !important;
		box-sizing: border-box !important;
		box-shadow: none !important;
		font-size: 13px;
		padding: 10px 12px;
	}
}

/* =========================================================
   Quick View Modal
   ========================================================= */
.sptp-modal {
	position: fixed;
	inset: 0;
	z-index: 99999;
	display: none;
}
.sptp-modal.is-open { display: block; }

body.sptp-modal-lock { overflow: hidden; }

.sptp-modal-overlay {
	position: absolute;
	inset: 0;
	background: rgba(0, 0, 0, 0.55);
	backdrop-filter: blur(2px);
}

.sptp-modal-dialog {
	position: relative;
	z-index: 1;
	max-width: 980px;
	width: calc(100% - 40px);
	max-height: calc(100vh - 60px);
	margin: 30px auto;
	background: #fff;
	border-radius: 16px;
	overflow: auto;
	box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
	animation: sptp-modal-in 0.25s ease;
}

@keyframes sptp-modal-in {
	from { opacity: 0; transform: translateY(16px); }
	to   { opacity: 1; transform: translateY(0); }
}

.sptp-modal-close {
	position: absolute;
	top: 14px;
	right: 14px;
	z-index: 3;
	width: 40px;
	height: 40px;
	border-radius: 50%;
	border: 1px solid rgba(0, 0, 0, 0.15);
	background: #fff;
	font-size: 24px;
	line-height: 1;
	cursor: pointer;
	color: #333;
	transition: background 0.2s ease;
}
.sptp-modal-close:hover { background: #f2f2f2; }

.sptp-modal-loading {
	padding: 60px 20px;
	text-align: center;
	font-family: inherit;
	color: #777;
}

/* Quick view content */
.sptp-qv {
	display: grid;
	grid-template-columns: 1fr 1fr;
	gap: 0;
}

.sptp-qv-gallery {
	background: #f7f7f7;
	display: flex;
	align-items: center;
	justify-content: center;
}
.sptp-qv-gallery img {
	width: 100%;
	height: auto;
	object-fit: contain;
	display: block;
}
.sptp-qv-single { display: block; }

.sptp-qv-info {
	padding: 40px 36px;
	font-family: inherit;
	display: flex;
	flex-direction: column;
	gap: 16px;
}

.sptp-qv-title {
	font-family: inherit;
	font-size: 28px;
	font-weight: 800;
	line-height: 1.15;
	margin: 0;
	color: inherit;
}

.sptp-qv-price {
	font-family: inherit;
	font-size: 20px;
	font-weight: 600;
}
.sptp-qv-price del { opacity: 0.5; font-weight: 400; margin-right: 8px; }
.sptp-qv-price ins { text-decoration: none; }

.sptp-qv-desc {
	font-family: inherit;
	font-size: 15px;
	line-height: 1.6;
	color: inherit;
}
.sptp-qv-desc p { margin: 0 0 8px; }

.sptp-qv-actions { margin-top: 4px; }

.sptp-qv-cart-form {
	display: flex;
	gap: 12px;
	align-items: stretch;
	flex-wrap: nowrap;
}

.sptp-qv-qty {
	display: inline-flex;
	align-items: center;
	flex: 0 0 auto;
	border: 1px solid rgba(0, 0, 0, 0.18);
	border-radius: 999px;
	padding: 4px 6px;
	background: #fff;
}
.sptp-qty-btn {
	border: none;
	background: transparent;
	width: 34px;
	min-width: 34px;
	height: 34px;
	padding: 0;
	font-size: 20px;
	line-height: 1;
	cursor: pointer;
	color: inherit;
	border-radius: 50%;
	flex: 0 0 auto;
}
.sptp-qty-btn:hover { background: rgba(0, 0, 0, 0.06); }
.sptp-qty-input.sptp-qty-input {
	width: 44px;
	min-width: 44px;
	max-width: 44px;
	flex: 0 0 44px;
	text-align: center;
	border: none;
	background: transparent;
	box-shadow: none;
	font-size: 16px;
	font-family: inherit;
	padding: 0;
	height: auto;
	-moz-appearance: textfield;
}
.sptp-qty-input::-webkit-outer-spin-button,
.sptp-qty-input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

.sptp-qv-addcart {
	flex: 1 1 auto;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	font-family: inherit;
	font-size: 15px;
	font-weight: 600;
	white-space: nowrap;
	padding: 13px 26px;
	border-radius: 999px;
	background: var(--sptp-primary, #3C0008);
	color: var(--sptp-accent, #F5F5DC);
	border: 1.5px solid var(--sptp-primary, #3C0008);
	text-decoration: none !important;
	cursor: pointer;
}
.sptp-qv-addcart:hover { opacity: 0.92; }

.sptp-qv-details {
	display: inline-flex;
	align-items: center;
	justify-content: space-between;
	gap: 10px;
	margin-top: 6px;
	padding-top: 16px;
	border-top: 1px solid rgba(0, 0, 0, 0.12);
	font-family: inherit;
	font-size: 15px;
	color: inherit;
	text-decoration: none !important;
}
.sptp-qv-details:hover { opacity: 0.8; }

@media (max-width: 768px) {
	.sptp-qv { grid-template-columns: 1fr; }
	.sptp-qv-info { padding: 24px 20px; }
	.sptp-qv-title { font-size: 22px; }
	.sptp-modal-dialog { margin: 16px auto; width: calc(100% - 24px); }
}
