/* Gift Box Builder. Everything is scoped to .gbb so it cannot leak into the theme. */
.gbb {
	--gbb-accent: #2f6fed;
	--gbb-on-accent: #ffffff;
	--gbb-ink: #171a21;
	--gbb-muted: #555c69;
	--gbb-line: rgba(30, 40, 65, 0.16);
	--gbb-glass: rgba(255, 255, 255, 0.55);
	--gbb-glass-strong: rgba(255, 255, 255, 0.72);
	--gbb-glass-edge: rgba(255, 255, 255, 0.8);
	--gbb-danger: #b3261e;
	--gbb-radius: 16px;

	position: relative;
	box-sizing: border-box;
	max-width: 1080px;
	margin: 0 auto;
	padding: 32px 28px;
	/* "clip" rather than "hidden", so the preview can stay pinned while the page scrolls. */
	overflow: clip;
	container: gbb / inline-size;
	border-radius: 28px;
	color: var(--gbb-ink);
	/* Soft colour glow behind the glass panels, tinted with the brand colour. */
	background:
		radial-gradient(55% 50% at 8% 4%, color-mix(in srgb, var(--gbb-accent) 34%, transparent), transparent 72%),
		radial-gradient(45% 45% at 96% 22%, color-mix(in srgb, var(--gbb-accent) 20%, transparent), transparent 70%),
		radial-gradient(60% 55% at 62% 104%, color-mix(in srgb, var(--gbb-accent) 28%, transparent), transparent 72%),
		linear-gradient(160deg, #f4f6fa, #e8ecf3);
	font-size: 16px;
	line-height: 1.5;
	text-align: left;
}

.gbb *,
.gbb *::before,
.gbb *::after {
	box-sizing: border-box;
}

.gbb [hidden] {
	display: none !important;
}

.gbb-glass {
	border: 1px solid var(--gbb-glass-edge);
	border-radius: 22px;
	background: var(--gbb-glass);
	box-shadow: 0 12px 40px rgba(24, 34, 64, 0.1), inset 0 1px 0 rgba(255, 255, 255, 0.85);
	-webkit-backdrop-filter: blur(22px) saturate(1.5);
	backdrop-filter: blur(22px) saturate(1.5);
}

@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
	.gbb-glass {
		background: rgba(255, 255, 255, 0.86);
	}
}

.gbb-title {
	margin: 0 0 22px;
	font-family: inherit;
	font-size: 1.75em;
	font-weight: 700;
	line-height: 1.2;
	letter-spacing: -0.01em;
	text-align: center;
	color: inherit;
}

.gbb-sr,
.gbb-card input,
.gbb-switch input {
	position: absolute;
	width: 1px;
	height: 1px;
	margin: -1px;
	padding: 0;
	overflow: hidden;
	clip: rect(0 0 0 0);
	clip-path: inset(50%);
	white-space: nowrap;
	border: 0;
}

/* Progress */
.gbb-progress {
	display: flex;
	max-width: 640px;
	margin: 0 auto 28px;
	padding: 0;
	list-style: none;
}

.gbb-progress__item {
	position: relative;
	flex: 1 1 0;
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 6px;
	min-width: 0;
	margin: 0;
	padding: 0;
	color: var(--gbb-muted);
	font-size: 0.8em;
	text-align: center;
}

.gbb-progress__item::before {
	content: "";
	position: absolute;
	top: 14px;
	right: 50%;
	width: 100%;
	height: 2px;
	background: var(--gbb-line);
}

.gbb-progress__item:first-child::before {
	display: none;
}

.gbb-progress__item.is-current::before,
.gbb-progress__item.is-done::before {
	background: var(--gbb-accent);
}

.gbb-progress__dot {
	position: relative;
	z-index: 1;
	display: grid;
	place-items: center;
	width: 30px;
	height: 30px;
	border: 1px solid var(--gbb-glass-edge);
	border-radius: 50%;
	background: var(--gbb-glass-strong);
	box-shadow: 0 2px 8px rgba(24, 34, 64, 0.1);
	font-weight: 600;
	line-height: 1;
}

.gbb-progress__item.is-current .gbb-progress__dot,
.gbb-progress__item.is-done .gbb-progress__dot {
	border-color: var(--gbb-accent);
	background: var(--gbb-accent);
	color: var(--gbb-on-accent);
}

.gbb-progress__item.is-current {
	color: var(--gbb-ink);
	font-weight: 600;
}

