/*
 * Elementor Shop Grid — structural + default styles.
 * Design system mirrors the xsmokehub Home page (Home.tsx): a vape-shop
 * aesthetic — DM Serif Display headings + Jost body, ink #222 / muted #888 /
 * line #E5E5E5 / surface #F5F5F5 palette, rounded-2xl cards, square images
 * with hover zoom + "View Product" overlay, black pill badges and buttons.
 * The Elementor controls override these defaults via generated CSS.
 */

/* ---- Wrapper ---- */
.esg-shop-grid {
	width: 100%;
}

/* =====================================================================
 * Category strip (Home.tsx "Category strip")
 * Full-width bottom-bordered tab bar, horizontally scrollable.
 * ===================================================================== */
.esg-toolbar {
	display: flex;
	flex-direction: column;
	gap: 18px;
	margin-bottom: 40px;
}

/*
 * Grouped filter controls. On desktop this is a plain wrapper keeping the
 * original order (category strip, then count + sort); on mobile it becomes the
 * collapsible panel opened by the hamburger toggle below.
 */
.esg-toolbar-panel {
	display: flex;
	flex-direction: column;
	gap: 18px;
	min-width: 0;
}

/* Mobile-only hamburger filter button (hidden on desktop where the category
   strip and sort dropdown render inline as before). */
.esg-filter-toggle {
	display: none;
	align-items: center;
	justify-content: center;
	gap: 8px;
	width: 100%;
	padding: 12px 16px;
	border: 1px solid #e5e5e5;
	border-radius: 10px;
	background-color: #ffffff;
	color: #222222;
	font-family: 'Jost', sans-serif;
	font-size: 13px;
	font-weight: 500;
	line-height: 1;
	cursor: pointer;
	box-shadow: none !important;
	transition: background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}

.esg-filter-toggle:hover,
.esg-filter-toggle:focus {
	background-color: #222222;
	border-color: #222222;
	color: #ffffff;
}

/* Hamburger icon: three stacked bars that morph into an X when open. */
.esg-toggle-icon {
	position: relative;
	display: inline-block;
	width: 16px;
	height: 14px;
}

.esg-toggle-icon span {
	position: absolute;
	left: 0;
	width: 100%;
	height: 2px;
	background-color: currentColor;
	border-radius: 2px;
	transition: top 0.22s ease, transform 0.22s ease, opacity 0.2s ease;
}

.esg-toggle-icon span:nth-child(1) {
	top: 0;
}

.esg-toggle-icon span:nth-child(2) {
	top: 6px;
}

.esg-toggle-icon span:nth-child(3) {
	top: 12px;
}

.esg-toolbar--filter.is-open .esg-toggle-icon span:nth-child(1) {
	top: 6px;
	transform: rotate(45deg);
}

.esg-toolbar--filter.is-open .esg-toggle-icon span:nth-child(2) {
	opacity: 0;
}

.esg-toolbar--filter.is-open .esg-toggle-icon span:nth-child(3) {
	top: 6px;
	transform: rotate(-45deg);
}

.esg-categories {
	display: flex;
	align-items: stretch;
	overflow-x: auto;
	gap: 0;
	margin: 0 -24px;
	padding: 0 24px;
	border-bottom: 1px solid #e5e5e5;
	-webkit-overflow-scrolling: touch;
	scrollbar-width: none;
}

.esg-categories::-webkit-scrollbar {
	display: none;
}

.esg-cat-btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	flex-shrink: 0;
	padding: 16px 20px;
	border: none;
	border-bottom: 2px solid transparent;
	border-radius: 0 !important;
	background: transparent;
	background-color: transparent !important;
	color: #888888;
	font-family: 'Jost', sans-serif;
	font-size: 14px;
	font-weight: 500;
	letter-spacing: 0;
	line-height: 1.2;
	text-transform: none;
	white-space: nowrap;
	cursor: pointer;
	box-shadow: none !important;
	transition: color 0.2s ease, border-color 0.2s ease;
}

.esg-cat-btn.is-active {
	background-color: transparent !important;
	border-bottom-color: #222222;
	color: #222222;
	font-weight: 500;
}

.esg-cat-btn:not(.is-active):hover,
.esg-cat-btn:not(.is-active):focus {
	background-color: transparent !important;
	border-bottom-color: transparent;
	color: #222222;
	box-shadow: none !important;
}

/* ---- Toolbar right: sort + count ---- */
.esg-toolbar-right {
	display: flex;
	align-items: center;
	justify-content: flex-end;
	gap: 16px;
}

