/* ==========================================================================
   Munti — set page (grouped product)
   Desktop: info on the right (first column in RTL), sticky gallery on the left.
   Mobile: full-width gallery, info below, total + buy bar pinned to the bottom.
   All colors from main.css tokens; the only raw color is "out of stock" (semantic).
   ========================================================================== */

.is-set-product .shop-wrap { --shop-max: 1520px; }

.munti-set {
	--set-danger: #8F2D22;
	--set-gap: clamp(var(--space-32), 4.6vw, var(--space-96));
	display: grid;
	/* Gallery column sized to the gallery itself (4:5 photo + thumbs); info takes the rest. */
	grid-template-columns: minmax(320px, 1fr) auto;
	grid-template-areas: "info gallery";
	gap: var(--set-gap);
	align-items: start;
}

/* ---------- Gallery: 4:5 portrait photo, thumbs in a column beside it ----------
   Height comes from the viewport (whole gallery visible), width = height × 0.8.
   In RTL the photo sits next to the info; thumbs on the outer edge. */
.set-gallery {
	--stage-w: min(calc((100svh - var(--munti-header-h) - 56px) * 0.8), 56vw, 780px);
	grid-area: gallery;
	position: sticky;
	inset-block-start: calc(var(--munti-header-h) + var(--space-20));
	display: grid;
	grid-template-columns: var(--stage-w) 72px;
	gap: var(--space-16);
	align-items: start;
	min-inline-size: 0;
}

.set-stage {
	position: relative;
	overflow: hidden;
	border-radius: var(--munti-radius);
	background: var(--munti-sand);
}

.set-track {
	display: flex;
	aspect-ratio: 4 / 5;
	overflow-x: auto;
	overscroll-behavior-x: contain;
	scroll-snap-type: x mandatory;
	scrollbar-width: none;
	transition: opacity 0.32s ease, transform 0.6s var(--munti-ease);
	cursor: zoom-in;
}
.set-track::-webkit-scrollbar { display: none; }
.set-track:focus-visible { outline: 2px solid var(--munti-ink); outline-offset: calc(-1 * var(--space-2)); }

/* Color switch: old gallery fades, new one settles in from slightly closer (opacity/transform only). */
.set-track.is-out { opacity: 0; transform: scale(1.015); transition-duration: 0.28s, 0.28s; }

.set-slide {
	flex: 0 0 100%;
	margin: 0;
	scroll-snap-align: start;
	scroll-snap-stop: always;
}
.set-slide img {
	display: block;
	inline-size: 100%;
	block-size: 100%;
	max-inline-size: none;
	object-fit: cover;
}

/* Bar under the photo: shown color name, counter, arrows */
.set-stage__bar {
	position: absolute;
	inset-inline: 0;
	inset-block-end: 0;
	display: flex;
	align-items: center;
	gap: var(--space-16);
	padding: var(--space-12) var(--space-16);
	pointer-events: none;
}
.set-stage__bar > * { pointer-events: auto; }

.set-stage__caption {
	margin: 0;
	margin-inline-end: auto;
	padding: var(--space-4) var(--space-12);
	background: rgb(var(--munti-linen-rgb) / 0.86);
	color: var(--munti-ink);
	font-size: var(--fs-xs);
	font-weight: var(--fw-medium);
	line-height: 1.3;
	transition: opacity 0.3s ease;
}
.set-stage__caption:empty { display: none; }

.set-counter {
	display: flex;
	align-items: center;
	gap: var(--space-8);
	margin: 0;
	padding: var(--space-4) var(--space-12);
	background: rgb(var(--munti-linen-rgb) / 0.86);
	color: var(--munti-ink);
	font-size: var(--fs-xs);
	line-height: 1.3;
}
.set-counter__sep { inline-size: 18px; block-size: 1px; background: currentColor; opacity: 0.5; }