/* Layout */
.gbb-layout {
	display: grid;
	grid-template-columns: minmax(0, 1.08fr) minmax(0, 0.92fr);
	gap: 24px;
	align-items: start;
}

.gbb-form {
	margin: 0;
	padding: 28px;
}

.gbb-preview {
	position: sticky;
	top: 24px;
	padding: 20px;
}

.gbb-fieldset {
	min-width: 0;
	margin: 0;
	padding: 0;
	border: 0;
}

.gbb-heading {
	display: block;
	width: 100%;
	margin: 0 0 6px;
	padding: 0;
	font-family: inherit;
	font-size: 1.3em;
	font-weight: 700;
	line-height: 1.3;
	letter-spacing: -0.01em;
	color: inherit;
}

.gbb-heading:focus {
	outline: none;
}

.gbb-hint {
	margin: 0 0 16px;
	color: var(--gbb-muted);
}

.gbb-counter {
	display: inline-block;
	margin-left: 6px;
	padding: 2px 10px;
	border-radius: 999px;
	background: rgba(30, 40, 65, 0.08);
	color: var(--gbb-ink);
	font-size: 0.85em;
	font-weight: 600;
	white-space: nowrap;
}

.gbb-counter.is-ok {
	background: color-mix(in srgb, var(--gbb-accent) 16%, transparent);
}

/* Cards */
.gbb-colors,
.gbb-items {
	display: grid;
	gap: 12px;
	margin-top: 18px;
}

.gbb-colors {
	grid-template-columns: repeat(3, minmax(0, 1fr));
}

.gbb-items {
	grid-template-columns: repeat(auto-fill, minmax(116px, 1fr));
	gap: 10px;
}

.gbb-card {
	position: relative;
	display: block;
	margin: 0;
	cursor: pointer;
}

.gbb-card__body {
	position: relative;
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: 8px;
	height: 100%;
	min-height: 104px;
	padding: 14px 8px;
	border: 1.5px solid var(--gbb-glass-edge);
	border-radius: var(--gbb-radius);
	background: rgba(255, 255, 255, 0.5);
	box-shadow: 0 2px 10px rgba(24, 34, 64, 0.06);
	text-align: center;
	transition: border-color 0.15s, background-color 0.15s, box-shadow 0.15s, transform 0.15s;
}

.gbb-card--color .gbb-card__body {
	gap: 12px;
	padding: 22px 8px 18px;
}

.gbb-card:hover .gbb-card__body {
	background: rgba(255, 255, 255, 0.78);
	transform: translateY(-1px);
}

.gbb-card input:focus-visible + .gbb-card__body {
	outline: 3px solid var(--gbb-ink);
	outline-offset: 2px;
}

.gbb-card input:checked + .gbb-card__body {
	border-color: var(--gbb-accent);
	background: color-mix(in srgb, var(--gbb-accent) 12%, rgba(255, 255, 255, 0.82));
	box-shadow: 0 6px 18px color-mix(in srgb, var(--gbb-accent) 24%, transparent);
}

.gbb-card.is-disabled {
	cursor: not-allowed;
}

.gbb-card.is-disabled .gbb-card__body {
	opacity: 0.45;
	transform: none;
	background: rgba(255, 255, 255, 0.4);
}

.gbb-card__label {
	font-size: 0.88em;
	font-weight: 600;
	line-height: 1.25;
}

.gbb-icon {
	flex: none;
	width: 30px;
	height: 30px;
}

.gbb-swatch {
	position: relative;
	display: block;
	width: 64px;
	height: 52px;
	border-radius: 8px;
	background: linear-gradient(135deg, rgba(255, 255, 255, 0.16), rgba(0, 0, 0, 0.14)), var(--swatch);
	box-shadow: 0 8px 16px rgba(20, 28, 50, 0.24), inset 0 0 0 1px rgba(0, 0, 0, 0.1);
}

.gbb-swatch::after {
	content: "";
	position: absolute;
	inset: auto 0 9px;
	height: 1px;
	background: rgba(128, 128, 128, 0.5);
}

.gbb-card__check {
	position: absolute;
	top: 7px;
	right: 7px;
	width: 18px;
	height: 18px;
	border: 1.5px solid rgba(30, 40, 65, 0.3);
	border-radius: 50%;
	background: rgba(255, 255, 255, 0.7);
}

.gbb-card input:checked + .gbb-card__body .gbb-card__check {
	border-color: var(--gbb-accent);
	background: var(--gbb-accent);
}

