/**
 * Photo gallery for single posts.
 */

.bb-gallery {
	margin: 0 0 20px;
}

/* The theme does not set border-box globally, so keep the gallery self-contained:
   a padded slide must still measure exactly one viewport wide. */
.bb-gallery,
.bb-gallery *,
.bb-gallery *:before,
.bb-gallery *:after,
.bb-photo-link,
.bb-photo-link * {
	box-sizing: border-box;
}

/* The height of this whole component comes from aspect-ratio and absolute
   insets, never from `height`. A responsive AdSense unit stamps
   `height: auto !important` inline on every ancestor of itself, and an inline
   !important beats any rule or inline height we could set -- so nothing here
   is allowed to depend on `height` being ours to control. JS keeps the ratio
   in step with whatever is on screen. */
.bb-gallery__viewport {
	position: relative;
	overflow: hidden;
	border-radius: 16px;
	background: #000;
	aspect-ratio: 3 / 2;
}

.bb-gallery__track {
	position: absolute;
	top: 0;
	right: 0;
	bottom: 0;
	left: 0;
	display: flex;
	transform: translate3d(0, 0, 0);
	transition: transform .35s cubic-bezier(.4, 0, .2, 1);
	will-change: transform;
}

/* No height: the flex line stretches every slide to the track on its own, and
   a stretched auto height survives the ad script rewriting it. */
.bb-gallery__slide {
	position: relative;
	flex: 0 0 100%;
	width: 100%;
}

.bb-gallery__slide--photo {
	display: block;
	line-height: 0;
}

.bb-gallery__slide--photo .bb-gallery__image {
	position: absolute;
	top: 0;
	right: 0;
	bottom: 0;
	left: 0;
	width: 100%;
	height: 100%;
	object-fit: contain;
	display: block;
	margin: 0;
	border-radius: 0;
}

/* Ad slide: an empty, neutral canvas that Ad Inserter fills in production. */
.bb-gallery__slide--ad {
	overflow: hidden;
	display: flex;
	align-items: center;
	justify-content: center;
	background: #f2f3f5;
	padding: 12px;
}

/* The unit carries its own 300x250 inline size, so this box only centres it
   and reserves the room. */
.bb-gallery__ad {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 100%;
	min-height: 250px;
}

/* Arrows -------------------------------------------------------------- */

.bb-gallery .flex-prev-pw,
.bb-gallery .flex-next-pw {
	position: absolute;
	top: 50%;
	transform: translateY(-50%);
	width: 44px;
	height: 44px;
	margin: 0;
	border-radius: 50%;
	background: rgba(24, 24, 24, .55);
	background-repeat: no-repeat;
	background-position: center;
	background-size: 11px 18px;
	cursor: pointer;
	z-index: 3;
	text-indent: 0;
	overflow: visible;
	-webkit-tap-highlight-color: transparent;
	transition: background-color .2s ease, opacity .2s ease;
}

.bb-gallery .flex-prev-pw {
	left: 12px;
	background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='11' height='18' viewBox='0 0 11 18' fill='none'%3E%3Cpath d='M9.5 1.5 2 9l7.5 7.5' stroke='%23fff' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
}

.bb-gallery .flex-next-pw {
	right: 12px;
	background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='11' height='18' viewBox='0 0 11 18' fill='none'%3E%3Cpath d='M1.5 1.5 9 9l-7.5 7.5' stroke='%23fff' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
}

.bb-gallery .flex-prev-pw:hover,
.bb-gallery .flex-next-pw:hover {
	background-color: rgba(24, 24, 24, .75);
}

.bb-gallery .flex-prev-pw:focus-visible,
.bb-gallery .flex-next-pw:focus-visible {
	outline: 2px solid #fff;
	outline-offset: 2px;
}

/* Dots ---------------------------------------------------------------- */

.bb-gallery__dots {
	position: absolute;
	left: 0;
	right: 0;
	bottom: 14px;
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 7px;
	z-index: 3;
	pointer-events: none;
}

.bb-gallery__dot {
	width: 8px;
	height: 8px;
	border-radius: 50%;
	background: rgba(255, 255, 255, .45);
	/* Keeps the dots legible over the light ad slide too. */
	box-shadow: 0 1px 2px rgba(0, 0, 0, .35);
	transition: background-color .2s ease;
}

.bb-gallery__dot.is-active {
	background: #fff;
}

/* Expanded (?photos=1) view ------------------------------------------- */

.bb-gallery--expanded .bb-gallery__viewport {
	transition: aspect-ratio .3s ease;
}

@media (max-width: 480px) {
	.bb-gallery__viewport {
		border-radius: 12px;
	}

	.bb-gallery .flex-prev-pw,
	.bb-gallery .flex-next-pw {
		width: 38px;
		height: 38px;
		background-size: 9px 15px;
	}

	.bb-gallery .flex-prev-pw {
		left: 8px;
	}

	.bb-gallery .flex-next-pw {
		right: 8px;
	}
}

/* Ad hold countdown ---------------------------------------------------- */

.bb-gallery__countdown {
	position: absolute;
	left: 0;
	right: 0;
	bottom: 0;
	display: flex;
	flex-direction: column;
	gap: 6px;
	padding: 10px 14px;
	background: rgba(24, 24, 24, .72);
	color: #fff;
	font-size: 13px;
	line-height: 1.2;
	z-index: 5;
}

