/* Sonido Gallery - Public gallery styles */

.sonido-gallery,
.sonido-gallery *,
.sonido-gallery *::before,
.sonido-gallery *::after {
	box-sizing: border-box;
}

.sonido-gallery {
	--sg-cols: 4;
	--sg-cols-tablet: 2;
	--sg-cols-mobile: 1;
	--sg-gap: 10px;

	display: flex;
	flex-wrap: wrap;
	justify-content: center;
	gap: var(--sg-gap);
	margin: 1.5em 0;
}

/*
 * Item sizing.
 *
 * Flexbox layout with justify-content:center naturally centers every row,
 * including incomplete last rows. Each item targets 1/N of the container
 * width at each breakpoint, computed with the columns variable.
 */
.sonido-gallery__item {
	flex: 0 1 auto;
	width: calc((100% - (var(--sg-cols-mobile) - 1) * var(--sg-gap)) / var(--sg-cols-mobile));
	max-width: 100%;
}

@media (min-width: 600px) {
	.sonido-gallery__item {
		width: calc((100% - (var(--sg-cols-tablet) - 1) * var(--sg-gap)) / var(--sg-cols-tablet));
	}
}

@media (min-width: 992px) {
	.sonido-gallery__item {
		width: calc((100% - (var(--sg-cols) - 1) * var(--sg-gap)) / var(--sg-cols));
	}
}

/*
 * "Large" thumbnail size override.
 *
 * When the user picks the large size, each thumbnail cell is forced to a
 * fixed 300x300 square. On small viewports the cell falls back to nearly
 * full width so the image remains visible without horizontal overflow.
 */
.sonido-gallery[data-pswp-size="large"] .sonido-gallery__item {
	flex: 0 0 300px;
	max-width: 300px;
}

@media (max-width: 599px) {
	.sonido-gallery[data-pswp-size="large"] .sonido-gallery__item {
		flex-basis: calc(100% - 2 * var(--sg-gap));
		max-width: calc(100% - 2 * var(--sg-gap));
	}
}

.sonido-gallery__item {
	margin: 0;
	overflow: hidden;
	position: relative;
}

.sonido-gallery__link {
	display: block;
	line-height: 0;
	overflow: hidden;
	position: relative;
	text-decoration: none;
}

.sonido-gallery__img {
	aspect-ratio: 1 / 1;
	display: block;
	height: auto;
	object-fit: cover;
	transition: transform 350ms ease;
	width: 100%;
}

.sonido-gallery--rounded .sonido-gallery__img,
.sonido-gallery--rounded .sonido-gallery__link {
	border-radius: 8px;
}

.sonido-gallery--rounded .sonido-gallery__link {
	overflow: hidden;
}

.sonido-gallery__link:hover .sonido-gallery__img,
.sonido-gallery__link:focus-visible .sonido-gallery__img {
	transform: scale(1.04);
}

.sonido-gallery__link:focus-visible {
	outline: 2px solid #2271b1;
	outline-offset: 2px;
}

.sonido-gallery__caption {
	background: #f6f7f7;
	color: #1f2937;
	font-size: 0.875rem;
	line-height: 1.45;
	padding: 8px 10px;
}

.sonido-gallery--caption-overlay .sonido-gallery__caption {
	background: linear-gradient(to bottom, transparent, rgba(0, 0, 0, 0.78));
	color: #fff;
	left: 0;
	padding: 36px 12px 12px;
	position: absolute;
	right: 0;
	transform: translateY(100%);
	transition: transform 280ms ease;
}

.sonido-gallery--caption-overlay .sonido-gallery__link:hover .sonido-gallery__caption,
.sonido-gallery--caption-overlay .sonido-gallery__link:focus-visible .sonido-gallery__caption {
	transform: translateY(0);
}

.sonido-gallery--caption-none .sonido-gallery__caption {
	display: none;
}

/*
 * PhotoSwipe reset.
 *
 * Vendored PhotoSwipe CSS relies on .pswp img { max-width: none; } to size
 * slides correctly. Many themes ship img { max-width: 100%; } with a higher
 * specificity selector (e.g. body.theme-name img) which overrides it and
 * collapses slide images to 0px width inside .pswp__zoom-wrap. Force the
 * reset here with !important so any theme loses the fight.
 */
.pswp img {
	max-width: none !important;
	height: auto !important;
}

.pswp .pswp__zoom-wrap {
	width: auto !important;
	height: auto !important;
}

/*
 * PhotoSwipe button reset.
 *
 * The vendored PhotoSwipe CSS declares its own .pswp__button rules, but many
 * themes apply button:focus / button:focus-visible outlines (often a red
 * brand color) with selectors that outrank PhotoSwipe's. The buttons end up
 * framed in a colored ring that breaks the popup UI. Force-reset outline
 * and box-shadow here with !important on every interactive state, then add
 * a single neutral :focus-visible ring for accessibility.
 */
.pswp button,
.pswp button:focus,
.pswp button:focus-visible,
.pswp button:hover,
.pswp button:active,
.pswp .pswp__button,
.pswp .pswp__button:focus,
.pswp .pswp__button:focus-visible,
.pswp .pswp__button:hover,
.pswp .pswp__button:active,
.pswp .pswp__button--arrow,
.pswp .pswp__button--arrow:focus,
.pswp .pswp__button--arrow:focus-visible,
.pswp .pswp__button--arrow:hover,
.pswp .pswp__button--arrow:active {
	outline: none !important;
	outline-offset: 0 !important;
	box-shadow: none !important;
	border-color: transparent !important;
}

.pswp button:focus-visible,
.pswp .pswp__button:focus-visible {
	outline: 2px solid rgba(255, 255, 255, 0.85) !important;
	outline-offset: 2px !important;
}
