/* Stitch Configurator – product page.
   Selectors are prefixed with .stitch-cfg so Avada's button and input styles do not leak in. */

.stitch-cfg {
	--stitch-accent: #341341;
	--stitch-line: #e2dde6;
	--stitch-muted: #8f829b;
	--stitch-text: #241f1a;
	--stitch-surface: #fff;
	display: flex;
	flex-direction: column;
	gap: 22px;
	margin: 8px 0 24px;
	width: 100%;
	clear: both;
}

/* ---------- Preview ---------- */
.stitch-cfg-preview {
	position: relative;
	container-type: inline-size;
	width: 100%;
	max-width: 520px;
	margin: 0 auto;
	line-height: 0;
	border-radius: 12px;
	overflow: hidden;
	background: #fff;
}
.stitch-cfg-preview.is-slotted { max-width: none; }
.stitch-cfg-preview .stitch-cfg-bag {
	display: block;
	width: 100%;
	height: auto;
	margin: 0;
	/* Product photos have an off-white (#FDFDFD) background; lift it to the page's pure white
	   so no faint square shows around the photo. Fabric colours change by ~1%. */
	filter: brightness(1.013);
}
.stitch-cfg-preview .stitch-cfg-app {
	position: absolute;
	left: var(--ax, 50%);
	top: var(--ay, 35%);
	width: var(--aw, 28%);
	height: auto;
	transform: translate(-50%, -50%);
	pointer-events: none;
	filter: drop-shadow(0 1px 1px rgba(0, 0, 0, .25));
}
.stitch-cfg-preview .stitch-cfg-name {
	position: absolute;
	left: var(--nx, 50%);
	top: var(--ny, 78%);
	transform: translate(-50%, -50%);
	max-width: none;
	white-space: nowrap;
	line-height: 1.1;
	font-size: 8cqw;
	font-weight: 600;
	text-shadow: none;
	pointer-events: none;
	unicode-bidi: plaintext;
}

/* Paid add-ons (tassels...): x = centre, y = top edge, w = width, all in % of the photo. */
.stitch-cfg-preview .stitch-cfg-addon {
	position: absolute;
	left: 50%;
	top: 10%;
	width: 25%;
	height: auto;
	transform: translateX(-50%);
	pointer-events: none;
	filter: drop-shadow(0 1px 1px rgba(0, 0, 0, .2));
}
.stitch-cfg-preview .stitch-cfg-addon[hidden] { display: none; }

/* ---------- Steps ---------- */
.stitch-cfg .stitch-cfg-step {
	border: 0;
	margin: 0;
	padding: 0;
	min-width: 0;
	display: flex;
	flex-direction: column;
	gap: 10px;
}
.stitch-cfg .stitch-cfg-label {
	padding: 0;
	margin: 0;
	font-size: 13px;
	font-weight: 700;
	letter-spacing: .08em;
	text-transform: uppercase;
}
.stitch-cfg .stitch-cfg-value {
	font-weight: 400;
	letter-spacing: 0;
	text-transform: none;
	color: var(--stitch-muted);
	margin-left: 4px;
}
.stitch-cfg .stitch-cfg-req { color: var(--stitch-accent); margin-left: 2px; }
.stitch-cfg .stitch-cfg-sub { font-size: 13px; color: var(--stitch-muted); }

/* Shared button reset. Themes (Avada included) style every <button> with strong selectors,
   so the configurator's own button looks are marked !important on purpose. */
.stitch-cfg button.stitch-cfg-chip,
.stitch-cfg button.stitch-cfg-app-btn,
.stitch-cfg button.stitch-cfg-font,
.stitch-cfg button.stitch-cfg-swatch {
	-webkit-appearance: none;
	appearance: none;
	box-shadow: none !important;
	text-transform: none !important;
	letter-spacing: 0 !important;
	min-height: 0 !important;
	line-height: 1.2 !important;
	margin: 0 !important;
	cursor: pointer !important;
	font-family: inherit !important;
	transition: border-color .15s ease;
}
.stitch-cfg button:focus-visible { outline: 2px solid var(--stitch-accent); outline-offset: 2px; }

