/* 3D Product Viewer for WooCommerce: button and pop-up. Override the custom properties to theme it. */

.w3dpv-launch,
.w3dpv-dialog {
	--w3dpv-accent: #1d2327;
	--w3dpv-surface: #ffffff;
	--w3dpv-stage: #f3f4f6;
	--w3dpv-text: #1d2327;
	--w3dpv-muted: #50575e;
	--w3dpv-error: #b32d2e;
	--w3dpv-radius: 10px;
	--w3dpv-focus: 0 0 0 3px #ffffff, 0 0 0 5px #2271b1;
}

/* Button: inherits the theme's .button look; only layout is set here. */
.w3dpv-launch {
	clear: both;
	margin: 1em 0;
}

.w3dpv-open {
	display: inline-flex !important;
	align-items: center;
	gap: 0.5em;
	cursor: pointer;
}

.w3dpv-open__icon {
	flex: none;
	width: 1.25em;
	height: 1.25em;
}

.w3dpv-open:focus-visible {
	outline: none;
	box-shadow: var(--w3dpv-focus);
}

/* Gallery: "View in 3D" in the bottom-right corner of the main image. */
.w3dpv-corner-host {
	position: relative;
}

.w3dpv-corner {
	--w3dpv-corner-bg: rgba(255, 255, 255, 0.94);
	--w3dpv-corner-text: #111111;
	position: absolute;
	right: 12px;
	bottom: 12px;
	z-index: 5;
	display: inline-flex;
	align-items: center;
	gap: 0.5em;
	margin: 0;
	padding: 10px 16px;
	border: 0;
	border-radius: var(--w3dpv-corner-radius, 999px);
	background: var(--w3dpv-corner-bg);
	color: var(--w3dpv-corner-text);
	font: inherit;
	font-size: 14px;
	font-weight: 600;
	line-height: 1.2;
	letter-spacing: normal;
	text-transform: none;
	box-shadow: 0 2px 12px rgba(0, 0, 0, 0.18);
	cursor: pointer;
	transition: background 0.15s ease, transform 0.15s ease;
}

.w3dpv-corner:hover {
	background: #ffffff;
	transform: translateY(-1px);
}

.w3dpv-corner:focus-visible {
	outline: none;
	box-shadow: 0 0 0 3px #ffffff, 0 0 0 5px #2271b1;
}

.w3dpv-corner__icon {
	flex: none;
	width: 18px;
	height: 18px;
}

@media (max-width: 640px) {
	.w3dpv-corner {
		right: 8px;
		bottom: 8px;
		padding: 8px 12px;
		font-size: 13px;
	}
}

/* Gallery: 3D tile in the thumbnail row. Size and border come from the theme's thumbnail
   class when the row has one; only the content and button reset are set here. */