.set-nav { display: flex; gap: var(--space-2); }
.set-nav__btn {
	display: grid;
	place-items: center;
	inline-size: 40px;
	block-size: 40px;
	padding: 0;
	border: 0;
	background: rgb(var(--munti-linen-rgb) / 0.86);
	color: var(--munti-ink);
	cursor: pointer;
	transition: background-color 0.25s ease, color 0.25s ease;
}
.set-nav__btn .icon { inline-size: 18px; block-size: 18px; }
.set-nav__btn:hover { background: var(--munti-ink); color: var(--munti-linen); }
.set-nav__btn:disabled { opacity: 0.35; cursor: default; background: rgb(var(--munti-linen-rgb) / 0.86); color: var(--munti-ink); }
.set-nav__btn:focus-visible { outline: 2px solid var(--munti-ink); outline-offset: var(--space-2); }

/* Thumbs: vertical column beside the photo (desktop); on mobile they become a thin progress bar. */
.set-thumbs {
	display: grid;
	grid-auto-flow: row;
	grid-template-columns: 72px;
	gap: var(--space-12);
	align-content: start;
	max-block-size: calc(var(--stage-w) * 1.25);
	overflow-y: auto;
	scrollbar-width: none;
	padding-inline-start: var(--space-8); /* Room for the indicator line, facing the photo */
	margin-inline-start: calc(-1 * var(--space-8));
	transition: opacity 0.3s ease;
}
.set-thumbs::-webkit-scrollbar { display: none; }
.set-thumbs.is-out { opacity: 0; }
.set-thumb {
	position: relative;
	display: block;
	padding: 0;
	border: 0;
	background: var(--munti-sand);
	aspect-ratio: 4 / 5;
	cursor: pointer;
	opacity: 0.5;
	transition: opacity 0.3s ease;
}
.set-thumb img { display: block; inline-size: 100%; block-size: 100%; object-fit: cover; }
/* Indicator: 1px vertical line on the photo side */
.set-thumb::after {
	content: "";
	position: absolute;
	inset-block: 0;
	inset-inline-start: calc(-1 * var(--space-8));
	inline-size: 1px;
	background: var(--munti-ink);
	transform: scaleY(0);
	transition: transform 0.45s var(--munti-ease);
}
.set-thumb:hover { opacity: 0.8; }
.set-thumb[aria-current="true"] { opacity: 1; }
.set-thumb[aria-current="true"]::after { transform: none; }
.set-thumb:focus-visible { outline: 2px solid var(--munti-ink); outline-offset: var(--space-2); }

/* ---------- Info ---------- */
.set-info {
	grid-area: info;
	display: grid;
	min-inline-size: 0;
	padding-block-start: clamp(var(--space-4), 2vh, var(--space-24));
}

.set-eyebrow {
	display: flex;
	align-items: center;
	gap: 0.75em;
	margin: 0 0 var(--space-16);
	font-size: var(--fs-xs);
	font-weight: var(--fw-medium);
	color: var(--munti-slate);
}
.set-eyebrow::before { content: ""; inline-size: 2.5em; block-size: 1px; background: currentColor; opacity: 0.6; }

.set-title {
	margin: 0;
	font-size: var(--fs-2xl);
	font-weight: 250;
	line-height: var(--lh-tight);
}

.set-lead {
	margin-block: var(--space-16) var(--space-24);
	max-inline-size: 44ch;
	color: var(--munti-slate);
	font-size: var(--fs-sm);
	line-height: 2;
}
.set-lead > * { margin: 0; }

/* Global options (fabric, wood) */
.set-opt {
	min-inline-size: 0;
	margin: 0;
	padding: var(--space-20) 0 var(--space-20);
	border: 0;
	border-block-start: 1px solid var(--munti-line);
}
/* A legend is drawn on the fieldset border: the top padding ended up under it and the
   section's top line got erased. float turns it back into a normal element. */
.set-opt__head {
	float: inline-start;
	display: flex;
	justify-content: space-between;
	align-items: baseline;
	gap: var(--space-16);
	inline-size: 100%;
	margin: 0 0 var(--space-12);
	padding: 0;
	font-size: var(--fs-sm);
	line-height: var(--lh-snug);
}
.set-opt__label { font-weight: var(--fw-medium); }
.set-opt__val { color: var(--munti-slate); font-size: var(--fs-xs); text-align: end; }