/* Filter chips */
.stitch-cfg .stitch-cfg-filters {
	display: flex;
	gap: 6px;
	overflow-x: auto;
	padding-bottom: 2px;
	scrollbar-width: thin;
}
.stitch-cfg button.stitch-cfg-chip {
	flex: none;
	font-size: 13px !important;
	padding: 6px 12px !important;
	border-radius: 999px !important;
	border: 1px solid var(--stitch-line) !important;
	background: var(--stitch-surface) !important;
	color: inherit !important;
	white-space: nowrap;
}
.stitch-cfg button.stitch-cfg-chip[aria-pressed="true"] {
	border-color: var(--stitch-accent) !important;
	color: var(--stitch-accent) !important;
	font-weight: 600 !important;
}

/* Applique grid */
.stitch-cfg .stitch-cfg-apps {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(78px, 1fr));
	gap: 8px;
	padding: 2px; /* No inner scrolling: all appliques show and the page scrolls (1.1.1). */
}
.stitch-cfg button.stitch-cfg-app-btn {
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 4px;
	padding: 6px 4px !important;
	border: 1px solid var(--stitch-line) !important;
	border-radius: 10px !important;
	background: var(--stitch-surface) !important;
	color: inherit !important;
	font-size: 11px !important;
	text-align: center !important;
	min-width: 0;
}
.stitch-cfg button.stitch-cfg-app-btn img {
	width: 56px !important;
	height: 56px !important;
	object-fit: contain;
	margin: 0 !important;
}
.stitch-cfg button.stitch-cfg-app-btn span {
	display: block;
	max-width: 100%;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}
.stitch-cfg button.stitch-cfg-app-btn[aria-selected="true"] {
	border: 2px dashed var(--stitch-accent) !important;
	padding: 5px 3px !important;
	color: var(--stitch-accent) !important;
	font-weight: 600 !important;
}
.stitch-cfg .stitch-cfg-none-ring {
	width: 46px !important;
	height: 46px;
	margin: 5px 0;
	border-radius: 50%;
	border: 2px dashed var(--stitch-line);
}

/* Name */
.stitch-cfg input.stitch-cfg-input {
	width: 100%;
	max-width: 100%;
	font-size: 16px; /* 16px stops iPhones zooming in. */
	padding: 10px 12px;
	border: 1px solid var(--stitch-line);
	border-radius: 8px;
	box-sizing: border-box;
	height: auto;
}
.stitch-cfg .stitch-cfg-msg { margin: 0; min-height: 1.2em; font-size: 13px; color: var(--stitch-muted); }
.stitch-cfg .stitch-cfg-msg.is-error { color: #b32d2e; font-weight: 600; }

.stitch-cfg .stitch-cfg-fonts {
	display: grid;
	grid-template-columns: repeat(2, minmax(0, 1fr));
	gap: 8px;
}
.stitch-cfg button.stitch-cfg-font {
	display: flex;
	flex-direction: column;
	align-items: center;
	padding: 8px 6px !important;
	border: 1px solid var(--stitch-line) !important;
	border-radius: 8px !important;
	background: var(--stitch-surface) !important;
	color: inherit !important;
	min-width: 0;
}
.stitch-cfg .stitch-cfg-font-sample {
	font-size: 22px;
	line-height: 1.3;
	max-width: 100%;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}
.stitch-cfg button.stitch-cfg-font small {
	font-family: system-ui, -apple-system, "Segoe UI", sans-serif !important;
	font-size: 11px !important;
	color: var(--stitch-muted) !important;
}
.stitch-cfg button.stitch-cfg-font[aria-pressed="true"] {
	border: 2px dashed var(--stitch-accent) !important;
	padding: 7px 5px !important;
}
.stitch-cfg button.stitch-cfg-font:disabled { opacity: .35; cursor: not-allowed !important;}

/* Thread swatches */
.stitch-cfg .stitch-cfg-threads { display: flex; flex-wrap: wrap; gap: 10px; }
.stitch-cfg button.stitch-cfg-swatch {
	position: relative;
	width: 38px !important;
	height: 38px !important;
	padding: 0 !important;
	border: 0 !important;
	border-radius: 50% !important;
	background: transparent !important;
}
.stitch-cfg button.stitch-cfg-swatch::before {
	content: "";
	position: absolute;
	inset: 5px;
	border-radius: 50% !important;
	background: var(--c) !important;
	box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .15) !important;
}
.stitch-cfg button.stitch-cfg-swatch[aria-pressed="true"]::after {
	content: "";
	position: absolute;
	inset: 0;
	border-radius: 50% !important;
	border: 2px dashed var(--stitch-accent) !important;
}

