/* Visit St Ives Gallery — justified photo grid + filter tabs */

.vsi-gallery {
	--vsi-row-h: 150px;
	--vsi-gap: 4px;
	--vsi-navy: #0a478b;
	--vsi-grey: #676767;
	--vsi-teal: #73c5c9;
	--vsi-light: #efeeee;
	margin: 0 0 40px;
	clear: both;
}

@media (min-width: 768px) {
	.vsi-gallery { --vsi-row-h: 210px; --vsi-gap: 6px; }
}

@media (min-width: 1200px) {
	.vsi-gallery { --vsi-row-h: 250px; }
}

/* Filter tabs: wrap onto extra lines when they don't fit */
.vsi-gallery__filters {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
	margin: 0 0 24px;
	padding: 2px;
}

.vsi-gallery__filter {
	flex: 0 0 auto;
	margin: 0;
	padding: 8px 18px;
	border: 1px solid var(--vsi-navy);
	border-radius: 999px;
	background: #fff;
	color: var(--vsi-navy);
	font: inherit;
	font-size: 15px;
	line-height: 1.2;
	cursor: pointer;
	transition: background-color .15s ease, color .15s ease;
}
.vsi-gallery__filter:hover { background: var(--vsi-light); }
.vsi-gallery__filter[aria-pressed="true"] {
	background: var(--vsi-navy);
	color: #fff;
}
.vsi-gallery__filter:focus-visible,
.vsi-gallery__item:focus-visible {
	outline: 3px solid var(--vsi-teal);
	outline-offset: 2px;
}

/* Sections */
.vsi-gallery__section + .vsi-gallery__section { margin-top: 36px; }
.vsi-gallery__section[hidden] { display: none; }

.vsi-gallery__heading {
	margin: 0 0 6px;
	color: var(--vsi-grey);
	font-family: "Merlo-Medium", "Helvetica Neue", Helvetica, Arial, sans-serif;
	font-size: 22px;
	line-height: 1.3;
}
.vsi-gallery .vsi-gallery__intro {
	margin: 0;
	padding: 0 0 15px;
	color: var(--vsi-grey);
	max-width: 100%;
}
.vsi-gallery__credit {
	margin: 10px 0 0;
	font-size: 13px;
	color: var(--vsi-grey);
}
.vsi-gallery__credit a { color: var(--vsi-navy); }

/* Justified grid: each tile's grow/basis is proportional to its aspect ratio (--r),
   so every row fills the width and all tiles in a row share the same height. */
.vsi-gallery__grid {
	display: flex;
	flex-wrap: wrap;
	gap: var(--vsi-gap);
	margin: 0;
}
.vsi-gallery__grid::after {
	/* Stops a short last row stretching into giant tiles */
	content: "";
	flex-grow: 999999;
}

.vsi-gallery__item {
	position: relative;
	display: block;
	flex-grow: var(--g, 100);
	flex-shrink: 1;
	flex-basis: calc(var(--r, 1) * var(--vsi-row-h));
	overflow: hidden;
	background: var(--vsi-light);
	cursor: zoom-in;
}
/* Neutralise the theme's link underline/border inside text areas */
.vsi-gallery a.vsi-gallery__item,
.vsi-gallery a.vsi-gallery__item:hover,
.vsi-gallery a.vsi-gallery__item:focus {
	border: 0;
	text-decoration: none;
	box-shadow: none;
}
.vsi-gallery__item::before {
	content: "";
	display: block;
	padding-bottom: calc(100% / var(--r, 1));
}

.vsi-gallery .vsi-gallery__item img {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	max-width: none;
	margin: 0;
	padding: 0;
	border: 0;
	object-fit: cover;
	transition: transform .4s ease, opacity .2s ease;
}

/* Square thumbnails in a 3-column grid (per-section "Layout" option) */
.vsi-gallery__grid--squares {
	display: grid;
	grid-template-columns: repeat(3, minmax(0, 1fr));
}
.vsi-gallery__grid--squares::after { content: none; }
.vsi-gallery__grid--squares .vsi-gallery__item { flex: none; }
.vsi-gallery__grid--squares .vsi-gallery__item::before { padding-bottom: 100%; }

@media (hover: hover) {
	.vsi-gallery__item:hover img { transform: scale(1.04); }
}

@media (prefers-reduced-motion: reduce) {
	.vsi-gallery__item img,
	.vsi-gallery__filter { transition: none; }
	.vsi-gallery__item:hover img { transform: none; }
}

/* Lightbox caption */
.pswp__vsi-caption {
	position: absolute;
	left: 50%;
	bottom: 16px;
	transform: translateX(-50%);
	max-width: min(92vw, 720px);
	padding: 8px 14px;
	border-radius: 4px;
	background: rgba(0, 0, 0, .55);
	color: #fff;
	font-size: 14px;
	line-height: 1.4;
	text-align: center;
	pointer-events: none;
}
.pswp__vsi-caption[hidden] { display: none; }
.pswp__vsi-caption small {
	display: block;
	opacity: .75;
	font-size: 12px;
}
