/* Native Image markup retains responsive sources; standalone tutorial blocks share a soft container. */
.wp-block-image.pst-tutorial-image,
.wp-block-image.is-style-contained {
	display: grid;
	grid-template-columns: minmax(0, 1fr);
	justify-items: center;
	position: relative;
}

.wp-block-image.pst-tutorial-image::before,
.wp-block-image.is-style-contained::before {
	content: "";
	grid-area: 1 / 1;
	place-self: stretch;
	border: 1px solid var(--wp--preset--color--line);
	border-radius: var(--wp--preset--border-radius--md);
	background: var(--wp--preset--color--surface);
}

.wp-block-image:is(.pst-tutorial-image, .is-style-contained) > :where(img, picture, .components-resizable-box__container) {
	grid-area: 1 / 1;
	align-self: center;
	z-index: 1;
	max-width: calc(100% - 32px);
	margin: 16px;
}

.wp-block-image:is(.pst-tutorial-image, .is-style-contained) > figcaption {
	grid-area: 2 / 1;
	justify-self: stretch;
	margin: 10px 0 0;
}

.pst-tutorial-image__open {
	grid-area: 1 / 1;
	align-self: center;
	z-index: 2;
	position: relative;
	padding: 0;
	border: 0;
	background: transparent;
	cursor: zoom-in;
}

.pst-tutorial-image__open[hidden] {
	display: none;
}

.pst-tutorial-image__notice {
	grid-area: 3 / 1;
	justify-self: stretch;
	margin-top: 8px;
	font-size: var(--wp--preset--font-size--x-small);
	color: var(--wp--preset--color--muted);
}

.pst-tutorial-image__cue {
	position: absolute;
	top: 7px;
	right: 7px;
	display: grid;
	place-items: center;
	width: 44px;
	height: 44px;
	border-radius: var(--wp--preset--border-radius--sm);
	background: var(--wp--preset--color--base);
	color: var(--wp--preset--color--contrast);
	box-shadow: 0 1px 5px #0002;
	opacity: 0;
}

.pst-tutorial-image__open:hover .pst-tutorial-image__cue,
.pst-tutorial-image__open:focus-visible .pst-tutorial-image__cue {
	opacity: 1;
}

@media (hover: none) {

	.pst-tutorial-image__cue {
		opacity: 1;
	}
}

dialog.pst-image-viewer {
	position: fixed;
	inset: 0;
	width: min(1400px, calc(100vw - 32px));
	height: calc(100svh - 32px);
	max-width: none;
	max-height: none;
	margin: auto;
	padding: 0;
	border: 0;
	border-radius: var(--wp--preset--border-radius--md);
	background: #111419;
	color: #f8f9fc;
}

.pst-image-viewer::backdrop {
	background: #05080dd6;
}

.pst-image-viewer__layout {
	display: grid;
	grid-template-columns: minmax(0, 1fr);
	grid-template-rows: auto minmax(0, 1fr) auto;
	height: 100%;
}

.pst-image-viewer__toolbar {
	display: flex;
	align-items: center;
	gap: 8px;
	padding: 10px 16px;
}

.pst-image-viewer__toolbar button {
	min-height: 44px;
	padding: 8px 12px;
	border: 1px solid #454c57;
	border-radius: var(--wp--preset--border-radius--sm);
	background: #1c222b;
	color: inherit;
	font: inherit;
	font-size: 0.8125rem;
	cursor: pointer;
}

.pst-image-viewer__size {
	font-size: 0.75rem;
}

.pst-image-viewer__close {
	margin-left: auto;
}

.pst-image-viewer__viewport {
	display: flex;
	align-items: safe center;
	justify-content: safe center;
	min-height: 0;
	min-width: 0;
	overflow: auto;
	overscroll-behavior: contain;
	padding: 16px;
}

.pst-image-viewer :focus-visible {
	outline: 2px solid #84b9ff;
	outline-offset: 2px;
}

.pst-image-viewer__viewport img {
	flex: none;
	max-width: none;
	max-height: none;
}

.pst-image-viewer__caption {
	margin: 0;
	padding: 12px 16px;
	font-size: 0.75rem;
	line-height: 1.6;
}

@media (max-width: 600px) {

	dialog.pst-image-viewer {
		width: 100vw;
		height: 100svh;
		border-radius: 0;
	}
}

.wp-block-image.pst-final-result {
	margin: 0;
	overflow: hidden;
	border-radius: var(--wp--preset--border-radius--lg);
	background: var(--wp--preset--color--surface);
}

.wp-block-image.pst-final-result img {
	display: block;
	width: 100%;
	height: auto;
	max-height: min(66svh, 660px);
	object-fit: contain;
	border-radius: 0;
}

@media (max-width: 782px) {

	.wp-block-image.pst-final-result {
		border-radius: 0;
	}

	.wp-block-image.pst-final-result img {
		max-height: 65svh;
	}
}
