/* Media lightbox (image, video, YouTube). Trigger matches the diagram expand button. */

[data-forwp-media-lightbox-host] {
	position: relative;
}

[data-forwp-media-lightbox-host] img {
	cursor: zoom-in;
}

.forwp-media-lightbox__open {
	position: absolute;
	top: 0.5rem;
	right: 0.5rem;
	z-index: 3;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 32px;
	height: 32px;
	padding: 0;
	border: 1px solid rgba(0, 0, 0, 0.12);
	border-radius: 8px;
	background: rgba(255, 255, 255, 0.92);
	color: #334155;
	box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
	cursor: zoom-in;
	opacity: 0.85;
	transition: opacity 0.15s ease;
}

.forwp-media-lightbox__open.is-bottom {
	top: auto;
	bottom: 0.75rem;
	right: 0.75rem;
}

.forwp-media-lightbox__open:hover,
.forwp-media-lightbox__open:focus-visible,
[data-forwp-media-lightbox-host]:hover .forwp-media-lightbox__open {
	opacity: 1;
}

.forwp-media-lightbox {
	position: fixed;
	inset: 0;
	z-index: 100000;
	display: flex;
	flex-direction: column;
	background: rgba(13, 17, 23, 0.96);
	color: #e2e8f0;
}

.forwp-media-lightbox__bar {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 1rem;
	padding: 0.5rem 0.75rem 0.5rem 1rem;
	border-bottom: 1px solid rgba(127, 127, 127, 0.2);
	font: 14px/1.3 -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.forwp-media-lightbox__title {
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
	opacity: 0.85;
}

.forwp-media-lightbox__close {
	display: inline-flex;
	flex: none;
	align-items: center;
	justify-content: center;
	width: 36px;
	height: 36px;
	padding: 0;
	border: 1px solid rgba(127, 127, 127, 0.3);
	border-radius: 8px;
	background: transparent;
	color: inherit;
	cursor: pointer;
}

.forwp-media-lightbox__close:hover,
.forwp-media-lightbox__close:focus-visible {
	background: rgba(127, 127, 127, 0.15);
}

.forwp-media-lightbox__stage {
	--forwp-mlb-h: calc(100vh - 53px - 2rem);
	display: flex;
	flex: 1;
	align-items: center;
	justify-content: center;
	min-height: 0;
	padding: 1rem;
	cursor: zoom-out;
}

.forwp-media-lightbox__frame {
	display: flex;
	align-items: center;
	justify-content: center;
	max-width: 100%;
	max-height: 100%;
	cursor: auto;
}

.forwp-media-lightbox__media {
	display: block;
	border: 0;
	border-radius: 8px;
	background: #000;
}

/* Image: fit the viewport. */
.forwp-media-lightbox.is-image .forwp-media-lightbox__media {
	max-width: 100%;
	max-height: var(--forwp-mlb-h);
	width: auto;
	height: auto;
	object-fit: contain;
	background: transparent;
}

/* Short (9:16): full viewport height. */
.forwp-media-lightbox.is-short .forwp-media-lightbox__media {
	height: min(var(--forwp-mlb-h), calc((100vw - 2rem) * 16 / 9));
	width: min(calc(var(--forwp-mlb-h) * 9 / 16), calc(100vw - 2rem));
	aspect-ratio: 9 / 16;
}

/* Landscape (16:9) and unknown video format. */
.forwp-media-lightbox:not(.is-image):not(.is-short) .forwp-media-lightbox__media {
	width: min(calc(100vw - 2rem), calc(var(--forwp-mlb-h) * 16 / 9));
	aspect-ratio: 16 / 9;
	height: auto;
}

@media (max-width: 600px) {
	.forwp-media-lightbox__stage {
		padding: 0.5rem;
	}
}
