/**
 * TeoAta — Armá tu Caja (mockup diseno-nuevo/Armá tu Caja, tokens plan.md §11.3).
 * Scope: .teo-box (builder) and body.teo-box-page (page tweaks). No global selectors.
 */

.teo-box,
body.teo-box-page {
	--teo-negro: #120a04;
	--teo-cacao: #2a1509;
	--teo-chocolate: #573016;
	--teo-caramelo: #b8712a;
	--teo-dorado: #d4a44e;
	--teo-crema: #f3e8d2;
	--teo-blanco: #fdf8f0;
	--teo-gris: #897769;
	--teo-gris-c: #e5d9c8;
	--teo-ok: #2e7d32;
	--teo-error: #8c3a2a;
	--teo-display: "Libre Baskerville", Georgia, serif;
	--teo-body: "Outfit", sans-serif;
}

/* Room for Shoptimizer's sticky header (61px on desktop) when the panel sticks / the anchor jumps. */
body.teo-box-page {
	--teo-box-sticky-top: 24px;
}

body.teo-box-page.sticky-d {
	--teo-box-sticky-top: 84px;
}

/*
 * ── Page ──
 * The product header stays native (child theme): gallery on the left, summary on the right.
 * The add to cart form becomes a call to action that scrolls to the builder below.
 */
body.teo-box-page .teo-box-cta {
	margin: 4px 0 24px;
}

body.teo-box-page .teo-box-cta__sizes {
	margin: 0 0 12px;
	font-family: var(--teo-body);
	font-size: 13px;
	font-weight: 400;
	color: var(--teo-gris);
}

body.teo-box-page .teo-box-cta__btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 10px;
	width: 100%;
	min-height: 48px;
	padding: 15px 24px;
	background: var(--teo-caramelo);
	color: var(--teo-negro);
	font-family: var(--teo-body);
	font-size: 12px;
	font-weight: 700;
	letter-spacing: 0.1em;
	line-height: 1.2;
	text-transform: uppercase;
	text-decoration: none;
	transition: background 0.2s;
}

body.teo-box-page .teo-box-cta__btn:hover,
body.teo-box-page .teo-box-cta__btn:focus-visible {
	background: var(--teo-dorado);
	color: var(--teo-negro);
}

/* ── Builder ── */
.teo-box {
	grid-column: 1 / -1;
	margin: 56px 0 60px;
	padding-top: 48px;
	border-top: 1px solid var(--teo-gris-c);
	font-family: var(--teo-body);
	color: var(--teo-cacao);
	scroll-margin-top: var(--teo-box-sticky-top);
}

.teo-box .teo-box__head {
	margin: 0 0 28px;
}

.teo-box .teo-box__eyebrow {
	margin: 0 0 10px;
	font-family: var(--teo-body);
	font-size: 9px;
	font-weight: 700;
	letter-spacing: 0.2em;
	text-transform: uppercase;
	color: var(--teo-caramelo);
}

.teo-box .teo-box__title {
	margin: 0;
	font-family: var(--teo-display);
	font-size: clamp(24px, 2.6vw, 34px);
	font-weight: 700;
	line-height: 1.15;
	color: var(--teo-negro);
}

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

.teo-box button {
	font-family: var(--teo-body);
	box-shadow: none;
	text-shadow: none;
}

.teo-box button:focus-visible,
.teo-box input:focus-visible + .teo-box-size__label {
	outline: 2px solid var(--teo-caramelo);
	outline-offset: 2px;
}

.teo-box .teo-box-step__title {
	display: block;
	margin: 0 0 14px;
	padding: 0;
	font-family: var(--teo-body);
	font-size: 11px;
	font-weight: 700;
	letter-spacing: 0.08em;
	line-height: 1.4;
	text-transform: uppercase;
	color: var(--teo-negro);
}

.teo-box .teo-box-step__help {
	margin: -8px 0 20px;
	font-size: 13px;
	font-weight: 300;
	line-height: 1.6;
	color: var(--teo-gris);
}

