/* ==========================================================================
   Box builder
   ========================================================================== */

.builder-intro { padding-block: clamp(28px, 4vw, 52px) clamp(20px, 3vw, 32px); }
.builder-intro h1 { font-size: clamp(2.6rem, 7vw, 5.2rem); margin-bottom: .2em; }

.builder-layout {
	display: grid;
	grid-template-columns: minmax(0, 1fr) 360px;
	gap: clamp(20px, 3vw, 40px);
	align-items: start;
	padding-bottom: clamp(48px, 8vw, 96px);
}
@media (max-width: 1000px) { .builder-layout { grid-template-columns: 1fr; } }

.builder-steps { display: grid; gap: 20px; }

.step {
	background: var(--white);
	border: 2px solid var(--ink);
	border-radius: var(--radius-lg);
	padding: clamp(18px, 3vw, 30px);
}
.step[hidden] { display: none; }
.step-head { display: flex; align-items: flex-start; gap: 14px; margin-bottom: 20px; }
.step-head h2 { font-size: clamp(1.3rem, 2.4vw, 1.6rem); margin: 2px 0 2px; }
.step-head p { margin: 0; color: var(--muted); font-size: .96rem; }
.step-head > div { flex: 1; }
.step-num {
	flex: none; display: grid; place-items: center;
	width: 40px; height: 40px; border-radius: 50%;
	background: var(--red); color: var(--white);
	font-family: var(--font-display); font-size: 1.3rem;
}
.optional { font-family: var(--font-body); font-size: .8rem; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; vertical-align: middle; margin-left: 6px; }

.pill {
	flex: none; align-self: center;
	padding: 6px 14px; border-radius: 999px;
	background: var(--kraft); font-weight: 800; font-size: .88rem; letter-spacing: .04em; text-transform: uppercase;
	transition: background-color .2s, color .2s;
}
.pill:empty { display: none; }
.pill.is-full { background: var(--ink); color: var(--gold); }

/* ---------- Tiers ---------- */

.tier-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
@media (max-width: 560px) { .tier-grid { grid-template-columns: 1fr; } }
.tier-skel { height: 168px; }

.tier {
	position: relative;
	display: grid; justify-items: start; gap: 2px;
	padding: 20px 18px 16px;
	text-align: left;
	background: var(--paper);
	border: 2px solid var(--line-strong); border-radius: var(--radius);
	cursor: pointer;
	transition: border-color .15s, background-color .15s, box-shadow .15s, transform .15s;
}
.tier:hover:not(:disabled) { border-color: var(--ink); }
.tier[aria-checked="true"] { background: var(--gold); border-color: var(--ink); box-shadow: 0 4px 0 0 var(--ink); transform: translateY(-2px); }
.tier:disabled { opacity: .5; cursor: not-allowed; }
.tier .ribbon { top: -11px; left: 14px; font-size: .66rem; padding: 3px 10px; }
.tier-slots { margin-bottom: 8px; gap: 4px; }
.tier-slots i { width: 12px; height: 12px; border-radius: 3px; }
.tier[aria-checked="true"] .tier-slots i { background: var(--white); }
.tier-count { font-weight: 700; }
.tier-count .display { font-size: 2.4rem; margin-right: 3px; vertical-align: -4px; }
.tier-price { font-size: 1.3rem; font-weight: 800; }
.tier-per { font-size: .85rem; color: var(--muted); }
.tier[aria-checked="true"] .tier-per { color: var(--ink-2); }

/* ---------- Items ---------- */

.item-grid {
	display: grid; grid-template-columns: repeat(auto-fill, minmax(168px, 1fr)); gap: 14px;
	list-style: none; margin: 0; padding: 0;
}
@media (max-width: 420px) { .item-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; } }
.item-skel { height: 260px; }