.bb-gallery__countdown[hidden] {
	display: none;
}

.bb-gallery__countdown-bar {
	display: block;
	height: 3px;
	border-radius: 2px;
	background: rgba(255, 255, 255, .25);
	overflow: hidden;
}

.bb-gallery__countdown-fill {
	display: block;
	height: 100%;
	width: 100%;
	border-radius: 2px;
	background: #fff;
	transition: width 1s linear;
}

/* While an ad holds the reader there is no way to page past it. */
.bb-gallery.is-locked .flex-prev-pw,
.bb-gallery.is-locked .flex-next-pw {
	display: none;
}

/* Gallery entry points on the article's photos ------------------------ */

.bb-photo-link {
	position: relative;
	display: inline-block;
	max-width: 100%;
	line-height: 0;
	text-decoration: none;
	color: #fff;
	border-radius: 14px;
	/* The arrows hang off the edges on purpose; the photo clips them in half. */
	overflow: hidden;
}

.bb-photo-link img {
	display: block;
	max-width: 100%;
	height: auto;
}

/* The overlays sit on top of the link, which is what actually takes the click. */
.bb-photo-link > span {
	pointer-events: none;
}

/* "View N photos" pill */

.bb-gallery-cta {
	position: absolute;
	left: 50%;
	bottom: 18px;
	transform: translateX(-50%);
	display: inline-flex;
	align-items: center;
	gap: 11px;
	padding: 13px 26px;
	border-radius: 999px;
	border: 1px solid rgba(255, 255, 255, .28);
	background: rgba(18, 18, 18, .82);
	backdrop-filter: blur(6px);
	-webkit-backdrop-filter: blur(6px);
	color: #fff;
	font-size: 17px;
	font-weight: 600;
	line-height: 1;
	white-space: nowrap;
	box-shadow: 0 6px 18px rgba(0, 0, 0, .32);
}

.bb-gallery-cta__icon {
	display: block;
	flex: 0 0 auto;
}

/* Lead photo: arrows and an expand control */

.bb-photo-arrow {
	position: absolute;
	top: 50%;
	display: flex;
	align-items: center;
	width: 84px;
	height: 84px;
	margin-top: -42px;
	border-radius: 50%;
	background: rgba(20, 20, 20, .58);
	color: #fff;
}

.bb-photo-arrow--prev {
	left: -40px;
	justify-content: flex-end;
	padding-right: 13px;
}

.bb-photo-arrow--next {
	right: -40px;
	justify-content: flex-start;
	padding-left: 13px;
}

.bb-photo-expand {
	position: absolute;
	top: 16px;
	right: 16px;
	display: flex;
	align-items: center;
	justify-content: center;
	width: 52px;
	height: 52px;
	border-radius: 50%;
	background: rgba(20, 20, 20, .72);
	color: #fff;
}

.bb-photo-expand svg {
	display: block;
}

.bb-photo-zoom {
	position: absolute;
	top: 50%;
	left: 50%;
	transform: translate(-50%, -50%);
	display: block;
	color: rgba(255, 255, 255, .85);
	filter: drop-shadow(0 2px 6px rgba(0, 0, 0, .45));
}

.bb-photo-zoom svg {
	display: block;
}

@media (max-width: 480px) {
	.bb-photo-link {
		border-radius: 10px;
	}

	.bb-gallery-cta {
		bottom: 12px;
		gap: 8px;
		padding: 10px 18px;
		font-size: 15px;
	}

	.bb-gallery-cta__icon {
		width: 19px;
		height: 19px;
	}

	.bb-photo-arrow {
		width: 62px;
		height: 62px;
		margin-top: -31px;
	}

	.bb-photo-arrow--prev {
		left: -28px;
		padding-right: 9px;
	}

	.bb-photo-arrow--next {
		right: -28px;
		padding-left: 9px;
	}

	.bb-photo-expand {
		top: 10px;
		right: 10px;
		width: 40px;
		height: 40px;
	}

	.bb-photo-expand svg {
		width: 19px;
		height: 19px;
	}

	.bb-photo-zoom svg {
		width: 54px;
		height: 54px;
	}
}

/* Related posts under the gallery ------------------------------------- */

.bb-related {
	margin: 24px 0 8px;
}

.bb-related__title {
	margin: 0 0 14px;
	font-size: 20px;
}

.bb-related__grid {
	display: grid;
	grid-template-columns: repeat(3, 1fr);
	gap: 18px;
}

.bb-related__card {
	display: block;
	text-decoration: none;
	color: inherit;
}

.bb-related__thumb {
	display: block;
	overflow: hidden;
	border-radius: 10px;
	background: #eceef1;
	aspect-ratio: 16 / 10;
}

.bb-related__thumb img {
	width: 100%;
	height: 100%;
	object-fit: cover;
	display: block;
}

.bb-related__name {
	display: block;
	margin-top: 8px;
	font-size: 15px;
	font-weight: 600;
	line-height: 1.3;
}

.bb-related__card:hover .bb-related__name {
	text-decoration: underline;
}

@media (max-width: 600px) {
	.bb-related__grid {
		grid-template-columns: repeat(2, 1fr);
		gap: 14px;
	}

	.bb-related__name {
		font-size: 14px;
	}
}

/* The title is a link in both views, but it must still read as a heading. */
.entry-title a {
	color: inherit;
	text-decoration: none;
}

.entry-title a:hover {
	text-decoration: underline;
}