/* Step 1: sizes */
.teo-box .teo-box-sizes {
	margin: 0 0 36px;
	padding: 0;
	border: 0;
	min-width: 0;
}

.teo-box .teo-box-sizes__list {
	display: flex;
	flex-wrap: wrap;
	gap: 10px;
}

.teo-box .teo-box-size {
	position: relative;
	display: flex;
	flex-direction: column;
	align-items: flex-start;
	gap: 2px;
	min-width: 100px;
	min-height: 44px;
	margin: 0;
	padding: 12px 20px;
	border: 1.5px solid var(--teo-gris-c);
	background: var(--teo-blanco);
	color: var(--teo-cacao);
	cursor: pointer;
	transition: border-color 0.2s, background 0.2s;
}

.teo-box .teo-box-size:hover {
	border-color: var(--teo-caramelo);
}

.teo-box .teo-box-size input {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	margin: 0;
	opacity: 0;
	cursor: pointer;
}

.teo-box .teo-box-size__label {
	font-size: 14px;
	font-weight: 700;
	line-height: 1.3;
}

.teo-box .teo-box-size__price {
	font-size: 12px;
	font-weight: 400;
	line-height: 1.3;
	opacity: 0.85;
}

.teo-box .teo-box-size__price .amount {
	color: inherit;
	font-weight: inherit;
}

.teo-box .teo-box-size.is-selected,
.teo-box .teo-box-size:has(input:checked) {
	background: var(--teo-caramelo);
	border-color: var(--teo-caramelo);
	color: var(--teo-negro);
}

.teo-box .teo-box-size.is-selected .teo-box-size__price {
	font-weight: 600;
}

/* Step 2 + panel */
.teo-box .teo-box-layout {
	display: grid;
	grid-template-columns: 400px minmax(0, 1fr);
	gap: 40px;
	align-items: start;
}

/* Panel "Tu caja" */
.teo-box .teo-box-panel {
	position: sticky;
	top: var(--teo-box-sticky-top);
	padding: 24px;
	border: 1.5px solid var(--teo-negro);
	background: var(--teo-crema);
}

.teo-box .teo-box-panel__head {
	display: flex;
	align-items: center;
	justify-content: space-between;
	margin-bottom: 4px;
}

.teo-box .teo-box-panel__title {
	margin: 0;
	font-family: var(--teo-display);
	font-size: 19px;
	font-weight: 700;
	line-height: 1.3;
	color: var(--teo-negro);
}

.teo-box .teo-box-panel__close {
	display: none;
	width: 44px;
	height: 44px;
	margin: -10px -10px -10px 0;
	padding: 0;
	border: 0;
	background: none;
	color: var(--teo-cacao);
	font-size: 26px;
	line-height: 1;
	cursor: pointer;
}

.teo-box .teo-box-counter {
	margin: 0 0 14px;
	font-size: 12px;
	font-weight: 400;
	color: var(--teo-gris);
}

.teo-box .teo-box-progress {
	height: 8px;
	margin-bottom: 18px;
	overflow: hidden;
	background: var(--teo-gris-c);
}

.teo-box .teo-box-progress__bar {
	width: 0;
	height: 100%;
	background: var(--teo-caramelo);
	transition: width 0.25s ease;
}

.teo-box .teo-box-slots {
	display: grid;
	grid-template-columns: repeat(var(--teo-box-cols, 4), minmax(0, 1fr));
	gap: 8px;
	margin-bottom: 18px;
}

.teo-box .teo-box-slot {
	display: block;
	aspect-ratio: 1;
	margin: 0;
	padding: 0;
	overflow: hidden;
	border: 0;
	border-radius: 4px;
	background: var(--teo-gris-c);
}

.teo-box .teo-box-slot--filled {
	position: relative;
	border: 1px solid var(--teo-negro);
	cursor: pointer;
	transition: transform 0.15s, opacity 0.15s;
}