.set-swatches {
	clear: both;
	display: flex;
	flex-wrap: wrap;
	gap: var(--space-8);
	/* Each swatch: 44px box (touch target) with a 32px dot; the 6px inset is offset here
	   so the first dot lines up with the heading text edge. */
	margin-inline: calc(-1 * var(--space-8));
}
.set-swatches.is-visual { gap: var(--space-4); }

.set-sw {
	position: relative;
	display: grid;
	place-items: center;
	inline-size: 44px;
	block-size: 44px;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: none;
	cursor: pointer;
	transition: box-shadow 0.25s ease;
}
/* Color or texture dot */
.set-sw::before {
	content: "";
	inline-size: 32px;
	block-size: 32px;
	border-radius: 50%;
	background: var(--sw-img, none) center / cover, var(--sw, var(--munti-sand));
	box-shadow: inset 0 0 0 1px rgb(var(--munti-ink-rgb) / 0.14);
	transition: transform 0.35s var(--munti-ease);
}
/* Ring on the box edge, not outside it, so nothing overflows the row. */
.set-sw:hover { box-shadow: inset 0 0 0 1px var(--munti-rose); }
.set-sw[aria-pressed="true"] { box-shadow: inset 0 0 0 1px var(--munti-ink); }
.set-sw[aria-pressed="true"]::before { transform: scale(0.94); }
.set-sw:focus-visible { outline: none; box-shadow: inset 0 0 0 2px var(--munti-ink); }

/* Unavailable in current combo: faded with a diagonal strike; still selectable (to show which piece lacks it). */
.set-sw.is-na::before { opacity: 0.4; }
.set-sw.is-na::after {
	content: "";
	position: absolute;
	inline-size: 32px;
	block-size: 1px;
	background: var(--munti-ink);
	transform: rotate(-45deg);
}

/* Non-color attribute: text button */
.set-sw--text,
.set-chip {
	inline-size: auto;
	block-size: auto;
	min-block-size: 2.4rem;
	padding: var(--space-8) var(--space-16);
	border-radius: var(--munti-radius-btn);
	background: transparent;
	box-shadow: inset 0 0 0 1px var(--munti-line);
	color: var(--munti-ink);
	font: inherit;
	font-size: var(--fs-sm);
	line-height: 1.2;
	transition: background-color 0.25s ease, color 0.25s ease, box-shadow 0.25s ease;
}
.set-sw--text::before,
.set-sw--text::after { display: none; }
.set-swatches:not(.is-visual) { margin-inline: 0; gap: var(--space-8); }
.set-sw--text:hover,
.set-chip:hover { box-shadow: inset 0 0 0 1px var(--munti-ink); }
.set-sw--text[aria-pressed="true"],
.set-chip[aria-pressed="true"] { background: var(--munti-ink); color: var(--munti-linen); box-shadow: none; }
.set-sw--text.is-na,
.set-chip.is-na { opacity: 0.45; text-decoration: line-through; }
.set-sw--text:focus-visible,
.set-chip:focus-visible { outline: 2px solid var(--munti-ink); outline-offset: var(--space-2); }

/* ---------- Pieces ---------- */
.set-pieces {
	padding-block-start: var(--space-20);
	border-block-start: 1px solid var(--munti-line);
}
.set-pieces__head {
	display: flex;
	justify-content: space-between;
	align-items: baseline;
	margin-block-end: var(--space-8);
}
.set-h { margin: 0; font-size: var(--fs-sm); font-weight: var(--fw-medium); line-height: var(--lh-snug); }

.set-link {
	padding: 0;
	border: 0;
	background: none;
	color: var(--munti-slate);
	font: inherit;
	font-size: var(--fs-xs);
	text-decoration: underline;
	text-underline-offset: 0.3em;
	cursor: pointer;
}
.set-link:hover { color: var(--munti-ink); }

.set-pieces__list { margin: 0; padding: 0; list-style: none; }

