/* Sear Genius Gallery: front end */

.sgg {
	container-type: inline-size;
	width: 100%;
	margin-block: 1.5em;
}

.sgg .sgg__grid {
	--sgg-cols: var(--sgg-cols-d);
	--sgg-h: var(--sgg-h-d);
}

/* The layout responds to the gallery's own width, so it also works in sidebars and narrow columns. */
@container (max-width: 1000px) {
	.sgg .sgg__grid {
		--sgg-cols: var(--sgg-cols-t);
	}
}

@container (max-width: 600px) {
	.sgg .sgg__grid {
		--sgg-cols: var(--sgg-cols-m);
		--sgg-h: var(--sgg-h-m);
	}
}

.sgg .sgg__item {
	position: relative;
	display: block;
	min-width: 0;
	margin: 0;
	padding: 0;
	overflow: hidden;
	aspect-ratio: var(--sgg-ar);
	border-radius: var(--sgg-radius);
	background: rgba(127, 127, 127, 0.12);
}

.sgg .sgg__link {
	display: block;
	width: 100%;
	height: 100%;
	border: 0;
	box-shadow: none;
	cursor: zoom-in;
}

.sgg .sgg__link:focus-visible {
	outline: 3px solid currentColor;
	outline-offset: -3px;
}

.sgg .sgg__img {
	display: block;
	width: 100%;
	max-width: none;
	height: 100%;
	margin: 0;
	padding: 0;
	border: 0;
	border-radius: 0;
	box-shadow: none;
	object-fit: cover;
	transition: transform 0.35s ease;
}

.sgg .sgg__link:hover .sgg__img,
.sgg .sgg__link:focus-visible .sgg__img {
	transform: scale(1.03);
}

/*
 * These layouts apply until the placement script runs, and in the block editor preview.
 * Justified: each image grows in proportion to its aspect ratio, so images in a row share a height.
 */
.sgg--justified .sgg__grid {
	display: flex;
	flex-wrap: wrap;
	gap: var(--sgg-gap);
}

.sgg--justified .sgg__item {
	flex-grow: var(--sgg-ar);
	flex-shrink: 1;
	flex-basis: calc(var(--sgg-ar) * var(--sgg-h));
}

/* Absorbs the spare space in the last row so its images stay at the target height. */
.sgg--justified .sgg__grid::after {
	content: "";
	flex: 999999 0 0;
}

.sgg--last-row-fill .sgg__grid::after {
	content: none;
}

.sgg--masonry .sgg__grid {
	column-count: var(--sgg-cols);
	column-gap: var(--sgg-gap);
}

.sgg--masonry .sgg__item {
	margin-bottom: var(--sgg-gap);
	break-inside: avoid;
}

/* Positioned by the placement script. */
.sgg .sgg__grid.is-placed {
	position: relative;
	display: block;
	column-count: auto;
}

.sgg .sgg__grid.is-placed::after {
	content: none;
}

.sgg .sgg__grid.is-placed .sgg__item {
	position: absolute;
	margin: 0;
	aspect-ratio: auto;
}

.sgg .sgg__item--video {
	background: #17181a;
}

.sgg .sgg__link--video {
	cursor: pointer;
}

.sgg .sgg__play {
	position: absolute;
	top: 50%;
	left: 50%;
	display: flex;
	align-items: center;
	justify-content: center;
	width: clamp(44px, 22%, 68px);
	aspect-ratio: 1;
	border-radius: 50%;
	background: rgba(0, 0, 0, 0.6);
	color: #fff;
	pointer-events: none;
	transform: translate(-50%, -50%);
	transition: background-color 0.2s ease;
}

.sgg .sgg__play svg {
	display: block;
	width: 58%;
	height: 58%;
	fill: currentColor;
}

.sgg .sgg__link--video:hover .sgg__play,
.sgg .sgg__link--video:focus-visible .sgg__play {
	background: rgba(0, 0, 0, 0.85);
}

/* Captions */
.sgg .sgg__caption {
	position: absolute;
	inset: auto 0 0;
	margin: 0;
	padding: 2.2em 0.85em 0.7em;
	background: linear-gradient(to top, rgba(0, 0, 0, 0.72), rgba(0, 0, 0, 0));
	color: #fff;
	font-size: 0.875rem;
	line-height: 1.35;
	text-align: left;
	pointer-events: none;
}

.sgg--captions-hover .sgg__caption {
	opacity: 0;
	transition: opacity 0.2s ease;
}

.sgg--captions-hover .sgg__item:hover .sgg__caption,
.sgg--captions-hover .sgg__item:focus-within .sgg__caption {
	opacity: 1;
}

/* Touch screens have no hover, so captions stay visible. */
@media (hover: none) {
	.sgg--captions-hover .sgg__caption {
		opacity: 1;
	}
}

@media (prefers-reduced-motion: reduce) {
	.sgg .sgg__img,
	.sgg--captions-hover .sgg__caption {
		transition: none;
	}

	.sgg .sgg__link:hover .sgg__img,
	.sgg .sgg__link:focus-visible .sgg__img {
		transform: none;
	}
}

/* Lightbox */
html.sgg-lb-open {
	overflow: hidden;
}

