/**
 * Finn Village — property galleries.
 *
 * Colour comes in as custom properties written onto the section by the
 * renderer, from the Settings screen, so the gallery follows the brand
 * wherever it is placed rather than hard-coding a palette here.
 *
 * Type deliberately inherits from the theme for body copy and labels — the
 * site sets Lato, and a gallery dropped into a page should look like it
 * belongs to that page. Only the heading reaches for Playfair Display, which
 * is the one face the brand uses for display type.
 */

.fv-gallery {
	/* Fallbacks, for the case where the section renders without its inline
	   variables — a cached fragment, say. These are the plugin defaults. */
	--fv-gold: #c8aa6e;
	--fv-gold-light: #e0c893;
	--fv-cream: #eceadf;
	--fv-cream-soft: #c6c2b2;
	--fv-navy: #1f2c3d;
	--fv-line: rgba(200, 170, 110, 0.28);
	--fv-line-soft: rgba(200, 170, 110, 0.12);

	--fv-gallery-columns: 3;
	--fv-gallery-gap: 14px;
	--fv-gallery-ratio: 4/3;

	margin: 0 0 2.5rem;
}

/* ---------- Heading ---------- */

.fv-gallery__head {
	margin-bottom: 1.5rem;
	text-align: center;
}

/*
 * The site sets its section headings in Playfair with a thin gold rule either
 * side. Matching that here is what stops a gallery reading as a bolted-on
 * plugin.
 */
.fv-gallery__title {
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 1rem;
	margin: 0 0 0.4rem;
	font-family: "Playfair Display", Georgia, "Times New Roman", serif;
	font-weight: 600;
	color: var(--fv-gold);
	line-height: 1.2;
}

.fv-gallery__title::before,
.fv-gallery__title::after {
	content: "";
	flex: 1 1 auto;
	max-width: 110px;
	height: 1px;
	background: var(--fv-line);
}

.fv-gallery__subtitle {
	margin: 0;
	color: var(--fv-cream-soft);
	font-size: 0.95em;
}

.fv-gallery__intro {
	max-width: 62ch;
	margin: 1rem auto 0;
}

/* ---------- Filters ---------- */

.fv-gallery__filters {
	display: flex;
	flex-wrap: wrap;
	justify-content: center;
	gap: 8px;
	margin-bottom: 1.25rem;
}

.fv-gallery__filter {
	display: inline-flex;
	align-items: center;
	gap: 8px;
	padding: 0.45em 1.1em;
	border: 1px solid var(--fv-line);
	border-radius: 999px;
	background: transparent;
	color: inherit;
	font: inherit;
	font-size: 0.9em;
	line-height: 1.4;
	cursor: pointer;
	transition: background-color 0.18s ease, color 0.18s ease, border-color 0.18s ease;
}

.fv-gallery__filter:hover,
.fv-gallery__filter:focus-visible {
	border-color: var(--fv-gold);
	background: var(--fv-line-soft);
}

.fv-gallery__filter.is-active {
	background: var(--fv-gold);
	border-color: var(--fv-gold);
	color: var(--fv-navy);
	font-weight: 600;
}

.fv-gallery__count {
	opacity: 0.7;
	font-variant-numeric: tabular-nums;
	font-size: 0.85em;
}

.fv-gallery__filter.is-active .fv-gallery__count {
	opacity: 0.85;
}

/* ---------- The grid ---------- */

.fv-gallery__grid {
	display: grid;
	grid-template-columns: repeat(var(--fv-gallery-columns), minmax(0, 1fr));
	gap: var(--fv-gallery-gap);
	margin: 0;
	padding: 0;
	list-style: none;
}

.fv-gallery__item {
	margin: 0;
	padding: 0;
	list-style: none;
	min-width: 0;
}

.fv-gallery__item.is-hidden,
.fv-gallery__item.is-capped {
	display: none;
}

.fv-gallery__link,
.fv-gallery__figure {
	position: relative;
	display: block;
	margin: 0;
	overflow: hidden;
	border-radius: 6px;
	border: 1px solid var(--fv-line-soft);
	background: var(--fv-line-soft);
	text-decoration: none;
	color: inherit;
}

.fv-gallery__image {
	display: block;
	width: 100%;
	height: 100%;
	object-fit: cover;
	transition: transform 0.4s ease;
}

.fv-gallery--grid .fv-gallery__link,
.fv-gallery--grid .fv-gallery__figure {
	aspect-ratio: var(--fv-gallery-ratio);
}

