/**
 * Benjima 3D Product Designer
 *
 * Everything is scoped under .bj3d and every value is written out, so a
 * theme that strips custom properties or resets display cannot reach in.
 */

.bj3d,
.bj3d * {
	box-sizing: border-box;
}

.bj3d {
	margin: 0 0 28px;
	color: #16181d;
	font-family: inherit;
	font-size: 15px;
	line-height: 1.6;
}

.bj3d-empty {
	padding: 16px 18px;
	border: 1px dashed #d8380f;
	border-radius: 10px;
	background: #fff6f4;
	color: #8c3116;
	font-size: 14px;
}

/* ==========================================================
   LAYOUT
   Flex with a basis rather than a grid with a media query, so
   it reacts to the container it is dropped into, not the window.
   ========================================================== */

.bj3d-grid {
	display: flex !important;
	flex-direction: row !important;
	flex-wrap: wrap;
	align-items: flex-start;
	gap: 24px;
	width: 100%;
}

.bj3d-stage-wrap {
	flex: 1 1 380px;
	min-width: 0;
	border: 1px solid #e2e5ea;
	border-radius: 16px;
	overflow: hidden;
	background: #ffffff;
}

.bj3d-side {
	flex: 0 1 330px;
	min-width: 0;
}

@media (max-width: 860px) {
	.bj3d-side {
		flex: 1 1 100%;
	}
}

/* ==========================================================
   STAGE
   ========================================================== */