.item {
	display: flex; flex-direction: column;
	padding: 10px 10px 12px;
	background: var(--paper);
	border: 2px solid transparent; border-radius: var(--radius);
	transition: border-color .15s, background-color .15s, opacity .15s;
}
.item.is-picked { border-color: var(--ink); background: #fff8e3; }
.builder.is-full .item:not(.is-picked):not(.is-out) { opacity: .55; }
.item.is-out { opacity: .5; }

.item-img {
	position: relative; aspect-ratio: 1; margin-bottom: 10px;
	background: var(--white); border-radius: 10px; overflow: hidden;
	display: grid; place-items: center;
}
.item-img img { width: 100%; height: 100%; object-fit: contain; padding: 8px; }
.item-ph { font-family: var(--font-display); font-size: 3rem; color: var(--kraft-2); }
.item-qty {
	position: absolute; top: 8px; right: 8px;
	min-width: 32px; height: 32px; padding: 0 8px;
	display: grid; place-items: center;
	background: var(--red); color: var(--white); border-radius: 999px;
	font-weight: 800; font-size: .9rem;
	animation: pop .25s ease;
}
.item-qty[hidden] { display: none; }
@keyframes pop { from { transform: scale(.4); } }

.item-title { font-size: .98rem; font-weight: 700; line-height: 1.25; margin: 0 0 4px; flex: 1; }
.item-desc { font-size: .84rem; color: var(--muted); margin: 0 0 8px; }
.item-ctrl { margin-top: 8px; }
.item-ctrl .btn[hidden], .stepper[hidden] { display: none; }
.sold-out { display: block; text-align: center; font-weight: 700; font-size: .88rem; color: var(--muted); padding: 8px; }

.stepper {
	display: grid; grid-template-columns: 38px 1fr 38px; align-items: center;
	height: 38px; border: 2px solid var(--ink); border-radius: 999px; background: var(--white);
	overflow: hidden;
}
.stepper button {
	height: 100%; border: 0; background: transparent; cursor: pointer;
	font-size: 1.3rem; font-weight: 700; line-height: 1;
}
.stepper button:hover:not(:disabled) { background: var(--kraft); }
.stepper button:disabled { opacity: .3; cursor: not-allowed; }
.stepper output { text-align: center; font-weight: 800; }

/* ---------- Premium ---------- */

.premium-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 12px; list-style: none; margin: 0; padding: 0; }
.premium {
	width: 100%; display: grid; grid-template-columns: 64px 1fr 28px; align-items: center; gap: 14px;
	padding: 10px 14px 10px 10px; text-align: left;
	background: var(--paper); border: 2px solid var(--line); border-radius: var(--radius);
	cursor: pointer; transition: border-color .15s, background-color .15s;
}
.premium:hover:not(:disabled) { border-color: var(--ink); }
.premium[aria-pressed="true"] { border-color: var(--ink); background: #fff8e3; }
.premium:disabled { opacity: .5; cursor: not-allowed; }
.premium-img { width: 64px; height: 64px; border-radius: 10px; background: var(--white); overflow: hidden; }
.premium-img img { width: 100%; height: 100%; object-fit: contain; padding: 4px; }
.premium-body { display: grid; gap: 1px; }
.premium-title { font-weight: 700; line-height: 1.2; }
.premium-price { font-weight: 800; color: var(--red); }
.premium-note { font-size: .8rem; color: var(--muted); }
.premium-check {
	width: 28px; height: 28px; border-radius: 50%; border: 2px solid var(--line-strong); background: var(--white);
	display: grid; place-items: center; transition: background-color .15s, border-color .15s;
}
.premium-check::after { content: "+"; font-weight: 800; color: var(--muted); }
.premium[aria-pressed="true"] .premium-check { background: var(--red); border-color: var(--red); }
.premium[aria-pressed="true"] .premium-check::after { content: "✓"; color: var(--white); font-size: .85rem; }

/* ---------- Tissue ---------- */

.tissue-grid { display: flex; flex-wrap: wrap; gap: 12px; }
.tissue {
	display: flex; align-items: center; gap: 12px;
	padding: 8px 18px 8px 8px;
	background: var(--paper); border: 2px solid var(--line); border-radius: 999px;
	font-weight: 700; cursor: pointer;
}
.tissue:hover { border-color: var(--ink); }
.tissue[aria-checked="true"] { border-color: var(--ink); background: #fff8e3; box-shadow: 0 3px 0 0 var(--ink); }
.tissue-swatch { width: 48px; height: 48px; border-radius: 50%; overflow: hidden; border: 2px solid var(--ink); }
.tissue-swatch img, .tissue-swatch span { width: 100%; height: 100%; object-fit: cover; display: block; }

/* ---------- Summary ---------- */

.summary { position: sticky; top: calc(var(--header-h) + 16px); }
.admin-bar .summary { top: calc(var(--header-h) + 48px); }
.summary-card {
	background: var(--white); border: 2px solid var(--ink); border-radius: var(--radius-lg);
	padding: 22px; box-shadow: 0 6px 0 0 var(--ink);
}
.summary-top { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 14px; }
.summary-top h2 { font-family: var(--font-display); font-weight: 400; text-transform: uppercase; font-size: 1.7rem; margin: 0; }
.summary-size { font-weight: 700; color: var(--muted); }

/* Box illustration: kraft box with item slots that fill as you pick */
.box-visual { position: relative; margin: 18px 6px 18px; }
.box-flaps { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; height: 18px; }
.box-flaps span { background: var(--kraft-2); border: 2px solid var(--ink); border-bottom: 0; border-radius: 6px 6px 0 0; }
.box-flaps span:first-child { transform: skewX(-18deg); transform-origin: bottom right; }
.box-flaps span:last-child { transform: skewX(18deg); transform-origin: bottom left; }
.box-slots {
	--cols: 5;
	display: grid; grid-template-columns: repeat(var(--cols), 1fr); gap: 6px;
	padding: 10px; background: var(--kraft); border: 2px solid var(--ink); border-bottom: 0;
	background-image: repeating-linear-gradient(45deg, transparent 0 9px, rgba(194, 31, 50, .06) 9px 18px);
}
.slot {
	aspect-ratio: 1; border-radius: 8px;
	border: 2px dashed rgba(23, 21, 19, .3);
	background: rgba(255, 255, 255, .45);
	overflow: hidden;
}
.slot.is-filled { border: 2px solid var(--ink); background: var(--white); animation: drop .3s ease; }
.slot img { width: 100%; height: 100%; object-fit: contain; padding: 3px; }
@keyframes drop { from { transform: translateY(-12px) scale(.8); opacity: 0; } }
.box-front {
	display: flex; justify-content: center; gap: .4em;
	padding: 8px; background: var(--white); border: 2px solid var(--ink); border-radius: 0 0 8px 8px;
	font-family: var(--font-display); text-transform: uppercase; font-size: 1.05rem; letter-spacing: .02em;
}
.box-front span:last-child { color: var(--red); }

.summary-lines { list-style: none; margin: 0 0 14px; padding: 0; max-height: 220px; overflow-y: auto; font-size: .94rem; }
.summary-lines li { display: flex; align-items: center; gap: 8px; padding: 6px 0; border-bottom: 1px dashed var(--line); }
.ln-qty { flex: none; min-width: 28px; font-weight: 800; color: var(--red); }
.ln-name { flex: 1; }
.ln-price { font-weight: 700; }
.ln-x {
	flex: none; width: 26px; height: 26px; border-radius: 50%;
	border: 1px solid var(--line-strong); background: var(--white); cursor: pointer; line-height: 1;
}
.ln-x:hover { background: var(--ink); color: var(--white); }
.ln-empty { color: var(--muted); justify-content: center; border: 0 !important; }
.is-tissue .ln-qty { color: var(--gold-deep); }

.summary-totals { margin: 0 0 12px; display: grid; gap: 6px; }
.summary-totals div { display: flex; justify-content: space-between; }
.summary-totals div[hidden] { display: none; }
.summary-totals dt { color: var(--muted); }
.summary-totals dd { margin: 0; font-weight: 700; }
.summary-totals .free { color: #1f7a3a; }
.summary-totals .grand { padding-top: 10px; margin-top: 4px; border-top: 2px solid var(--ink); font-size: 1.25rem; }
.summary-totals .grand dt { color: var(--ink); font-weight: 700; }
.summary-totals .grand dd { font-weight: 800; }

.summary-msg { min-height: 1.5em; margin: 0 0 12px; font-size: .92rem; color: var(--muted); text-align: center; }
.summary-msg.is-ready { color: #1f7a3a; font-weight: 700; }
.summary-error { margin: 12px 0 0; padding: 10px 12px; border-radius: 10px; background: #fde8eb; color: var(--red-deep); font-size: .92rem; font-weight: 600; }
.summary-error[hidden] { display: none; }

/* ---------- Mobile bottom bar ---------- */

.mobile-bar { display: none; }
@media (max-width: 1000px) {
	.summary { position: static; }
	.mobile-bar {
		position: fixed; left: 10px; right: 10px; bottom: 10px; z-index: 60;
		display: flex; align-items: center; justify-content: space-between; gap: 12px;
		padding: 10px 10px 10px 18px;
		background: var(--ink); color: var(--white);
		border-radius: 999px; box-shadow: var(--shadow-pop);
	}
	.mobile-bar-info { display: grid; line-height: 1.2; }
	.mobile-bar-info strong { font-size: 1.15rem; }
	.mobile-bar-info span { font-size: .82rem; color: #cfc6b8; }
	.mobile-bar .btn { box-shadow: none; }
	.builder { padding-bottom: 80px; }
}
