/**
 * ShopGrid front-end styles.
 *
 * Every colour, radius and font is driven by a CSS custom property set from
 * the plugin settings, so merchants restyle the listing without editing CSS.
 * Everything is scoped under .shopgrid to avoid leaking into the theme.
 */

.shopgrid {
	--sg-accent: #111;
	--sg-accent-text: #fff;
	--sg-text: #111;
	--sg-muted: #666;
	--sg-border: #dcdcdc;
	--sg-card-bg: #fff;
	--sg-sale: #d8332a;
	--sg-badge-new: #111;
	--sg-badge-new-text: #fff;
	/* Falls back to the accent so one colour drives the whole card unless
	   the merchant deliberately sets a different one. */
	--sg-quick-bg: var(--sg-accent);
	--sg-quick-text: var(--sg-accent-text);
	--sg-star: #f5b301;
	--sg-prog-fill: #2e7d32;
	--sg-prog-track: #e8e8e8;
	--sg-prog-text: #111;
	--sg-radius: 0px;
	--sg-font-size: 13px;
	--sg-heading-tt: uppercase;
	--sg-ratio: 3/4;
	--sg-cols: 4;
	--sg-gap: 20px;

	box-sizing: border-box;
	color: var(--sg-text);
	font-size: var(--sg-font-size);
	max-width: 1440px;
	margin: 0 auto;
	padding: 0 16px;
}

.shopgrid[style*="--sg-page-bg"] {
	background: var(--sg-page-bg);
}

.shopgrid *,
.shopgrid *::before,
.shopgrid *::after {
	box-sizing: inherit;
}

.shopgrid[style*="--sg-font"] {
	font-family: var(--sg-font);
}

.shopgrid button {
	font-family: inherit;
	font-size: inherit;
}

.shopgrid :focus-visible {
	outline: 2px solid var(--sg-accent);
	outline-offset: 2px;
}

.shopgrid .screen-reader-text {
	position: absolute;
	width: 1px;
	height: 1px;
	padding: 0;
	margin: -1px;
	overflow: hidden;
	clip: rect(0, 0, 0, 0);
	white-space: nowrap;
	border: 0;
}

/* ── Header ───────────────────────────────────────────────────────────── */

.shopgrid .sg-head {
	text-align: center;
	margin: 0 0 20px;
}

.shopgrid .sg-title {
	font-size: 1.9em;
	letter-spacing: .04em;
	text-transform: var(--sg-heading-tt);
	margin: 0 0 6px;
	color: var(--sg-text);
}

.shopgrid .sg-sub {
	color: var(--sg-muted);
	margin: 0;
	font-size: 1.05em;
}

/* ── Toolbar & tabs ───────────────────────────────────────────────────── */

.shopgrid .sg-toolbar {
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 18px;
	flex-wrap: wrap;
	margin: 0 0 18px;
	position: relative;
}

.shopgrid .sg-count {
	margin: 0;
	color: var(--sg-muted);
	letter-spacing: .08em;
	text-transform: uppercase;
	font-size: .92em;
}

.shopgrid .sg-count-num {
	font-weight: 700;
	color: var(--sg-text);
}

.shopgrid .sg-tabs {
	display: flex;
	gap: 2px;
	flex-wrap: wrap;
	justify-content: center;
}

.shopgrid .sg-tabs-secondary {
	margin: 0 0 18px;
}

.shopgrid .sg-tab {
	background: transparent;
	border: 1px solid var(--sg-border);
	border-radius: var(--sg-radius);
	color: var(--sg-text);
	cursor: pointer;
	letter-spacing: .1em;
	text-transform: uppercase;
	font-size: .92em;
	padding: 11px 24px;
	transition: background .15s, color .15s, border-color .15s;
}

.shopgrid .sg-tab:hover {
	border-color: var(--sg-accent);
}

.shopgrid .sg-tab.is-active {
	background: var(--sg-accent);
	border-color: var(--sg-accent);
	color: var(--sg-accent-text);
}

/* ── Layout ───────────────────────────────────────────────────────────── */

.shopgrid .sg-body {
	display: block;
}

.shopgrid.sg-has-sidebar .sg-body {
	display: grid;
	grid-template-columns: 220px minmax(0, 1fr);
	gap: 32px;
	align-items: start;
}

.shopgrid .sg-main {
	min-width: 0;
}

/* ── Filter layout: right sidebar ─────────────────────────────────────── */
.shopgrid.sg-filter--right.sg-has-sidebar .sg-body {
	grid-template-columns: minmax(0, 1fr) 220px;
}
.shopgrid.sg-filter--right .sg-sidebar {
	order: 2;
}
.shopgrid.sg-filter--right .sg-main {
	order: 1;
}

/* ── Filter layout: slide-in drawer (off-canvas, all widths) ──────────── */
.shopgrid.sg-filter--drawer.sg-has-sidebar .sg-body {
	display: block;
}
.shopgrid.sg-filter--drawer .sg-filter-open {
	display: inline-flex;
}
.shopgrid.sg-filter--drawer .sg-sidebar {
	position: fixed;
	top: 0;
	bottom: 0;
	right: 0;
	left: auto;
	width: min(360px, 90vw);
	background: var(--sg-card-bg);
	padding: 18px 20px 32px;
	overflow-y: auto;
	z-index: 99998;
	transform: translateX(102%);
	transition: transform .28s ease;
	box-shadow: 0 0 40px rgba(0, 0, 0, .2);
}
.shopgrid.sg-filter--drawer .sg-sidebar.is-open {
	transform: translateX(0);
}
.shopgrid.sg-filter--drawer .sg-sidebar-head {
	display: flex;
}