.w3dpv-thumb {
	display: inline-flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: 2px;
	margin: 0;
	padding: 0;
	background-color: var(--w3dpv-stage, #f3f4f6);
	color: var(--w3dpv-text, #1d2327);
	font: inherit;
	font-size: 11px;
	font-weight: 700;
	line-height: 1;
	letter-spacing: 0.04em;
	text-transform: none;
	cursor: pointer;
	appearance: none;
	-webkit-appearance: none;
}

.w3dpv-thumb__icon {
	width: 24px;
	height: 24px;
}

.w3dpv-thumb:focus-visible {
	outline: 2px solid #2271b1;
	outline-offset: 2px;
}

/* Standard WooCommerce thumbnail list (li > img). */
.w3dpv-thumb-item {
	list-style: none;
}

.w3dpv-thumb-item {
	container-type: inline-size;
}

.w3dpv-thumb-item .w3dpv-thumb {
	width: 100%;
	aspect-ratio: 1;
	/* Never let the icon and label stretch the tile beyond a square. */
	min-height: 0;
	overflow: hidden;
	border: 0;
	opacity: 0.7;
	transition: opacity 0.15s ease;
}

.w3dpv-thumb-item .w3dpv-thumb__icon {
	width: min(24px, 50cqi);
	height: min(24px, 50cqi);
}

@container (max-width: 44px) {
	.w3dpv-thumb-item .w3dpv-thumb__text {
		display: none;
	}
}

.w3dpv-thumb-item .w3dpv-thumb:hover,
.w3dpv-thumb-item .w3dpv-thumb:focus-visible {
	opacity: 1;
}

/* Page scroll lock while the pop-up is open. */
html.w3dpv-is-open,
html.w3dpv-is-open body {
	overflow: hidden !important;
}

/* Dialog */
.w3dpv-dialog {
	box-sizing: border-box;
	width: min(960px, calc(100vw - 32px));
	max-width: none;
	height: min(780px, calc(100vh - 32px));
	max-height: none;
	margin: auto;
	padding: 0;
	border: 0;
	border-radius: var(--w3dpv-radius);
	background: var(--w3dpv-surface);
	color: var(--w3dpv-text);
	box-shadow: 0 24px 64px rgba(0, 0, 0, 0.35);
	overflow: hidden;
}

@supports (height: 100dvh) {
	.w3dpv-dialog {
		height: min(780px, calc(100dvh - 32px));
	}
}

.w3dpv-dialog:not([open]) {
	display: none;
}

.w3dpv-dialog::backdrop {
	background: rgba(17, 17, 17, 0.72);
}

/* Browsers without <dialog>: emulate the modal layer. */
.w3dpv-dialog--fallback[open] {
	position: fixed;
	inset: 0;
	z-index: 100000;
	display: block;
	outline: 9999px solid rgba(17, 17, 17, 0.72);
}

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

.w3dpv-dialog__inner {
	display: flex;
	flex-direction: column;
	height: 100%;
}

.w3dpv-dialog__header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 12px;
	padding: 12px 12px 12px 20px;
	border-bottom: 1px solid rgba(0, 0, 0, 0.08);
}

.w3dpv-dialog .w3dpv-dialog__title {
	margin: 0;
	padding: 0;
	font-size: 1.125rem;
	line-height: 1.3;
	font-weight: 600;
	color: inherit;
	text-transform: none;
	letter-spacing: normal;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.w3dpv-dialog .w3dpv-dialog__close {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	flex: none;
	width: 44px;
	height: 44px;
	min-width: 0;
	margin: 0;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: transparent;
	color: var(--w3dpv-text);
	box-shadow: none;
	cursor: pointer;
}

.w3dpv-dialog .w3dpv-dialog__close:hover {
	background: rgba(0, 0, 0, 0.06);
}

.w3dpv-dialog .w3dpv-dialog__close:focus-visible,
.w3dpv-dialog .w3dpv-retry:focus-visible,
.w3dpv-model:focus-visible {
	outline: none;
	box-shadow: var(--w3dpv-focus);
}

.w3dpv-stage {
	position: relative;
	flex: 1 1 auto;
	min-height: 0;
	background: var(--w3dpv-stage);
}

.w3dpv-model {
	display: block;
	width: 100%;
	height: 100%;
	background: transparent;
	--poster-color: transparent;
}

.w3dpv-model[hidden] {
	display: none;
}

/* Zoom buttons, bottom-right of the 3D stage. */
.w3dpv-zoom {
	position: absolute;
	right: 16px;
	bottom: 16px;
	z-index: 3;
	display: flex;
	flex-direction: column;
	gap: 8px;
}

.w3dpv-zoom[hidden] {
	display: none;
}

.w3dpv-dialog .w3dpv-zoom__btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 44px;
	height: 44px;
	min-width: 0;
	margin: 0;
	padding: 0;
	border: 1px solid rgba(0, 0, 0, 0.08);
	border-radius: 50%;
	background: var(--w3dpv-surface);
	color: var(--w3dpv-text);
	box-shadow: 0 2px 10px rgba(0, 0, 0, 0.16);
	cursor: pointer;
	transition: background 0.15s ease;
}

.w3dpv-dialog .w3dpv-zoom__btn:hover {
	background: #f0f0f1;
}

.w3dpv-dialog .w3dpv-zoom__btn:focus-visible {
	outline: none;
	box-shadow: var(--w3dpv-focus);
}

@media (max-width: 640px) {
	.w3dpv-zoom {
		right: 12px;
		bottom: 12px;
	}
}

/* Loading */
.w3dpv-loading,
.w3dpv-error {
	position: absolute;
	inset: 0;
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: 12px;
	padding: 24px;
	text-align: center;
}

.w3dpv-loading[hidden],
.w3dpv-error[hidden] {
	display: none;
}

.w3dpv-loading {
	pointer-events: none;
	background: var(--w3dpv-stage);
}

.w3dpv-loading__text {
	margin: 0;
	color: var(--w3dpv-muted);
	font-size: 0.95rem;
}

.w3dpv-spinner {
	width: 40px;
	height: 40px;
	border: 3px solid rgba(0, 0, 0, 0.12);
	border-top-color: var(--w3dpv-accent);
	border-radius: 50%;
	animation: w3dpv-spin 0.8s linear infinite;
}

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

.w3dpv-progress {
	width: min(240px, 70%);
	height: 4px;
	border-radius: 2px;
	background: rgba(0, 0, 0, 0.12);
	overflow: hidden;
}

.w3dpv-progress__bar {
	display: block;
	width: 0;
	height: 100%;
	background: var(--w3dpv-accent);
	transition: width 0.2s ease-out;
}

/* Error */
.w3dpv-error {
	background: var(--w3dpv-stage);
	color: var(--w3dpv-text);
}

.w3dpv-error__icon {
	color: var(--w3dpv-error);
}

.w3dpv-error__title {
	margin: 0 0 4px;
	font-weight: 600;
	font-size: 1.05rem;
}

.w3dpv-error__text {
	max-width: 32em;
	margin: 0;
	color: var(--w3dpv-muted);
}

.w3dpv-dialog .w3dpv-retry[hidden] {
	display: none;
}

.w3dpv-dialog__help {
	margin: 0;
	padding: 10px 20px;
	font-size: 0.85rem;
	line-height: 1.45;
	color: var(--w3dpv-muted);
	border-top: 1px solid rgba(0, 0, 0, 0.08);
}

.w3dpv-has-error .w3dpv-dialog__help {
	display: none;
}

.w3dpv-sr-only {
	position: absolute !important;
	width: 1px !important;
	height: 1px !important;
	margin: -1px !important;
	padding: 0 !important;
	overflow: hidden !important;
	clip: rect(0, 0, 0, 0) !important;
	white-space: nowrap !important;
	border: 0 !important;
}

/* Phones: full-screen sheet. */
@media (max-width: 640px) {
	.w3dpv-dialog {
		width: 100vw;
		height: 100vh;
		border-radius: 0;
	}

	@supports (height: 100dvh) {
		.w3dpv-dialog {
			height: 100dvh;
		}
	}

	.w3dpv-dialog__header {
		padding: 8px 8px 8px 16px;
	}

	.w3dpv-dialog__help {
		padding: 8px 16px calc(8px + env(safe-area-inset-bottom, 0px));
	}
}

@media (prefers-reduced-motion: reduce) {
	.w3dpv-spinner {
		animation-duration: 2.4s;
	}

	.w3dpv-progress__bar {
		transition: none;
	}
}

@media (forced-colors: active) {
	.w3dpv-dialog {
		border: 1px solid CanvasText;
	}

	.w3dpv-progress__bar {
		background: Highlight;
	}
}