.esg-count {
	font-family: 'Jost', sans-serif;
	font-size: 12px;
	font-weight: 400;
	letter-spacing: 0.48px;
	line-height: 18px;
	color: #888888;
	white-space: nowrap;
}

/* ---- Sort dropdown ---- */
.esg-sort {
	appearance: none;
	-webkit-appearance: none;
	-moz-appearance: none;
	width: 170px;
	height: 40px;
	padding: 0 34px 0 16px;
	border: 1px solid #e5e5e5;
	border-radius: 8px;
	background-color: #ffffff;
	background-image: url("data:image/svg+xml,%3Csvg%20xmlns='http://www.w3.org/2000/svg'%20width='10'%20height='6'%20viewBox='0%200%2010%206'%20fill='none'%3E%3Cpath%20d='M1%201L5%205L9%201'%20stroke='%23222'%20stroke-width='1.5'/%3E%3C/svg%3E");
	background-repeat: no-repeat;
	background-position: right 14px center;
	background-size: 10px 6px;
	font-family: 'Jost', sans-serif;
	font-size: 12px;
	font-weight: 400;
	letter-spacing: 0.4px;
	line-height: 1;
	color: #222222;
	cursor: pointer;
	transition: border-color 0.2s ease;
}

.esg-sort:focus {
	outline: none;
	border-color: #222222;
}

/* =====================================================================
 * Section heading (Home.tsx "Featured Products" header)
 * ===================================================================== */
.esg-heading {
	display: flex;
	align-items: flex-end;
	justify-content: space-between;
	gap: 24px;
	margin-bottom: 40px;
}

.esg-eyebrow {
	display: block;
	margin-bottom: 8px;
	font-family: 'Jost', sans-serif;
	font-size: 12px;
	font-weight: 500;
	letter-spacing: 0.2em;
	line-height: 1;
	text-transform: uppercase;
	color: #888888;
}

.esg-title {
	margin: 0;
	font-family: 'DM Serif Display', serif;
	font-size: 36px;
	font-weight: 400;
	line-height: 1.15;
	color: #222222;
}

.esg-view-all {
	flex-shrink: 0;
	font-family: 'Jost', sans-serif;
	font-size: 14px;
	font-weight: 500;
	line-height: 1;
	color: #222222;
	text-decoration: underline;
	text-decoration-offset: 4px;
	transition: opacity 0.2s ease;
}

.esg-view-all:hover {
	opacity: 0.6;
}

/* =====================================================================
 * Product grid
 * ===================================================================== */
.esg-grid {
	display: grid;
	grid-template-columns: repeat(4, minmax(0, 1fr)); /* fallback; Elementor overrides */
	column-gap: 24px;
	row-gap: 24px;
	transition: opacity 0.2s ease;
}

.esg-grid.is-loading {
	opacity: 0.4;
	pointer-events: none;
}

/* =====================================================================
 * Product card (Home.tsx Featured Products card)
 * ===================================================================== */
.esg-product {
	box-sizing: border-box;
	display: flex;
	flex-direction: column;
	background-color: #ffffff;
	border: 1px solid #e5e5e5;
	border-radius: 16px;
	overflow: hidden;
	transition: box-shadow 0.3s ease, border-color 0.3s ease;
}

.esg-product:hover {
	box-shadow: 0 10px 20px rgba(0, 0, 0, 0.05);
	border-color: #dcdcde;
}

/* ---- Image area (square) ---- */
.esg-image-wrapper {
	position: relative;
	overflow: hidden;
	background: #f5f5f5;
	aspect-ratio: 1 / 1;
}

.esg-link {
	display: block;
	position: relative;
	width: 100%;
	height: 100%;
}

.esg-img {
	position: absolute;
	top: 0;
	left: 0;
	width: 100%;
	height: 100%;
	object-fit: cover;
	display: block;
	transition: opacity 0.35s ease, transform 0.5s ease;
}

.esg-img--primary {
	opacity: 1;
}

.esg-img--hover {
	opacity: 0;
}

.esg-product:hover .esg-img--primary {
	transform: scale(1.05);
}

.esg-product:hover .esg-img--hover {
	transform: scale(1.05);
}

/* Only swap when a hover image actually exists (.has-hover). */
.esg-image-wrapper.has-hover:hover .esg-img--primary {
	opacity: 0;
}

.esg-image-wrapper.has-hover:hover .esg-img--hover {
	opacity: 1;
}

