/*
 * Portfolio video gallery.
 *
 * Replaces the video-gallery-block plugin. Layout is plain CSS Grid, so column
 * widths are recalculated by the browser during a resize or zoom instead of
 * being repositioned by JavaScript afterwards.
 */

.ra-gallery {
	--ra-gap: 10px;
	--ra-side: 15%;
	--ra-accent: var(--ast-global-color-1, #218848);
	--ra-chip: var(--ast-global-color-3, #000000);
	--ra-ease: cubic-bezier(0.22, 1, 0.36, 1);

	width: 100%;
	background: #ffffff;
}

.ra-gallery--reel {
	--ra-side: 10%;
}

/*
 * The side padding is a percentage, and percentages resolve against the
 * containing block. It has to sit on a child of the full-bleed element so that
 * 15% means 15% of the window, not 15% of the theme's content column.
 */
.ra-gallery__inner {
	box-sizing: border-box;
	width: 100%;
	padding: 10px var(--ra-side);
}

/* ---------------------------------------------------------------- filters */

.ra-gallery__filters {
	display: flex;
	flex-wrap: wrap;
	justify-content: center;
	gap: 12px;
	margin: 0 0 20px;
	padding: 20px 0;
}

.ra-gallery__filter {
	margin: 0;
	padding: 10px 20px;
	border: 0;
	border-radius: 50px;
	background: var(--ra-chip);
	color: #ffffff;
	font-family: inherit;
	font-size: 14px;
	line-height: 1.2;
	cursor: pointer;
	transition: background-color 0.25s ease, transform 0.25s var(--ra-ease);
}

.ra-gallery__filter:hover,
.ra-gallery__filter[aria-pressed='true'] {
	background: var(--ra-accent);
}

.ra-gallery__filter:active {
	transform: scale(0.96);
}

.ra-gallery__filter:focus-visible {
	outline: 2px solid var(--ra-accent);
	outline-offset: 3px;
}

/* ------------------------------------------------------------------- grid */

.ra-gallery__grid {
	display: grid;
	grid-template-columns: repeat(3, minmax(0, 1fr));
	gap: var(--ra-gap);
}

.ra-gallery--reel .ra-gallery__grid {
	grid-template-columns: minmax(0, 1fr);
}

.ra-gallery__item {
	position: relative;
	display: block;
	overflow: hidden;
	aspect-ratio: 16 / 9;
	background: #000000;
	text-decoration: none;
}

.ra-gallery__item[hidden] {
	display: none;
}

.ra-gallery__item:focus-visible {
	outline: 3px solid var(--ra-accent);
	outline-offset: 2px;
}

.ra-gallery__thumb {
	display: block;
	width: 100%;
	height: 100%;
	object-fit: cover;
	transition: transform 0.5s var(--ra-ease);
}

.ra-gallery__item:hover .ra-gallery__thumb,
.ra-gallery__item:focus-visible .ra-gallery__thumb {
	transform: scale(1.045);
}

.ra-gallery__play {
	position: absolute;
	inset: 0;
	display: flex;
	align-items: center;
	justify-content: center;
	opacity: 0;
	background: radial-gradient(circle at center, rgba(0, 0, 0, 0.4) 0%, rgba(0, 0, 0, 0.12) 55%, rgba(0, 0, 0, 0) 75%);
	transition: opacity 0.3s ease;
}

.ra-gallery__item:hover .ra-gallery__play,
.ra-gallery__item:focus-visible .ra-gallery__play {
	opacity: 1;
}

.ra-gallery__play svg {
	width: 15%;
	min-width: 38px;
	max-width: 72px;
	height: auto;
	fill: #ffffff;
	filter: drop-shadow(0 2px 10px rgba(0, 0, 0, 0.55));
	transform: scale(0.82);
	transition: transform 0.35s var(--ra-ease);
}

.ra-gallery__item:hover .ra-gallery__play svg,
.ra-gallery__item:focus-visible .ra-gallery__play svg {
	transform: scale(1);
}

.ra-gallery__empty {
	padding: 40px 0 20px;
	text-align: center;
	color: #666666;
	font-size: 15px;
}

/* --------------------------------------------------------------- lightbox */

.ra-lightbox {
	position: fixed;
	inset: 0;
	z-index: 100000;
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: 14px;
	padding: 64px 20px 28px;
	background: rgba(24, 24, 27, 0.95);
	opacity: 0;
	transition: opacity 0.28s ease;
}

.ra-lightbox.is-open {
	opacity: 1;
}

.ra-lightbox__stage {
	position: relative;
	/* Never taller than the room left over, and clear of the arrow buttons. */
	width: min(calc(100% - 110px), 1536px, calc((100vh - 190px) * 16 / 9));
	width: min(calc(100% - 110px), 1536px, calc((100dvh - 190px) * 16 / 9));
	aspect-ratio: 16 / 9;
	background: #000000;
	box-shadow: 0 24px 70px rgba(0, 0, 0, 0.55);
	transform: scale(0.97);
	transition: transform 0.32s var(--ra-ease, cubic-bezier(0.22, 1, 0.36, 1));
}

.ra-lightbox.is-open .ra-lightbox__stage {
	transform: scale(1);
}

.ra-lightbox__stage iframe {
	display: block;
	width: 100%;
	height: 100%;
	border: 0;
}

.ra-lightbox__caption {
	max-width: min(100%, 1536px);
	margin: 0;
	color: rgba(255, 255, 255, 0.82);
	font-size: 14px;
	line-height: 1.4;
	text-align: center;
}

.ra-lightbox__button {
	position: absolute;
	display: flex;
	align-items: center;
	justify-content: center;
	width: 46px;
	height: 46px;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: rgba(255, 255, 255, 0.1);
	color: #ffffff;
	cursor: pointer;
	transition: background-color 0.22s ease, transform 0.22s var(--ra-ease, ease);
}

.ra-lightbox__button:hover {
	background: rgba(255, 255, 255, 0.22);
}

.ra-lightbox__button:active {
	transform: scale(0.92);
}

.ra-lightbox__button:focus-visible {
	outline: 2px solid #ffffff;
	outline-offset: 3px;
}

.ra-lightbox__button svg {
	width: 20px;
	height: 20px;
	fill: none;
	stroke: currentColor;
	stroke-width: 2;
	stroke-linecap: round;
	stroke-linejoin: round;
}

.ra-lightbox__close {
	top: 14px;
	right: 16px;
}

.ra-lightbox__prev {
	top: 50%;
	left: 16px;
	margin-top: -23px;
}

.ra-lightbox__next {
	top: 50%;
	right: 16px;
	margin-top: -23px;
}

.ra-lightbox__count {
	position: absolute;
	top: 22px;
	left: 20px;
	color: rgba(255, 255, 255, 0.55);
	font-size: 13px;
	letter-spacing: 0.04em;
}

html.ra-lightbox-open,
html.ra-lightbox-open body {
	overflow: hidden;
}

/* ------------------------------------------------------------ responsive */

@media only screen and (max-width: 1024px) {
	.ra-gallery {
		--ra-side: 8%;
	}

	.ra-gallery--reel {
		--ra-side: 6%;
	}

	.ra-gallery__grid {
		grid-template-columns: repeat(2, minmax(0, 1fr));
	}
}

@media only screen and (max-width: 600px) {
	.ra-gallery {
		--ra-side: 5%;
	}

	.ra-gallery--reel {
		--ra-side: 5%;
	}

	.ra-gallery__grid {
		grid-template-columns: minmax(0, 1fr);
	}

	.ra-gallery__filters {
		gap: 8px;
		margin-bottom: 14px;
		padding: 16px 0;
	}

	.ra-gallery__filter {
		padding: 8px 16px;
	}

	.ra-lightbox {
		padding: 58px 12px 22px;
	}

	.ra-lightbox__stage {
		width: min(100%, calc((100vh - 150px) * 16 / 9));
		width: min(100%, calc((100dvh - 150px) * 16 / 9));
	}

	.ra-lightbox__button {
		width: 40px;
		height: 40px;
	}

	.ra-lightbox__prev {
		left: 8px;
	}

	.ra-lightbox__next {
		right: 8px;
	}
}

/* Hover zoom and motion are decoration; drop them if the visitor opts out. */
@media (prefers-reduced-motion: reduce) {
	.ra-gallery__filter,
	.ra-gallery__thumb,
	.ra-gallery__play,
	.ra-gallery__play svg,
	.ra-lightbox,
	.ra-lightbox__stage,
	.ra-lightbox__button {
		transition: none;
	}

	.ra-gallery__item:hover .ra-gallery__thumb,
	.ra-gallery__item:focus-visible .ra-gallery__thumb {
		transform: none;
	}

	.ra-lightbox__stage {
		transform: none;
	}
}