.set-piece {
	position: relative;
	display: grid;
	grid-template-columns: minmax(0, 1fr) auto;
	gap: var(--space-16);
	align-items: center;
	padding-block: var(--space-16);
}
.set-piece + .set-piece::before {
	content: "";
	position: absolute;
	inset-block-start: 0;
	inset-inline: 0;
	block-size: 1px;
	background: var(--munti-line);
	transform: scaleY(0.5);
}

.set-piece__main { display: grid; gap: var(--space-4); min-inline-size: 0; }
.set-piece__name { margin: 0; font-size: var(--fs-base); font-weight: var(--fw-regular); line-height: var(--lh-snug); }
.set-piece.is-on .set-piece__name { font-weight: var(--fw-medium); }
.set-piece__price { margin: 0; font-size: var(--fs-sm); color: var(--munti-slate); }
.set-piece__note { margin: 0; font-size: var(--fs-xs); color: var(--set-danger); }
.set-piece__note:empty { display: none; }
.set-piece.is-out .set-piece__price { text-decoration: line-through; opacity: 0.6; }

.set-chips { display: flex; flex-wrap: wrap; gap: var(--space-8); margin-block: var(--space-4) var(--space-2); }
.set-chip { min-block-size: 2rem; padding: var(--space-4) var(--space-12); font-size: var(--fs-xs); cursor: pointer; }

/* Quantity: "Add" → stepper */
.set-qty { justify-self: end; }
.set-qty__add,
.set-qty__step {
	display: inline-grid;
	align-items: center;
	block-size: 2.5rem;
	box-shadow: inset 0 0 0 1px rgb(var(--munti-ink-rgb) / 0.3);
}
.set-qty__add {
	padding: 0 var(--space-16);
	border: 0;
	background: transparent;
	color: var(--munti-ink);
	font: inherit;
	font-size: var(--fs-xs);
	font-weight: var(--fw-medium);
	cursor: pointer;
	transition: background-color 0.25s ease, color 0.25s ease;
}
.set-qty__add:hover { background: var(--munti-ink); color: var(--munti-linen); }
.set-qty__step { display: none; grid-template-columns: 34px 2.1rem 34px; box-shadow: inset 0 0 0 1px var(--munti-ink); }
.set-qty__step button {
	block-size: 100%;
	padding: 0;
	border: 0;
	background: none;
	color: inherit;
	font: inherit;
	font-size: 1.05rem;
	line-height: 1;
	cursor: pointer;
	transition: background-color 0.2s ease;
}
.set-qty__step button:hover:not(:disabled) { background: rgb(var(--munti-ink-rgb) / 0.07); }
.set-qty__step button:disabled { opacity: 0.3; cursor: default; }
.set-qty__step output { text-align: center; font-size: var(--fs-sm); }
.set-piece.is-on .set-qty__add { display: none; }
.set-piece.is-on .set-qty__step { display: inline-grid; }
.set-qty button:focus-visible { outline: 2px solid var(--munti-ink); outline-offset: var(--space-2); }
.set-piece.is-out .set-qty__add { opacity: 0.4; pointer-events: none; }

/* Piece linked from cart/order email: flashes once. */
.set-piece.is-flash { animation: set-flash 1.6s ease; }
@keyframes set-flash {
	0%, 100% { background: transparent; }
	25% { background: rgb(var(--munti-ink-rgb) / 0.06); }
}

/* ---------- Total and buy ---------- */
/* Desktop: in flow below the pieces (sticky would cover them). Mobile: fixed to the bottom. */
.set-summary {
	display: grid;
	gap: var(--space-12);
	margin-block: var(--space-8) var(--space-24);
	padding: var(--space-20) 0 max(var(--space-20), env(safe-area-inset-bottom));
	border-block-start: 1px solid var(--munti-ink);
	background: var(--munti-linen);
}
.set-summary__sum { display: flex; justify-content: space-between; align-items: baseline; gap: var(--space-16); }
.set-summary__label { font-size: var(--fs-sm); color: var(--munti-slate); }
.set-summary__total { font-size: var(--fs-lg); font-weight: var(--fw-light); line-height: 1.2; transition: opacity 0.2s ease; }
.set-summary__total.is-tick { opacity: 0.35; }
.set-summary__price { display: flex; align-items: baseline; gap: var(--space-12); min-inline-size: 0; }
.set-summary__was { font-size: var(--fs-sm); color: var(--munti-slate); text-decoration-thickness: 1px; }
/* Full-set discount (Denzo Group Discount plugin): hint until complete, confirmation when complete. */
.set-deal { margin: 0; font-size: var(--fs-xs); color: var(--munti-slate); }
.has-deal .set-deal { color: var(--munti-ink); }