.sgg-lb {
	position: fixed;
	inset: 0;
	width: 100%;
	max-width: none;
	height: 100%;
	max-height: none;
	margin: 0;
	padding: 0;
	overflow: hidden;
	border: 0;
	background: #0b0b0c;
	color: #fff;
	font: 400 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

.sgg-lb::backdrop {
	background: #0b0b0c;
}

.sgg-lb__stage {
	position: absolute;
	inset: 0;
	display: flex;
	align-items: center;
	justify-content: center;
	overflow: hidden;
	padding: 56px 16px;
	touch-action: none;
	user-select: none;
	-webkit-user-select: none;
}

.sgg-lb.has-caption .sgg-lb__stage {
	padding-bottom: 88px;
}

.sgg-lb__img {
	display: block;
	max-width: 100%;
	max-height: 100%;
	width: auto;
	height: auto;
	margin: 0;
	padding: 0;
	border: 0;
	border-radius: 0;
	box-shadow: none;
	object-fit: contain;
	cursor: zoom-in;
	opacity: 0;
	transform-origin: 0 0;
	transition: opacity 0.2s ease;
	-webkit-user-drag: none;
}

.sgg-lb__img.is-ready {
	opacity: 1;
}

.sgg-lb.is-zoomed .sgg-lb__img {
	cursor: grab;
}

.sgg-lb.is-dragging .sgg-lb__img {
	cursor: grabbing;
}

.sgg-lb__spinner {
	position: absolute;
	top: 50%;
	left: 50%;
	width: 36px;
	height: 36px;
	margin: -18px 0 0 -18px;
	border: 3px solid rgba(255, 255, 255, 0.25);
	border-top-color: #fff;
	border-radius: 50%;
	opacity: 0;
	pointer-events: none;
	animation: sgg-spin 0.8s linear infinite;
	transition: opacity 0.15s ease 0.15s;
}

.sgg-lb.is-loading .sgg-lb__spinner {
	opacity: 1;
}

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

.sgg-lb__bar {
	position: absolute;
	inset: 0 0 auto;
	z-index: 2;
	display: flex;
	align-items: center;
	gap: 4px;
	height: 56px;
	padding: 0 8px 0 18px;
	pointer-events: none;
}

.sgg-lb__counter {
	margin-right: auto;
	font-variant-numeric: tabular-nums;
	opacity: 0.85;
}

.sgg-lb .sgg-lb__btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 44px;
	height: 44px;
	min-width: 0;
	margin: 0;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: transparent;
	box-shadow: none;
	color: #fff;
	cursor: pointer;
	pointer-events: auto;
	transition: background-color 0.15s ease;
}

.sgg-lb .sgg-lb__btn:hover {
	background: rgba(255, 255, 255, 0.16);
	color: #fff;
}

.sgg-lb .sgg-lb__btn:focus-visible {
	outline: 2px solid #fff;
	outline-offset: 1px;
}

.sgg-lb .sgg-lb__btn svg {
	display: block;
	width: 24px;
	height: 24px;
	fill: none;
	stroke: currentColor;
	stroke-width: 2;
	stroke-linecap: round;
	stroke-linejoin: round;
}

.sgg-lb .sgg-lb__nav {
	position: absolute;
	top: 50%;
	z-index: 2;
	margin-top: -24px;
	width: 48px;
	height: 48px;
	background: rgba(0, 0, 0, 0.45);
}

.sgg-lb .sgg-lb__nav:hover {
	background: rgba(0, 0, 0, 0.75);
}

.sgg-lb__prev {
	left: 12px;
}

.sgg-lb__next {
	right: 12px;
}

.sgg-lb.is-single .sgg-lb__nav,
.sgg-lb.is-single .sgg-lb__counter {
	visibility: hidden;
}

.sgg-lb.is-zoomed .sgg-lb__nav {
	opacity: 0.35;
}

.sgg-lb__caption {
	position: absolute;
	inset: auto 0 0;
	z-index: 2;
	max-height: 88px;
	overflow-y: auto;
	margin: 0;
	padding: 12px 20px 18px;
	text-align: center;
}

.sgg-lb__caption:empty {
	display: none;
}

.sgg-lb.is-zoomed .sgg-lb__caption {
	display: none;
}

.sgg-lb__video {
	display: none;
	flex: none;
	background: #000;
}

.sgg-lb__video iframe,
.sgg-lb__video video {
	display: block;
	width: 100%;
	height: 100%;
	margin: 0;
	padding: 0;
	border: 0;
}

.sgg-lb.is-video .sgg-lb__video {
	display: block;
}

.sgg-lb.is-video .sgg-lb__img,
.sgg-lb.is-video .sgg-lb__zoom {
	display: none;
}

@media (min-width: 601px) {
	.sgg-lb.is-video .sgg-lb__stage {
		padding-right: 72px;
		padding-left: 72px;
	}
}

@media (max-width: 600px) {
	.sgg-lb .sgg-lb__nav {
		display: none;
	}
}

@media (prefers-reduced-motion: reduce) {
	.sgg-lb__img,
	.sgg-lb__spinner {
		transition: none;
	}
}