/* ── Drawer backdrop (used by drawer mode + the mobile drawer) ────────── */
.shopgrid .sg-scrim {
	position: fixed;
	inset: 0;
	background: rgba(0, 0, 0, .45);
	opacity: 0;
	visibility: hidden;
	transition: opacity .25s ease, visibility .25s ease;
	z-index: 99997;
	cursor: pointer;
}
.shopgrid .sg-sidebar.is-open ~ .sg-scrim {
	opacity: 1;
	visibility: visible;
}

.shopgrid .sg-bar {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 16px;
	flex-wrap: wrap;
	margin: 0 0 16px;
	min-height: 1px;
}

/* ── Sidebar ──────────────────────────────────────────────────────────── */

.shopgrid .sg-filter-open {
	display: none;
}

.shopgrid .sg-sidebar-head {
	display: none;
	align-items: center;
	justify-content: space-between;
	padding: 0 0 12px;
	margin: 0 0 12px;
	border-bottom: 1px solid var(--sg-border);
}

.shopgrid .sg-sidebar-title {
	margin: 0;
	font-size: 1.1em;
	letter-spacing: .1em;
	text-transform: uppercase;
}

.shopgrid .sg-sidebar-close {
	background: none;
	border: 0;
	cursor: pointer;
	font-size: 26px;
	line-height: 1;
	color: var(--sg-text);
	padding: 0 4px;
}

.shopgrid .sg-fgroup {
	border-bottom: 1px solid var(--sg-border);
	padding: 0 0 14px;
	margin: 0 0 14px;
}

.shopgrid .sg-fgroup-title {
	margin: 0 0 8px;
	font-size: 1em;
}

.shopgrid .sg-fgroup-toggle {
	display: flex;
	align-items: center;
	justify-content: space-between;
	width: 100%;
	background: none;
	border: 0;
	cursor: pointer;
	padding: 0;
	color: var(--sg-text);
	font-weight: 700;
	letter-spacing: .08em;
	text-transform: uppercase;
	font-size: .95em;
}

.shopgrid .sg-fgroup-chev {
	width: 8px;
	height: 8px;
	border-right: 1.5px solid currentColor;
	border-bottom: 1.5px solid currentColor;
	transform: rotate(45deg);
	transition: transform .2s;
	margin-bottom: 3px;
}

.shopgrid .sg-fgroup.is-collapsed .sg-fgroup-chev {
	transform: rotate(-135deg);
	margin-bottom: -3px;
}

.shopgrid .sg-fgroup.is-collapsed .sg-fgroup-body {
	display: none;
}

.shopgrid .sg-check {
	display: flex;
	align-items: center;
	gap: 8px;
	cursor: pointer;
	padding: 4px 0;
	color: var(--sg-text);
	line-height: 1.4;
}

.shopgrid .sg-check input {
	margin: 0;
	flex: 0 0 auto;
	accent-color: var(--sg-accent);
}

.shopgrid .sg-check-count {
	margin-left: auto;
	color: var(--sg-muted);
	font-style: normal;
	font-size: .9em;
}

.shopgrid .sg-select {
	width: 100%;
	padding: 7px 8px;
	border: 1px solid var(--sg-border);
	border-radius: var(--sg-radius);
	background: var(--sg-card-bg);
	color: var(--sg-text);
}

/* Swatch filter */

.shopgrid .sg-swatch-list {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
}

.shopgrid .sg-swatch-opt {
	position: relative;
	cursor: pointer;
	line-height: 0;
}

.shopgrid .sg-swatch-opt input {
	position: absolute;
	opacity: 0;
	width: 100%;
	height: 100%;
	margin: 0;
	cursor: pointer;
}

.shopgrid .sg-swatch-dot {
	display: block;
	width: 22px;
	height: 22px;
	border-radius: 50%;
	border: 1px solid var(--sg-border);
	box-shadow: inset 0 0 0 2px var(--sg-card-bg);
	transition: box-shadow .15s, border-color .15s;
}

.shopgrid .sg-swatch-opt input:checked + .sg-swatch-dot {
	border-color: var(--sg-accent);
	box-shadow: inset 0 0 0 2px var(--sg-card-bg), 0 0 0 2px var(--sg-accent);
}

/* Pill filter */

.shopgrid .sg-pill-list {
	display: flex;
	flex-wrap: wrap;
	gap: 6px;
}

.shopgrid .sg-pill {
	cursor: pointer;
	position: relative;
}

.shopgrid .sg-pill input {
	position: absolute;
	opacity: 0;
	pointer-events: none;
}

.shopgrid .sg-pill span {
	display: inline-block;
	border: 1px solid var(--sg-border);
	border-radius: var(--sg-radius);
	padding: 5px 12px;
	font-size: .92em;
	transition: background .15s, color .15s, border-color .15s;
}

.shopgrid .sg-pill input:checked + span {
	background: var(--sg-accent);
	border-color: var(--sg-accent);
	color: var(--sg-accent-text);
}

.shopgrid .sg-pill input:focus-visible + span {
	outline: 2px solid var(--sg-accent);
	outline-offset: 2px;
}

/* Price filter */

.shopgrid .sg-price-range {
	display: flex;
	align-items: center;
	gap: 6px;
	flex-wrap: wrap;
}

.shopgrid .sg-price-range input {
	width: 68px;
	padding: 6px 8px;
	border: 1px solid var(--sg-border);
	border-radius: var(--sg-radius);
	background: var(--sg-card-bg);
	color: var(--sg-text);
	font-size: .95em;
}

.shopgrid .sg-price-sep {
	color: var(--sg-muted);
}

.shopgrid .sg-price-go {
	padding: 6px 12px;
	background: var(--sg-accent);
	color: var(--sg-accent-text);
	border: 0;
	border-radius: var(--sg-radius);
	cursor: pointer;
	letter-spacing: .06em;
	text-transform: uppercase;
	font-size: .85em;
}

