/**
 * PSDM Card Preview 3D — viewer modal + launch buttons.
 *
 * Pure CSS 3D (perspective + preserve-3d card, backface-hidden faces); JS
 * only writes the rotate transform + --cp3d-sheen. Sized with relative units
 * so it holds on small laptops and phones (responsive rule: never tuned to
 * one monitor). Theme tokens carry literal fallbacks — the designer surface
 * has no theme CSS.
 */

/* ------------------------------------------------------------ launch btn */
.psdm-cp3d-open {
	display: inline-flex;
	align-items: center;
	gap: 8px;
	margin: 10px 0 4px;
	padding: 9px 16px;
	border: 1px solid var(--ps-brand, #0e9448);
	border-radius: 999px;
	background: #fff;
	color: var(--ps-brand, #0e9448);
	font-size: 13px;
	font-weight: 600;
	line-height: 1;
	cursor: pointer;
	transition: background 0.15s ease, color 0.15s ease;
}
.psdm-cp3d-open:hover,
.psdm-cp3d-open:focus-visible {
	background: var(--ps-brand, #0e9448);
	color: #fff;
}
.psdm-cp3d-open svg {
	width: 16px;
	height: 16px;
	flex: 0 0 auto;
}

/* --------------------------------------------------------------- overlay */
.psdm-cp3d-overlay {
	position: fixed;
	inset: 0;
	z-index: 999999;
	display: none;
	align-items: center;
	justify-content: center;
	background: rgba(15, 18, 24, 0.66);
	-webkit-backdrop-filter: blur(4px);
	backdrop-filter: blur(4px);
	padding: clamp(8px, 3vmin, 28px);
}
.psdm-cp3d-overlay.psdm-cp3d-on { display: flex; }
.psdm-cp3d-lock { overflow: hidden; }

.psdm-cp3d-dialog {
	display: flex;
	flex-direction: column;
	align-items: stretch;
	width: min(92vw, 680px);
	max-height: 92vh;
	color: #f4f6f9;
}

.psdm-cp3d-head {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 12px;
	padding: 0 2px 10px;
}
.psdm-cp3d-title {
	font-size: clamp(15px, 2.4vmin, 18px);
	font-weight: 600;
	letter-spacing: 0.01em;
}
.psdm-cp3d-x {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	padding: 0;
	width: 34px;
	height: 34px;
	border: 0;
	border-radius: 50%;
	background: rgba(255, 255, 255, 0.12);
	color: #fff;
	font-size: 22px;
	line-height: 1;
	cursor: pointer;
}
.psdm-cp3d-x:hover,
.psdm-cp3d-x:focus-visible { background: rgba(255, 255, 255, 0.24); }

/* ----------------------------------------------------------------- stage */
.psdm-cp3d-stage {
	position: relative;
	display: flex;
	align-items: center;
	justify-content: center;
	flex: 1 1 auto;
	min-height: min(62vh, 460px);
	perspective: 1400px;
	touch-action: none;
	cursor: grab;
}
.psdm-cp3d-stage:active { cursor: grabbing; }

.psdm-cp3d-card {
	position: relative;
	transform-style: preserve-3d;
	will-change: transform;
}
.psdm-cp3d-card.psdm-cp3d-ease { transition: transform 0.55s cubic-bezier(0.22, 0.8, 0.3, 1); }
@media (prefers-reduced-motion: reduce) {
	.psdm-cp3d-card.psdm-cp3d-ease { transition: none; }
}

.psdm-cp3d-face {
	position: absolute;
	inset: 0;
	overflow: hidden;
	backface-visibility: hidden;
	-webkit-backface-visibility: hidden;
	background: transparent;
	box-shadow: 0 1px 0 rgba(255, 255, 255, 0.35) inset, 0 18px 50px rgba(0, 0, 0, 0.45);
}
.psdm-cp3d-face img {
	display: block;
	width: 100%;
	height: 100%;
	object-fit: fill;
	-webkit-user-drag: none;
	user-select: none;
	pointer-events: none;
}
.psdm-cp3d-back { transform: rotateY(180deg); }

/* Moving paper sheen, driven by --cp3d-sheen (background-position). */
.psdm-cp3d-face::after {
	content: "";
	position: absolute;
	inset: 0;
	border-radius: inherit;
	background-image: linear-gradient(105deg, rgba(255, 255, 255, 0) 42%, rgba(255, 255, 255, 0.22) 50%, rgba(255, 255, 255, 0) 58%);
	background-size: 240% 100%;
	background-position: var(--cp3d-sheen, 50% 0);
	pointer-events: none;
}

/* Single-sided products: plain paper back. */
.psdm-cp3d-face.psdm-cp3d-blank {
	display: flex;
	align-items: center;
	justify-content: center;
	background: linear-gradient(160deg, #ffffff 0%, #f2f3f5 100%);
}
.psdm-cp3d-blank-label {
	font-size: 12px;
	font-weight: 600;
	letter-spacing: 0.14em;
	text-transform: uppercase;
	color: #b7bcc4;
}

.psdm-cp3d-shadow {
	position: absolute;
	left: 50%;
	bottom: clamp(4px, 4vmin, 30px);
	width: 60%;
	height: 24px;
	transform: translateX(-50%);
	background: radial-gradient(ellipse at center, rgba(0, 0, 0, 0.4) 0%, rgba(0, 0, 0, 0) 68%);
	filter: blur(6px);
	pointer-events: none;
}

/* ------------------------------------------------------------------ foot */
.psdm-cp3d-foot {
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 16px;
	padding-top: 12px;
}
.psdm-cp3d-hint {
	font-size: 12.5px;
	color: rgba(244, 246, 249, 0.72);
}
.psdm-cp3d-flip {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	line-height: 1;
	padding: 8px 18px;
	border: 1px solid rgba(255, 255, 255, 0.35);
	border-radius: 999px;
	background: rgba(255, 255, 255, 0.1);
	color: #fff;
	font-size: 13px;
	font-weight: 600;
	cursor: pointer;
	transition: background 0.15s ease;
}
.psdm-cp3d-flip:hover,
.psdm-cp3d-flip:focus-visible { background: rgba(255, 255, 255, 0.22); }

/* In-designer "3D Preview" pill — same recipe as the Guides toggle: the
   stock .menu-item stacks icon-over-label (column) and fades non-active
   items to 0.15, so force a row layout + full opacity. Matches the Guides
   pill metrics exactly (boss 2026-08-03: icon beside text, both centered). */
.nbd-main-bar .menu-item.psdm-cardprev-toggle {
	display: inline-flex !important;
	flex-direction: row !important;
	align-items: center;
	justify-content: center;
	gap: 8px;
	margin: 0 4px;
	padding: 10px 18px !important;
	border: 0;
	border-radius: var(--ax-r-pill, 999px);
	line-height: 1;
	cursor: pointer;
	color: var(--ax-gray-900, #171922);
	background: transparent;
	opacity: 1 !important;
}
.nbd-main-bar .menu-item.psdm-cardprev-toggle:hover {
	background: var(--ax-accent-100, #eef1ff);
}
.nbd-main-bar .menu-item.psdm-cardprev-toggle svg {
	width: 18px;
	height: 18px;
	flex: 0 0 auto;
}
.nbd-main-bar .menu-item.psdm-cardprev-toggle span {
	color: inherit !important;
	opacity: 1 !important;
	font-weight: 700;
	font-size: var(--ax-text, 14px);
}

/* Short viewports: keep the whole dialog reachable. */
@media (max-height: 560px) {
	.psdm-cp3d-stage { min-height: 46vh; }
	.psdm-cp3d-head { padding-bottom: 4px; }
}
