/*
 * Poster Studio front end.
 *
 * Every colour, radius and font comes from the --ps-* tokens below. They fall
 * back to the active theme's variables (block themes: --wp--preset--*,
 * Flatsome: --fs-color-*), so the studio picks up the site's look. Override
 * any token on .ps-studio in the theme to customise it.
 */
.ps-studio {
	--ps-accent: var(--wp--preset--color--primary, var(--fs-color-primary, #1d1d1f));
	--ps-accent-contrast: #fff;
	--ps-text: var(--wp--preset--color--contrast, var(--fs-color-base, #1d1d1f));
	--ps-muted: #6e6e73;
	--ps-surface: var(--wp--preset--color--base, #fff);
	--ps-surface-alt: #f5f4f1;
	--ps-border: rgba(0, 0, 0, 0.12);
	--ps-border-strong: rgba(0, 0, 0, 0.32);
	--ps-ok: var(--fs-color-success, #2f6b3a);
	--ps-warn: #8a5a00;
	--ps-warn-bg: #fff6e0;
	--ps-error: var(--fs-color-alert, #b42318);
	--ps-error-bg: #fdecea;
	--ps-radius: 2px;
	--ps-gap: 24px;
	--ps-stage-max-h: 72vh;
	--ps-font: inherit;

	color: var(--ps-text);
	font-family: var(--ps-font);
	line-height: 1.5;
	margin: 0 auto;
	max-width: 1280px;
}

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

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

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

.ps-studio .ps-button {
	align-items: center;
	background: transparent;
	border: 1px solid var(--ps-border-strong);
	border-radius: var(--ps-radius);
	color: var(--ps-text);
	cursor: pointer;
	display: inline-flex;
	font: inherit;
	font-weight: 600;
	justify-content: center;
	letter-spacing: 0.02em;
	line-height: 1.2;
	margin: 0;
	min-height: 48px;
	padding: 12px 24px;
	text-decoration: none;
	text-transform: none;
	transition: background-color 0.15s, color 0.15s, border-color 0.15s;
}

.ps-studio .ps-button:hover {
	border-color: var(--ps-text);
}

.ps-studio .ps-button--primary {
	background: var(--ps-accent);
	border-color: var(--ps-accent);
	color: var(--ps-accent-contrast);
}

.ps-studio .ps-button--primary:hover {
	filter: brightness(0.92);
	border-color: var(--ps-accent);
}

.ps-studio .ps-button:disabled {
	cursor: not-allowed;
	opacity: 0.45;
}

.ps-studio .ps-link {
	align-self: flex-start;
	background: none;
	border: 0;
	color: var(--ps-text);
	cursor: pointer;
	font: inherit;
	font-size: 0.875rem;
	margin: 0;
	padding: 4px 0;
	text-decoration: underline;
	text-underline-offset: 3px;
}

.ps-studio .ps-icon-button {
	background: var(--ps-surface);
	border: 1px solid var(--ps-border);
	border-radius: 50%;
	color: var(--ps-text);
	cursor: pointer;
	flex: none;
	font-size: 1.25rem;
	height: 44px;
	line-height: 1;
	margin: 0;
	padding: 0;
	width: 44px;
}

.ps-studio :focus-visible {
	outline: 2px solid var(--ps-accent);
	outline-offset: 2px;
}

/* ---------- start ---------- */

.ps-start {
	display: grid;
	gap: 40px;
}

.ps-drop {
	align-items: center;
	background: var(--ps-surface-alt);
	border: 1px dashed var(--ps-border-strong);
	border-radius: var(--ps-radius);
	display: flex;
	flex-direction: column;
	gap: 12px;
	padding: 64px 24px;
	text-align: center;
	transition: background-color 0.15s, border-color 0.15s;
}

.ps-drop.is-over {
	background: var(--ps-surface);
	border-color: var(--ps-accent);
}

.ps-drop__icon {
	color: var(--ps-muted);
	height: 48px;
	width: 48px;
}

.ps-studio .ps-drop__title {
	font-size: clamp(1.5rem, 3vw, 2rem);
	font-weight: 400;
	letter-spacing: -0.01em;
	margin: 0;
}

.ps-drop__hint,
.ps-drop__limits {
	color: var(--ps-muted);
	margin: 0;
}

.ps-drop__limits {
	font-size: 0.8125rem;
}

.ps-progress {
	max-width: 360px;
	width: 100%;
}

.ps-progress__track {
	background: var(--ps-border);
	height: 4px;
	overflow: hidden;
}

.ps-progress__bar {
	background: var(--ps-accent);
	height: 100%;
	transition: width 0.2s;
	width: 0;
}

.ps-progress__label {
	color: var(--ps-muted);
	display: block;
	font-size: 0.8125rem;
	margin-top: 8px;
}

.ps-studio .ps-heading {
	font-size: 0.75rem;
	font-weight: 600;
	letter-spacing: 0.12em;
	margin: 0 0 12px;
	padding: 0;
	text-transform: uppercase;
}

.ps-recent__grid {
	display: grid;
	gap: 12px;
	grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
	list-style: none;
	margin: 0;
	padding: 0;
}

.ps-recent__item {
	aspect-ratio: 1;
	background: var(--ps-surface-alt);
	border: 1px solid var(--ps-border);
	cursor: pointer;
	display: block;
	margin: 0;
	padding: 8px;
	width: 100%;
}

.ps-recent__item:hover {
	border-color: var(--ps-text);
}

.ps-recent__item img {
	display: block;
	height: 100%;
	object-fit: contain;
	width: 100%;
}

/* ---------- editor ---------- */

.ps-editor {
	align-items: start;
	display: grid;
	gap: var(--ps-gap);
	grid-template-columns: minmax(0, 1fr);
}

@media (min-width: 900px) {
	.ps-editor {
		gap: 48px;
		grid-template-columns: minmax(0, 1.5fr) minmax(320px, 1fr);
	}

	.ps-stage {
		position: sticky;
		top: 24px;
	}
}

.ps-stage {
	align-items: center;
	background: var(--ps-surface-alt);
	display: flex;
	flex-direction: column;
	gap: 16px;
	padding: clamp(16px, 4vw, 48px);
}

.ps-crop-holder {
	display: flex;
	justify-content: center;
	width: 100%;
}

.ps-crop {
	background: #ddd;
	box-shadow: 0 1px 2px rgba(0, 0, 0, 0.12), 0 12px 32px rgba(0, 0, 0, 0.14);
	cursor: grab;
	overflow: hidden;
	position: relative;
	touch-action: none;
	user-select: none;
	width: min(100%, calc(var(--ps-stage-max-h) * var(--ps-ratio)));
}

.ps-crop.is-dragging {
	cursor: grabbing;
}

/* Frame drawn outside the crop box so the crop keeps the print's exact aspect. */
.ps-crop--framed {
	box-shadow: 0 0 0 clamp(8px, 2vw, 16px) var(--ps-frame, #1b1b1b), 0 2px 4px clamp(8px, 2vw, 16px) rgba(0, 0, 0, 0.12), 0 16px 40px clamp(8px, 2vw, 16px) rgba(0, 0, 0, 0.12);
	margin: clamp(8px, 2vw, 16px);
	width: min(calc(100% - 2 * clamp(8px, 2vw, 16px)), calc(var(--ps-stage-max-h) * var(--ps-ratio)));
}

.ps-crop--canvas {
	box-shadow: 4px 6px 0 rgba(0, 0, 0, 0.08), 0 12px 32px rgba(0, 0, 0, 0.16);
}

.ps-crop__img {
	left: 0;
	max-width: none !important;
	pointer-events: none;
	position: absolute;
	top: 0;
	transform-origin: 0 0;
}

.ps-wrap-guide {
	border: 1px dashed rgba(255, 255, 255, 0.9);
	box-shadow: 0 0 0 9999px rgba(255, 255, 255, 0.45);
	pointer-events: none;
	position: absolute;
}

.ps-zoom {
	align-items: center;
	display: flex;
	gap: 12px;
	max-width: 360px;
	width: 100%;
}

.ps-zoom input[type="range"] {
	accent-color: var(--ps-accent);
	flex: 1;
	margin: 0;
	min-height: 44px;
}

.ps-hint {
	color: var(--ps-muted);
	font-size: 0.8125rem;
	margin: 0;
	text-align: center;
}

/* ---------- panel ---------- */

.ps-panel {
	display: flex;
	flex-direction: column;
	gap: 28px;
}

.ps-studio .ps-field {
	border: 0;
	margin: 0;
	min-width: 0;
	padding: 0;
}

.ps-segmented {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
}

.ps-segmented__option {
	align-items: center;
	border: 1px solid var(--ps-border);
	border-radius: var(--ps-radius);
	cursor: pointer;
	display: inline-flex;
	font-size: 0.9375rem;
	gap: 8px;
	margin: 0;
	min-height: 44px;
	padding: 8px 16px;
}

.ps-segmented__option:hover {
	border-color: var(--ps-border-strong);
}

input:checked + .ps-segmented__option {
	border-color: var(--ps-text);
	box-shadow: inset 0 0 0 1px var(--ps-text);
}

input:focus-visible + .ps-segmented__option,
input:focus-visible + .ps-size {
	outline: 2px solid var(--ps-accent);
	outline-offset: 2px;
}

input:disabled + .ps-segmented__option {
	cursor: not-allowed;
	opacity: 0.4;
}

.ps-swatch {
	border: 1px solid var(--ps-border-strong);
	border-radius: 50%;
	display: inline-block;
	height: 18px;
	width: 18px;
}

.ps-sizes {
	display: grid;
	gap: 8px;
}

.ps-size {
	align-items: baseline;
	border: 1px solid var(--ps-border);
	border-radius: var(--ps-radius);
	cursor: pointer;
	display: grid;
	gap: 2px 16px;
	grid-template-columns: 1fr auto;
	margin: 0;
	padding: 12px 16px;
}

.ps-size:hover {
	border-color: var(--ps-border-strong);
}

input:checked + .ps-size {
	border-color: var(--ps-text);
	box-shadow: inset 0 0 0 1px var(--ps-text);
}

.ps-size__name {
	font-weight: 600;
}

.ps-size__price {
	font-variant-numeric: tabular-nums;
}

.ps-size__note {
	color: var(--ps-muted);
	font-size: 0.8125rem;
	grid-column: 1 / -1;
}

.ps-size--warn .ps-size__note {
	color: var(--ps-warn);
}

.ps-size--locked {
	cursor: not-allowed;
	opacity: 0.5;
}

.ps-size--locked .ps-size__note {
	color: var(--ps-error);
}

.ps-studio .ps-note {
	border-radius: var(--ps-radius);
	font-size: 0.875rem;
	margin: 0;
	padding: 12px 16px;
}

.ps-note--warn {
	background: var(--ps-warn-bg);
	color: var(--ps-warn);
}

.ps-note--locked {
	background: var(--ps-error-bg);
	color: var(--ps-error);
}

.ps-buy {
	border-top: 1px solid var(--ps-border);
	display: grid;
	gap: 16px;
	padding-top: 24px;
}

.ps-buy__summary {
	align-items: baseline;
	display: flex;
	gap: 16px;
	justify-content: space-between;
}

.ps-buy__label {
	color: var(--ps-muted);
	font-size: 0.9375rem;
}

.ps-total {
	font-size: 1.5rem;
	font-variant-numeric: tabular-nums;
	font-weight: 600;
}

.ps-buy__actions {
	display: flex;
	gap: 12px;
}

.ps-studio .ps-qty {
	border: 1px solid var(--ps-border-strong);
	border-radius: var(--ps-radius);
	font: inherit;
	height: 48px;
	margin: 0;
	padding: 0 8px;
	text-align: center;
	width: 72px;
}

.ps-add {
	flex: 1;
}

.ps-added {
	background: var(--ps-surface-alt);
	padding: 20px;
}

.ps-studio .ps-added__title {
	font-weight: 600;
	margin: 0 0 12px;
}

.ps-added__actions {
	align-items: center;
	display: flex;
	flex-wrap: wrap;
	gap: 12px;
}

/* Sticky purchase bar on small screens. */
@media (max-width: 899px) {
	.ps-buy {
		background: var(--ps-surface);
		border-top: 1px solid var(--ps-border);
		bottom: 0;
		/* Full-width background without widening the page. */
		box-shadow: 0 0 0 100vmax var(--ps-surface);
		clip-path: inset(0 -100vmax);
		margin: 0;
		padding: 16px 0;
		position: sticky;
		z-index: 5;
	}
}

/* ---------- loading ---------- */

.ps-loading {
	display: flex;
	justify-content: center;
	padding: 80px 0;
}

.ps-spinner {
	animation: ps-spin 0.8s linear infinite;
	border: 2px solid var(--ps-border);
	border-radius: 50%;
	border-top-color: var(--ps-text);
	height: 28px;
	width: 28px;
}

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

@media (prefers-reduced-motion: reduce) {
	.ps-studio * {
		animation: none !important;
		transition: none !important;
	}
}

/* ---------- My designs ---------- */

.ps-my-designs__grid {
	display: grid;
	gap: 24px;
	grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
	list-style: none;
	margin: 16px 0 0;
	padding: 0;
}

.ps-my-designs__item {
	display: flex;
	flex-direction: column;
	gap: 8px;
	margin: 0;
}

.ps-my-designs__image {
	align-items: center;
	aspect-ratio: 1;
	background: var(--ps-surface-alt);
	display: flex;
	justify-content: center;
	padding: 12px;
}

.ps-my-designs__image img {
	box-shadow: 0 6px 16px rgba(0, 0, 0, 0.12);
	max-height: 100%;
	max-width: 100%;
}

.ps-studio .ps-my-designs__meta {
	font-size: 0.875rem;
	margin: 0;
	overflow-wrap: anywhere;
}

.ps-my-designs__meta span {
	color: var(--ps-muted);
	font-size: 0.8125rem;
}

.ps-my-designs__actions {
	align-items: center;
	display: flex;
	flex-wrap: wrap;
	gap: 12px;
}

.ps-my-designs__actions .ps-button {
	min-height: 40px;
	padding: 8px 16px;
}

/* ---------- room view ---------- */

.ps-view-toggle {
	background: var(--ps-surface);
	border: 1px solid var(--ps-border);
	border-radius: 999px;
	display: inline-flex;
	padding: 3px;
}

.ps-studio .ps-view-toggle__button {
	background: transparent;
	border: 0;
	border-radius: 999px;
	color: var(--ps-muted);
	cursor: pointer;
	font: inherit;
	font-size: 0.875rem;
	margin: 0;
	min-height: 36px;
	padding: 6px 18px;
}

.ps-studio .ps-view-toggle__button[aria-pressed="true"] {
	background: var(--ps-text);
	color: var(--ps-surface);
}

.ps-room {
	overflow: hidden;
	position: relative;
	width: 100%;
}

.ps-room__scene {
	display: block;
	height: auto;
	max-width: none !important;
	width: 100%;
}

.ps-room__art {
	filter: drop-shadow(2px 6px 6px rgba(0, 0, 0, 0.28));
	left: 0;
	position: absolute;
	top: 0;
	transform-origin: 0 0;
}

.ps-room__overlay {
	height: 100%;
	inset: 0;
	mix-blend-mode: multiply;
	pointer-events: none;
	position: absolute;
	width: 100%;
}

.ps-scenes {
	display: flex;
	gap: 8px;
	overflow-x: auto;
	width: 100%;
}

.ps-studio .ps-scenes__item {
	background: none;
	border: 2px solid transparent;
	cursor: pointer;
	flex: none;
	margin: 0;
	padding: 0;
	width: 88px;
}

.ps-studio .ps-scenes__item[aria-pressed="true"] {
	border-color: var(--ps-text);
}

.ps-scenes__item img {
	aspect-ratio: 3 / 2;
	display: block;
	object-fit: cover;
	width: 100%;
}

/* ---------- AI ---------- */

.ps-start__tabs {
	justify-self: center;
}

.ps-ai {
	background: var(--ps-surface-alt);
	display: flex;
	flex-direction: column;
	gap: 20px;
	margin: 0 auto;
	max-width: 760px;
	padding: clamp(24px, 4vw, 48px);
	width: 100%;
}

.ps-studio .ps-ai__prompt {
	background: var(--ps-surface);
	border: 1px solid var(--ps-border-strong);
	border-radius: var(--ps-radius);
	font: inherit;
	margin: -8px 0 0;
	min-height: 112px;
	padding: 12px 14px;
	resize: vertical;
	width: 100%;
}

.ps-studio .ps-ai-balance {
	color: var(--ps-muted);
	font-size: 0.875rem;
	margin: 0;
}

.ps-studio .ps-ai-balance.is-short {
	color: var(--ps-error);
}

.ps-ai-progress {
	align-items: center;
	display: flex;
	gap: 12px;
}

.ps-ai__results {
	display: grid;
	gap: 12px;
	grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
	list-style: none;
	margin: 0;
	padding: 0;
}

.ps-studio .ps-ai__result {
	background: var(--ps-surface);
	border: 2px solid transparent;
	cursor: pointer;
	display: block;
	margin: 0;
	padding: 6px;
	width: 100%;
}

.ps-studio .ps-ai__result:hover,
.ps-studio .ps-ai__result:focus-visible {
	border-color: var(--ps-text);
}

.ps-ai__result img {
	display: block;
	height: auto;
	width: 100%;
}

.ps-upscale {
	background: var(--ps-surface-alt);
	display: grid;
	gap: 8px;
	padding: 16px;
}

.ps-studio .ps-upscale__title {
	font-weight: 600;
	margin: 0;
}

.ps-studio .ps-upscale__text {
	color: var(--ps-muted);
	font-size: 0.875rem;
	margin: 0;
}

.ps-upscale__actions {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
}

.ps-upscale__actions .ps-button {
	min-height: 40px;
	padding: 8px 14px;
}

.ps-free-shipping {
	color: var(--ps-ok);
	display: block;
	font-size: 0.8125rem;
	font-weight: 600;
}

/* ---------- personalised templates ---------- */

.ps-tpl__cards {
	display: grid;
	gap: 12px;
	grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
	margin-top: 16px;
}

.ps-studio .ps-tpl__card {
	background: var(--ps-surface, #fff);
	border: 1px solid var(--ps-border);
	border-radius: var(--ps-radius);
	color: var(--ps-text);
	cursor: pointer;
	display: grid;
	gap: 6px;
	padding: 20px;
	text-align: left;
}

.ps-studio .ps-tpl__card:hover,
.ps-studio .ps-tpl__card:focus-visible {
	border-color: var(--ps-text);
}

.ps-tpl__card-title {
	font-size: 1.125rem;
	font-weight: 600;
}

.ps-tpl__card-text {
	color: var(--ps-muted);
	font-size: 0.875rem;
}

.ps-tpl__editor {
	align-items: start;
	display: grid;
	gap: 28px;
	grid-template-columns: minmax(0, 1fr);
}

@media (min-width: 820px) {
	.ps-tpl__editor {
		grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr);
	}

	.ps-tpl__preview {
		position: sticky;
		top: 24px;
	}
}

.ps-tpl__preview {
	align-items: center;
	aspect-ratio: 2 / 3;
	background: var(--ps-surface-alt);
	border-radius: var(--ps-radius);
	display: flex;
	justify-content: center;
	padding: 16px;
	position: relative;
}

.ps-tpl__preview.is-landscape {
	aspect-ratio: 3 / 2;
}

.ps-tpl__preview img {
	box-shadow: 0 6px 24px rgba(0, 0, 0, 0.18);
	display: block;
	max-height: 100%;
	max-width: 100%;
	transition: opacity 0.2s;
}

.ps-tpl__preview .ps-spinner {
	display: none;
	left: 50%;
	position: absolute;
	top: 50%;
	transform: translate(-50%, -50%);
}

.ps-tpl__preview.is-loading img {
	opacity: 0.6;
}

.ps-tpl__preview.is-loading .ps-spinner {
	display: block;
}

.ps-tpl__form {
	display: grid;
	gap: 18px;
}

.ps-studio .ps-tpl__input {
	border: 1px solid var(--ps-border-strong);
	border-radius: var(--ps-radius);
	box-sizing: border-box;
	font: inherit;
	margin: 0;
	min-height: 44px;
	padding: 8px 12px;
	width: 100%;
}

.ps-tpl__place {
	position: relative;
}

.ps-studio .ps-tpl__hint {
	margin-top: 6px;
	text-align: left;
}

.ps-studio .ps-tpl__cities {
	background: #fff;
	border: 1px solid var(--ps-border-strong);
	border-radius: var(--ps-radius);
	box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
	left: 0;
	list-style: none;
	margin: 4px 0 0;
	max-height: 280px;
	overflow: auto;
	padding: 4px 0;
	position: absolute;
	right: 0;
	z-index: 20;
}

.ps-studio .ps-tpl__cities li {
	margin: 0;
}

.ps-studio .ps-tpl__cities button {
	background: none;
	border: 0;
	color: var(--ps-text);
	cursor: pointer;
	font: inherit;
	padding: 10px 14px;
	text-align: left;
	width: 100%;
}

.ps-studio .ps-tpl__cities button:hover,
.ps-studio .ps-tpl__cities button:focus-visible {
	background: var(--ps-surface-alt);
}

.ps-tpl__swatch {
	align-items: center;
	border: 1px solid var(--ps-border-strong);
	border-radius: 50%;
	display: inline-flex;
	font-family: Georgia, serif;
	font-size: 11px;
	height: 26px;
	justify-content: center;
	width: 26px;
}

/* ---------- credit packs ---------- */

.ps-packs {
	display: grid;
	gap: 8px;
}

.ps-packs__list {
	display: grid;
	gap: 8px;
	grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
}

.ps-studio .ps-pack {
	border: 1px solid var(--ps-border);
	border-radius: var(--ps-radius);
	color: var(--ps-text);
	display: grid;
	gap: 2px;
	padding: 12px 14px;
	text-decoration: none;
}

.ps-studio .ps-pack:hover,
.ps-studio .ps-pack:focus-visible {
	border-color: var(--ps-text);
}

.ps-pack__credits {
	font-weight: 600;
}

.ps-pack__price {
	font-size: 1.125rem;
	font-variant-numeric: tabular-nums;
}

.ps-pack__per {
	color: var(--ps-muted);
	font-size: 0.8125rem;
}

/* ---------- theme hardening ----------
 * Themes style bare labels (Flatsome: `input[type=radio] + label { display: inline }`,
 * bold, margins). These rules out-rank them so the studio looks the same everywhere. */

.ps-studio label.ps-size {
	display: grid;
	font-size: inherit;
	font-weight: 400;
	margin: 0;
}

.ps-studio label.ps-segmented__option {
	display: inline-flex;
	font-weight: 400;
	margin: 0;
}

.ps-studio label.ps-button {
	display: inline-flex;
	margin: 0;
}

.ps-studio label.ps-heading {
	display: block;
}

.ps-studio button.ps-tpl__card,
.ps-studio .ps-tpl__cities button {
	font-size: inherit;
	font-weight: 400;
	height: auto;
	letter-spacing: normal;
	line-height: 1.4;
	margin: 0;
	min-height: 0;
	text-transform: none;
	white-space: normal;
}
