/**
 * Siddhi Vinayak Product Showcase - front-end styles.
 *
 * Every selector is prefixed with .svps- so the plugin can never leak into a
 * theme (Astra, Hello Elementor, block themes) or be overwritten by one.
 * All tunable values come from CSS custom properties which the Settings page
 * prints as an inline :root block; the values below are the fallbacks.
 */

/* -------------------------------------------------------------------------
   1. Tokens
   ---------------------------------------------------------------------- */

:root {
	--svps-primary: #43d19e;
	--svps-accent: #e2231a;
	--svps-border: #e5e5e5;
	--svps-card-bg: #ffffff;
	--svps-text: #222222;
	--svps-card-radius: 24px;
	--svps-badge-radius: 20px;
	--svps-title-size: 16px;
	--svps-heading-size: 32px;
	--svps-image-height: 240px;
	--svps-gap: 24px;
	--svps-cols: 3;
	--svps-slides: 1;
	--svps-shadow: 0 14px 30px rgba(18, 18, 18, 0.08);
	--svps-focus: #1a73e8;
}

/* -------------------------------------------------------------------------
   2. Section shell
   ---------------------------------------------------------------------- */

.svps-products-section {
	box-sizing: border-box;
	width: 100%;
	max-width: 100%;
	margin: 0 auto;
	/* Never let a slider or grid push the page sideways. */
	overflow: visible;
}

.svps-products-section *,
.svps-products-section *::before,
.svps-products-section *::after {
	box-sizing: border-box;
}

.svps-section-header {
	text-align: center;
	margin: 0 0 28px;
}

.svps-section-title {
	margin: 0;
	padding: 0;
	font-size: var(--svps-heading-size);
	line-height: 1.2;
	font-weight: 700;
	color: var(--svps-text);
	letter-spacing: -0.01em;
}

.svps-heading-decoration {
	display: block;
	width: 64px;
	height: 4px;
	margin: 12px auto 0;
	border-radius: 4px;
	background: var(--svps-accent);
}

.svps-empty,
.svps-note {
	grid-column: 1 / -1;
	margin: 0;
	padding: 28px 16px;
	text-align: center;
	color: var(--svps-text);
	opacity: 0.75;
	font-size: 15px;
}

/* -------------------------------------------------------------------------
   3. Product card
   ---------------------------------------------------------------------- */

.svps-product-card {
	position: relative;
	display: flex;
	flex-direction: column;
	height: 100%;
	background: var(--svps-card-bg);
	border: 1px solid var(--svps-border);
	border-radius: var(--svps-card-radius);
	overflow: hidden;
	transition: transform 0.28s ease, box-shadow 0.28s ease, border-color 0.28s ease;
}

.svps-product-card:hover,
.svps-product-card:focus-within {
	transform: translateY(-4px);
	box-shadow: var(--svps-shadow);
	border-color: rgba(0, 0, 0, 0.08);
}

/* Themes such as Astra underline every link inside the content area with a
   selector that out-specifies a single class (e.g. `.entry-content a`), and
   text-decoration cannot be cancelled by a descendant. The card link is our
   own element, so it is overridden explicitly here — narrowly, and without
   touching any other link on the page. */
.svps-products-section a.svps-card-link,
.svps-products-section a.svps-card-link:link,
.svps-products-section a.svps-card-link:visited,
.svps-products-section a.svps-card-link:hover,
.svps-products-section a.svps-card-link:focus,
.svps-products-section a.svps-card-link:active {
	display: flex;
	flex-direction: column;
	flex: 1 1 auto;
	min-height: 0;
	color: inherit;
	background: none;
	border: 0;
	box-shadow: none;
	text-decoration: none !important;
	text-underline-offset: 0;
}

.svps-products-section a.svps-card-link:focus-visible {
	outline: 2px solid var(--svps-focus);
	outline-offset: -3px;
	border-radius: inherit;
}

/* Image area: fixed height, image contained, never cropped or stretched. */
.svps-product-image {
	position: relative;
	display: flex;
	align-items: center;
	justify-content: center;
	height: var(--svps-image-height);
	padding: 18px;
	overflow: hidden;
	background: var(--svps-card-bg);
}

.svps-product-image .svps-product-img {
	display: block;
	width: auto;
	height: auto;
	max-width: 100%;
	max-height: 100%;
	object-fit: contain;
	margin: 0;
	border-radius: 0;
	box-shadow: none;
	transition: transform 0.35s ease;
}

.svps-product-card:hover .svps-product-img {
	transform: scale(1.04);
}

.svps-product-placeholder {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 100%;
	height: 100%;
	color: var(--svps-border);
	background: rgba(0, 0, 0, 0.02);
	border-radius: calc(var(--svps-card-radius) / 2);
}

.svps-product-placeholder svg {
	width: 46px;
	height: 46px;
}