/* ---- "View Product" overlay (Home.tsx hover overlay) ---- */
.esg-view-overlay {
	position: absolute;
	inset: 0;
	z-index: 2;
	display: flex;
	align-items: center;
	justify-content: center;
	background: rgba(0, 0, 0, 0.4);
	color: #ffffff;
	font-family: 'Jost', sans-serif;
	font-size: 12px;
	font-weight: 500;
	letter-spacing: 0.08em;
	line-height: 1;
	text-transform: uppercase;
	opacity: 0;
	transition: opacity 0.3s ease;
	pointer-events: none;
}

.esg-product:hover .esg-view-overlay {
	opacity: 1;
}

/* ---- Badges ---- */
.esg-badge {
	display: inline-flex;
	align-items: center;
	gap: 4px;
	font-family: 'Jost', sans-serif;
	white-space: nowrap;
}

/* New In / Limited → black pill badge (Home.tsx badge, top-left). */
.esg-badge--new,
.esg-badge--limited {
	padding: 4px 10px;
	border-radius: 999px;
	background: #222222;
	color: #ffffff;
	font-size: 10px;
	font-weight: 600;
	letter-spacing: 0.05em;
	text-transform: uppercase;
}

/* Authenticated seal → small white pill, stacks above the main badge. */
.esg-badge--auth {
	padding: 3px 8px;
	border-radius: 999px;
	border: 1px solid #e5e5e5;
	background: rgba(255, 255, 255, 0.92);
	color: #222222;
	font-size: 10px;
	font-weight: 500;
	letter-spacing: 0.05em;
	text-transform: uppercase;
	backdrop-filter: blur(4px);
	-webkit-backdrop-filter: blur(4px);
}

.esg-badges-left {
	position: absolute;
	top: 12px;
	left: 12px;
	z-index: 3;
	display: flex;
	flex-direction: column;
	align-items: flex-start;
	gap: 6px;
}

.esg-badges-right {
	position: absolute;
	top: 12px;
	right: 12px;
	z-index: 3;
	display: flex;
	align-items: center;
	gap: 8px;
}

/*
 * ---- Wishlist (heart) button: icon only, revealed on image hover ----
 * (see the notes in class-widget-shop-grid.php about woosw-btn-has-icon)
 */
.esg-wishlist-btn {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 34px;
	height: 34px;
	padding: 0;
	border-radius: 999px;
	border: 1px solid #e5e5e5;
	background: rgba(255, 255, 255, 0.92);
	color: #222222;
	cursor: pointer;
	opacity: 0;
	transition: opacity 0.35s ease;
	font-size: 0 !important;
	line-height: 0 !important;
}

.esg-image-wrapper:hover .esg-wishlist-btn {
	opacity: 1;
}

/* Override the theme's generic button hover styles. */
.esg-wishlist-btn:hover,
.esg-wishlist-btn:focus {
	background-color: rgba(255, 255, 255, 0.92) !important;
	box-shadow: none !important;
	outline: none !important;
}

.esg-wishlist-btn > *:not(.esg-wishlist-icon) {
	display: none !important;
}

.esg-wishlist-btn::before,
.esg-wishlist-btn::after {
	content: none !important;
}

.esg-wishlist-icon {
	display: flex;
	align-items: center;
	justify-content: center;
	line-height: 1;
}

.esg-wishlist-icon i,
.esg-wishlist-icon svg {
	display: block;
}

.esg-wishlist-icon i {
	font-size: 18px;
}

.esg-wishlist-icon svg {
	width: 18px;
	height: 18px;
}

.esg-wishlist-icon--on {
	display: none;
}

.esg-wishlist-btn.woosw-added .esg-wishlist-icon--off {
	display: none;
}

.esg-wishlist-btn.woosw-added .esg-wishlist-icon--on {
	display: flex;
}

/* ---- Content area (Home.tsx card body) ---- */
.esg-content {
	padding: 16px;
	display: flex;
	flex-direction: column;
	flex: 1;
}

.esg-brand {
	margin: 0;
	font-family: 'Jost', sans-serif;
	font-size: 10px;
	font-weight: 500;
	letter-spacing: 0.1em;
	line-height: 1.4;
	text-transform: uppercase;
	color: #888888;
	margin-bottom: 4px;
}

.esg-name {
	margin: 0;
	font-family: 'Jost', sans-serif;
	font-size: 14px;
	font-weight: 600;
	line-height: 1.3;
	color: #222222;
	margin-bottom: 4px;
}

/* Short description ("info" line) */
.esg-info {
	margin: 0 0 12px;
	font-family: 'Jost', sans-serif;
	font-size: 12px;
	font-weight: 400;
	line-height: 1.5;
	color: #888888;
	display: -webkit-box;
	-webkit-line-clamp: 2;
	-webkit-box-orient: vertical;
	overflow: hidden;
}