.bj3d-stage {
	position: relative;
	width: 100%;
	overflow: hidden;

	/* a soft pool of light under the product, which is what makes a flat
	   backdrop read as a studio rather than a grey rectangle */
	background:
		radial-gradient(ellipse 70% 50% at 50% 62%, rgba(255, 255, 255, 0.95), rgba(255, 255, 255, 0) 70%),
		linear-gradient(180deg, #eceae7 0%, #f4f3f1 48%, #e4e2df 100%);
}

.bj3d-stage canvas {
	display: block;
	width: 100%;
	height: 100%;
	touch-action: none;
	outline: none;
}

.bj3d-loading {
	position: absolute;
	inset: 0;
	z-index: 2;
	display: grid;
	place-items: center;
	padding: 24px;
	background: #f2f2f0;
	color: #6b7383;
	font-size: 13px;
	text-align: center;
}

.bj3d-bar {
	display: flex;
	align-items: center;
	gap: 8px;
	flex-wrap: wrap;
	padding: 10px 14px;
	border-top: 1px solid #e2e5ea;
	background: #f7f8fa;
}

.bj3d-mini {
	padding: 8px 14px;
	border: 1px solid #d8dce3;
	border-radius: 18px;
	background: #ffffff;
	color: #2c3342;
	font-family: inherit;
	font-size: 12.5px;
	font-weight: 600;
	cursor: pointer;
	transition: background 0.18s, color 0.18s, border-color 0.18s;
}

.bj3d-mini:hover {
	border-color: #16181d;
	background: #16181d;
	color: #ffffff;
}

.bj3d-mini.is-on {
	border-color: #16181d;
	background: #16181d;
	color: #ffffff;
}

.bj3d-hint {
	margin-left: auto;
	color: #8a919e;
	font-size: 11.5px;
	letter-spacing: 0.03em;
}

@media (max-width: 520px) {
	.bj3d-hint {
		display: none;
	}
}

/* ==========================================================
   SIDE PANEL
   ========================================================== */

.bj3d-title {
	margin: 0 0 14px;
	padding: 0;
	font-size: 24px;
	font-weight: 700;
	line-height: 1.2;
}

.bj3d-label {
	margin: 20px 0 9px;
	font-size: 11px;
	font-weight: 700;
	letter-spacing: 0.14em;
	text-transform: uppercase;
	color: #8a919e;
}

.bj3d-side > div:first-of-type .bj3d-label,
.bj3d-side > .bj3d-label:first-child {
	margin-top: 0;
}

/* ---- model picker ---- */

.bj3d-models {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
	gap: 8px;
}

.bj3d-model {
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 6px;
	padding: 10px 8px;
	border: 1.5px solid #e2e5ea;
	border-radius: 10px;
	background: #ffffff;
	font-family: inherit;
	font-size: 12px;
	font-weight: 600;
	color: #2c3342;
	line-height: 1.25;
	text-align: center;
	cursor: pointer;
}

.bj3d-model img {
	width: 100%;
	max-width: 54px;
	height: auto;
	border-radius: 6px;
}

.bj3d-model:hover {
	border-color: #9db4d8;
}

.bj3d-model.is-on {
	border-color: #16181d;
	box-shadow: inset 0 0 0 1px #16181d;
}

/* ---- colour swatches ---- */

.bj3d-swatches {
	display: flex;
	gap: 9px;
	flex-wrap: wrap;
}

.bj3d-sw {
	width: 42px;
	height: 42px;
	padding: 0;
	border: 0;
	border-radius: 9px;
	box-shadow: inset 0 0 0 1px rgba(16, 16, 16, 0.14);
	cursor: pointer;
	transition: transform 0.16s;
}

.bj3d-sw:hover {
	transform: scale(1.08);
}

.bj3d-sw.is-on {
	box-shadow: inset 0 0 0 1px rgba(16, 16, 16, 0.14), 0 0 0 3px #16181d;
}

/* ---- upload ---- */

.bj3d-drop {
	padding: 20px 14px;
	border: 2px dashed #d8dce3;
	border-radius: 12px;
	background: #f7f8fa;
	text-align: center;
	cursor: pointer;
	transition: border-color 0.2s, background 0.2s;
}

.bj3d-drop:hover,
.bj3d-drop.is-over {
	border-color: #16181d;
	background: #eef1f5;
}

.bj3d-drop b {
	display: block;
	font-size: 14px;
	font-weight: 700;
}

.bj3d-drop span {
	display: block;
	margin-top: 4px;
	color: #8a919e;
	font-size: 12px;
}

/* ---- inputs ---- */

.bj3d-row {
	display: flex;
	gap: 8px;
}

.bj3d input[type="text"],
.bj3d input[type="email"],
.bj3d input[type="tel"],
.bj3d textarea {
	width: 100%;
	padding: 11px 13px;
	border: 1px solid #d8dce3;
	border-radius: 9px;
	background: #ffffff;
	color: #16181d;
	font-family: inherit;
	font-size: 14.5px;
	line-height: normal;
}

.bj3d input:focus,
.bj3d textarea:focus {
	border-color: #16181d;
	outline: none;
}

.bj3d textarea {
	min-height: 78px;
	resize: vertical;
}

.bj3d-slider {
	display: block;
	margin-bottom: 12px;
}

.bj3d-slider span {
	display: block;
	margin-bottom: 5px;
	color: #6b7383;
	font-size: 12px;
}

.bj3d-slider b {
	color: #16181d;
}

.bj3d-slider input[type="range"] {
	width: 100%;
	accent-color: #16181d;
}

.bj3d-slider input[type="color"] {
	width: 100%;
	height: 40px;
	padding: 3px;
	border: 1px solid #d8dce3;
	border-radius: 9px;
	background: #ffffff;
	cursor: pointer;
}

/* ---- layers ---- */

.bj3d-layers {
	display: grid;
	gap: 6px;
	margin-top: 12px;
}

.bj3d-layers:empty {
	display: none;
}

.bj3d-layer {
	display: flex;
	align-items: center;
	gap: 10px;
	padding: 7px 10px;
	border: 1.5px solid #e2e5ea;
	border-radius: 9px;
	background: #ffffff;
	cursor: pointer;
}

.bj3d-layer:hover {
	border-color: #9db4d8;
}

.bj3d-layer.is-on {
	border-color: #16181d;
	box-shadow: inset 0 0 0 1px #16181d;
}

.bj3d-layer img {
	width: 30px;
	height: 30px;
	object-fit: contain;
	border-radius: 5px;
	background: #f2f2f0;
}

.bj3d-layer i {
	display: grid;
	place-items: center;
	width: 30px;
	height: 30px;
	border-radius: 5px;
	background: #f2f2f0;
	color: #6b7383;
	font-style: normal;
	font-weight: 700;
	font-size: 13px;
}

.bj3d-layer span {
	flex: 1 1 auto;
	min-width: 0;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
	font-size: 13px;
}

.bj3d-layer button {
	flex: 0 0 auto;
	padding: 0 4px;
	border: 0;
	background: none;
	color: #b0b7c3;
	font-size: 19px;
	line-height: 1;
	cursor: pointer;
}

.bj3d-layer button:hover {
	color: #b02a2a;
}

/* ---- buttons ---- */

.bj3d-btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 8px;
	padding: 12px 20px;
	border: 1.5px solid #16181d;
	border-radius: 9px;
	background: #16181d;
	color: #ffffff;
	font-family: inherit;
	font-size: 13.5px;
	font-weight: 700;
	cursor: pointer;
	transition: background 0.18s, color 0.18s, opacity 0.18s;
}

