/*
 * Gallery lightbox and tiles (pixel-fix plan chunk 03; NISA-50 to -56), as the v6.5 prototype
 * (markup.html, NISA gallery). The overlay is the prototype's literal dark glass in both themes.
 * Divi limitation: Divi's own lightbox opens only the thumbnail, with no counter, caption row or
 * keyboard stepping, and a Group can't show a zoom cursor or a stretched link.
 */

/* Tiles: the whole tile is the link to its full-size picture; prototype hover (0.18s, 3px lift). */
html body .cds-lightbox-gallery > .et_pb_group {
	position: relative;
	cursor: zoom-in;
	transition: border-color 0.18s ease, transform 0.18s ease;
}

html body .cds-lightbox-gallery > .et_pb_group .et_pb_image,
html body .cds-lightbox-gallery > .et_pb_group .et_pb_image_wrap {
	position: static;
}

/* Chunk 09 (parity): the stretched link's own pointer cursor hid the tile's zoom-in cursor (prototype: zoom-in). */
html body .cds-lightbox-gallery > .et_pb_group .et_pb_image a[href] {
	cursor: zoom-in;
}

html body .cds-lightbox-gallery > .et_pb_group .et_pb_image a[href]::after {
	content: "";
	position: absolute;
	inset: 0;
	z-index: 1;
}

html body .cds-lightbox-gallery > .et_pb_group:hover {
	border-color: hsl(from var(--gcid-cds-accent) h s l / 0.5) !important;
	transform: translateY(-3px);
}

/* WCAG 2.4.7: the ring goes round the whole tile while its link has keyboard focus. */
html body .cds-lightbox-gallery > .et_pb_group:has(a[href]:focus-visible) {
	outline: 2px solid var(--gcid-cds-accent);
	outline-offset: 2px;
}

html body .cds-lightbox-gallery > .et_pb_group a[href]:focus-visible {
	outline: none;
}

/* The overlay: a native modal <dialog>, so it sits above the header in the top layer. */
.cds-lightbox {
	position: fixed;
	inset: 0;
	width: 100%;
	height: 100%;
	max-width: none;
	max-height: none;
	margin: 0;
	padding: 48px 84px;
	border: 0;
	box-sizing: border-box;
	overflow: hidden;
	background: rgba(4, 4, 4, 0.94);
	-webkit-backdrop-filter: blur(6px);
	backdrop-filter: blur(6px);
	color: #F2F2F3;
	cursor: zoom-out;
}

.cds-lightbox[open] {
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
}

.cds-lightbox::backdrop {
	background: transparent;
}

.cds-lightbox:focus {
	outline: none;
}

.cds-lightbox__frame {
	display: flex;
	align-items: center;
	justify-content: center;
	min-height: 0;
	cursor: default;
}

.cds-lightbox__img {
	display: block;
	box-sizing: border-box;
	max-width: calc(100vw - 168px);
	max-height: calc(100vh - 188px); /* 96px padding + the prototype's 92px caption allowance: 712px at 900px */
	object-fit: contain;
	border: 1px solid rgba(255, 255, 255, 0.14);
	box-shadow: 0 24px 80px rgba(0, 0, 0, 0.7);
}

.cds-lightbox__caprow {
	display: flex;
	align-items: center;
	gap: 18px;
	max-width: 820px;
	margin: 20px 0 0;
	padding: 0;
	cursor: default;
}

.cds-lightbox__count {
	flex-shrink: 0;
	font-family: var(--gvid-cds-font-mono, "IBM Plex Mono"), monospace;
	font-size: 12px;
	line-height: normal;
	letter-spacing: 0.14em;
	color: #7D8DEB;
}

.cds-lightbox__cap {
	font-family: var(--gvid-cds-font-mono, "IBM Plex Mono"), monospace;
	font-size: 13px;
	line-height: 1.6;
	letter-spacing: 0.06em;
	color: #C9C9C9;
}

.cds-lightbox__nav {
	position: absolute;
	top: 0;
	bottom: 0;
	width: 84px;
	display: flex;
	align-items: center;
	justify-content: center;
	margin: 0;
	padding: 0;
	border: 0;
	background: transparent;
	color: rgba(255, 255, 255, 0.45);
	font-family: inherit;
	font-size: 34px;
	line-height: 1;
	cursor: pointer;
	transition: color 0.18s ease, background-color 0.18s ease;
}

.cds-lightbox__nav--prev {
	left: 0;
}

.cds-lightbox__nav--next {
	right: 0;
}

.cds-lightbox__nav:hover {
	color: #FFFFFF;
	background-color: rgba(255, 255, 255, 0.04);
}

.cds-lightbox__nav:focus-visible {
	outline: 2px solid #7D8DEB;
	outline-offset: -6px;
}

/* WCAG 2.4.7 / 2.1.1: not in the prototype; hidden until it has keyboard focus. */
.cds-lightbox__close {
	position: absolute;
	top: 12px;
	left: 50%;
	transform: translateX(-50%);
	z-index: 2;
	padding: 8px 16px;
	border: 1px solid rgba(255, 255, 255, 0.55);
	border-radius: 100px;
	background: rgba(5, 5, 5, 0.72);
	color: #F2F2F3;
	font-family: inherit;
	font-size: 14px;
	font-weight: 600;
	cursor: pointer;
}

.cds-lightbox__close:not(:focus-visible) {
	width: 1px;
	height: 1px;
	padding: 0;
	overflow: hidden;
	clip-path: inset(50%);
	white-space: nowrap;
	border: 0;
}

.cds-lightbox__close:focus-visible {
	outline: 2px solid #7D8DEB;
	outline-offset: 2px;
}

/* Phone: the 84px side strips and padding left a 222px picture; give the picture the width. The
   strips narrow to 44px (still a 44px touch target) and overlay the picture's edges. */
@media (max-width: 767px) {
	.cds-lightbox {
		padding: 56px 8px;
	}

	.cds-lightbox__img {
		max-width: calc(100vw - 16px);
		max-height: calc(100vh - 188px);
	}

	.cds-lightbox__caprow {
		max-width: 100%;
		padding: 0 36px;
	}

	.cds-lightbox__nav {
		width: 44px;
		top: auto;
		bottom: 0;
		height: 100%;
		z-index: 1;
		background-color: rgba(4, 4, 4, 0.35);
		color: rgba(255, 255, 255, 0.85); /* over the picture: keep the glyph at 3:1 or better (1.4.11) */
	}
}

@media (prefers-reduced-motion: reduce) {
	html body .cds-lightbox-gallery > .et_pb_group:hover {
		transform: none;
	}

	html body .cds-lightbox-gallery > .et_pb_group,
	.cds-lightbox__nav {
		transition: none;
	}
}