.fv-gallery__link:hover .fv-gallery__image,
.fv-gallery__link:focus-visible .fv-gallery__image {
	transform: scale(1.04);
}

.fv-gallery__link:focus-visible {
	outline: 2px solid var(--fv-gold);
	outline-offset: 3px;
}

/* ---------- Captions ---------- */

.fv-gallery__caption {
	position: absolute;
	inset: auto 0 0 0;
	padding: 1.6em 0.9em 0.7em;
	background: linear-gradient(to top, rgba(0, 0, 0, 0.72), transparent);
	color: #fff;
	font-size: 0.85em;
	line-height: 1.35;
	opacity: 0;
	transform: translateY(6px);
	transition: opacity 0.22s ease, transform 0.22s ease;
}

.fv-gallery__link:hover .fv-gallery__caption,
.fv-gallery__link:focus-visible .fv-gallery__caption,
.fv-gallery__figure .fv-gallery__caption {
	opacity: 1;
	transform: none;
}

/* A caption that only appears on hover is unreachable on a touch screen, so
   below the tablet breakpoint it simply stays visible. */
@media (hover: none) {
	.fv-gallery__caption {
		opacity: 1;
		transform: none;
	}
}

/* ---------- Masonry ----------
 *
 * CSS columns rather than a JavaScript layout: no library, no reflow on load,
 * and the tiles keep their own proportions, which is the point of asking for
 * masonry in the first place.
 */

.fv-gallery--masonry .fv-gallery__grid {
	display: block;
	column-count: var(--fv-gallery-columns);
	column-gap: var(--fv-gallery-gap);
}

.fv-gallery--masonry .fv-gallery__item {
	break-inside: avoid;
	margin-bottom: var(--fv-gallery-gap);
}

.fv-gallery--masonry .fv-gallery__image {
	height: auto;
}

/* ---------- Strip ---------- */

.fv-gallery--strip .fv-gallery__grid {
	display: flex;
	overflow-x: auto;
	scroll-snap-type: x mandatory;
	scrollbar-width: thin;
	padding-bottom: 6px;
}

.fv-gallery--strip .fv-gallery__item {
	flex: 0 0 calc((100% - (var(--fv-gallery-columns) - 1) * var(--fv-gallery-gap)) / var(--fv-gallery-columns));
	scroll-snap-align: start;
}

.fv-gallery--strip .fv-gallery__link,
.fv-gallery--strip .fv-gallery__figure {
	aspect-ratio: var(--fv-gallery-ratio);
}

.fv-gallery__more-wrap {
	margin: 1.5rem 0 0;
	text-align: center;
}

/*
 * Reads as a sibling of the filter chips rather than a third thing: same
 * pill, same gold, just wider and plainly a continuation of the set.
 */
.fv-gallery__more {
	display: inline-flex;
	align-items: center;
	gap: 8px;
	padding: 0.6em 1.8em;
	border: 1px solid var(--fv-gold);
	border-radius: 999px;
	background: transparent;
	color: var(--fv-gold);
	font: inherit;
	font-size: 0.92em;
	font-weight: 600;
	line-height: 1.4;
	cursor: pointer;
	transition: background-color 0.18s ease, color 0.18s ease;
}

.fv-gallery__more::after {
	content: "";
	width: 0;
	height: 0;
	border-left: 4px solid transparent;
	border-right: 4px solid transparent;
	border-top: 5px solid currentColor;
}

.fv-gallery__more:hover,
.fv-gallery__more:focus-visible {
	background: var(--fv-gold);
	color: var(--fv-navy);
}

.fv-gallery__more:focus-visible {
	outline: 2px solid var(--fv-gold);
	outline-offset: 3px;
}

.fv-gallery__none {
	margin: 1.5rem 0;
	text-align: center;
	color: var(--fv-cream-soft);
}

.fv-gallery__empty {
	padding: 1rem 1.2rem;
	border: 1px dashed var(--fv-gold);
	border-radius: 6px;
	background: var(--fv-line-soft);
}

/* ---------- Narrow screens ----------
 *
 * Six columns of hot tub on a phone is six thumbnails nobody can see. The
 * column count is capped rather than respected below these widths.
 */

@media (max-width: 900px) {
	.fv-gallery__grid {
		grid-template-columns: repeat(min(var(--fv-gallery-columns), 2), minmax(0, 1fr));
	}

	.fv-gallery--masonry .fv-gallery__grid {
		column-count: min(var(--fv-gallery-columns), 2);
	}

	.fv-gallery--strip .fv-gallery__item {
		flex-basis: 70%;
	}
}

