/*
 * LPC Gallery
 * Matched to the Lost Prairie Cabins site (Genesis / Altitude Pro):
 * fonts inherit from the theme (Mukta), gold accent #ce9308, square corners,
 * 10px gaps, uppercase letter-spaced buttons, 0.2s ease-in-out transitions.
 * Colours use currentColor so the gallery reads correctly on the dark
 * #242424 bands and on white pages without separate settings.
 */

.lpc-gallery {
	--lpc-gap: 10px;
	--lpc-accent: var(--wp--preset--color--theme-primary, #ce9308);
	--lpc-accent-text: #000;
	--lpc-ease: 0.2s ease-in-out;
	margin: 0 0 30px;
	color: inherit;
	font-family: inherit;
}

.lpc-gallery:last-child {
	margin-bottom: 0;
}

/* ---------- Filter buttons ---------- */

.lpc-gallery__filters {
	display: flex;
	flex-wrap: wrap;
	gap: 10px;
	margin: 0 0 24px;
	padding: 0;
}

/* Two-class selectors so the theme's global button / button:hover rules don't win. */
.lpc-gallery .lpc-gallery__filter {
	-webkit-appearance: none;
	appearance: none;
	display: inline-block;
	width: auto;
	min-width: 0;
	height: auto;
	margin: 0;
	padding: 13px 22px 11px;
	border: 1px solid currentColor;
	border-color: color-mix(in srgb, currentColor 40%, transparent);
	border-radius: 0;
	background: transparent;
	box-shadow: none;
	color: inherit;
	font-family: inherit;
	font-size: 14px;
	font-weight: 800;
	line-height: 1;
	letter-spacing: 2px;
	text-transform: uppercase;
	text-decoration: none;
	white-space: nowrap;
	cursor: pointer;
	transition: background-color var(--lpc-ease), border-color var(--lpc-ease), color var(--lpc-ease), box-shadow var(--lpc-ease);
}

.lpc-gallery .lpc-gallery__filter:hover {
	background: transparent;
	border-color: var(--lpc-accent);
	color: inherit;
	box-shadow: none;
}

.lpc-gallery .lpc-gallery__filter.is-active,
.lpc-gallery .lpc-gallery__filter.is-active:hover {
	background: var(--lpc-accent);
	border-color: var(--lpc-accent);
	color: var(--lpc-accent-text);
	box-shadow: inset 0 0 200px rgba(255, 255, 255, 0);
}

.lpc-gallery .lpc-gallery__filter.is-active:hover {
	/* Same subtle lift the theme's buttons use. */
	box-shadow: inset 0 0 200px rgba(255, 255, 255, 0.15);
}

.lpc-gallery .lpc-gallery__filter:focus {
	outline: none;
}

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

/* ---------- Grid ---------- */

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

.lpc-gallery .lpc-gallery__item {
	position: relative;
	min-width: 0;
	margin: 0;
	padding: 0;
}

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

.lpc-gallery .lpc-gallery__link {
	display: block;
	position: relative;
	overflow: hidden;
	aspect-ratio: var(--lpc-ratio, 4/3);
	background: rgba(128, 128, 128, 0.15);
	border: 0;
	box-shadow: none;
	text-decoration: none;
	cursor: zoom-in;
}

.lpc-gallery--ratio-auto .lpc-gallery__link {
	aspect-ratio: auto;
}

.lpc-gallery .lpc-gallery__img {
	display: block;
	width: 100%;
	height: 100%;
	max-width: none;
	margin: 0;
	padding: 0;
	border: 0;
	border-radius: 0;
	object-fit: cover;
	transition: transform 0.4s ease-in-out, opacity var(--lpc-ease);
}

.lpc-gallery--ratio-auto .lpc-gallery__img {
	height: auto;
}

.lpc-gallery .lpc-gallery__link:hover .lpc-gallery__img {
	transform: scale(1.03);
}

.lpc-gallery .lpc-gallery__link:focus {
	outline: none;
}

.lpc-gallery .lpc-gallery__link:focus-visible {
	outline: 2px solid var(--lpc-accent);
	outline-offset: 2px;
}

.lpc-gallery .lpc-gallery__caption {
	margin: 10px 0 0;
	padding: 0;
	color: inherit;
	opacity: 0.85;
	font-family: inherit;
	font-size: 16px;
	font-weight: 400;
	font-style: normal;
	line-height: 1.5;
	text-align: left;
}

/* Filtering animation */
.lpc-gallery__item.is-entering {
	animation: lpc-fade-in 0.25s ease-in-out;
}

@keyframes lpc-fade-in {
	from { opacity: 0; }
	to { opacity: 1; }
}

.lpc-gallery__empty,
.lpc-gallery__notice {
	margin: 0 0 24px;
	font-size: 16px;
	opacity: 0.85;
}

.lpc-gallery__notice {
	padding: 10px 14px;
	border-left: 3px solid var(--lpc-accent, #ce9308);
	background: rgba(206, 147, 8, 0.1);
}

.lpc-gallery__status {
	position: absolute !important;
	width: 1px;
	height: 1px;
	margin: -1px;
	padding: 0;
	overflow: hidden;
	clip: rect(0 0 0 0);
	clip-path: inset(50%);
	white-space: nowrap;
	border: 0;
}

/* Breakpoints follow the theme's own (1023px and 600px). */
@media only screen and (max-width: 1023px) {
	.lpc-gallery__grid {
		grid-template-columns: repeat(var(--lpc-cols-t, 2), minmax(0, 1fr));
	}
}

@media only screen and (max-width: 600px) {
	.lpc-gallery__grid {
		grid-template-columns: repeat(var(--lpc-cols-m, 1), minmax(0, 1fr));
	}

	.lpc-gallery__filters {
		gap: 8px;
		margin-bottom: 18px;
	}

	.lpc-gallery .lpc-gallery__filter {
		padding: 11px 14px 9px;
		font-size: 12px;
		letter-spacing: 1.5px;
	}

	.lpc-gallery .lpc-gallery__caption {
		font-size: 15px;
	}
}

/* ---------- Lightbox ---------- */

body.lpc-lightbox-open {
	overflow: hidden;
}

.lpc-lightbox {
	--lpc-accent: var(--wp--preset--color--theme-primary, #ce9308);
	position: fixed;
	inset: 0;
	z-index: 100000;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 64px 72px;
	background: rgba(0, 0, 0, 0.94);
	color: #fff;
	font-family: inherit;
	opacity: 0;
	transition: opacity 0.2s ease-in-out;
}

/* display:flex above would otherwise override the hidden attribute. Hidden = gone,
   so nothing inside can be focused or clicked while closed. Only opacity animates,
   which keeps the buttons focusable the instant the viewer opens. */
.lpc-lightbox[hidden] {
	display: none;
}

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

.lpc-lightbox__figure {
	display: flex;
	flex-direction: column;
	align-items: center;
	max-width: 100%;
	max-height: 100%;
	margin: 0;
}

.lpc-lightbox__img {
	display: block;
	width: auto;
	height: auto;
	max-width: 100%;
	max-height: calc(100vh - 170px);
	margin: 0;
	object-fit: contain;
	transition: opacity 0.2s ease-in-out;
}

.lpc-lightbox__img.is-loading {
	opacity: 0;
}

.lpc-lightbox__caption {
	max-width: 60ch;
	margin: 14px 0 0;
	color: #fff;
	font-size: 16px;
	font-weight: 400;
	line-height: 1.5;
	text-align: center;
}

.lpc-lightbox__caption:empty {
	display: none;
}

.lpc-lightbox__counter {
	position: absolute;
	top: 24px;
	left: 28px;
	margin: 0;
	color: #fff;
	font-size: 14px;
	font-weight: 800;
	letter-spacing: 2px;
	text-transform: uppercase;
	line-height: 1;
}

.lpc-lightbox .lpc-lightbox__btn {
	-webkit-appearance: none;
	appearance: none;
	position: absolute;
	display: flex;
	align-items: center;
	justify-content: center;
	width: 48px;
	height: 48px;
	min-width: 0;
	margin: 0;
	padding: 0;
	border: 0;
	border-radius: 0;
	background: transparent;
	box-shadow: none;
	color: #fff;
	cursor: pointer;
	transition: color 0.2s ease-in-out, background-color 0.2s ease-in-out;
}

.lpc-lightbox .lpc-lightbox__btn:hover {
	background: transparent;
	color: var(--lpc-accent);
	box-shadow: none;
}

.lpc-lightbox .lpc-lightbox__btn:focus {
	outline: none;
}

.lpc-lightbox .lpc-lightbox__btn:focus-visible {
	outline: 2px solid var(--lpc-accent);
	outline-offset: 2px;
}

.lpc-lightbox .lpc-lightbox__btn[hidden] {
	display: none;
}

.lpc-lightbox .lpc-lightbox__btn svg {
	width: 28px;
	height: 28px;
	fill: none;
	stroke: currentColor;
	stroke-width: 1.75;
	stroke-linecap: square;
}

.lpc-lightbox__close {
	top: 12px;
	right: 14px;
}

.lpc-lightbox__prev,
.lpc-lightbox__next {
	top: 50%;
	transform: translateY(-50%);
}

.lpc-lightbox__prev {
	left: 12px;
}

.lpc-lightbox__next {
	right: 12px;
}

@media only screen and (max-width: 600px) {
	.lpc-lightbox {
		padding: 60px 12px 84px;
	}

	.lpc-lightbox__img {
		max-height: calc(100vh - 190px);
	}

	/* Arrows move to the bottom on phones; swiping also works. */
	.lpc-lightbox__prev,
	.lpc-lightbox__next {
		top: auto;
		bottom: 18px;
		transform: none;
	}

	.lpc-lightbox__prev {
		left: calc(50% - 56px);
	}

	.lpc-lightbox__next {
		right: calc(50% - 56px);
	}

	.lpc-lightbox__counter {
		top: 22px;
		left: 16px;
		font-size: 12px;
	}
}

@media (prefers-reduced-motion: reduce) {
	.lpc-gallery .lpc-gallery__img,
	.lpc-gallery .lpc-gallery__filter,
	.lpc-lightbox,
	.lpc-lightbox__img {
		transition: none;
	}

	.lpc-gallery .lpc-gallery__link:hover .lpc-gallery__img {
		transform: none;
	}

	.lpc-gallery__item.is-entering {
		animation: none;
	}
}