.set-add {
	position: relative;
	display: flex;
	align-items: center;
	justify-content: center;
	gap: var(--space-12);
	min-block-size: 3.35rem;
	padding: 0 var(--space-24);
	border: 0;
	border-radius: var(--munti-radius-btn);
	background: var(--munti-ink);
	color: var(--munti-linen);
	font: inherit;
	font-size: var(--fs-sm);
	font-weight: var(--fw-medium);
	cursor: pointer;
	overflow: hidden;
	transition: background-color 0.3s ease, opacity 0.3s ease;
}
.set-add::after {
	content: "";
	inline-size: 18px;
	block-size: 18px;
	background: currentColor;
	-webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 32 32' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M27 16H5'/%3E%3Cpath d='M14 7L5 16L14 25'/%3E%3C/svg%3E") center / contain no-repeat;
	mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 32 32' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M27 16H5'/%3E%3Cpath d='M14 7L5 16L14 25'/%3E%3C/svg%3E") center / contain no-repeat;
	transition: transform 0.45s var(--munti-ease);
}
.set-add:hover:not(:disabled) { background: var(--munti-slate); }
.set-add:hover:not(:disabled)::after { transform: translateX(-4px); }
.set-add:disabled { opacity: 0.4; cursor: not-allowed; }
.set-add:focus-visible { outline: 2px solid var(--munti-ink); outline-offset: var(--space-4); }
/* Adding: thin progress bar on the button's bottom edge */
.set-add.is-busy { cursor: progress; }
.set-add.is-busy::before {
	content: "";
	position: absolute;
	inset-inline: 0;
	inset-block-end: 0;
	block-size: 2px;
	background: var(--munti-rose);
	transform-origin: right;
	animation: set-busy 1.1s var(--munti-ease) infinite;
}
@keyframes set-busy {
	0% { transform: scaleX(0); }
	60% { transform: scaleX(1); opacity: 1; }
	100% { transform: scaleX(1); opacity: 0; }
}

.set-msg { margin: 0; font-size: var(--fs-xs); color: var(--munti-slate); }
.set-msg:empty { display: none; }
.set-msg.is-error { color: var(--set-danger); }

/* ---------- Fullscreen view ---------- */
.set-lightbox {
	position: fixed;
	inset: 0;
	z-index: 200;
	display: grid;
	grid-template-rows: 1fr auto;
	background: var(--munti-ink);
	color: var(--munti-linen);
	clip-path: circle(0 at var(--lx, 50%) var(--ly, 50%));
	transition: clip-path 0.8s cubic-bezier(0.76, 0, 0.24, 1);
}
.set-lightbox.is-open { clip-path: circle(150vmax at var(--lx, 50%) var(--ly, 50%)); }
.set-lightbox.is-closing { transition-duration: 0.6s; transition-timing-function: cubic-bezier(0.32, 0, 0.15, 1); }
.set-lightbox[hidden] { display: none; }
.set-lightbox .set-track { aspect-ratio: auto; block-size: 100%; cursor: default; }
.set-lightbox .set-slide img { object-fit: contain; padding: clamp(var(--space-12), 4vh, var(--space-48)) clamp(var(--space-12), 4vw, var(--space-64)) 0; }
.set-lightbox__bar {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: var(--space-16);
	padding: var(--space-16) clamp(var(--space-12), 4vw, var(--space-64)) max(var(--space-16), env(safe-area-inset-bottom));
}
.set-lightbox .set-counter,
.set-lightbox .set-nav__btn { background: transparent; color: var(--munti-linen); }
.set-lightbox .set-nav__btn:hover { background: var(--munti-linen); color: var(--munti-ink); }
.set-lightbox__close { margin-inline-end: auto; }
html.set-lb-open { overflow: hidden; }