@media (prefers-reduced-motion: reduce) {
	.stitch-cfg button { transition: none; }
}

/* Anything the script hides must stay hidden, whatever display a rule above gives it. */
.stitch-cfg [hidden],
.stitch-cfg-form [hidden],
.stitch-cfg-drawer[hidden] { display: none !important; }

/* ---------- Page layout (1.2.0, design B) ----------
   The script wraps the add-to-cart form in two parts: a "stage" with the live preview and a
   "panel" with everything else (title, size & colour, tabs, add to cart).
   800px and wider: two columns, preview pinned on the left.
   Under 800px (phones, small tablets): preview pinned, compact, at the top while the options scroll. */
.stitch-cfg-layout { display: block; }
.stitch-cfg-stage {
	position: sticky;
	top: var(--stitch-sticky-top, 0px);
	z-index: 30; /* Above everything in the options panel (Avada dropdowns use z-index 5–10). */
	background: #fff;
	padding-block: 6px 10px;
	margin-bottom: 12px;
}
.stitch-cfg-stage .stitch-cfg-preview {
	width: min(100%, 40vh);
	max-width: none;
}
.stitch-cfg-panel {
	min-width: 0;
	color: var(--stitch-text, #241f1a);
	/* Keep every layer inside the panel (Avada selects, swatches, arrows) below the pinned preview. */
	position: relative;
	z-index: 0;
	isolation: isolate;
}

@media (min-width: 800px) {
	.stitch-cfg-layout {
		display: grid;
		grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr);
		gap: 48px;
		align-items: start;
	}
	.stitch-cfg-stage {
		top: var(--stitch-sticky-top-wide, 24px);
		padding: 0;
		margin: 0;
	}
	.stitch-cfg-stage .stitch-cfg-preview {
		width: 100%;
		max-width: 620px;
	}
}

/* ---------- Summary chips under the preview (wide screens only) ---------- */
.stitch-cfg-summary {
	display: none;
	list-style: none;
	margin: 14px 0 0;
	padding: 0;
	flex-wrap: wrap;
	justify-content: center;
	gap: 6px;
}
.stitch-cfg-summary li {
	margin: 0;
	padding: 5px 12px;
	border-radius: 999px;
	background: #f5f2f7;
	color: #341341;
	font-size: 13px;
	line-height: 1.3;
}
@media (min-width: 800px) {
	.stitch-cfg-summary { display: flex; }
}