.gbb-card input:checked + .gbb-card__body .gbb-card__check::after {
	content: "";
	position: absolute;
	left: 5px;
	top: 1.5px;
	width: 5px;
	height: 9px;
	border: solid var(--gbb-on-accent);
	border-width: 0 2px 2px 0;
	transform: rotate(45deg);
}

/* Logo upload */
.gbb-drop {
	position: relative;
	margin-top: 4px;
}

.gbb-drop__input {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	opacity: 0;
	cursor: pointer;
}

.gbb-drop.has-file .gbb-drop__input,
.gbb-drop.has-file .gbb-drop__label {
	display: none;
}

.gbb-drop__label {
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 4px;
	margin: 0;
	padding: 30px 16px;
	border: 1.5px dashed rgba(30, 40, 65, 0.4);
	border-radius: var(--gbb-radius);
	background: rgba(255, 255, 255, 0.45);
	text-align: center;
	transition: border-color 0.15s, background-color 0.15s;
}

.gbb-drop:hover .gbb-drop__label,
.gbb-drop.is-over .gbb-drop__label {
	border-color: var(--gbb-accent);
	background: color-mix(in srgb, var(--gbb-accent) 10%, rgba(255, 255, 255, 0.8));
}

.gbb-drop__input:focus-visible + .gbb-drop__label {
	outline: 3px solid var(--gbb-ink);
	outline-offset: 2px;
}

.gbb-drop__title {
	margin-top: 4px;
	font-weight: 700;
}

.gbb-drop__sub {
	color: var(--gbb-muted);
	font-size: 0.9em;
}

.gbb-drop__file {
	display: flex;
	align-items: center;
	gap: 14px;
	padding: 12px 14px;
	border: 1.5px solid var(--gbb-glass-edge);
	border-radius: var(--gbb-radius);
	background: var(--gbb-glass-strong);
}