.teo-box .teo-box-slot--filled:hover {
	opacity: 0.75;
}

.teo-box .teo-box-slot--filled:hover::after {
	content: "×";
	position: absolute;
	inset: 0;
	display: flex;
	align-items: center;
	justify-content: center;
	background: rgba(18, 10, 4, 0.35);
	color: var(--teo-blanco);
	font-size: 20px;
	font-weight: 600;
}

.teo-box .teo-box-slot img {
	display: block;
	width: 100%;
	height: 100%;
	object-fit: cover;
}

.teo-box .teo-box-total {
	display: flex;
	align-items: baseline;
	justify-content: space-between;
	margin-bottom: 4px;
	padding-top: 14px;
	border-top: 1px solid var(--teo-gris-c);
}

.teo-box .teo-box-total__label {
	font-size: 12px;
	font-weight: 500;
	letter-spacing: 0.05em;
	text-transform: uppercase;
	color: var(--teo-gris);
}

.teo-box .teo-box-total__price {
	font-family: var(--teo-display);
	font-size: 22px;
	font-weight: 700;
	color: var(--teo-chocolate);
}

.teo-box .teo-box-total__price .amount {
	color: inherit;
}

.teo-box .teo-box-total__note {
	margin: 0 0 18px;
	font-size: 11px;
	color: var(--teo-gris);
}

.teo-box .teo-box-status {
	margin: 0 0 16px;
	padding: 10px 12px;
	font-size: 12px;
	font-weight: 600;
	line-height: 1.45;
}

.teo-box .teo-box-status--pending {
	background: rgba(184, 113, 42, 0.12);
	border: 1px solid rgba(184, 113, 42, 0.3);
	color: var(--teo-chocolate);
}

.teo-box .teo-box-status--ok {
	background: rgba(46, 125, 50, 0.12);
	border: 1px solid rgba(46, 125, 50, 0.3);
	color: var(--teo-ok);
}

.teo-box .teo-box-status--error {
	background: rgba(140, 58, 42, 0.1);
	border: 1px solid rgba(140, 58, 42, 0.35);
	color: var(--teo-error);
}

.teo-box .teo-box-add,
.teo-box .teo-box-clear {
	display: block;
	width: 100%;
	min-height: 44px;
	margin: 0 0 10px;
	border-radius: 0;
	font-weight: 700;
	line-height: 1.2;
	text-transform: uppercase;
	cursor: pointer;
}

.teo-box .teo-box-add {
	padding: 15px;
	border: 0;
	background: var(--teo-gris-c);
	color: var(--teo-gris);
	font-size: 12px;
	letter-spacing: 0.1em;
	cursor: not-allowed;
	transition: background 0.2s;
}

.teo-box .teo-box-add.is-active:not(:disabled) {
	background: var(--teo-caramelo);
	color: var(--teo-negro);
	cursor: pointer;
}

.teo-box .teo-box-add.is-active:not(:disabled):hover {
	background: var(--teo-dorado);
}

.teo-box .teo-box-add[aria-busy="true"] {
	background: var(--teo-caramelo);
	color: var(--teo-negro);
	opacity: 0.7;
	cursor: progress;
}

.teo-box .teo-box-clear {
	margin: 0;
	padding: 11px;
	border: 1.5px solid var(--teo-gris-c);
	background: none;
	color: var(--teo-gris);
	font-size: 11px;
	font-weight: 600;
	letter-spacing: 0.08em;
}

.teo-box .teo-box-clear:hover:not(:disabled) {
	border-color: var(--teo-gris);
	color: var(--teo-cacao);
}

.teo-box .teo-box-clear:disabled {
	opacity: 0.5;
	cursor: default;
}

/* Flavor cards */
.teo-box .teo-box-flavors {
	display: grid;
	grid-template-columns: repeat(4, minmax(0, 1fr));
	gap: 14px;
	margin: 0;
	padding: 0;
	list-style: none;
}