/* Badge */
.svps-product-badge {
	position: absolute;
	top: 14px;
	left: 14px;
	z-index: 2;
	display: inline-block;
	max-width: calc(100% - 28px);
	padding: 5px 12px;
	border-radius: var(--svps-badge-radius);
	background: var(--svps-primary);
	color: #fff;
	font-size: 11px;
	font-weight: 700;
	line-height: 1.3;
	letter-spacing: 0.06em;
	text-transform: uppercase;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

/* Title */
.svps-product-title {
	margin: 0;
	padding: 0 16px 22px;
	text-align: center;
	font-size: var(--svps-title-size);
	line-height: 1.4;
	font-weight: 600;
	color: var(--svps-text);
	word-break: break-word;
}

/* -------------------------------------------------------------------------
   4. Grid
   ---------------------------------------------------------------------- */

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

/* -------------------------------------------------------------------------
   5. Slider
   ---------------------------------------------------------------------- */

.svps-slider {
	position: relative;
	width: 100%;
}

.svps-slider-viewport {
	overflow: hidden;
	/* Keeps focus rings from being clipped on the vertical axis. */
	padding: 4px;
	margin: -4px;
}

.svps-slider-track {
	display: flex;
	gap: var(--svps-gap);
	transition: transform 0.45s cubic-bezier(0.22, 0.61, 0.36, 1);
	will-change: transform;
	touch-action: pan-y;
}

.svps-slider-track.svps-dragging {
	transition: none;
	cursor: grabbing;
	user-select: none;
}

.svps-slide {
	flex: 0 0 calc((100% - (var(--svps-slides) - 1) * var(--svps-gap)) / var(--svps-slides));
	min-width: 0;
}

/* Before JS runs, show the slides as a plain scrollable row so there is no
   layout jump and the section still works with JavaScript disabled. */
.svps-slider:not(.svps-ready) .svps-slider-viewport {
	overflow-x: auto;
	-webkit-overflow-scrolling: touch;
	scrollbar-width: none;
}

.svps-slider:not(.svps-ready) .svps-slider-viewport::-webkit-scrollbar {
	display: none;
}

.svps-slider:not(.svps-ready) .svps-slide {
	flex: 0 0 clamp(220px, 42vw, 320px);
}

/* Navigation arrows */
.svps-slider-nav {
	display: flex;
	gap: 12px;
	justify-content: center;
	margin-top: 24px;
}

.svps-slider-arrow {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 44px;
	height: 44px;
	padding: 0;
	border: 1px solid var(--svps-border);
	border-radius: 50%;
	background: var(--svps-card-bg);
	color: var(--svps-text);
	cursor: pointer;
	transition: background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease, opacity 0.2s ease;
	-webkit-appearance: none;
	appearance: none;
}

.svps-slider-arrow:hover:not([disabled]) {
	background: var(--svps-text);
	border-color: var(--svps-text);
	color: #fff;
}

.svps-slider-arrow:focus-visible {
	outline: 2px solid var(--svps-focus);
	outline-offset: 2px;
}

.svps-slider-arrow[disabled] {
	opacity: 0.38;
	cursor: default;
}

.svps-slider-arrow svg {
	width: 20px;
	height: 20px;
	display: block;
}

/* Hidden entirely when there is nothing to scroll. */
.svps-slider.svps-nav-hidden .svps-slider-nav {
	display: none;
}

/* Whether sliding is needed depends on the viewport, so only show the arrows
   once the script has measured the track. Without JavaScript the slides fall
   back to a scrollable row, where arrows would do nothing anyway. */
.svps-slider:not(.svps-ready) .svps-slider-nav {
	display: none;
}

/* Fewer products than slots: keep them left-aligned at their natural width
   instead of stretching to fill the row. */
.svps-slider.svps-fits .svps-slider-track {
	transform: none !important;
}

/* -------------------------------------------------------------------------
   6. Filter bar
   ---------------------------------------------------------------------- */

.svps-filter {
	display: flex;
	flex-wrap: wrap;
	gap: 10px;
	justify-content: center;
	margin: 0 0 28px;
}

.svps-filter-btn {
	padding: 9px 20px;
	border: 1px solid var(--svps-border);
	border-radius: 999px;
	background: var(--svps-card-bg);
	color: var(--svps-text);
	font-size: 14px;
	font-weight: 600;
	line-height: 1.3;
	cursor: pointer;
	transition: background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease;
	-webkit-appearance: none;
	appearance: none;
}

.svps-filter-btn:hover {
	border-color: var(--svps-text);
}

.svps-filter-btn.is-active {
	background: var(--svps-text);
	border-color: var(--svps-text);
	color: #fff;
}

.svps-filter-btn:focus-visible {
	outline: 2px solid var(--svps-focus);
	outline-offset: 2px;
}

.svps-filter.is-busy {
	opacity: 0.7;
	pointer-events: none;
}

/* -------------------------------------------------------------------------
   7. Load more
   ---------------------------------------------------------------------- */

.svps-load-more-wrap {
	display: flex;
	justify-content: center;
	margin-top: 36px;
}

.svps-load-more {
	display: inline-flex;
	align-items: center;
	gap: 10px;
	min-height: 46px;
	padding: 12px 34px;
	border: 1px solid var(--svps-border);
	border-radius: 999px;
	background: var(--svps-card-bg);
	color: var(--svps-text);
	font-size: 14px;
	font-weight: 700;
	letter-spacing: 0.06em;
	text-transform: uppercase;
	cursor: pointer;
	transition: background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease;
	-webkit-appearance: none;
	appearance: none;
}

.svps-load-more:hover:not([disabled]) {
	background: var(--svps-text);
	border-color: var(--svps-text);
	color: #fff;
}

.svps-load-more:focus-visible {
	outline: 2px solid var(--svps-focus);
	outline-offset: 2px;
}

.svps-load-more[disabled] {
	cursor: default;
	opacity: 0.75;
}

.svps-load-more-spinner {
	display: none;
	width: 16px;
	height: 16px;
	border: 2px solid currentColor;
	border-right-color: transparent;
	border-radius: 50%;
	animation: svps-spin 0.7s linear infinite;
}

.svps-load-more.is-loading .svps-load-more-spinner {
	display: inline-block;
}

.svps-grid-wrapper.is-loading .svps-product-grid {
	opacity: 0.55;
	transition: opacity 0.2s ease;
}

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

.svps-error {
	grid-column: 1 / -1;
	margin: 16px 0 0;
	text-align: center;
	color: #b32d2e;
	font-size: 14px;
}

/* Newly appended cards fade in gently. */
.svps-product-card.svps-appear {
	animation: svps-fade-in 0.35s ease both;
}

@keyframes svps-fade-in {
	from {
		opacity: 0;
		transform: translateY(10px);
	}
	to {
		opacity: 1;
		transform: none;
	}
}

/* Screen-reader-only helper (self-contained, does not rely on the theme). */
.svps-grid-status.screen-reader-text {
	position: absolute !important;
	width: 1px;
	height: 1px;
	margin: -1px;
	padding: 0;
	overflow: hidden;
	clip: rect(0 0 0 0);
	clip-path: inset(50%);
	white-space: nowrap;
	border: 0;
}

/* -------------------------------------------------------------------------
   8. Responsive
   ---------------------------------------------------------------------- */

/* Tablet: 768px - 1199px */
@media (max-width: 1199px) {
	.svps-product-grid:not(.svps-static-row) {
		grid-template-columns: repeat(2, minmax(0, 1fr));
	}

	.svps-static-row {
		grid-template-columns: repeat(3, minmax(0, 1fr));
	}

	.svps-section-title {
		font-size: clamp(22px, calc(var(--svps-heading-size) * 0.82), var(--svps-heading-size));
	}
}

/* Mobile: 480px - 767px */
@media (max-width: 767px) {
	.svps-product-grid:not(.svps-static-row) {
		grid-template-columns: repeat(2, minmax(0, 1fr));
	}

	.svps-static-row {
		grid-template-columns: repeat(2, minmax(0, 1fr));
	}

	.svps-product-image {
		height: clamp(140px, 40vw, var(--svps-image-height));
		padding: 14px;
	}

	.svps-product-title {
		padding: 0 12px 18px;
	}

	.svps-section-title {
		font-size: clamp(20px, calc(var(--svps-heading-size) * 0.7), var(--svps-heading-size));
	}

	.svps-load-more-wrap {
		margin-top: 28px;
	}
}

/* Small mobile: < 480px */
@media (max-width: 479px) {
	.svps-product-grid:not(.svps-static-row) {
		grid-template-columns: minmax(0, 1fr);
	}

	.svps-static-row {
		grid-template-columns: minmax(0, 1fr);
	}

	.svps-product-badge {
		top: 10px;
		left: 10px;
		padding: 4px 10px;
		font-size: 10px;
	}

	.svps-slider-arrow {
		width: 40px;
		height: 40px;
	}

	.svps-filter-btn {
		padding: 8px 16px;
		font-size: 13px;
	}
}

/* -------------------------------------------------------------------------
   9. Motion & print
   ---------------------------------------------------------------------- */

@media (prefers-reduced-motion: reduce) {
	.svps-product-card,
	.svps-product-img,
	.svps-slider-track,
	.svps-slider-arrow,
	.svps-load-more,
	.svps-filter-btn {
		transition: none !important;
	}

	.svps-product-card:hover {
		transform: none;
	}

	.svps-product-card:hover .svps-product-img {
		transform: none;
	}

	.svps-product-card.svps-appear {
		animation: none;
	}

	.svps-load-more-spinner {
		animation-duration: 2s;
	}
}

@media print {
	.svps-slider-nav,
	.svps-load-more-wrap,
	.svps-filter {
		display: none !important;
	}

	.svps-slider-track {
		transform: none !important;
		flex-wrap: wrap;
	}
}