.gbb-drop__thumb {
	flex: none;
	width: 64px;
	height: 48px;
	padding: 4px;
	border-radius: 8px;
	background: repeating-conic-gradient(#e3e6ec 0% 25%, #f7f8fa 0% 50%) 50% / 12px 12px;
	object-fit: contain;
}

.gbb-drop__name {
	flex: 1 1 auto;
	min-width: 0;
	overflow: hidden;
	font-weight: 600;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.gbb .gbb-link {
	flex: none;
	min-height: 44px;
	margin: 0;
	padding: 0 8px;
	border: 0;
	background: none;
	color: var(--gbb-ink);
	font: inherit;
	font-weight: 600;
	text-decoration: underline;
	text-transform: none;
	letter-spacing: 0;
	cursor: pointer;
	box-shadow: none;
}

.gbb .gbb-link:focus-visible {
	outline: 3px solid var(--gbb-ink);
	outline-offset: 2px;
	border-radius: 6px;
}

.gbb-switch {
	position: relative;
	display: flex;
	align-items: center;
	gap: 12px;
	min-height: 44px;
	margin: 14px 0 0;
	cursor: pointer;
}

.gbb-switch__track {
	position: relative;
	flex: none;
	width: 44px;
	height: 26px;
	border: 1px solid rgba(30, 40, 65, 0.35);
	border-radius: 999px;
	background: rgba(30, 40, 65, 0.16);
	transition: background-color 0.15s, border-color 0.15s;
}

.gbb-switch__track::after {
	content: "";
	position: absolute;
	top: 2px;
	left: 2px;
	width: 20px;
	height: 20px;
	border-radius: 50%;
	background: #fff;
	box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
	transition: transform 0.15s;
}

.gbb-switch input:checked + .gbb-switch__track {
	border-color: var(--gbb-accent);
	background: var(--gbb-accent);
}

.gbb-switch input:checked + .gbb-switch__track::after {
	transform: translateX(18px);
}

.gbb-switch input:focus-visible + .gbb-switch__track {
	outline: 3px solid var(--gbb-ink);
	outline-offset: 2px;
}

/* Fields */
.gbb-fields {
	display: grid;
	grid-template-columns: repeat(2, minmax(0, 1fr));
	gap: 16px;
	margin-top: 16px;
}

.gbb-field {
	margin: 0;
}

.gbb-field--wide {
	grid-column: 1 / -1;
}

.gbb-field label {
	display: block;
	margin: 0 0 6px;
	font-weight: 600;
}

.gbb-req {
	color: var(--gbb-danger);
}

.gbb-optional {
	margin-left: 4px;
	color: var(--gbb-muted);
	font-size: 0.8rem;
	font-weight: 400;
	letter-spacing: 0;
}

.gbb-field input,
.gbb-field textarea {
	display: block;
	width: 100%;
	min-height: 48px;
	margin: 0;
	padding: 10px 14px;
	border: 1px solid rgba(30, 40, 65, 0.42);
	border-radius: 12px;
	background: rgba(255, 255, 255, 0.72);
	color: var(--gbb-ink);
	font: inherit;
	line-height: 1.4;
	box-shadow: none;
}

.gbb-field textarea {
	resize: vertical;
}

.gbb-field input::placeholder,
.gbb-field textarea::placeholder {
	color: #6b7280;
	opacity: 1;
}

.gbb-field input:focus,
.gbb-field textarea:focus {
	border-color: var(--gbb-ink);
	background: #fff;
	outline: 2px solid var(--gbb-ink);
	outline-offset: 1px;
}

.gbb-field [aria-invalid="true"] {
	border-color: var(--gbb-danger);
}

.gbb-error {
	display: block;
	margin: 8px 0 0;
	color: var(--gbb-danger);
	font-size: 0.92em;
	font-weight: 600;
}

.gbb-hp {
	position: absolute;
	left: -9999px;
	width: 1px;
	height: 1px;
	overflow: hidden;
}

/* Summary */
.gbb-summary {
	margin: 14px 0 16px;
	padding: 4px 18px;
	border: 1px solid var(--gbb-glass-edge);
	border-radius: var(--gbb-radius);
	background: rgba(255, 255, 255, 0.5);
}

.gbb-summary > div {
	display: grid;
	grid-template-columns: 130px minmax(0, 1fr);
	gap: 12px;
	padding: 11px 0;
	border-bottom: 1px solid var(--gbb-line);
}

.gbb-summary > div:last-child {
	border-bottom: 0;
}

.gbb-summary dt {
	margin: 0;
	color: var(--gbb-muted);
	font-weight: 400;
}

.gbb-summary dd {
	margin: 0;
	font-weight: 600;
	overflow-wrap: anywhere;
}

.gbb-summary__items {
	display: grid;
	gap: 6px;
	margin: 0;
	padding: 0;
	list-style: none;
}

.gbb-summary__items li {
	display: flex;
	align-items: center;
	gap: 8px;
	margin: 0;
	padding: 0;
}

.gbb-summary__items .gbb-icon {
	width: 20px;
	height: 20px;
}

/* Buttons */
.gbb-nav {
	display: flex;
	justify-content: flex-end;
	gap: 12px;
	margin-top: 26px;
}

.gbb .gbb-btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-height: 48px;
	margin: 0;
	padding: 10px 28px;
	border: 1px solid transparent;
	border-radius: 999px;
	font: inherit;
	font-weight: 700;
	line-height: 1.2;
	text-decoration: none;
	text-transform: none;
	letter-spacing: 0;
	cursor: pointer;
	transition: filter 0.15s, background-color 0.15s, transform 0.15s;
}

.gbb .gbb-btn--primary {
	border-color: var(--gbb-accent);
	background: var(--gbb-accent);
	color: var(--gbb-on-accent);
	box-shadow: 0 8px 20px color-mix(in srgb, var(--gbb-accent) 34%, transparent);
}

.gbb .gbb-btn--primary:hover {
	filter: brightness(0.93);
	transform: translateY(-1px);
}

.gbb .gbb-btn--ghost {
	margin-right: auto;
	border-color: var(--gbb-glass-edge);
	background: var(--gbb-glass-strong);
	color: var(--gbb-ink);
	box-shadow: 0 2px 10px rgba(24, 34, 64, 0.08);
}

.gbb .gbb-btn--ghost:hover {
	background: #fff;
}

.gbb .gbb-btn:focus-visible {
	outline: 3px solid var(--gbb-ink);
	outline-offset: 2px;
}

.gbb .gbb-btn:disabled {
	opacity: 0.6;
	cursor: default;
	transform: none;
}

/* Preview */
.gbb-views {
	display: flex;
	width: max-content;
	margin: 0 auto 14px;
	padding: 3px;
	border: 1px solid var(--gbb-glass-edge);
	border-radius: 999px;
	background: rgba(30, 40, 65, 0.07);
}

.gbb .gbb-views__btn {
	min-width: 76px;
	min-height: 36px;
	margin: 0;
	padding: 4px 16px;
	border: 0;
	border-radius: 999px;
	background: transparent;
	color: var(--gbb-muted);
	font: inherit;
	font-size: 0.88em;
	font-weight: 600;
	text-transform: none;
	letter-spacing: 0;
	cursor: pointer;
	box-shadow: none;
}

.gbb .gbb-views__btn.is-active {
	background: #fff;
	color: var(--gbb-ink);
	box-shadow: 0 2px 8px rgba(24, 34, 64, 0.14);
}

.gbb .gbb-views__btn:focus-visible {
	outline: 3px solid var(--gbb-ink);
	outline-offset: 2px;
}

.gbb-stage {
	/* Neutral colours until a box colour is chosen. */
	--box: #d3d7df;
	--wall: #b6bbc6;
	--tray: #e7eaef;
	--it: #cdd1d9;
	--it2: #b3b8c2;
	--it3: #989eaa;
	--hint: #5a606b;

	display: block;
	width: 100%;
	height: auto;
	max-width: 460px;
	margin: 0 auto;
	overflow: visible;
}

.gbb-stage rect,
.gbb-stage path,
.gbb-stage circle {
	transition: fill 0.3s;
}

.gbb-stage__view {
	opacity: 0;
	visibility: hidden;
	transition: opacity 0.3s, visibility 0.3s;
}

.gbb-stage__view.is-active {
	opacity: 1;
	visibility: visible;
}

.gbb-stage__empty,
.gbb-stage__placeholder text {
	fill: var(--hint);
	font-family: inherit;
	font-size: 15px;
}

.gbb-stage__placeholder {
	color: var(--hint);
}

.gbb-slot {
	transform-box: fill-box;
	transform-origin: center;
}

.gbb-slot.is-new {
	animation: gbb-pop 0.4s cubic-bezier(0.2, 0.9, 0.3, 1.2);
}

@keyframes gbb-pop {
	from {
		opacity: 0;
		transform: scale(0.82) translateY(-10px);
	}
}

.gbb-preview__note {
	margin: 10px 0 0;
	color: var(--gbb-muted);
	font-size: 0.8em;
	text-align: center;
}

/* Thank you */
.gbb-done {
	max-width: 560px;
	margin: 0 auto;
	padding: 40px 24px;
	text-align: center;
}

.gbb-done svg {
	margin-bottom: 12px;
	color: #1e7a46;
}

.gbb-done p {
	margin: 0;
	color: var(--gbb-muted);
}

/*
 * Narrow layouts. These follow the width of the builder itself, not the screen,
 * so it also stacks correctly inside a narrow page column.
 */
@container gbb (max-width: 780px) {
	.gbb-layout {
		grid-template-columns: minmax(0, 1fr);
		gap: 14px;
	}

	.gbb-form {
		padding: 20px 16px;
	}

	/* The preview sits on top and stays in view while items are being picked. */
	.gbb-preview {
		position: sticky;
		top: var(--gbb-sticky-top, 8px);
		z-index: 2;
		order: -1;
		padding: 10px 12px 12px;
		background: rgba(255, 255, 255, 0.78);
	}

	.gbb-views {
		margin-bottom: 8px;
	}

	.gbb .gbb-views__btn {
		min-height: 30px;
	}

	.gbb-stage {
		max-width: 250px;
	}

	.gbb-preview__note {
		display: none;
	}

	/* Typing steps: keep the fields near the top instead of the picture. */
	.gbb[data-step="4"] .gbb-preview,
	.gbb[data-step="6"] .gbb-preview {
		display: none;
	}

	.gbb-progress {
		margin-bottom: 18px;
	}
}

@container gbb (max-width: 560px) {
	.gbb-progress__label {
		display: none;
	}

	.gbb-title {
		font-size: 1.45em;
	}

	.gbb-colors {
		gap: 8px;
	}

	.gbb-swatch {
		width: 52px;
		height: 42px;
	}

	.gbb-fields {
		grid-template-columns: minmax(0, 1fr);
	}

	.gbb-summary > div {
		grid-template-columns: 96px minmax(0, 1fr);
	}

	.gbb .gbb-btn {
		flex: 1 1 0;
		padding: 10px 16px;
	}

	.gbb .gbb-btn--ghost {
		flex: 0 0 auto;
	}
}

@container gbb (max-width: 420px) {
	.gbb-items {
		grid-template-columns: repeat(2, minmax(0, 1fr));
	}
}

@media (max-width: 600px) {
	.gbb {
		padding: 20px 12px;
		border-radius: 20px;
	}
}

@media (prefers-reduced-motion: reduce) {
	.gbb *,
	.gbb *::before,
	.gbb *::after {
		animation: none !important;
		transition: none !important;
	}
}