.teo-box .teo-box-flavor {
	display: flex;
	flex-direction: column;
	margin: 0;
	border: 1.5px solid var(--teo-gris-c);
	background: var(--teo-blanco);
	transition: border-color 0.2s, box-shadow 0.2s;
}

.teo-box .teo-box-flavor.is-selected {
	border-color: var(--teo-caramelo);
	box-shadow: inset 0 0 0 1px var(--teo-caramelo);
}

.teo-box .teo-box-flavor__media {
	position: relative;
	aspect-ratio: 1;
	overflow: hidden;
}

.teo-box .teo-box-flavor__media.has-img,
.teo-box .teo-box-slot.has-img {
	background: var(--teo-crema);
}

.teo-box .teo-box-flavor__media img {
	display: block;
	width: 100%;
	height: 100%;
	margin: 0;
	object-fit: cover;
}

.teo-box .teo-box-flavor__badge {
	position: absolute;
	top: 8px;
	left: 8px;
	padding: 4px 8px;
	background: var(--teo-negro);
	color: var(--teo-crema);
	font-size: 10px;
	font-weight: 700;
	letter-spacing: 0.08em;
	text-transform: uppercase;
}

.teo-box .teo-box-flavor__badge--extra {
	background: var(--teo-caramelo);
	color: var(--teo-negro);
	letter-spacing: 0.02em;
	text-transform: none;
}

.teo-box .teo-box-flavor__badge .amount {
	color: inherit;
}

.teo-box .teo-box-flavor.is-soldout .teo-box-flavor__media img,
.teo-box .teo-box-flavor.is-soldout .teo-box-flavor__media {
	filter: grayscale(0.6);
}

.teo-box .teo-box-flavor.is-soldout .teo-box-flavor__body {
	opacity: 0.55;
}

.teo-box .teo-box-flavor__body {
	display: flex;
	flex: 1;
	flex-direction: column;
	padding: 10px 11px 11px;
}

.teo-box .teo-box-flavor__name {
	margin: 0 0 3px;
	font-family: var(--teo-display);
	font-size: 12.5px;
	font-weight: 700;
	line-height: 1.25;
	color: var(--teo-negro);
}

.teo-box .teo-box-flavor__desc {
	margin: 0 0 9px;
	font-size: 11px;
	font-weight: 300;
	line-height: 1.4;
	color: var(--teo-gris);
}

.teo-box .teo-box-stepper {
	display: flex;
	align-items: stretch;
	margin-top: auto;
	border: 1.5px solid var(--teo-gris-c);
	background: var(--teo-blanco);
}

.teo-box .teo-box-stepper__btn {
	flex: 0 0 36px;
	height: 36px;
	margin: 0;
	padding: 0;
	border: 0;
	border-radius: 0;
	background: none;
	color: var(--teo-cacao);
	font-size: 16px;
	font-weight: 500;
	line-height: 1;
	cursor: pointer;
}

.teo-box .teo-box-stepper__btn:hover:not(:disabled) {
	background: var(--teo-crema);
}

.teo-box .teo-box-stepper__btn:disabled {
	opacity: 0.3;
	cursor: default;
}

.teo-box .teo-box-stepper__qty,
.teo-box .teo-box-stepper__input {
	flex: 1;
	min-width: 0;
	border-left: 1.5px solid var(--teo-gris-c);
	border-right: 1.5px solid var(--teo-gris-c);
	font-size: 12px;
	font-weight: 600;
	text-align: center;
	color: var(--teo-negro);
}

.teo-box .teo-box-stepper__qty {
	display: flex;
	align-items: center;
	justify-content: center;
}

/* Without JS: plain number inputs; with JS: stepper buttons. */
.teo-box:not(.teo-box--js) .teo-box-stepper__btn,
.teo-box:not(.teo-box--js) .teo-box-stepper__qty,
.teo-box:not(.teo-box--js) .teo-box-slots,
.teo-box:not(.teo-box--js) .teo-box-clear,
.teo-box.teo-box--js .teo-box-stepper__input {
	display: none;
}