.shopgrid .sg-clear-all {
	background: none;
	border: 0;
	border-bottom: 1px solid currentColor;
	color: var(--sg-muted);
	cursor: pointer;
	padding: 0;
	font-size: .92em;
}

.shopgrid .sg-clear-all:hover {
	color: var(--sg-text);
}

/* ── Active tags ──────────────────────────────────────────────────────── */

.shopgrid .sg-tags {
	display: flex;
	flex-wrap: wrap;
	gap: 7px;
	list-style: none;
	margin: 0;
	padding: 0;
	align-items: center;
}

.shopgrid .sg-tag {
	margin: 0;
}

.shopgrid .sg-tag-remove {
	display: inline-flex;
	align-items: center;
	gap: 7px;
	background: transparent;
	border: 1px solid var(--sg-border);
	border-radius: var(--sg-radius);
	color: var(--sg-text);
	cursor: pointer;
	padding: 5px 11px;
	font-size: .9em;
}

.shopgrid .sg-tag-remove:hover {
	border-color: var(--sg-accent);
}

.shopgrid .sg-tag-x {
	font-size: 1.2em;
	line-height: 1;
	color: var(--sg-muted);
}

/* ── Sort ─────────────────────────────────────────────────────────────── */

/* ── Toolbar tools: "Sort by" + "Filter", right-aligned ───────────────── */
.shopgrid .sg-bar-tools {
	display: flex;
	align-items: center;
	gap: clamp(16px, 3vw, 34px);
	margin-left: auto;
}

.shopgrid .sg-sort-btn {
	display: inline-flex;
}
.shopgrid .sg-sort-btn,
.shopgrid .sg-filter-open {
	align-items: center;
	gap: 8px;
	background: none;
	border: 0;
	border-radius: 0;
	padding: 6px 2px;
	margin: 0;
	cursor: pointer;
	color: var(--sg-text);
	font-weight: 700;
	font-size: 1.05em;
	letter-spacing: 0;
	text-transform: none;
	line-height: 1;
}

.shopgrid .sg-tool-ico {
	width: 20px;
	height: 20px;
	flex: 0 0 auto;
}

.shopgrid .sg-sort-btn:hover,
.shopgrid .sg-filter-open:hover {
	color: var(--sg-muted);
}

/* Sort dropdown menu */
.shopgrid .sg-sort {
	position: relative;
}

.shopgrid .sg-sort-menu {
	position: absolute;
	top: calc(100% + 10px);
	right: 0;
	z-index: 40;
	min-width: 280px;
	background: var(--sg-card-bg);
	border: 1px solid var(--sg-border);
	box-shadow: 0 18px 40px rgba(0, 0, 0, .14);
	padding: 4px 0;
}

.shopgrid .sg-sort-menu[hidden] {
	display: none;
}

.shopgrid .sg-sort-opt {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 16px;
	width: 100%;
	background: none;
	border: 0;
	border-top: 1px solid var(--sg-border);
	cursor: pointer;
	text-align: left;
	color: var(--sg-text);
	font-size: 1.08em;
	padding: 16px 22px;
	line-height: 1.2;
}

.shopgrid .sg-sort-opt:first-child {
	border-top: 0;
}

.shopgrid .sg-sort-opt:hover {
	background: rgba(0, 0, 0, .03);
}

.shopgrid .sg-sort-opt.is-active {
	font-weight: 700;
}

.shopgrid .sg-sort-check {
	width: 20px;
	height: 20px;
	flex: 0 0 auto;
	opacity: 0;
}

.shopgrid .sg-sort-opt.is-active .sg-sort-check {
	opacity: 1;
}

/* ── Progress bars ────────────────────────────────────────────────────── */

.shopgrid .sg-ship-bar,
.shopgrid .sg-results-bar {
	margin: 0 0 18px;
}

.shopgrid .sg-results-bar {
	margin: 22px auto 14px;
	max-width: 320px;
	text-align: center;
}

.shopgrid .sg-ship-text,
.shopgrid .sg-results-text {
	margin: 0 0 7px;
	color: var(--sg-prog-text);
	font-size: .95em;
	letter-spacing: .02em;
}

.shopgrid .sg-ship-track,
.shopgrid .sg-results-track {
	height: 6px;
	background: var(--sg-prog-track);
	border-radius: 99px;
	overflow: hidden;
}

.shopgrid .sg-ship-fill,
.shopgrid .sg-results-fill {
	display: block;
	height: 100%;
	background: var(--sg-prog-fill);
	border-radius: 99px;
	transition: width .45s ease;
}

.shopgrid .sg-ship-bar.is-complete .sg-ship-text {
	font-weight: 700;
}

/* Loading bar */

.shopgrid .sg-loadbar {
	height: 2px;
	background: transparent;
	overflow: hidden;
	margin: 0 0 -2px;
	position: relative;
	z-index: 2;
}

.shopgrid .sg-loadbar span {
	display: block;
	height: 100%;
	width: 0;
	background: var(--sg-accent);
	transition: width .3s ease, opacity .3s ease;
	opacity: 0;
}

.shopgrid.is-loading .sg-loadbar span {
	width: 92%;
	opacity: 1;
	transition: width 1.4s cubic-bezier(.1, .8, .2, 1), opacity .2s;
}

/* ── Grid ─────────────────────────────────────────────────────────────── */

.shopgrid .sg-grid-wrap {
	transition: opacity .2s;
}

.shopgrid.is-loading .sg-grid-wrap {
	opacity: .45;
	pointer-events: none;
}

.shopgrid .sg-grid {
	display: grid;
	grid-template-columns: repeat(var(--sg-cols), minmax(0, 1fr));
	gap: var(--sg-gap);
}

/* ── Card ─────────────────────────────────────────────────────────────── */