/* ---- Rating: stars + review count (Home.tsx) ---- */
.esg-rating {
	display: flex;
	align-items: center;
	gap: 8px;
	margin-bottom: 16px;
}

.esg-stars {
	display: inline-flex;
	gap: 2px;
}

/* Force the star SVGs to render at the design size (13×13) even when the
   theme applies global svg width/height rules that would distort them. */
.esg-stars svg {
	display: block;
	width: 13px !important;
	height: 13px !important;
	flex-shrink: 0;
}

/* Keep the star shape itself intact. The polygon inherits its fill from the
   <svg> (fill="#222" filled / fill="none" outline), but the theme's global
   `svg polygon { fill: currentColor }` rules override that and turn the
   outline stars into solid blobs — at 13px they read as dots. Re-inherit so
   filled stars stay filled and empty stars stay outline. */
.esg-stars svg polygon {
	fill: inherit !important;
	stroke: inherit !important;
	stroke-width: inherit !important;
}

.esg-review-count {
	font-family: 'Jost', sans-serif;
	font-size: 11px;
	font-weight: 400;
	line-height: 1;
	color: #888888;
}

/* ---- Card footer: price + Add to Cart (Home.tsx) ---- */
.esg-card-footer {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 12px;
	margin-top: auto;
}

.esg-price {
	display: flex;
	align-items: baseline;
	gap: 8px;
}

.esg-sale {
	font-family: 'Jost', sans-serif;
	font-size: 16px;
	font-weight: 600;
	line-height: 1.3;
	color: #222222;
}

.esg-regular {
	font-family: 'Jost', sans-serif;
	font-size: 13px;
	font-weight: 400;
	line-height: 1.3;
	text-decoration: line-through;
	color: #bbbbbb;
}

/*
 * wc_price() wraps the price in its own spans; force them to inherit the
 * card price color so the color control applies to both text and strike.
 */
.esg-price .amount,
.esg-price .woocommerce-Price-amount,
.esg-price .woocommerce-Price-currencySymbol,
.esg-price bdi {
	color: inherit !important;
}

/* Add to Cart button (Home.tsx black pill) */
.esg-add-to-bag {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 6px;
	flex-shrink: 0;
	padding: 8px 16px;
	border-radius: 8px;
	border: none;
	background-color: #222222 !important;
	color: #ffffff !important;
	font-family: 'Jost', sans-serif;
	font-size: 12px;
	font-weight: 500;
	line-height: 1;
	text-decoration: none;
	cursor: pointer;
	box-shadow: none !important;
	transition: background-color 0.2s ease;
}

.esg-add-to-bag:hover {
	background-color: #000000 !important;
	color: #ffffff !important;
}

/* "Added ✓" success state (Home.tsx green flash). Raised specificity so it
   still wins over the Elementor-generated background-color: !important rule
   for .esg-add-to-bag when the button is mid-flash. */
.esg-shop-grid .esg-add-to-bag.is-added {
	background-color: #4caf50 !important;
}

.esg-add-to-bag.loading {
	opacity: 0.7;
	pointer-events: none;
}

/* Hide the "View cart" link WooCommerce inserts after AJAX add-to-cart. */
.wc-forward {
	display: none !important;
}

/* ---- Pagination ---- */
.esg-pagination {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	justify-content: center;
	gap: 10px;
}

.esg-pagination:not(:empty) {
	margin-top: 40px;
}

.esg-page-btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-width: 36px;
	height: 36px;
	padding: 0 12px;
	border: 1px solid #e5e5e5;
	border-radius: 10px !important;
	background-color: #ffffff !important;
	color: #666666;
	font-family: 'Jost', sans-serif;
	font-size: 13px;
	font-weight: 500;
	line-height: 1;
	cursor: pointer;
	box-shadow: none !important;
	transition: color 0.2s ease, background-color 0.2s ease, border-color 0.2s ease;
}

.esg-page-btn.is-active {
	background-color: #222222 !important;
	border-color: #222222;
	color: #ffffff;
}

.esg-page-btn:not(.is-active):hover,
.esg-page-btn:not(.is-active):focus {
	background-color: #ffffff !important;
	border-color: #222222;
	color: #222222;
	box-shadow: none !important;
}

.esg-page-dots {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-width: 20px;
	height: 36px;
	color: #888888;
	font-family: 'Jost', sans-serif;
	font-size: 12px;
}

