/**
 * Pick n Mix for WooCommerce - sweet-stall front-end styles.
 * Self-contained and theme-agnostic. Override the --pnm-* variables in your
 * theme to re-colour the stall.
 */

.pnm-wc-stall {
	--pnm-accent: #e05a8a;      /* candy pink   */
	--pnm-accent-2: #ffd23f;    /* toffee yellow*/
	--pnm-jar: #ffffff;
	--pnm-ink: #3a2b2f;
	--pnm-muted: #8a7c80;
	--pnm-border: #f0d9e2;
	--pnm-bag: #f3e4c7;         /* paper bag    */
	--pnm-bag-dark: #e4d0aa;
	--pnm-radius: 16px;

	margin-top: 1.5em;
	color: var(--pnm-ink);
}

.pnm-wc-stall-layout {
	display: grid;
	grid-template-columns: 1fr;
	gap: 1.5em;
}

@media (min-width: 900px) {
	.pnm-wc-stall-layout {
		grid-template-columns: 1fr 320px;
		align-items: start;
	}
}

/* ----------------------------------------------------------------------
 * Full-width single-product layout.
 *
 * With the featured image removed, most themes still reserve the empty
 * gallery column and leave the summary at ~half width. On pick n mix
 * product pages we hide that empty column and let the summary (which holds
 * our stall + bag) span the full width. Covers the common float-based and
 * CSS-grid single-product layouts.
 * ---------------------------------------------------------------------- */

body.pnm-wc-no-product-image div.product .woocommerce-product-gallery,
body.pnm-wc-no-product-image div.product > .images,
body.pnm-wc-no-product-image div.product div.images {
	display: none !important;
}

body.pnm-wc-no-product-image div.product .summary,
body.pnm-wc-no-product-image div.product .entry-summary,
body.pnm-wc-no-product-image div.product .summary.entry-summary {
	width: 100% !important;
	max-width: 100% !important;
	float: none !important;
	flex: 1 1 100% !important;      /* beat flex-basis column widths */
	flex-basis: 100% !important;
	margin-left: 0 !important;
	margin-right: 0 !important;
	clear: both !important;
	grid-column: 1 / -1 !important; /* span every column in grid layouts */
}

/* Element the picker breaks out into, tagged by JS as a last-resort override. */
.pnm-wc-fullwidth-col {
	width: 100% !important;
	max-width: 100% !important;
	flex: 1 1 100% !important;
	flex-basis: 100% !important;
	float: none !important;
	grid-column: 1 / -1 !important;
}

/* ---------- Stall / signboard ---------- */