.shopgrid .sg-card {
	background: var(--sg-card-bg);
	display: flex;
	flex-direction: column;
	position: relative;
	min-width: 0;
}

.shopgrid .sg-card-media {
	position: relative;
	overflow: hidden;
	border-radius: var(--sg-radius);
}

.shopgrid .sg-card-link {
	display: block;
	text-decoration: none;
	color: inherit;
}

.shopgrid .sg-card-img {
	display: block;
	position: relative;
	aspect-ratio: var(--sg-ratio);
	overflow: hidden;
	background: #f4f4f4;
}

.shopgrid .sg-img {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	object-fit: cover;
	display: block;
	transition: transform .5s ease, opacity .35s ease;
}

.shopgrid .sg-img-alt {
	opacity: 0;
}

.shopgrid .sg-card:hover .sg-img-main {
	transform: scale(1.045);
}

.shopgrid .sg-card:hover .sg-img-alt {
	opacity: 1;
}

/* Badges */

.shopgrid .sg-badge-cat {
	position: absolute;
	top: 10px;
	right: 10px;
	background: rgba(0, 0, 0, .85);
	color: #fff;
	font-size: .78em;
	font-weight: 700;
	letter-spacing: .1em;
	text-transform: uppercase;
	padding: 6px 10px;
	line-height: 1;
	border-radius: var(--sg-radius);
	z-index: 3;
}

.shopgrid .sg-badges {
	position: absolute;
	top: 10px;
	left: 10px;
	display: flex;
	flex-direction: column;
	align-items: flex-start;
	gap: 5px;
	z-index: 3;
}

.shopgrid .sg-badge {
	font-size: .78em;
	font-weight: 700;
	letter-spacing: .08em;
	text-transform: uppercase;
	padding: 5px 9px;
	line-height: 1;
	border-radius: var(--sg-radius);
	color: #fff;
}

.shopgrid .sg-badge-sale {
	background: var(--sg-sale);
}

.shopgrid .sg-badge-new {
	background: var(--sg-badge-new);
	color: var(--sg-badge-new-text);
}

.shopgrid .sg-badge-oos {
	background: #6b6b6b;
}

/* Quick add */

.shopgrid .sg-quick {
	position: absolute;
	left: 0;
	right: 0;
	bottom: 0;
	display: flex;
	align-items: center;
	gap: 5px;
	flex-wrap: wrap;
	padding: 10px;
	background: linear-gradient(to top, rgba(0, 0, 0, .78), rgba(0, 0, 0, 0));
	transform: translateY(101%);
	transition: transform .25s ease;
	z-index: 4;
}

.shopgrid .sg-card:hover .sg-quick,
.shopgrid .sg-quick.is-open {
	transform: translateY(0);
}

.shopgrid .sg-quick-label {
	color: #fff;
	font-size: .8em;
	letter-spacing: .1em;
	text-transform: uppercase;
	margin-right: 4px;
	opacity: .85;
}

.shopgrid .sg-size {
	position: relative;
	flex: 0 1 auto;
	background: transparent;
	border: 1px solid #fff;
	border-radius: var(--sg-radius);
	color: #fff;
	cursor: pointer;
	font-size: .82em;
	letter-spacing: .04em;
	text-transform: uppercase;
	padding: 5px 6px;
	min-width: 24px;
	line-height: 1;
	white-space: nowrap;
	transition: background .15s, color .15s;
}

/* Values shrink a little before they wrap, so a run of five or six sizes
   still fits one row on a narrow card. */
.shopgrid .sg-size:not(.sg-size-swatch) {
	flex-shrink: 1;
	min-width: 0;
	padding-left: 4px;
	padding-right: 4px;
}

.shopgrid .sg-size:not(.is-disabled):hover {
	background: #fff;
	color: #111;
}

.shopgrid .sg-size.is-disabled {
	opacity: .5;
	cursor: not-allowed;
	border-color: rgba(255, 255, 255, .45);
}

.shopgrid .sg-size.is-disabled::before {
	content: "";
	position: absolute;
	inset: 0;
	background:
		linear-gradient(to top right, transparent calc(50% - 1px), rgba(255, 255, 255, .7) 50%, transparent calc(50% + 1px));
	pointer-events: none;
}

.shopgrid .sg-size.is-loading {
	opacity: .6;
	pointer-events: none;
}

.shopgrid .sg-size.is-done {
	background: #fff;
	color: #111;
}

/* Colour swatch buttons inside quick add */