.bj3d-ghost {
	background: transparent;
	color: #16181d;
}

.bj3d-ghost:hover {
	background: #16181d;
	color: #ffffff;
}

.bj3d-primary {
	border-color: #AA151B;
	background: #AA151B;
}

.bj3d-primary:hover {
	background: #c4191f;
}

.bj3d-wide {
	width: 100%;
}

.bj3d-btn:disabled {
	opacity: 0.55;
	cursor: not-allowed;
}

.bj3d-actions {
	margin-top: 18px;
}

/* ---- form ---- */

.bj3d-form {
	margin-top: 8px;
	padding-top: 18px;
	border-top: 1px solid #eceff3;
}

.bj3d-form input,
.bj3d-form textarea {
	margin-bottom: 9px;
}

/* off screen rather than hidden, so bots still fill it */
.bj3d-trap {
	position: absolute;
	left: -9999px;
	top: -9999px;
	width: 1px;
	height: 1px;
	overflow: hidden;
}

.bj3d-note {
	margin: 10px 0 0;
	font-size: 13px;
	line-height: 1.55;
}

.bj3d-note:empty {
	display: none;
}

.bj3d-note.is-ok {
	color: #14532d;
}

.bj3d-note.is-bad {
	color: #7a1015;
}

@media (prefers-reduced-motion: reduce) {
	.bj3d * {
		transition-duration: 0.01ms !important;
	}
}

/* ==========================================================
   POLISH
   ========================================================== */

/* ---- loading, with a spinner rather than bare words ---- */