/* ---- Responsive: tablet 2 columns, mobile 1 column ---- */
@media (max-width: 1024px) {
	.esg-grid {
		grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
	}
}

@media (max-width: 767px) {
	/*
	 * Two compact columns on phones / small tablets (typical shop grid). The
	 * Elementor "Products per Row" control only governs ≥768px widths.
	 */
	.esg-grid {
		grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
		column-gap: 10px;
		row-gap: 14px;
	}

	.esg-heading {
		flex-direction: column;
		align-items: flex-start;
		gap: 16px;
	}

	.esg-toolbar-right {
		justify-content: flex-start;
	}

	.esg-title {
		font-size: 28px;
	}

	/* ---- Mobile filter: hamburger button expands categories + sort ---- */
	.esg-toolbar--filter {
		gap: 0;
	}

	.esg-toolbar--filter .esg-filter-toggle {
		display: flex;
	}

	.esg-toolbar--filter .esg-toolbar-panel {
		display: none;
	}

	.esg-toolbar--filter.is-open .esg-toolbar-panel {
		display: flex;
	}

	/* Keep the opened hamburger button light: touch taps leave it focused,
	   which would otherwise trigger the black hover state on the bar. */
	.esg-toolbar--filter.is-open .esg-filter-toggle,
	.esg-toolbar--filter.is-open .esg-filter-toggle:hover,
	.esg-toolbar--filter.is-open .esg-filter-toggle:focus {
		background-color: #ffffff;
		border-color: #222222;
		color: #222222;
	}

	/* Inside the open panel the category strip becomes wrapped pills. */
	.esg-toolbar--filter.is-open .esg-categories {
		flex-wrap: wrap;
		gap: 8px;
		margin: 0;
		padding: 0;
		border-bottom: none;
		overflow: visible;
	}

	.esg-toolbar--filter.is-open .esg-cat-btn {
		margin: 0;
		padding: 8px 14px;
		border: 1px solid #e5e5e5;
		border-bottom-width: 1px;
		border-radius: 999px !important;
		white-space: nowrap;
		/* Hard white pills so the theme can't paint these buttons black. */
		background-color: #ffffff !important;
		color: #888888;
		box-shadow: none !important;
	}

	.esg-toolbar--filter.is-open .esg-cat-btn:not(.is-active):hover,
	.esg-toolbar--filter.is-open .esg-cat-btn:not(.is-active):focus {
		background-color: #f5f5f5 !important;
		border-color: #d0d0d0;
		color: #222222;
		box-shadow: none !important;
	}

	/*
	 * Selected pill: ink outline on white, never a solid black fill — the
	 * filled version (and the theme's button rules) made the chosen chip read
	 * as an all-black blob.
	 */
	.esg-toolbar--filter.is-open .esg-cat-btn.is-active {
		background-color: #ffffff !important;
		border-color: #222222;
		color: #222222;
		font-weight: 600;
		box-shadow: none !important;
	}

	/* Sort dropdown fills the row once expanded. */
	.esg-toolbar--filter .esg-toolbar-right {
		flex-direction: column;
		align-items: stretch;
		gap: 10px;
	}

	.esg-toolbar--filter .esg-sort {
		width: 100%;
	}

	/*
	 * Card footer stacks on mobile: price on its own line with a full-width
	 * Add to Cart underneath. A long price (sale + regular) previously fought
	 * the button for the shared row and pushed the layout around.
	 */
	.esg-card-footer {
		flex-direction: column;
		align-items: stretch;
		gap: 10px;
	}

	.esg-price {
		flex-wrap: wrap;
	}

	.esg-add-to-bag {
		width: 100%;
		min-height: 36px;
	}

	/* Touch devices have no hover, so keep the wishlist heart reachable. */
	.esg-image-wrapper .esg-wishlist-btn {
		opacity: 1;
	}
}

/* Compact cards where two columns get tight on small phones. */
@media (max-width: 479px) {
	.esg-content {
		padding: 12px;
	}

	.esg-brand {
		margin-bottom: 3px;
		letter-spacing: 1px;
	}

	.esg-name {
		font-size: 13px;
		margin-bottom: 4px;
	}

	.esg-info {
		margin-bottom: 10px;
	}

	.esg-rating {
		margin-bottom: 10px;
	}

	.esg-sale {
		font-size: 14px;
	}

	.esg-regular {
		font-size: 12px;
	}

	.esg-card-footer {
		gap: 8px;
	}

	.esg-add-to-bag {
		padding: 7px 10px;
		font-size: 11px;
	}

	.esg-wishlist-btn {
		width: 30px;
		height: 30px;
	}
}
