/* ---------------------------------------------------------------------------
   AMA Lightbox
   Uses <dialog> where available, so the top layer, focus trapping and Esc are
   handled by the browser. The <div> fallback is styled identically.
   --------------------------------------------------------------------------- */

html.ama-lightbox-lock,
html.ama-lightbox-lock body {
	overflow: hidden;
}

.ama-lightbox {
	position: fixed;
	inset: 0;
	z-index: 99999;
	display: flex;
	align-items: center;
	justify-content: center;
	width: 100%;
	max-width: 100%;
	height: 100%;
	max-height: 100%;
	margin: 0;
	padding: 0;
	border: 0;
	background: rgba(17, 17, 17, 0.5);
	color: #fff;
	overflow: hidden;
	overscroll-behavior: contain;
}

.ama-lightbox::backdrop {
	background: rgba(17, 17, 17, 0.15);
}

/* The UA hides a closed <dialog> with `dialog:not([open]) { display: none }`,
   but the display:flex above outranks it — so the overlay would keep painting
   after close(). Restate it at matching specificity. */
dialog.ama-lightbox:not([open]) {
	display: none;
}

/* <dialog> hides itself when closed; the fallback needs telling. */
.ama-lightbox[hidden] {
	display: none;
}

.ama-lightbox__frame {
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: 0.75rem;
	width: 100%;
	height: 100%;
	padding: 3.5rem 1rem 3rem;
	box-sizing: border-box;
}

.ama-lightbox__img {
	display: block;
	max-width: 100%;
	max-height: 100%;
	width: auto;
	height: auto;
	object-fit: contain;
	background: #fff;              /* transparent product PNGs need a backdrop */
	border-radius: 2px;
	opacity: 1;
	transition: opacity 0.2s ease;
}

.ama-lightbox.is-loading .ama-lightbox__img {
	opacity: 0.25;
}

.ama-lightbox__caption {
	max-width: 60ch;
	margin: 0;
	font-size: 0.875rem;
	line-height: 1.5;
	text-align: center;
	color: rgba(255, 255, 255, 0.85);
}

.ama-lightbox__counter {
	position: absolute;
	left: 50%;
	bottom: 0.75rem;
	transform: translateX(-50%);
	margin: 0;
	font-size: 0.8125rem;
	font-variant-numeric: tabular-nums;
	color: rgba(255, 255, 255, 0.7);
}

/* --- controls ------------------------------------------------------------ */

.ama-lightbox__btn {
	position: absolute;
	display: flex;
	align-items: center;
	justify-content: center;
	width: 2.75rem;
	height: 2.75rem;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: rgba(255, 255, 255, 0.12);
	color: #fff;
	cursor: pointer;
	transition: background-color 0.15s ease;
	-webkit-tap-highlight-color: transparent;
	user-select: none
}

.ama-lightbox__btn:hover,
.ama-lightbox__btn:focus-visible {
	background: rgba(255, 255, 255, 0.24);
}

.ama-lightbox__btn:focus-visible {
	outline: 2px solid #fff;
	outline-offset: 2px;
}

.ama-lightbox__btn[hidden] {
	display: none;
}

.ama-lightbox__btn svg {
	width: 1.5rem;
	height: 1.5rem;
	fill: none;
	stroke: currentColor;
	stroke-width: 2;
	stroke-linecap: round;
	stroke-linejoin: round;
}

.ama-lightbox__close {
	top: max(0.75rem, env(safe-area-inset-top));
	right: max(0.75rem, env(safe-area-inset-right));
}

.ama-lightbox__prev {
	top: 50%;
	left: max(0.75rem, env(safe-area-inset-left));
	transform: translateY(-50%);
}

.ama-lightbox__next {
	top: 50%;
	right: max(0.75rem, env(safe-area-inset-right));
	transform: translateY(-50%);
}

/* On narrow screens arrows sit at the bottom, clear of the image. */
@media (max-width: 40rem) {
	.ama-lightbox__prev,
	.ama-lightbox__next {
		top: auto;
		bottom: max(0.75rem, env(safe-area-inset-bottom));
		transform: none;
	}

	.ama-lightbox__counter {
		bottom: 1.75rem;
	}

	.ama-lightbox__frame {
		padding-bottom: 4.5rem;
	}
}

/* --- source images ------------------------------------------------------- */

/* A linked image inside a scope is interactive — say so. */
.editor-content a[href] > img,
.item__content-editor a[href] > img,
.is-item__media a[href] > img {
	cursor: zoom-in;
}

@media (prefers-reduced-motion: reduce) {
	.ama-lightbox__img,
	.ama-lightbox__btn {
		transition: none;
	}
}