/* ---------- Title, price, short description ---------- */
.stitch-cfg-head { margin: 0 0 20px; }
.stitch-cfg-head .stitch-cfg-title {
	font-family: "GFS Didot", Georgia, serif;
	text-transform: uppercase;
	letter-spacing: .04em;
	font-size: clamp(24px, 3vw, 32px);
	line-height: 1.15;
	font-weight: 400;
	color: #341341;
	margin: 0 0 8px;
}
.stitch-cfg-head .stitch-cfg-price {
	font-size: 20px;
	color: #341341;
	margin: 0 0 12px;
}
.stitch-cfg-head .stitch-cfg-price del { color: var(--stitch-muted, #8f829b); margin-right: 6px; }
.stitch-cfg-head .stitch-cfg-price ins { text-decoration: none; }
.stitch-cfg-head .stitch-cfg-intro {
	font-size: 15px;
	line-height: 1.6;
	color: #241f1a;
	margin: 0;
}

/* Text-style buttons: "Full details", "Size chart", "Next: add a name". */
button.stitch-cfg-more,
button.stitch-cfg-chart-link,
button.stitch-cfg-next {
	-webkit-appearance: none;
	appearance: none;
	background: none !important;
	border: 0 !important;
	box-shadow: none !important;
	padding: 0 !important;
	margin: 0 !important;
	min-height: 0 !important;
	width: auto !important;
	color: #341341 !important;
	font-family: inherit !important;
	font-size: 14px !important;
	font-weight: 600 !important;
	letter-spacing: 0 !important;
	text-transform: none !important;
	line-height: 1.4 !important;
	text-decoration: underline !important;
	text-underline-offset: 3px;
	cursor: pointer !important;
}
button.stitch-cfg-more { margin-left: 4px !important; }
button.stitch-cfg-chart-link {
	display: inline-flex !important;
	align-items: center;
	gap: 6px;
}
.stitch-cfg-head button.stitch-cfg-chart-link { margin-top: 10px !important; }
button.stitch-cfg-next {
	align-self: flex-end;
	margin-top: 6px !important;
	text-decoration: none !important;
	border: 1px solid #341341 !important;
	border-radius: 999px !important;
	padding: 8px 16px !important;
}
button.stitch-cfg-more:focus-visible,
button.stitch-cfg-chart-link:focus-visible,
button.stitch-cfg-next:focus-visible { outline: 2px solid #341341; outline-offset: 3px; }

/* ---------- "Size & colour" card around the variation choices ---------- */
.stitch-cfg-card {
	border: 1px solid var(--stitch-line, #e2dde6);
	border-radius: 12px;
	padding: 14px 16px 6px;
	margin: 0 0 20px;
	background: #fff;
}
.stitch-cfg-card-head {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 12px;
	margin-bottom: 8px;
}
.stitch-cfg-card .stitch-cfg-label,
.stitch-cfg-card-head .stitch-cfg-label {
	font-size: 13px;
	font-weight: 700;
	letter-spacing: .08em;
	text-transform: uppercase;
	color: #341341;
}
.stitch-cfg-card table.variations { margin: 0 !important; border: 0; }
.stitch-cfg-card table.variations th,
.stitch-cfg-card table.variations td { border: 0; background: none; }

/* ---------- Tabs: Applique / Name / Details ---------- */
.stitch-cfg .stitch-cfg-tabs {
	display: flex;
	gap: 4px;
	border-bottom: 1px solid var(--stitch-line);
	overflow-x: auto;
	scrollbar-width: none;
	scroll-margin-top: 90px;
	margin-bottom: -6px;
}
.stitch-cfg .stitch-cfg-tabs::-webkit-scrollbar { display: none; }
.stitch-cfg button.stitch-cfg-tab {
	-webkit-appearance: none;
	appearance: none;
	flex: 1 0 auto;
	display: inline-flex !important;
	align-items: center;
	justify-content: center;
	gap: 8px;
	min-height: 48px !important;
	margin: 0 0 -1px !important;
	padding: 10px 12px !important;
	background: none !important;
	border: 0 !important;
	border-bottom: 3px solid transparent !important;
	border-radius: 0 !important;
	box-shadow: none !important;
	color: var(--stitch-muted) !important;
	font-family: inherit !important;
	font-size: 14px !important;
	font-weight: 600 !important;
	letter-spacing: .06em !important;
	text-transform: uppercase !important;
	line-height: 1.2 !important;
	cursor: pointer !important;
	white-space: nowrap;
}
.stitch-cfg button.stitch-cfg-tab[aria-selected="true"] {
	color: #341341 !important;
	border-bottom-color: #341341 !important;
}
.stitch-cfg .stitch-cfg-tab-num {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 22px;
	height: 22px;
	border-radius: 50%;
	border: 1px solid currentColor;
	font-size: 12px;
	letter-spacing: 0;
	text-transform: none;
}
.stitch-cfg button.stitch-cfg-tab[aria-selected="true"] .stitch-cfg-tab-num {
	background: #341341;
	border-color: #341341;
	color: #fff;
}

/* Tab panels */
.stitch-cfg .stitch-cfg-step[role="tabpanel"] { padding-top: 6px; }
.stitch-cfg .stitch-cfg-details {
	display: block;
	font-size: 15px;
	line-height: 1.65;
	color: #241f1a;
}
.stitch-cfg .stitch-cfg-details > :first-child { margin-top: 0; }
.stitch-cfg .stitch-cfg-details > :last-child { margin-bottom: 0; }

/* Add-on price next to the step title, and the price with extras above Add to cart. */
.stitch-cfg .stitch-cfg-addon-price {
	font-weight: 600;
	letter-spacing: 0;
	text-transform: none;
	color: var(--stitch-accent);
	margin-left: 4px;
}
.stitch-cfg .stitch-cfg-total {
	margin: 0;
	font-size: 15px;
	font-weight: 700;
}
.stitch-cfg .stitch-cfg-total[hidden] { display: none; }

/* Message shown when Add to cart is pressed with something missing. */
.stitch-cfg .stitch-cfg-alert {
	margin: 0;
	padding: 10px 14px;
	border-radius: 8px;
	background: #fbeaea;
	color: #8a1f1f;
	font-size: 14px;
	font-weight: 600;
}

/* ---------- Size chart drawer ---------- */
html.stitch-cfg-noscroll { overflow: hidden; }
.stitch-cfg-drawer {
	position: fixed;
	inset: 0;
	z-index: 100000;
}
.stitch-cfg-drawer-backdrop {
	position: absolute;
	inset: 0;
	background: rgba(36, 31, 26, .45);
}
.stitch-cfg-drawer-panel {
	position: absolute;
	top: 0;
	right: 0;
	bottom: 0;
	width: min(440px, 100%);
	overflow-y: auto;
	background: #fff;
	padding: 20px 22px 32px;
	box-sizing: border-box;
	box-shadow: -8px 0 30px rgba(0, 0, 0, .15);
	color: #241f1a;
	font-size: 15px;
	outline: none;
	animation: stitch-cfg-slide .2s ease-out;
}
@keyframes stitch-cfg-slide { from { transform: translateX(30px); opacity: 0; } to { transform: none; opacity: 1; } }
.stitch-cfg-drawer-top {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 12px;
	margin-bottom: 14px;
}
.stitch-cfg-drawer .stitch-cfg-drawer-title {
	margin: 0;
	font-family: "GFS Didot", Georgia, serif;
	text-transform: uppercase;
	letter-spacing: .05em;
	font-size: 22px;
	font-weight: 400;
	color: #341341;
}
.stitch-cfg-drawer button.stitch-cfg-drawer-close {
	-webkit-appearance: none;
	appearance: none;
	width: 44px !important;
	height: 44px !important;
	min-height: 0 !important;
	padding: 0 !important;
	margin: 0 !important;
	border: 1px solid var(--stitch-line, #e2dde6) !important;
	border-radius: 50% !important;
	background: #fff !important;
	box-shadow: none !important;
	color: #341341 !important;
	font-size: 24px !important;
	line-height: 1 !important;
	cursor: pointer !important;
}
.stitch-cfg-drawer-note { margin: 0 0 14px; color: #8f829b; font-size: 14px; }
.stitch-cfg-drawer-table { overflow-x: auto; margin-bottom: 16px; }
.stitch-cfg-drawer-table table {
	width: 100%;
	border-collapse: collapse;
	margin: 0;
	font-size: 14px;
}
.stitch-cfg-drawer-table th,
.stitch-cfg-drawer-table td {
	padding: 10px 8px;
	border: 0;
	border-bottom: 1px solid #e2dde6;
	text-align: left;
	white-space: nowrap;
}
.stitch-cfg-drawer-table th {
	color: #341341;
	font-size: 12px;
	font-weight: 700;
	letter-spacing: .06em;
	text-transform: uppercase;
	background: #f5f2f7;
}
.stitch-cfg-drawer-img { display: block; width: 100%; height: auto; border-radius: 8px; }

@media (prefers-reduced-motion: reduce) {
	.stitch-cfg-drawer-panel { animation: none; }
}

/* The live preview replaces the product gallery on configurator products
   (otherwise phones show the bag twice). */
body.stitch-cfg-product .woocommerce-product-gallery,
body.stitch-cfg-product .fusion-woo-product-images {
	display: none !important;
}