@media (max-width: 560px) {
	.fv-gallery__grid {
		grid-template-columns: minmax(0, 1fr);
	}

	.fv-gallery--masonry .fv-gallery__grid {
		column-count: 1;
	}

	.fv-gallery--strip .fv-gallery__item {
		flex-basis: 86%;
	}

	.fv-gallery__title::before,
	.fv-gallery__title::after {
		max-width: 40px;
	}
}

/* ======================================================================
 * The lightbox
 *
 * Built by the script on first use rather than printed with every gallery,
 * so a page with four galleries on it carries one dialog, not four.
 * ====================================================================== */

.fv-lightbox {
	position: fixed;
	inset: 0;
	z-index: 2147482000;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 3.5rem 1rem;
	background: rgba(8, 10, 24, 0.94);
	opacity: 0;
	visibility: hidden;
	transition: opacity 0.2s ease, visibility 0.2s ease;
}

.fv-lightbox.is-open {
	opacity: 1;
	visibility: visible;
}

.fv-lightbox__figure {
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 0.9rem;
	margin: 0;
	max-width: 100%;
	max-height: 100%;
}

.fv-lightbox__image {
	max-width: 100%;
	max-height: calc(100vh - 9rem);
	width: auto;
	height: auto;
	object-fit: contain;
	border-radius: 4px;
	background: rgba(255, 255, 255, 0.04);
}

.fv-lightbox__caption {
	margin: 0;
	max-width: 60ch;
	text-align: center;
	color: var(--fv-cream, #eceadf);
	font-size: 0.95rem;
	line-height: 1.4;
}

.fv-lightbox__button {
	position: absolute;
	display: flex;
	align-items: center;
	justify-content: center;
	width: 44px;
	height: 44px;
	border: 1px solid rgba(224, 200, 147, 0.35);
	border-radius: 50%;
	background: rgba(8, 10, 24, 0.6);
	color: var(--fv-gold-light, #e0c893);
	font-size: 20px;
	line-height: 1;
	cursor: pointer;
	transition: background-color 0.18s ease, border-color 0.18s ease;
}

.fv-lightbox__button:hover,
.fv-lightbox__button:focus-visible {
	background: rgba(224, 200, 147, 0.16);
	border-color: var(--fv-gold-light, #e0c893);
}

.fv-lightbox__button:focus-visible {
	outline: 2px solid var(--fv-gold-light, #e0c893);
	outline-offset: 2px;
}

.fv-lightbox__close {
	top: 1rem;
	right: 1rem;
}

.fv-lightbox__prev {
	left: 1rem;
	top: 50%;
	transform: translateY(-50%);
}

.fv-lightbox__next {
	right: 1rem;
	top: 50%;
	transform: translateY(-50%);
}

.fv-lightbox__counter {
	position: absolute;
	top: 1.35rem;
	left: 1.25rem;
	color: var(--fv-cream-soft, #c6c2b2);
	font-size: 0.85rem;
	font-variant-numeric: tabular-nums;
}

/* One photograph needs no way to reach the next one. */
.fv-lightbox--single .fv-lightbox__prev,
.fv-lightbox--single .fv-lightbox__next,
.fv-lightbox--single .fv-lightbox__counter {
	display: none;
}

.fv-lightbox__spinner {
	position: absolute;
	width: 34px;
	height: 34px;
	border: 2px solid rgba(224, 200, 147, 0.25);
	border-top-color: var(--fv-gold-light, #e0c893);
	border-radius: 50%;
	animation: fv-lightbox-spin 0.8s linear infinite;
}

@keyframes fv-lightbox-spin {
	to {
		transform: rotate(360deg);
	}
}

.fv-lightbox:not(.is-loading) .fv-lightbox__spinner {
	display: none;
}

/* The page behind must not scroll while the viewer is open. */
html.fv-lightbox-open,
html.fv-lightbox-open body {
	overflow: hidden;
}

@media (max-width: 560px) {
	.fv-lightbox {
		padding: 3.5rem 0.5rem;
	}

	.fv-lightbox__prev {
		left: 0.5rem;
	}

	.fv-lightbox__next {
		right: 0.5rem;
	}
}

@media (prefers-reduced-motion: reduce) {
	.fv-gallery__image,
	.fv-gallery__caption,
	.fv-gallery__filter,
	.fv-gallery__more,
	.fv-lightbox {
		transition: none;
	}

	.fv-gallery__link:hover .fv-gallery__image,
	.fv-gallery__link:focus-visible .fv-gallery__image {
		transform: none;
	}

	.fv-lightbox__spinner {
		animation: none;
	}
}
