/* BS Photo Gallery — front end. Per-gallery values arrive as CSS variables on .bspg. */

/* ---------- Grid ---------- */
.bspg {
	position: relative;
	/* Keep the tiles' internal z-index (title, link) inside the gallery, so theme overlays like the
	   mobile menu stay on top of it. */
	isolation: isolate;
	width: 100%;
	max-width: 100%;
	margin: 0 0 1.5em;
}
.bspg .bspg-items {
	position: relative;
	min-height: 10px;
}
/* Tiles are positioned by bspg.js; keep them hidden until the first layout. */
.bspg:not(.bspg-ready) .bspg-items {
	visibility: hidden;
}
.bspg .bspg-item {
	position: absolute;
	top: 0;
	left: 0;
	box-sizing: border-box;
	overflow: hidden;
	background: var(--bspg-hover-bg, #000);
	border-radius: var(--bspg-radius, 0);
}
.bspg.bspg-animate .bspg-item {
	transition: left .4s, top .4s, width .4s, height .4s, opacity .4s, transform .4s;
}
.bspg .bspg-item.is-hidden {
	opacity: 0;
	transform: scale(.001);
	visibility: hidden;
	pointer-events: none;
	transition: opacity .4s, transform .4s, visibility 0s .4s;
}
.bspg .bspg-item-content {
	position: absolute;
	inset: 0;
	opacity: 0;
	transition: opacity .2s linear;
}
.bspg .bspg-item.is-loaded .bspg-item-content {
	opacity: 1;
}
/* !important: themes commonly force img { height: auto } with high specificity. */
.bspg .bspg-items .bspg-img {
	position: absolute;
	inset: 0;
	display: block;
	width: 100% !important;
	height: 100% !important;
	max-width: none !important;
	max-height: none !important;
	margin: 0;
	padding: 0;
	border: 0;
	border-radius: 0;
	object-fit: cover;
	object-position: var(--bspg-x, 50%) var(--bspg-y, 50%);
	transition: opacity .2s linear, transform .3s linear;
}
/* Hover effects are for pointers that can hover.
 *
 * A touch device has no hover, so iOS Safari synthesises one: the first
 * tap fires mouseover, and if that visibly changes the page it swallows
 * the click and waits for a second tap. With the dim below unguarded,
 * the first tap on a photo only darkened it — the lightbox opened on the
 * second. (And once a tile had been tapped the hover state stuck to it,
 * so it then worked first time, until the next page load.)
 *
 * Guarding these on `hover: hover` means a touch device never has a
 * hover state to apply, so the first tap is a click. Desktop is
 * untouched. The reveal effects below go the same way for the same
 * reason — on touch the title and caption they uncover were only ever
 * reachable by spending a tap on them. */
@media (hover: hover) {
	.bspg .bspg-item:hover .bspg-img {
		opacity: var(--bspg-hover-opacity, .5);
	}
	.bspg .bspg-item.effect-none:hover .bspg-img {
		opacity: 1;
	}
}
.bspg .bspg-link {
	position: absolute;
	inset: 0;
	z-index: 3;
	display: block;
	background: none;
	cursor: zoom-in;
}
.bspg .bspg-link.bspg-external {
	cursor: pointer;
}
/* Themes (e.g. Twenty Twenty-One) give focused links a solid background, which would cover the photo. */
.bspg .bspg-items .bspg-link:focus,
.bspg .bspg-items .bspg-link:hover {
	background: none !important;
	text-decoration: none !important;
	outline: none;
}
.bspg .bspg-items .bspg-link:focus-visible {
	outline: 2px solid #005fcc;
	outline-offset: -2px;
}

/* ---------- Captions ---------- */
.bspg .bspg-figc {
	position: absolute;
	inset: 0;
	z-index: 2;
	color: var(--bspg-text, #fff);
	text-align: center;
	pointer-events: none;
}
.bspg .bspg-title {
	margin: 0;
	font-size: var(--bspg-title, 16px);
	line-height: 1.3;
}
.bspg .bspg-caption {
	margin: 0;
	font-size: var(--bspg-caption, 14px);
}
@media (max-width: 480px) {
	.bspg .bspg-title {
		font-size: var(--bspg-title-m, 12px);
	}
	.bspg .bspg-caption {
		font-size: var(--bspg-caption-m, 10px);
	}
}

/* Effect: pufrobo — title near the top slides up, bar + caption fade in. */
.bspg .effect-pufrobo .bspg-figc {
	text-align: right;
}
.bspg .effect-pufrobo .bspg-title,
.bspg .effect-pufrobo .bspg-caption {
	position: absolute;
	right: 5%;
	left: 5%;
	padding: 10px 0;
}
.bspg .effect-pufrobo .bspg-title {
	top: 10%;
	transform: translate3d(0, 20px, 0);
	transition: transform .35s;
}
.bspg .effect-pufrobo .bspg-title::after {
	content: "";
	position: absolute;
	top: 80%;
	left: 0;
	width: 100%;
	height: 4px;
	background: var(--bspg-text, #fff);
	transform: translate3d(0, 40px, 0);
}
.bspg .effect-pufrobo .bspg-caption {
	bottom: 20%;
	margin-bottom: 2em;
	line-height: 1.5;
	letter-spacing: 1px;
	transform: translate3d(0, 100%, 0);
}
.bspg .effect-pufrobo .bspg-caption,
.bspg .effect-pufrobo .bspg-title::after {
	opacity: 0;
	transition: opacity .35s, transform .35s;
}
@media (hover: hover) {
	.bspg .effect-pufrobo:hover .bspg-title {
		transform: translate3d(0, 0, 0);
	}
	.bspg .effect-pufrobo:hover .bspg-caption,
	.bspg .effect-pufrobo:hover .bspg-title::after {
		margin-top: 10px;
		margin-bottom: 5px;
		opacity: 1;
		transform: translate3d(0, 0, 0);
	}
}

/* Effect: appear — title bottom-left, on hover it slides slightly to the right. */
.bspg .effect-appear .bspg-figc-inner {
	position: absolute;
	bottom: 10px;
	left: 0;
	width: 100%;
	box-sizing: border-box;
	padding: 1em 1.5em 0 10px;
	text-align: left;
	transition: transform .35s;
}
.bspg .effect-appear .bspg-title {
	font-weight: 700;
}
@media (hover: hover) {
	.bspg .effect-appear:hover .bspg-figc-inner {
		transform: translate3d(12px, 0, 0);
	}
}

/* ---------- Filters ---------- */
.bspg .bspg-filters ul {
	margin: 0 0 20px;
	padding: 0;
	list-style: none;
}
.bspg .bspg-filters li {
	display: inline-block;
	margin: 0 10px 0 0;
	padding: 0;
}
.bspg .bspg-filters a {
	display: inline-block;
	line-height: 1;
	color: #333;
	text-decoration: none;
	border-bottom: 1px solid transparent;
	transition: border-color .35s ease-in;
	user-select: none;
}
.bspg .bspg-filters .is-current a {
	border-bottom-color: currentColor;
}
@media (hover: hover) {
	.bspg .bspg-filters a:hover {
		border-bottom-color: currentColor;
	}
}

/* ---------- Lightbox ----------
 * Layout: [top bar: title, counter, buttons] / [stage: photos] / [bottom: caption, thumbnail strip].
 * Photos never sit under the controls; arrows float over the stage edges on desktop.
 */
html.bspg-lb-open {
	overflow: hidden;
}
.bspg-lb {
	--bspg-lb-ink: #f5f5f7;
	--bspg-lb-muted: rgba(245, 245, 247, .62);
	--bspg-lb-glass: rgba(255, 255, 255, .08);
	--bspg-lb-glass-hover: rgba(255, 255, 255, .16);
	--bspg-lb-line: rgba(255, 255, 255, .1);
	--bspg-lb-ease: cubic-bezier(.2, .8, .2, 1);
	position: fixed;
	inset: 0;
	z-index: 99999;
	display: grid;
	/* The column is stated, and stated as minmax(0, 1fr), because the
	   implicit `auto` column it would otherwise get is allowed to grow
	   past the viewport to fit its content — and two children push it
	   there: the top bar (a long gallery title) and the thumbnail strip
	   (one 64px thumb per photo). The grid then measures wider than the
	   screen, the stage inherits that width, and the photo is centred in
	   a box whose right-hand side is off-screen. minmax(0, …) lets the
	   track be narrower than its content, which is what makes the
	   overflow:hidden below actually clip rather than widen.
	   The landscape rule at the bottom of this file already did this for
	   its two columns; the default single-column case did not. */
	grid-template-columns: minmax(0, 1fr);
	grid-template-rows: auto minmax(0, 1fr) auto;
	height: 100vh;
	height: 100dvh;
	/* The track holds every slide side by side; without clipping, mobile browsers count the
	   off-screen slides as page width and zoom the whole page out. */
	overflow: hidden;
	color: var(--bspg-lb-ink);
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
	font-size: 15px;
	line-height: 1.4;
	-webkit-font-smoothing: antialiased;
	-webkit-tap-highlight-color: transparent;
	touch-action: none;
	user-select: none;
	outline: 0;
}

/* Backdrop: deep, slightly translucent, with the page blurred behind it. */
.bspg-lb-bg {
	position: absolute;
	inset: 0;
	z-index: -1;
	background: rgba(12, 12, 14, .92);
	-webkit-backdrop-filter: blur(18px) saturate(120%);
	backdrop-filter: blur(18px) saturate(120%);
	opacity: 0;
	transition: opacity .35s ease;
}
.bspg-lb.is-open .bspg-lb-bg {
	opacity: var(--bspg-lb-fade, 1);
}
.bspg-lb.is-closing .bspg-lb-bg {
	transition-duration: .3s;
}

/* Controls fade in after the photo, and out when idle / hidden by a tap. */
.bspg-lb-top,
.bspg-lb-caption,
.bspg-lb-thumbs,
.bspg-lb .bspg-lb-nav {
	opacity: 0;
	transition: opacity .25s ease;
}
.bspg-lb.is-open .bspg-lb-top,
.bspg-lb.is-open .bspg-lb-caption,
.bspg-lb.is-open .bspg-lb-thumbs,
.bspg-lb.is-open .bspg-lb-nav {
	opacity: 1;
	transition-delay: .1s;
}
.bspg-lb.is-open.is-idle .bspg-lb-top,
.bspg-lb.is-open.is-idle .bspg-lb-nav,
.bspg-lb.is-open.is-chrome-hidden .bspg-lb-top,
.bspg-lb.is-open.is-chrome-hidden .bspg-lb-caption,
.bspg-lb.is-open.is-chrome-hidden .bspg-lb-thumbs,
.bspg-lb.is-open.is-chrome-hidden .bspg-lb-nav,
.bspg-lb.is-open.is-zoomed .bspg-lb-caption,
.bspg-lb.is-open.is-zoomed .bspg-lb-thumbs,
.bspg-lb.is-open.is-zoomed .bspg-lb-nav {
	opacity: 0;
	pointer-events: none;
	transition-delay: 0s;
}

/* Top bar. */
.bspg-lb-top {
	position: relative;
	z-index: 3; /* Above a zoomed photo, which overflows the stage. */
	/* A grid item's automatic minimum size is its content, so without
	   this the title + buttons set a floor the track cannot go below.
	   The title already has overflow:hidden + ellipsis to absorb it. */
	min-width: 0;
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 16px;
	padding: max(12px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) 8px max(20px, env(safe-area-inset-left));
	min-height: 44px;
}
.bspg-lb-info {
	display: flex;
	align-items: baseline;
	gap: 12px;
	min-width: 0;
}
.bspg-lb-title {
	overflow: hidden;
	font-size: 15px;
	font-weight: 600;
	letter-spacing: .01em;
	white-space: nowrap;
	text-overflow: ellipsis;
}
.bspg-lb-title:empty {
	display: none;
}
.bspg-lb-counter {
	flex-shrink: 0;
	color: var(--bspg-lb-muted);
	font-size: 13px;
	font-variant-numeric: tabular-nums;
	letter-spacing: .04em;
}
.bspg-lb-actions {
	display: flex;
	gap: 8px;
	flex-shrink: 0;
}

/* Stage and slides. */
.bspg-lb-stage {
	position: relative;
	z-index: 1;
	min-height: 0;
}
.bspg-lb-track {
	position: absolute;
	inset: 0;
	display: flex;
	gap: 16px;
	will-change: transform;
}
.bspg-lb-track.is-sliding {
	transition: transform .45s var(--bspg-lb-ease);
}
.bspg-lb-slide {
	position: relative;
	flex: 0 0 100%;
	display: flex;
	align-items: center;
	justify-content: center;
	box-sizing: border-box;
	min-width: 0;
	padding: 8px 88px;
	overflow: hidden;
}
.bspg-lb .bspg-lb-img {
	display: block;
	flex: none;
	max-width: none;
	max-height: none;
	margin: 0;
	border-radius: 6px;
	box-shadow: 0 24px 64px rgba(0, 0, 0, .45);
	object-fit: cover;
	transform-origin: 0 0;
	transition: transform .3s var(--bspg-lb-ease), filter .35s ease;
	-webkit-user-drag: none;
}
@media (hover: hover) {
	.bspg-lb .bspg-lb-img {
		cursor: zoom-in;
	}
}
/* Thumbnail shown while the full photo loads. */
.bspg-lb .bspg-lb-img.is-preview {
	filter: blur(6px);
}
.bspg-lb-slide.is-loading::after {
	content: "";
	position: absolute;
	top: 50%;
	left: 50%;
	width: 36px;
	height: 36px;
	margin: -18px 0 0 -18px;
	border: 2px solid rgba(255, 255, 255, .15);
	border-top-color: var(--bspg-lb-ink);
	border-radius: 50%;
	animation: bspg-spin .8s linear infinite;
}
@keyframes bspg-spin {
	to { transform: rotate(360deg); }
}
.bspg-lb-slide.is-zoomed {
	z-index: 1;
	overflow: visible;
}
.bspg-lb-slide.is-zoomed .bspg-lb-img {
	border-radius: 0;
	box-shadow: none;
	cursor: grab;
}
.bspg-lb-slide.is-zoomed.is-panning .bspg-lb-img {
	cursor: grabbing;
}
/* No photo-in / fade when the open animation grows the photo out of its thumbnail. */
.bspg-lb:not(.is-flipping) .bspg-lb-stage {
	opacity: 0;
	transform: scale(.97);
	transition: opacity .3s ease, transform .35s var(--bspg-lb-ease);
}
.bspg-lb.is-open:not(.is-flipping) .bspg-lb-stage {
	opacity: 1;
	transform: none;
}

/* Bottom: caption + thumbnail strip. */
.bspg-lb-bottom {
	padding: 0 0 max(12px, env(safe-area-inset-bottom));
	min-width: 0;
}
.bspg-lb-caption {
	position: relative;
	z-index: 3;
	max-width: 720px;
	max-height: 22vh;
	margin: 0 auto;
	padding: 6px 20px 10px;
	overflow-y: auto;
	color: rgba(245, 245, 247, .82);
	font-size: 14px;
	line-height: 1.5;
	text-align: center;
	user-select: text;
}
.bspg-lb-caption:empty {
	display: none;
}
.bspg-lb-caption strong {
	display: block;
	color: var(--bspg-lb-ink);
	font-weight: 600;
}
.bspg-lb-thumbs {
	position: relative; /* Offset parent for centering the active thumbnail. */
	z-index: 3;
	display: flex;
	gap: 8px;
	padding: 6px max(16px, env(safe-area-inset-left));
	overflow-x: auto;
	scrollbar-width: none;
	touch-action: pan-x;
	overscroll-behavior: contain;
}
.bspg-lb-thumbs::-webkit-scrollbar {
	display: none;
}
.bspg-lb .bspg-lb-thumb {
	flex: none;
	width: 64px;
	height: 48px;
	margin: 0 !important;
	padding: 0 !important;
	overflow: hidden;
	border: 0 !important;
	border-radius: 6px !important;
	background: var(--bspg-lb-glass) !important;
	box-shadow: none !important;
	opacity: .45;
	cursor: pointer;
	transition: opacity .2s ease, box-shadow .2s ease, transform .2s ease;
}
/* Center the strip when it fits, scroll from the start when it does not. */
.bspg-lb .bspg-lb-thumb:first-child {
	margin-left: auto !important;
}
.bspg-lb .bspg-lb-thumb:last-child {
	margin-right: auto !important;
}
.bspg-lb .bspg-lb-thumb img {
	display: block;
	width: 100%;
	height: 100%;
	max-width: none;
	margin: 0;
	object-fit: cover;
	pointer-events: none;
}
@media (hover: hover) {
	.bspg-lb .bspg-lb-thumb:hover {
		opacity: .8;
	}
}
.bspg-lb .bspg-lb-thumb.is-active {
	opacity: 1;
	box-shadow: 0 0 0 2px var(--bspg-lb-ink) !important;
}
.bspg-lb .bspg-lb-thumb:focus:not(:focus-visible) {
	outline: none !important;
}
.bspg-lb .bspg-lb-thumb:focus-visible {
	outline: 2px solid var(--bspg-lb-ink);
	outline-offset: 2px;
}

/* Buttons: round "glass" controls. Reset theme button styles (many themes style every <button>). */
.bspg-lb .bspg-lb-btn {
	display: inline-flex !important;
	align-items: center;
	justify-content: center;
	box-sizing: border-box;
	width: 44px;
	height: 44px;
	min-height: 0;
	margin: 0 !important;
	padding: 0 !important;
	border: 1px solid var(--bspg-lb-line) !important;
	border-radius: 50% !important;
	background: var(--bspg-lb-glass) !important;
	color: var(--bspg-lb-ink) !important;
	box-shadow: none !important;
	-webkit-backdrop-filter: blur(8px);
	backdrop-filter: blur(8px);
	font: inherit;
	line-height: 1;
	text-decoration: none;
	cursor: pointer;
	transition: background-color .2s ease, transform .2s ease, opacity .25s ease;
}
@media (hover: hover) {
	.bspg-lb .bspg-lb-btn:hover {
		background: var(--bspg-lb-glass-hover) !important;
	}
}
.bspg-lb .bspg-lb-btn:active {
	transform: scale(.94);
}
.bspg-lb .bspg-lb-btn:focus:not(:focus-visible) {
	outline: none !important;
}
.bspg-lb .bspg-lb-btn:focus-visible {
	outline: 2px solid var(--bspg-lb-ink) !important;
	outline-offset: 2px;
}
.bspg-lb .bspg-lb-btn svg {
	width: 20px;
	height: 20px;
	fill: none;
	stroke: currentColor;
	stroke-width: 1.75;
	stroke-linecap: round;
	stroke-linejoin: round;
	pointer-events: none;
}
.bspg-lb .bspg-lb-nav {
	position: absolute;
	top: 50%;
	z-index: 2;
	width: 52px;
	height: 52px;
	margin-top: -26px !important;
}
.bspg-lb .bspg-lb-nav:active {
	transform: scale(.94);
}
.bspg-lb .bspg-lb-nav svg {
	width: 24px;
	height: 24px;
	stroke-width: 2;
}
.bspg-lb .bspg-lb-prev {
	left: max(20px, env(safe-area-inset-left));
}
.bspg-lb .bspg-lb-next {
	right: max(20px, env(safe-area-inset-right));
}
.bspg-lb.is-open .bspg-lb-nav[disabled] {
	opacity: .25;
	cursor: default;
	pointer-events: none;
}
.bspg-lb.is-single .bspg-lb-nav,
.bspg-lb.is-single .bspg-lb-counter {
	display: none !important;
}

/* Tablets and phones. */
@media (max-width: 768px) {
	.bspg-lb-slide {
		padding: 4px 64px;
	}
	.bspg-lb .bspg-lb-nav {
		width: 44px;
		height: 44px;
		margin-top: -22px !important;
	}
	.bspg-lb .bspg-lb-prev {
		left: max(10px, env(safe-area-inset-left));
	}
	.bspg-lb .bspg-lb-next {
		right: max(10px, env(safe-area-inset-right));
	}
}
@media (max-width: 600px) {
	.bspg-lb-top {
		padding-left: max(16px, env(safe-area-inset-left));
		padding-right: max(10px, env(safe-area-inset-right));
	}
	.bspg-lb-slide {
		padding: 0;
	}
	.bspg-lb .bspg-lb-img {
		border-radius: 0;
		box-shadow: none;
	}
	.bspg-lb .bspg-lb-thumb {
		width: 44px;
		height: 44px;
	}
	.bspg-lb-thumbs {
		gap: 6px;
	}
	.bspg-lb-caption {
		font-size: 13px;
	}
}
/* Touch screens: swipe instead of arrows. */
@media (hover: none) and (pointer: coarse) {
	.bspg-lb .bspg-lb-nav {
		display: none !important;
	}
	.bspg-lb-slide {
		padding-left: 0;
		padding-right: 0;
	}
}
/* Short landscape screens (phones turned sideways): thumbnails move to a vertical strip on the right,
   so the photo keeps the full height. */
@media (max-height: 500px) and (orientation: landscape) {
	.bspg-lb {
		grid-template-columns: minmax(0, 1fr) auto;
	}
	.bspg-lb-top {
		grid-column: 1 / -1;
		padding-top: max(6px, env(safe-area-inset-top));
		padding-bottom: 4px;
	}
	.bspg-lb-stage {
		grid-column: 1;
		grid-row: 2;
	}
	.bspg-lb-bottom {
		display: contents;
	}
	.bspg-lb-caption {
		grid-column: 1;
		grid-row: 3;
		max-height: 15vh;
		padding-bottom: max(4px, env(safe-area-inset-bottom));
	}
	.bspg-lb-thumbs {
		grid-column: 2;
		grid-row: 2 / 4;
		flex-direction: column;
		gap: 6px;
		padding: 4px max(10px, env(safe-area-inset-right)) max(8px, env(safe-area-inset-bottom)) 6px;
		overflow-x: hidden;
		overflow-y: auto;
		touch-action: pan-y;
	}
	.bspg-lb .bspg-lb-thumb {
		width: 52px;
		height: 40px;
	}
	.bspg-lb .bspg-lb-thumb:first-child {
		margin-left: 0 !important;
		margin-top: auto !important;
	}
	.bspg-lb .bspg-lb-thumb:last-child {
		margin-right: 0 !important;
		margin-bottom: auto !important;
	}
	.bspg-lb .bspg-lb-next {
		right: calc(max(10px, env(safe-area-inset-right)) + 70px);
	}
}
@media (prefers-reduced-motion: reduce) {
	.bspg *,
	.bspg-lb,
	.bspg-lb * {
		transition-duration: 0s !important;
		animation-duration: 0s !important;
	}
}