.teo-box:not(.teo-box--js) .teo-box-stepper__input {
	height: 36px;
	border: 0;
	background: none;
}

.teo-box .teo-box-empty {
	padding: 16px;
	background: var(--teo-crema);
	font-size: 13px;
	color: var(--teo-chocolate);
}

/* Placeholder gradients (mockup .grad1–.grad4) when a bonbon has no photo. */
.teo-box .teo-box-grad1 { background: linear-gradient(135deg, #3d1e0a, #7a3e1a); }
.teo-box .teo-box-grad2 { background: linear-gradient(135deg, #573016, #b8712a); }
.teo-box .teo-box-grad3 { background: linear-gradient(135deg, #b8712a, #d4a44e); }
.teo-box .teo-box-grad4 { background: linear-gradient(135deg, #2a1509, #573016); }

/* Mobile bar + drawer (hidden on desktop) */
.teo-box .teo-box-bar,
.teo-box .teo-box-backdrop {
	display: none;
}

/* ── Responsive ── */
@media (max-width: 1100px) {
	.teo-box .teo-box-layout {
		grid-template-columns: 340px minmax(0, 1fr);
		gap: 28px;
	}

	.teo-box .teo-box-flavors {
		grid-template-columns: repeat(3, minmax(0, 1fr));
	}
}

@media (max-width: 900px) {
	body.teo-box-page {
		padding-bottom: calc(76px + env(safe-area-inset-bottom));
	}

	.teo-box {
		margin-top: 36px;
		padding-top: 32px;
	}

	/*
	 * Sizes: all visible at once, no horizontal scroll. Equal buttons in one row
	 * (5 sizes fit from 320px); extra sizes wrap onto a new row.
	 */
	.teo-box .teo-box-sizes {
		margin-bottom: 28px;
	}

	.teo-box .teo-box-sizes__list {
		display: grid;
		grid-template-columns: repeat(auto-fit, minmax(46px, 1fr));
		gap: 6px;
	}

	.teo-box .teo-box-size {
		align-items: center;
		justify-content: center;
		gap: 3px;
		min-width: 0;
		min-height: 60px;
		padding: 10px 4px;
		text-align: center;
	}

	.teo-box .teo-box-size__label {
		font-size: 12.5px;
		line-height: 1.2;
	}

	.teo-box .teo-box-size__price {
		font-size: 11px;
		white-space: nowrap;
	}

	.teo-box .teo-box-layout {
		display: block;
	}

	.teo-box .teo-box-flavors {
		grid-template-columns: repeat(3, minmax(0, 1fr));
		gap: 10px;
	}

	.teo-box .teo-box-stepper__btn {
		flex-basis: 44px;
		height: 44px;
		font-size: 18px;
	}

	/* Without JS the panel stays in the flow, above the flavors. */
	.teo-box:not(.teo-box--js) .teo-box-panel {
		position: static;
		margin-bottom: 28px;
	}

	.teo-box.teo-box--js .teo-box-panel {
		position: fixed;
		z-index: 100001;
		right: 0;
		bottom: 0;
		left: 0;
		top: auto;
		max-height: 88vh;
		overflow-y: auto;
		overscroll-behavior: contain;
		padding: 20px 16px calc(20px + env(safe-area-inset-bottom));
		border-width: 1.5px 0 0;
		transform: translateY(105%);
		visibility: hidden;
		transition: transform 0.28s ease, visibility 0s linear 0.28s;
	}

	.teo-box.teo-box--open .teo-box-panel {
		transform: none;
		visibility: visible;
		transition: transform 0.28s ease;
	}

	.teo-box .teo-box-panel__close {
		display: inline-flex;
		align-items: center;
		justify-content: center;
	}

	/* Keep status + button in view inside the drawer, even for x36. */
	.teo-box .teo-box-slots {
		max-width: min(260px, 34vh);
		gap: 6px;
		margin-right: auto;
		margin-left: auto;
	}

	.teo-box.teo-box--js .teo-box-backdrop:not([hidden]) {
		display: block;
		position: fixed;
		z-index: 100000;
		inset: 0;
		background: rgba(18, 10, 4, 0.45);
	}

	.teo-box.teo-box--js .teo-box-bar:not([hidden]) {
		display: flex;
		position: fixed;
		z-index: 99999;
		right: 0;
		bottom: 0;
		left: 0;
		align-items: center;
		gap: 12px;
		padding: 10px 16px calc(10px + env(safe-area-inset-bottom));
		border-top: 1.5px solid var(--teo-negro);
		background: var(--teo-crema);
		box-shadow: 0 -6px 20px rgba(18, 10, 4, 0.12);
	}

	.teo-box .teo-box-bar__toggle {
		display: flex;
		flex: 1 1 auto;
		flex-direction: column;
		align-items: flex-start;
		gap: 4px;
		min-width: 0;
		min-height: 44px;
		margin: 0;
		padding: 0;
		border: 0;
		background: none;
		color: var(--teo-cacao);
		text-align: left;
		cursor: pointer;
	}

	.teo-box .teo-box-bar__count {
		font-size: 12px;
		font-weight: 600;
		color: var(--teo-negro);
	}

	.teo-box .teo-box-bar__progress {
		display: block;
		width: 100%;
		max-width: 140px;
		height: 5px;
		background: var(--teo-gris-c);
	}

	.teo-box .teo-box-bar__progress-fill {
		display: block;
		width: 0;
		height: 100%;
		background: var(--teo-caramelo);
		transition: width 0.25s ease;
	}

	.teo-box .teo-box-bar__view {
		font-size: 11px;
		font-weight: 600;
		letter-spacing: 0.06em;
		text-transform: uppercase;
		text-decoration: underline;
		text-underline-offset: 3px;
		color: var(--teo-caramelo);
	}

	.teo-box .teo-box-bar__price {
		flex: 0 0 auto;
		font-family: var(--teo-display);
		font-size: 17px;
		font-weight: 700;
		color: var(--teo-chocolate);
	}

	.teo-box .teo-box-bar__add {
		flex: 0 0 auto;
		width: auto;
		margin: 0;
		padding: 14px 16px;
		font-size: 11px;
	}

	html.teo-box-lock,
	html.teo-box-lock body {
		overflow: hidden;
	}
}

@media (max-width: 359px) {
	.teo-box .teo-box-sizes__list {
		gap: 4px;
	}

	.teo-box .teo-box-size {
		padding: 8px 2px;
	}

	.teo-box .teo-box-size__label {
		font-size: 11.5px;
	}

	.teo-box .teo-box-size__price {
		font-size: 10px;
	}

	/* Bottom bar: counter and "Ver caja" on one line; the button text may take two. */
	.teo-box .teo-box-bar {
		gap: 8px;
	}

	.teo-box .teo-box-bar__count,
	.teo-box .teo-box-bar__view {
		white-space: nowrap;
	}

	.teo-box .teo-box-bar__count {
		font-size: 11px;
	}

	.teo-box .teo-box-bar__price {
		font-size: 14px;
	}

	.teo-box .teo-box-bar__add {
		max-width: 108px;
		padding: 8px 10px;
		font-size: 10px;
		line-height: 1.25;
		white-space: normal;
	}
}

@media (max-width: 599px) {
	.teo-box .teo-box-flavors {
		grid-template-columns: repeat(2, minmax(0, 1fr));
	}

	.teo-box .teo-box-bar__price {
		font-size: 15px;
	}

	.teo-box .teo-box-bar__add {
		padding: 14px 12px;
		letter-spacing: 0.06em;
	}
}

@media (prefers-reduced-motion: reduce) {
	.teo-box .teo-box-panel,
	.teo-box .teo-box-progress__bar,
	.teo-box .teo-box-bar__progress-fill {
		transition: none;
	}
}