.pnm-wc-stall-signboard {
	display: flex;
	align-items: center;
	gap: 0.6em;
	background: repeating-linear-gradient(
		45deg,
		var(--pnm-accent),
		var(--pnm-accent) 18px,
		color-mix( in srgb, var(--pnm-accent) 82%, #fff ) 18px,
		color-mix( in srgb, var(--pnm-accent) 82%, #fff ) 36px
	);
	color: #fff;
	padding: 0.7em 1em;
	border-radius: var(--pnm-radius);
	box-shadow: 0 4px 0 rgba( 0, 0, 0, 0.08 );
	margin-bottom: 1.1em;
}

.pnm-wc-stall-sign-icon {
	font-size: 1.6em;
	line-height: 1;
}

.pnm-wc-rule {
	margin: 0;
	font-weight: 700;
	font-size: 1.05em;
	text-shadow: 0 1px 1px rgba( 0, 0, 0, 0.18 );
}

/* ---------- Shelf of jars ---------- */

.pnm-wc-shelf {
	list-style: none;
	margin: 0;
	padding: 0;
	display: grid;
	/* Up to two treats per row on small screens... */
	grid-template-columns: repeat(2, 1fr);
	gap: 0.9em;
}

/* ...and a maximum of three per row once there is room. */
@media (min-width: 560px) {
	.pnm-wc-shelf {
		grid-template-columns: repeat(3, 1fr);
	}
}

.pnm-wc-jar {
	margin: 0;
}

.pnm-wc-jar-btn {
	position: relative;
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 0.4em;
	width: 100%;
	height: 100%;
	cursor: pointer;
	background: var(--pnm-jar);
	border: 2px solid var(--pnm-border);
	border-radius: var(--pnm-radius);
	padding: 0.9em 0.6em 0.7em;
	text-align: center;
	transition: transform 0.12s ease, box-shadow 0.12s ease, border-color 0.12s ease;
	color: inherit;
	font: inherit;
}

.pnm-wc-jar-btn:hover:not(:disabled) {
	transform: translateY(-3px);
	border-color: var(--pnm-accent);
	box-shadow: 0 8px 18px color-mix( in srgb, var(--pnm-accent) 22%, transparent );
}

.pnm-wc-jar-btn:active:not(:disabled) {
	transform: translateY(-1px) scale(0.98);
}

.pnm-wc-jar-btn:disabled {
	cursor: not-allowed;
}

.pnm-wc-jar.is-picked .pnm-wc-jar-btn {
	border-color: var(--pnm-accent);
	background: color-mix( in srgb, var(--pnm-accent) 8%, var(--pnm-jar) );
}

.pnm-wc-jar--oos .pnm-wc-jar-btn {
	opacity: 0.5;
	filter: grayscale(0.7);
}

.pnm-wc-jar-image img {
	width: 84px;
	height: 84px;
	object-fit: cover;
	border-radius: 50%;
	background: color-mix( in srgb, var(--pnm-accent) 6%, #fff );
	box-shadow: inset 0 0 0 4px rgba( 255, 255, 255, 0.6 ), 0 2px 6px rgba( 0, 0, 0, 0.08 );
	display: block;
}

/* Product name under each treat image. Forced visible and dark so a theme
 * that restyles button text (e.g. white button text) can't hide it on the
 * white tile. */
.pnm-wc-stall .pnm-wc-jar-name {
	display: block !important;
	visibility: visible !important;
	margin-top: 0.35em;
	font-weight: 600;
	font-size: 0.9em;
	line-height: 1.25;
	color: var(--pnm-ink) !important;
	text-transform: none;
	letter-spacing: normal;
	overflow-wrap: anywhere;
	word-wrap: break-word;
	hyphens: auto;
}

.pnm-wc-jar-add {
	font-size: 0.72em;
	font-weight: 700;
	letter-spacing: 0.03em;
	text-transform: uppercase;
	color: var(--pnm-accent);
}

.pnm-wc-jar-stock {
	font-size: 0.72em;
	font-weight: 700;
	text-transform: uppercase;
	color: #b00;
}

/* Count badge on a picked jar */
.pnm-wc-jar-badge {
	position: absolute;
	top: -8px;
	right: -8px;
	min-width: 24px;
	height: 24px;
	padding: 0 6px;
	border-radius: 999px;
	background: var(--pnm-accent-2);
	color: var(--pnm-ink);
	font-size: 0.8em;
	font-weight: 800;
	line-height: 24px;
	box-shadow: 0 2px 5px rgba( 0, 0, 0, 0.2 );
	transform: scale(0);
	transition: transform 0.18s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.pnm-wc-jar-badge.is-active {
	transform: scale(1);
}

/* ---------- The bag ---------- */

.pnm-wc-bag-panel {
	position: sticky;
	top: 1.5em;
}

.pnm-wc-bag {
	position: relative;
	color: var(--pnm-ink);
	background-color: var(--pnm-bag);
	/* Candy-stripe paper with a soft sheen at the top. */
	background-image:
		linear-gradient( 180deg, rgba( 255, 255, 255, 0.5 ), rgba( 255, 255, 255, 0 ) 32% ),
		repeating-linear-gradient(
			90deg,
			color-mix( in srgb, var(--pnm-bag) 93%, #fff ) 0,
			color-mix( in srgb, var(--pnm-bag) 93%, #fff ) 13px,
			color-mix( in srgb, var(--pnm-bag) 88%, #000 ) 13px,
			color-mix( in srgb, var(--pnm-bag) 88%, #000 ) 26px
		);
	border-radius: 4px 4px 26px 26px;
	box-shadow:
		0 14px 28px rgba( 0, 0, 0, 0.17 ),
		inset 0 -26px 28px -22px rgba( 0, 0, 0, 0.3 ),
		inset 0 1px 0 rgba( 255, 255, 255, 0.55 );
	padding-top: 24px; /* room for the folded cuff */
	margin-top: 10px;  /* room for the twist tie */
	transition: transform 0.2s ease;
}

/* Folded, pinked (zig-zag) paper cuff along the top of the bag. */
.pnm-wc-bag::before {
	content: "";
	position: absolute;
	top: 0;
	left: 0;
	right: 0;
	height: 24px;
	background: linear-gradient(
		180deg,
		color-mix( in srgb, var(--pnm-bag-dark) 78%, #fff ),
		var(--pnm-bag-dark)
	);
	box-shadow: 0 2px 3px rgba( 0, 0, 0, 0.12 );
	-webkit-mask:
		linear-gradient( #000 0 0 ) top / 100% 16px no-repeat,
		conic-gradient( from -45deg at 50% 0, #000 90deg, transparent 0 ) bottom / 16px 9px repeat-x;
	mask:
		linear-gradient( #000 0 0 ) top / 100% 16px no-repeat,
		conic-gradient( from -45deg at 50% 0, #000 90deg, transparent 0 ) bottom / 16px 9px repeat-x;
}

/* Twisted-paper tie peeking above the bag. */
.pnm-wc-bag::after {
	content: "";
	position: absolute;
	top: -9px;
	left: 50%;
	width: 48px;
	height: 16px;
	transform: translateX( -50% );
	background: linear-gradient(
		180deg,
		color-mix( in srgb, var(--pnm-bag-dark) 75%, #fff ),
		var(--pnm-bag-dark)
	);
	border-radius: 10px 10px 5px 5px / 12px 12px 5px 5px;
	box-shadow: inset 0 -2px 3px rgba( 0, 0, 0, 0.2 );
}

.pnm-wc-bag--bump {
	transform: translateY(-4px) scale(1.01);
}

.pnm-wc-bag-top {
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 0.8em 1em 0.4em;
}

.pnm-wc-bag-title {
	font-weight: 800;
	font-size: 1.05em;
}

.pnm-wc-count {
	font-weight: 800;
	background: var(--pnm-accent);
	color: #fff;
	padding: 0.15em 0.7em;
	border-radius: 999px;
	white-space: nowrap;
	font-size: 0.9em;
}

.pnm-wc-progress {
	height: 8px;
	margin: 0 1em;
	background: rgba( 0, 0, 0, 0.08 );
	border-radius: 999px;
	overflow: hidden;
}

.pnm-wc-progress-bar {
	display: block;
	height: 100%;
	width: 0;
	background: linear-gradient( 90deg, var(--pnm-accent-2), var(--pnm-accent) );
	transition: width 0.3s ease;
}

.pnm-wc-bag-body {
	padding: 0.75em 1em;
	min-height: 70px;
}

.pnm-wc-bag-empty {
	margin: 0;
	color: var(--pnm-muted);
	font-size: 0.9em;
	text-align: center;
	padding: 0.6em 0;
}

.pnm-wc-bag-items {
	list-style: none;
	margin: 0;
	padding: 0;
	display: flex;
	flex-direction: column;
	gap: 0.4em;
}

.pnm-wc-bag-item {
	display: flex;
	align-items: center;
	gap: 0.5em;
	background: var(--pnm-jar);
	border-radius: 999px;
	padding: 0.25em 0.5em;
	box-shadow: 0 1px 3px rgba( 0, 0, 0, 0.08 );
	animation: pnm-pop 0.22s ease;
}

@keyframes pnm-pop {
	from { transform: scale(0.85); opacity: 0; }
	to   { transform: scale(1); opacity: 1; }
}

.pnm-wc-bag-item-thumb {
	width: 30px;
	height: 30px;
	border-radius: 50%;
	object-fit: cover;
	flex: 0 0 auto;
}

.pnm-wc-bag-item-name {
	flex: 1 1 auto;
	font-size: 0.88em;
	font-weight: 600;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

.pnm-wc-bag-item-qty {
	font-size: 0.82em;
	font-weight: 800;
	color: var(--pnm-accent);
}

.pnm-wc-bag-remove {
	flex: 0 0 auto;
	width: 22px;
	height: 22px;
	border-radius: 50%;
	border: none;
	background: color-mix( in srgb, var(--pnm-accent) 14%, #fff );
	color: var(--pnm-ink);
	font-size: 1em;
	line-height: 1;
	cursor: pointer;
	padding: 0;
}

.pnm-wc-bag-remove:hover {
	background: var(--pnm-accent);
	color: #fff;
}

.pnm-wc-bag-foot {
	padding: 0.5em 1em 1em;
	border-top: 1px dashed var(--pnm-bag-dark);
}

.pnm-wc-message {
	margin: 0.4em 0 0.6em;
	font-weight: 600;
	font-size: 0.9em;
	min-height: 1.2em;
	color: var(--pnm-muted);
}

.pnm-wc-ready .pnm-wc-message {
	color: #2e7d32;
}

.pnm-wc-price {
	display: flex;
	align-items: baseline;
	justify-content: space-between;
	margin-bottom: 0.6em;
}

.pnm-wc-price-label {
	font-weight: 600;
}

.pnm-wc-price-value {
	font-weight: 800;
	font-size: 1.25em;
	color: var(--pnm-accent);
}

.pnm-wc-submit {
	width: 100%;
	border-radius: 999px !important;
}

.pnm-wc-submit[disabled] {
	opacity: 0.55;
	cursor: not-allowed;
}

/* ---------- Fly-to-bag animation ---------- */

.pnm-wc-fly {
	position: fixed;
	z-index: 9999;
	width: 60px;
	height: 60px;
	border-radius: 50%;
	object-fit: cover;
	pointer-events: none;
	transform: translate(-50%, -50%) scale(1) rotate(0deg);
	transition: left 0.65s cubic-bezier(0.5, -0.3, 0.7, 0.4),
		top 0.65s cubic-bezier(0.5, -0.3, 0.7, 0.4),
		transform 0.65s ease-in,
		opacity 0.65s ease-in;
	box-shadow: 0 4px 10px rgba( 0, 0, 0, 0.25 );
}

@media (prefers-reduced-motion: reduce) {
	.pnm-wc-fly {
		display: none;
	}

	.pnm-wc-jar-btn,
	.pnm-wc-progress-bar,
	.pnm-wc-bag,
	.pnm-wc-jar-badge {
		transition: none;
	}
}