.shopgrid .sg-size-swatch {
	width: 26px;
	height: 26px;
	min-width: 0;
	padding: 0;
	border-radius: 50%;
	background: var(--sg-swatch, #ccc);
	border: 1px solid rgba(255, 255, 255, .8);
	box-shadow: inset 0 0 0 2px rgba(0, 0, 0, .35);
}

.shopgrid .sg-size-swatch:not(.is-disabled):hover,
.shopgrid .sg-size-swatch.is-selected {
	background: var(--sg-swatch, #ccc);
	box-shadow: inset 0 0 0 2px rgba(0, 0, 0, .35), 0 0 0 2px #fff;
}

.shopgrid .sg-size.is-selected {
	background: #fff;
	color: #111;
}

/* One row per variation attribute */

.shopgrid .sg-quick-step {
	display: flex;
	align-items: center;
	gap: 5px;
	flex-wrap: wrap;
	width: 100%;
}

/* The label takes its own line so the values below it get the full card
   width and stay on one row. */
.shopgrid .sg-quick-step .sg-quick-label {
	flex: 0 0 100%;
	margin: 0 0 1px;
}

.shopgrid .sg-quick-step + .sg-quick-step {
	margin-top: 7px;
	padding-top: 7px;
	border-top: 1px solid rgba(255, 255, 255, .22);
}

.shopgrid .sg-quick-note {
	color: #fff;
	font-size: .84em;
	letter-spacing: .04em;
	width: 100%;
	margin-top: 7px;
	opacity: .9;
}

/* The quantity + add bar revealed once a variation resolves */

.shopgrid .sg-quick-confirm {
	display: flex;
	align-items: stretch;
	gap: 8px;
	width: 100%;
	margin-top: 8px;
	padding-top: 8px;
	border-top: 1px solid rgba(255, 255, 255, .22);
	opacity: 0;
	transform: translateY(4px);
	transition: opacity .18s ease, transform .18s ease;
}

.shopgrid .sg-quick-confirm.is-open {
	opacity: 1;
	transform: none;
}

.shopgrid .sg-quick-simple .sg-quick-confirm {
	margin-top: 0;
	padding-top: 0;
	border-top: 0;
}

.shopgrid .sg-chosen {
	display: flex;
	align-items: center;
	color: #fff;
	font-size: .84em;
	font-weight: 700;
	letter-spacing: .06em;
	text-transform: uppercase;
	white-space: nowrap;
	margin-right: auto;
}

.shopgrid .sg-quick-reset {
	background: transparent;
	border: 0;
	color: #fff;
	cursor: pointer;
	font-size: 20px;
	line-height: 1;
	padding: 0 4px;
	opacity: .75;
	flex: 0 0 auto;
}

.shopgrid .sg-quick-reset:hover {
	opacity: 1;
}

/* Add-to-cart button and "Select options" link */

.shopgrid .sg-add {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 7px;
	flex: 0 0 auto;
	background: var(--sg-quick-bg);
	border: 1px solid var(--sg-quick-bg);
	border-radius: var(--sg-radius);
	color: var(--sg-quick-text);
	cursor: pointer;
	font-size: .84em;
	font-weight: 700;
	letter-spacing: .1em;
	text-transform: uppercase;
	padding: 9px 16px;
	line-height: 1;
	text-align: center;
	text-decoration: none;
	transition: filter .15s, background .15s, color .15s;
}

.shopgrid .sg-add:hover {
	filter: brightness(1.12);
}

/* On a narrow card the icon alone carries the meaning. */
.shopgrid .sg-quick-confirm .sg-add-text {
	display: none;
}

.shopgrid .sg-quick-simple .sg-add-text,
.sg-sheet .sg-add-text {
	display: inline;
}

.shopgrid .sg-add-icon {
	flex: 0 0 auto;
}

.shopgrid .sg-add.is-loading {
	opacity: .6;
	pointer-events: none;
}

.shopgrid .sg-add.is-done {
	background: var(--sg-quick-bg);
	border-color: var(--sg-quick-bg);
	color: var(--sg-quick-text);
}

.shopgrid .sg-add-link {
	display: block;
}

/* Quantity stepper */

.shopgrid .sg-qty {
	display: inline-flex;
	align-items: stretch;
	flex: 0 0 auto;
	border: 1px solid #fff;
	border-radius: var(--sg-radius);
	overflow: hidden;
	background: rgba(255, 255, 255, .12);
}

.shopgrid .sg-qty button {
	background: transparent;
	border: 0;
	color: #fff;
	cursor: pointer;
	font-size: 14px;
	line-height: 1;
	padding: 0 9px;
	transition: background .15s, color .15s;
}

.shopgrid .sg-qty button:hover {
	background: #fff;
	color: #111;
}

.shopgrid .sg-qty-input {
	width: 34px;
	background: transparent;
	border: 0;
	border-left: 1px solid rgba(255, 255, 255, .45);
	border-right: 1px solid rgba(255, 255, 255, .45);
	color: #fff;
	text-align: center;
	font-size: .86em;
	padding: 7px 0;
	-moz-appearance: textfield;
	appearance: textfield;
}

.shopgrid .sg-qty-input::-webkit-outer-spin-button,
.shopgrid .sg-qty-input::-webkit-inner-spin-button {
	-webkit-appearance: none;
	margin: 0;
}

.shopgrid .sg-qty-input:focus {
	outline: none;
	background: rgba(255, 255, 255, .18);
}

/* The simple-product row needs its controls on one line. */

.shopgrid .sg-quick-simple {
	flex-wrap: nowrap;
}

.shopgrid .sg-quickbar {
	display: none;
	width: 100%;
	background: var(--sg-quick-bg);
	color: var(--sg-quick-text);
	border: 0;
	cursor: pointer;
	font-size: .82em;
	font-weight: 700;
	letter-spacing: .1em;
	text-transform: uppercase;
	padding: 11px;
}

/* Card body */

.shopgrid .sg-card-body {
	padding: 12px 2px 0;
	display: flex;
	flex-direction: column;
	gap: 6px;
	flex: 1;
}

.shopgrid .sg-card-title {
	margin: 0;
	font-size: 1.05em;
	font-weight: 700;
	letter-spacing: .04em;
	text-transform: var(--sg-heading-tt);
	line-height: 1.3;
}

.shopgrid .sg-card-title a {
	color: var(--sg-text);
	text-decoration: none;
}

.shopgrid .sg-card-title a:hover {
	text-decoration: underline;
}

.shopgrid .sg-card-sub,
.shopgrid .sg-no-reviews {
	margin: 0;
	color: var(--sg-muted);
	font-size: .92em;
	line-height: 1.35;
}

/* Rating */

.shopgrid .sg-rating {
	display: flex;
	align-items: center;
	gap: 6px;
	font-size: .92em;
	color: var(--sg-muted);
}

.shopgrid .sg-stars {
	position: relative;
	display: inline-block;
	width: 74px;
	height: 13px;
	background: currentColor;
	opacity: .25;
	-webkit-mask: repeat-x left center/15px 13px var(--sg-star-mask);
	mask: repeat-x left center/15px 13px var(--sg-star-mask);
}

.shopgrid .sg-stars,
.shopgrid .sg-stars-fill {
	--sg-star-mask: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 15 13'%3E%3Cpath d='M7.5 0l2 4.2 4.5.6-3.3 3.2.8 4.5-4-2.2-4 2.2.8-4.5L1 4.8l4.5-.6z'/%3E%3C/svg%3E");
}

.shopgrid .sg-stars-fill {
	position: absolute;
	inset: 0;
	width: 0;
	background: var(--sg-star);
	opacity: 1;
	-webkit-mask: repeat-x left center/15px 13px var(--sg-star-mask);
	mask: repeat-x left center/15px 13px var(--sg-star-mask);
}

.shopgrid .sg-rating-num {
	color: var(--sg-text);
	font-weight: 700;
}

/* Spec icons */

.shopgrid .sg-specs {
	display: flex;
	flex-wrap: wrap;
	gap: 6px;
}

.shopgrid .sg-spec {
	position: relative;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 24px;
	height: 24px;
	border: 1px solid var(--sg-border);
	border-radius: 50%;
	background: #f6f6f6;
	color: var(--sg-text);
	cursor: default;
	transition: background .15s, color .15s, border-color .15s;
}

.shopgrid .sg-spec:hover {
	background: var(--sg-accent);
	border-color: var(--sg-accent);
	color: var(--sg-accent-text);
}

.shopgrid .sg-spec:hover::after {
	content: attr(data-tip);
	position: absolute;
	bottom: calc(100% + 6px);
	left: 50%;
	transform: translateX(-50%);
	background: #111;
	color: #fff;
	padding: 4px 8px;
	border-radius: 3px;
	font-size: 11px;
	white-space: nowrap;
	pointer-events: none;
	z-index: 6;
	box-shadow: 0 2px 6px rgba(0, 0, 0, .2);
}

.shopgrid .sg-spec:hover::before {
	content: "";
	position: absolute;
	bottom: 100%;
	left: 50%;
	transform: translateX(-50%);
	border: 5px solid transparent;
	border-top-color: #111;
	pointer-events: none;
	z-index: 6;
}

/* Swatches */

.shopgrid .sg-swatches {
	display: flex;
	flex-wrap: wrap;
	gap: 5px;
}

.shopgrid .sg-swatch {
	width: 13px;
	height: 13px;
	border-radius: 50%;
	border: 1px solid var(--sg-border);
	display: block;
}

/* Footer */

.shopgrid .sg-card-foot {
	display: flex;
	align-items: baseline;
	justify-content: space-between;
	gap: 10px;
	margin-top: auto;
	padding-top: 4px;
}

.shopgrid .sg-price {
	font-weight: 700;
	color: var(--sg-text);
	font-size: 1.05em;
}

.shopgrid .sg-price del {
	color: var(--sg-muted);
	font-weight: 400;
	margin-right: 5px;
	font-size: .9em;
}

.shopgrid .sg-price ins {
	text-decoration: none;
	color: var(--sg-sale);
}

.shopgrid .sg-low-stock {
	color: var(--sg-sale);
	font-size: .85em;
	letter-spacing: .04em;
	white-space: nowrap;
}

/* ── Load more & empty ────────────────────────────────────────────────── */

.shopgrid .sg-more-wrap {
	text-align: center;
	margin: 26px 0 0;
}

.shopgrid .sg-more {
	background: transparent;
	border: 1px solid var(--sg-accent);
	border-radius: var(--sg-radius);
	color: var(--sg-accent);
	cursor: pointer;
	letter-spacing: .12em;
	text-transform: uppercase;
	padding: 13px 42px;
	transition: background .15s, color .15s;
}

.shopgrid .sg-more:hover {
	background: var(--sg-accent);
	color: var(--sg-accent-text);
}

.shopgrid .sg-more.is-loading {
	opacity: .6;
	pointer-events: none;
}

.shopgrid .sg-empty {
	text-align: center;
	padding: 48px 16px;
	color: var(--sg-muted);
}

.shopgrid .sg-empty-title {
	font-size: 1.15em;
	color: var(--sg-text);
	margin: 0 0 6px;
}

.shopgrid .sg-empty-hint {
	margin: 0 0 14px;
}

/* ── Quick add inside a theme's own product loop ──────────────────────── */

/* The wrapper reuses .shopgrid so it inherits every colour variable and
   component rule, but it must not inherit the listing's page geometry. */
.shopgrid.sg-loop {
	max-width: none;
	margin: 0;
	padding: 0;
}

/* Below the card: a normal block, so it cannot disturb any theme layout. */
.shopgrid.sg-loop-below .sg-quick {
	position: static;
	transform: none;
	background: var(--sg-accent);
	border-radius: var(--sg-radius);
	padding: 9px 10px;
	margin: 8px 0;
}

.shopgrid.sg-loop-below .sg-quick-label,
.shopgrid.sg-loop-below .sg-size,
.shopgrid.sg-loop-below .sg-chosen,
.shopgrid.sg-loop-below .sg-quick-reset {
	color: var(--sg-accent-text);
}

.shopgrid.sg-loop-below .sg-size {
	border-color: var(--sg-accent-text);
}

.shopgrid.sg-loop-below .sg-size:not(.is-disabled):hover,
.shopgrid.sg-loop-below .sg-size.is-selected {
	background: var(--sg-accent-text);
	color: var(--sg-accent);
}

/* Remove the theme's own loop button where quick add replaced it.
   The PHP filter handles themes that use WooCommerce's template; this covers
   the ones that override it and print the anchor directly, where no filter
   runs and the markup exists regardless. `!important` is deliberate — it has
   to beat theme rules such as `li.product:hover .p-add { opacity: 1 }`. */
.sg-has-quickadd .add_to_cart_button,
.sg-has-quickadd a.button[class*="product_type_"],
.sg-has-quickadd button.button[class*="product_type_"] {
	display: none !important;
}

/* Overlay: the script measures where the product image ends and pins the
   control to that line. No theme markup is moved — `top` is set inline on
   this element only, and it sits bottom-anchored via the transform. */
.shopgrid.sg-loop-overlay {
	position: absolute;
	left: 0;
	right: 0;
	top: 0;
	transform: translateY(-100%);
	z-index: 3;
	opacity: 0;
	visibility: hidden;
	transition: opacity .2s ease, visibility .2s;
}

.shopgrid.sg-loop-overlay .sg-quick {
	position: static;
	transform: none;
}

li.product:hover .shopgrid.sg-loop-overlay[data-sg-placed],
li.product:focus-within .shopgrid.sg-loop-overlay[data-sg-placed],
.wc-block-grid__product:hover .shopgrid.sg-loop-overlay[data-sg-placed],
.product:hover .shopgrid.sg-loop-overlay[data-sg-placed],
.shopgrid.sg-loop-overlay[data-sg-placed]:focus-within {
	opacity: 1;
	visibility: visible;
}

/* Until it has been measured it stays hidden, so it can never flash in the
   wrong position or affect the card's layout. */
.shopgrid.sg-loop-overlay:not([data-sg-placed]) {
	pointer-events: none;
}

/* Touch devices have no hover — show it, since there is nothing to reveal. */
@media (hover: none) {
	.shopgrid.sg-loop-overlay[data-sg-placed] {
		opacity: 1;
		visibility: visible;
		transform: none;
	}
}

/* The mobile bar behaves as it does on a ShopGrid card. */
.shopgrid.sg-loop .sg-quickbar {
	margin-top: 8px;
}

.shopgrid.sg-loop-overlay .sg-quickbar {
	margin-top: 0;
}

/* ── Mobile quick-add sheet ───────────────────────────────────────────── */

/* Above sticky add-to-cart bars, cookie notices and chat widgets, which
   routinely sit in the high hundred-thousands. A modal that a theme bar can
   cover is worse than no modal at all. */
.sg-sheet {
	position: fixed;
	inset: 0;
	z-index: 2147483000;
	display: none;
}

.sg-sheet.is-open {
	display: block;
}

.sg-sheet-backdrop {
	position: absolute;
	inset: 0;
	background: rgba(0, 0, 0, .5);
}

.sg-sheet-panel {
	position: absolute;
	left: 0;
	right: 0;
	bottom: 0;
	background: #fff;
	color: #111;
	padding: 20px 18px calc(20px + env(safe-area-inset-bottom));
	border-radius: 14px 14px 0 0;
	max-height: 76vh;
	overflow-y: auto;
}

/* The panel carries the `shopgrid` class to inherit the component rules, so
   the listing's page geometry has to be undone here. */
.sg-sheet-panel.shopgrid {
	max-width: none;
	margin: 0;
	padding: 20px 18px calc(20px + env(safe-area-inset-bottom));
}

.sg-sheet-title {
	margin: 0 0 4px;
	font-size: 15px;
	font-weight: 700;
	color: var(--sg-text);
}

.sg-sheet-hint {
	margin: 0 0 14px;
	font-size: 13px;
	color: #666;
}

/* Equal columns rather than shrink-to-fit, so five sizes read as one even
   set instead of a cramped row of different widths. */
.sg-sheet-body .sg-quick-step {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(54px, 1fr));
	gap: 8px;
	margin-bottom: 14px;
	align-items: stretch;
}

.sg-sheet-body .sg-quick-label {
	grid-column: 1 / -1;
	color: var(--sg-muted);
	font-size: 11px;
	letter-spacing: .1em;
	text-transform: uppercase;
	margin: 0 0 2px;
}

/* Stated in full rather than as a border-colour override — the panel sits
   outside any listing, so nothing supplies the width and style for it. */
.sg-sheet-body .sg-size {
	border: 1px solid var(--sg-border);
	border-radius: var(--sg-radius);
	background: transparent;
	color: var(--sg-text);
	padding: 14px 6px;
	font-size: 14px;
	font-weight: 600;
	min-width: 0;
	width: 100%;
	line-height: 1;
	text-align: center;
}

.sg-sheet-body .sg-size:not(.is-disabled):hover,
.sg-sheet-body .sg-size.is-selected {
	background: var(--sg-accent);
	border-color: var(--sg-accent);
	color: var(--sg-accent-text);
}

.sg-sheet-body .sg-size.is-disabled {
	opacity: .4;
	text-decoration: line-through;
	cursor: not-allowed;
}

.sg-sheet-body .sg-size-swatch {
	width: 34px;
	height: 34px;
	padding: 0;
	min-width: 0;
	background: var(--sg-swatch, #ccc);
	border: 1px solid #ddd;
	box-shadow: none;
}

.sg-sheet-body .sg-size-swatch.is-selected {
	background: var(--sg-swatch, #ccc);
	box-shadow: 0 0 0 2px #111;
}

.sg-sheet-body .sg-size.is-disabled::before {
	background: linear-gradient(to top right, transparent calc(50% - 1px), rgba(17, 17, 17, .45) 50%, transparent calc(50% + 1px));
}

.sg-sheet-body .sg-quick-confirm {
	display: flex;
	align-items: stretch;
	gap: 10px;
	margin-top: 4px;
	padding-top: 14px;
	border-top: 1px solid #eee;
}

.sg-sheet-body .sg-chosen {
	color: var(--sg-text);
	font-size: 14px;
}

.sg-sheet-body .sg-quick-note {
	color: #b3261e;
	font-size: 13px;
}

.sg-sheet-body .sg-qty {
	border: 1px solid var(--sg-border);
	border-radius: var(--sg-radius);
	background: transparent;
	overflow: hidden;
	flex: 0 0 auto;
}

.sg-sheet-body .sg-qty button {
	color: var(--sg-text);
	background: transparent;
	font-size: 17px;
	padding: 0 12px;
}

.sg-sheet-body .sg-qty button:hover {
	background: var(--sg-accent);
	color: var(--sg-accent-text);
}

/* The base centring lives on a .shopgrid-scoped rule, so it is restated
   here — a left-aligned number in a stepper reads as a text field. */
.sg-sheet-body .sg-qty-input {
	border-left: 1px solid var(--sg-border);
	border-right: 1px solid var(--sg-border);
	background: transparent;
	color: var(--sg-text);
	width: 52px;
	text-align: center;
	font-size: 15px;
	font-weight: 600;
	padding: 12px 0;
	-moz-appearance: textfield;
	appearance: textfield;
}

.sg-sheet-body .sg-qty-input::-webkit-outer-spin-button,
.sg-sheet-body .sg-qty-input::-webkit-inner-spin-button {
	-webkit-appearance: none;
	margin: 0;
}

.sg-sheet-body .sg-add {
	flex: 1;
	padding: 14px 18px;
	font-size: 13px;
}

.sg-sheet-body .sg-quick-reset {
	color: var(--sg-muted);
	font-size: 22px;
}

.sg-sheet-body .sg-quick-reset:hover {
	color: var(--sg-text);
}

/* The sheet has room for the label, unlike a card. Matches the specificity
   of the card rule that hides it, and comes later, so it wins. */
.sg-sheet-body .sg-quick-confirm .sg-add-text {
	display: inline;
}

.sg-sheet-close {
	position: absolute;
	top: 12px;
	right: 14px;
	background: none;
	border: 0;
	font-size: 26px;
	line-height: 1;
	cursor: pointer;
	color: #111;
}

/* Toast */

.sg-toast {
	position: fixed;
	left: 50%;
	bottom: 24px;
	transform: translate(-50%, 20px);
	background: #111;
	color: #fff;
	padding: 11px 20px;
	border-radius: 4px;
	font-size: 13px;
	z-index: 2147483001;
	opacity: 0;
	transition: opacity .25s, transform .25s;
	pointer-events: none;
	max-width: calc(100vw - 32px);
	text-align: center;
}

.sg-toast.is-visible {
	opacity: 1;
	transform: translate(-50%, 0);
}

.sg-toast.is-error {
	background: #b3261e;
}

/* ── Responsive ───────────────────────────────────────────────────────── */

@media (max-width: 1024px) {
	.shopgrid.sg-has-sidebar .sg-body {
		grid-template-columns: 190px minmax(0, 1fr);
		gap: 24px;
	}

	.shopgrid .sg-grid {
		grid-template-columns: repeat(min(var(--sg-cols), 3), minmax(0, 1fr));
	}
}

@media (max-width: 860px) {
	.shopgrid.sg-has-sidebar .sg-body {
		display: block;
	}

	.shopgrid .sg-filter-open {
		display: inline-flex;
	}

	.shopgrid .sg-sidebar {
		position: fixed;
		top: 0;
		bottom: 0;
		left: 0;
		width: min(320px, 88vw);
		background: var(--sg-card-bg);
		padding: 18px;
		overflow-y: auto;
		z-index: 99998;
		transform: translateX(-102%);
		transition: transform .25s ease;
		box-shadow: 0 0 30px rgba(0, 0, 0, .18);
	}

	.shopgrid .sg-sidebar.is-open {
		transform: translateX(0);
	}

	.shopgrid .sg-sidebar-head {
		display: flex;
	}

	.shopgrid .sg-grid {
		grid-template-columns: repeat(2, minmax(0, 1fr));
		gap: 14px;
	}

	.shopgrid .sg-quick {
		display: none !important;
	}

	.shopgrid .sg-quickbar {
		display: block;
	}

	.shopgrid .sg-toolbar {
		gap: 12px;
	}

	.shopgrid .sg-tab {
		padding: 9px 16px;
		font-size: .88em;
	}
}

@media (max-width: 480px) {
	.shopgrid {
		padding: 0 12px;
	}

	.shopgrid .sg-grid {
		gap: 12px;
	}

	.shopgrid .sg-bar {
		gap: 10px;
	}

	.shopgrid .sg-bar-tools {
		gap: 18px;
	}

	.shopgrid .sg-sort-menu {
		min-width: min(280px, 78vw);
	}
}

@media (max-width: 380px) {
	.shopgrid .sg-grid {
		grid-template-columns: 1fr;
	}
}

body.sg-no-scroll {
	overflow: hidden;
}

/* ── Motion & print ───────────────────────────────────────────────────── */

@media (prefers-reduced-motion: reduce) {
	.shopgrid *,
	.sg-sheet *,
	.sg-toast {
		transition-duration: .01ms !important;
		animation-duration: .01ms !important;
	}

	.shopgrid .sg-card:hover .sg-img-main {
		transform: none;
	}
}

@media print {
	.shopgrid .sg-sidebar,
	.shopgrid .sg-quick,
	.shopgrid .sg-quickbar,
	.shopgrid .sg-more-wrap,
	.shopgrid .sg-filter-open {
		display: none !important;
	}
}

/* Hide a theme/Woo archive title when a ShopGrid heading is shown in its place
   (the woocommerce_show_page_title filter handles well-behaved themes; this
   covers themes that print the title regardless). */
body.sg-hide-archive-title .woocommerce-products-header,
body.sg-hide-archive-title .woocommerce-products-header__title,
body.sg-hide-archive-title .woo-wrap .page-title {
	display: none !important;
}