/* ---------- Mobile and tablet ---------- */
@media (max-width: 899px) {
	.munti-set {
		grid-template-columns: minmax(0, 1fr);
		grid-template-areas: "gallery" "info";
		gap: var(--space-24);
	}
	.is-set-product .shop-wrap { padding-block-start: 0; }
	.set-gallery {
		position: relative;
		inset-block-start: auto;
		grid-template-columns: minmax(0, 1fr);
		margin-inline: calc(-1 * var(--munti-gutter));
		gap: var(--space-12);
	}
	.set-stage { border-radius: 0; }
	/* Full-width 4:5; height capped on tablet so the photo doesn't fill the screen. */
	.set-track { aspect-ratio: 4 / 5; max-block-size: 78svh; }
	.set-stage__bar { padding: var(--space-12) var(--munti-gutter); }
	.set-nav { display: none; } /* Swipe on mobile */

	/* Thumbs → thin progress bar (same buttons) */
	.set-thumbs {
		grid-auto-flow: column;
		grid-template-columns: none;
		grid-auto-columns: minmax(0, 1fr);
		gap: var(--space-4);
		max-block-size: none;
		overflow: visible;
		margin: 0;
		padding-inline: var(--munti-gutter);
	}
	.set-thumb {
		aspect-ratio: auto;
		block-size: 14px;
		background: none;
		opacity: 1;
	}
	.set-thumb img { display: none; }
	.set-thumb::after {
		inset-block: auto var(--space-8);
		inset-inline: 0;
		inline-size: auto;
		block-size: 1px;
		background: rgb(var(--munti-ink-rgb) / 0.18);
		transform: none;
	}
	.set-thumb[aria-current="true"]::after { background: var(--munti-ink); }

	.set-title { font-size: var(--fs-xl); }
	.set-piece { grid-template-columns: minmax(0, 1fr); row-gap: var(--space-12); }
	.set-qty { grid-column: 1; justify-self: start; }

	/* Total and button: pinned to the bottom */
	.set-summary {
		position: fixed;
		inset-inline: 0;
		inset-block-end: 0;
		z-index: 40;
		grid-template-columns: minmax(0, 1fr) auto;
		align-items: center;
		gap: var(--space-4) var(--space-16);
		margin: 0;
		padding: var(--space-12) var(--munti-gutter) max(var(--space-12), env(safe-area-inset-bottom));
		border-block-start: 1px solid var(--munti-line);
		background: rgb(var(--munti-linen-rgb) / 0.94);
	}
	@supports ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
		.set-summary {
			background: rgb(var(--munti-linen-rgb) / 0.84);
			-webkit-backdrop-filter: blur(14px) saturate(1.15);
			backdrop-filter: blur(14px) saturate(1.15);
		}
	}
	.set-summary__sum { flex-direction: column; align-items: flex-start; gap: 0; }
	.set-summary__label { font-size: var(--fs-xs); }
	.set-summary__total { font-size: var(--fs-md); font-weight: var(--fw-regular); }
	.set-add { min-block-size: 3rem; padding-inline: var(--space-20); }
	.set-msg,
	.set-deal { grid-column: 1 / -1; order: 3; }
	.set-msg { order: 4; }
	/* Old price above the total, so the button stays beside it */
	.set-summary__price { flex-direction: column; align-items: flex-start; gap: 0; }
	.set-summary__was { font-size: var(--fs-xs); line-height: 1.3; }
	.is-set-product .site-footer { padding-block-end: var(--space-128); }
	html.menu-open .set-summary,
	html.cart-open .set-summary { visibility: hidden; }
}

@media (prefers-reduced-motion: reduce) {
	.set-track { scroll-behavior: auto; }
	.set-lightbox { transition: none; }
}