.bj3d-loading {
	gap: 14px;
	grid-auto-flow: row;
	align-content: center;
	justify-items: center;
	background:
		radial-gradient(ellipse 70% 50% at 50% 62%, rgba(255, 255, 255, 0.95), rgba(255, 255, 255, 0) 70%),
		linear-gradient(180deg, #eceae7 0%, #f4f3f1 48%, #e4e2df 100%);
}

.bj3d-loading::before {
	content: "";
	width: 30px;
	height: 30px;
	border: 3px solid rgba(22, 24, 29, 0.14);
	border-top-color: #16181d;
	border-radius: 50%;
	animation: bj3d-spin 0.85s linear infinite;
}

@keyframes bj3d-spin {
	to { transform: rotate(360deg); }
}

/* a failure message has no spinner, because nothing is still happening */
.bj3d-loading.is-error::before {
	display: none;
}

.bj3d-loading.is-error {
	color: #8c3116;
	max-width: 34ch;
	line-height: 1.6;
}

/* ---- the cursor tells you what a drag will do ---- */

.bj3d-stage canvas {
	cursor: grab;
}

.bj3d-stage canvas:active {
	cursor: grabbing;
}

/* ---- the side panel follows you down a long page ---- */

@media (min-width: 1100px) {
	.bj3d-side {
		position: sticky;
		top: 24px;
		max-height: calc(100vh - 48px);
		overflow-y: auto;
		overscroll-behavior: contain;
		padding-right: 4px;
	}

	/* a thin scrollbar, so the panel does not jump when it appears */
	.bj3d-side::-webkit-scrollbar {
		width: 8px;
	}

	.bj3d-side::-webkit-scrollbar-thumb {
		border-radius: 4px;
		background: #d8dce3;
	}
}

/* ---- swatches read as a colour card ---- */

.bj3d-sw {
	position: relative;
}

/* a tick on the chosen one, drawn rather than an icon font */
.bj3d-sw.is-on::after {
	content: "";
	position: absolute;
	left: 50%;
	top: 46%;
	width: 7px;
	height: 13px;
	border: solid rgba(255, 255, 255, 0.95);
	border-width: 0 2.5px 2.5px 0;
	transform: translate(-50%, -50%) rotate(45deg);
	filter: drop-shadow(0 0 1px rgba(0, 0, 0, 0.45));
}

/* ---- buttons lift slightly, which reads as pressable ---- */

.bj3d-btn:not(:disabled):hover {
	transform: translateY(-1px);
}

.bj3d-btn {
	transition: background 0.18s, color 0.18s, transform 0.18s, opacity 0.18s;
}

.bj3d-btn:not(:disabled):active {
	transform: translateY(0);
}

/* ---- keyboard focus stays visible, whatever the theme does ---- */

.bj3d :focus-visible {
	outline: 3px solid #AA151B;
	outline-offset: 2px;
	border-radius: 6px;
}

/* ---- layers get a little room to breathe ---- */

.bj3d-layers {
	max-height: 230px;
	overflow-y: auto;
}

/* ---- the send form reads as a separate step ---- */

.bj3d-form {
	margin-top: 22px;
	padding: 18px;
	border: 1px solid #e2e5ea;
	border-radius: 12px;
	background: #fafbfc;
}

.bj3d-form .bj3d-label {
	margin-top: 0;
}

/* ---- the note carries its own colour block ---- */

.bj3d-note.is-ok,
.bj3d-note.is-bad {
	margin-top: 12px;
	padding: 10px 12px;
	border-radius: 9px;
}

.bj3d-note.is-ok {
	background: rgba(22, 163, 74, 0.12);
	border: 1px solid rgba(22, 163, 74, 0.4);
}

.bj3d-note.is-bad {
	background: rgba(170, 21, 27, 0.08);
	border: 1px solid rgba(170, 21, 27, 0.35);
}

/* ---- phones ---- */

@media (max-width: 600px) {
	.bj3d-grid {
		gap: 18px;
	}

	.bj3d-stage-wrap {
		border-radius: 12px;
	}

	.bj3d-sw {
		width: 38px;
		height: 38px;
	}

	.bj3d-bar {
		padding: 9px 10px;
	}

	.bj3d-mini {
		padding: 8px 12px;
		font-size: 12px;
	}
}

/* ---- dark themes: keep the panel readable without a theme toggle ---- */

@media (prefers-color-scheme: dark) {
	.bj3d {
		color: #e9eaec;
	}

	.bj3d-stage-wrap,
	.bj3d-layer,
	.bj3d-model,
	.bj3d input[type="text"],
	.bj3d input[type="email"],
	.bj3d input[type="tel"],
	.bj3d textarea {
		border-color: #353a42;
		background: #1c1f24;
		color: #e9eaec;
	}

	.bj3d-bar,
	.bj3d-drop,
	.bj3d-form {
		border-color: #353a42;
		background: #22262c;
	}

	.bj3d-mini {
		border-color: #3a4049;
		background: #2a2e35;
		color: #e9eaec;
	}

	.bj3d-mini:hover,
	.bj3d-mini.is-on {
		background: #e9eaec;
		color: #16181d;
		border-color: #e9eaec;
	}

	.bj3d-ghost {
		border-color: #e9eaec;
		color: #e9eaec;
	}

	.bj3d-ghost:hover {
		background: #e9eaec;
		color: #16181d;
	}

	.bj3d-layer.is-on,
	.bj3d-model.is-on {
		border-color: #e9eaec;
		box-shadow: inset 0 0 0 1px #e9eaec;
	}
}
