/* Reference category gallery pages. */

.mf-refg-back {
	margin-bottom: 8px;
}

.mf-refg__grid {
	display: grid;
	grid-template-columns: repeat(3, minmax(0, 1fr));
	gap: 22px;
	margin: 0;
	padding: 0;
	list-style: none;
}

.mf-refg__grid > li {
	margin: 0;
	padding: 0;
}

.mf-refg .mf-refg__item {
	position: relative;
	display: block;
	width: 100%;
	padding: 0 !important;
	overflow: hidden;
	border: 0 !important;
	border-radius: 5px;
	background: #151515 !important;
	color: #fff;
	line-height: 0;
	text-align: left;
	cursor: zoom-in;
	aspect-ratio: 4 / 3;
	box-shadow: 0 0 0 1px rgba(21, 21, 21, 0.08);
	transition: transform 0.35s var(--mf-ease, ease), box-shadow 0.35s var(--mf-ease, ease);
}

.mf-refg .mf-refg__item img {
	display: block;
	width: 100% !important;
	max-width: none !important;
	height: 100% !important;
	object-fit: cover;
	transition: transform 0.6s var(--mf-ease, ease), filter 0.35s var(--mf-ease, ease);
}

.mf-refg__item::after {
	content: "";
	position: absolute;
	inset: 0;
	background: linear-gradient(0deg, rgba(21, 21, 21, 0.92) 0%, rgba(21, 21, 21, 0.55) 45%, rgba(21, 21, 21, 0) 75%);
	opacity: 0;
	transition: opacity 0.35s var(--mf-ease, ease);
	pointer-events: none;
}

.mf-refg__caption {
	position: absolute;
	right: 0;
	bottom: 0;
	left: 0;
	z-index: 1;
	padding: 20px 22px 22px;
	color: #fff !important;
	font-size: 15px;
	font-weight: 500;
	line-height: 1.45;
	opacity: 0;
	transform: translateY(12px);
	transition: opacity 0.35s var(--mf-ease, ease), transform 0.35s var(--mf-ease, ease);
	pointer-events: none;
}

.mf-refg__caption::before {
	content: "";
	display: block;
	width: 28px;
	height: 3px;
	margin-bottom: 12px;
	border-radius: 2px;
	background: var(--mf-accent, #f5b307);
}

.mf-refg__item:hover,
.mf-refg__item:focus-visible {
	transform: translateY(-4px);
	box-shadow: 0 18px 40px rgba(21, 21, 21, 0.16), 0 0 0 1px rgba(245, 179, 7, 0.35);
}

.mf-refg__item:focus-visible {
	outline: 2px solid var(--mf-accent, #f5b307);
	outline-offset: 3px;
}

.mf-refg__item:hover img,
.mf-refg__item:focus-visible img {
	transform: scale(1.05);
}

.mf-refg__item:hover::after,
.mf-refg__item:focus-visible::after,
.mf-refg__item:hover .mf-refg__caption,
.mf-refg__item:focus-visible .mf-refg__caption {
	opacity: 1;
	transform: none;
}

/* Touch screens have no hover: keep the name visible. */
@media (hover: none) {
	.mf-refg__item::after,
	.mf-refg__caption {
		opacity: 1;
		transform: none;
	}
}

/* Lightbox */
.mf-refg-lb {
	position: fixed;
	inset: 0;
	z-index: 99999;
	display: grid;
	grid-template-columns: 72px minmax(0, 1fr) 72px;
	align-items: center;
	padding: 28px 24px;
	background: rgba(15, 15, 15, 0.96);
	opacity: 0;
	transition: opacity 0.25s ease;
}

.mf-refg-lb.is-open {
	opacity: 1;
}

.mf-refg-lb[hidden] {
	display: none;
}

.mf-refg-lb__figure {
	grid-column: 2;
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 18px;
	min-width: 0;
	margin: 0;
}

.mf-refg-lb__img {
	display: block;
	max-width: 100%;
	max-height: calc(100svh - 190px);
	width: auto;
	height: auto;
	border-radius: 5px;
	object-fit: contain;
	box-shadow: 0 30px 80px rgba(0, 0, 0, 0.45);
}

.mf-refg-lb__caption {
	display: flex;
	align-items: baseline;
	gap: 16px;
	max-width: 960px;
	color: #fff;
	font-size: 16px;
	font-weight: 500;
	line-height: 1.5;
	text-align: center;
}

.mf-refg-lb__count {
	flex: none;
	color: var(--mf-accent, #f5b307);
	font-size: 14px;
	font-weight: 600;
	letter-spacing: 0.04em;
}

.mf-refg-lb .mf-refg-lb__btn {
	display: grid;
	place-items: center;
	width: 48px;
	height: 48px;
	padding: 0 !important;
	border: 1px solid rgba(255, 255, 255, 0.28);
	border-radius: 5px;
	background: rgba(21, 21, 21, 0.6);
	color: #fff;
	cursor: pointer;
	transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}

.mf-refg-lb__btn svg {
	width: 20px;
	height: 20px;
	fill: none;
	stroke: currentColor;
	stroke-width: 2;
	stroke-linecap: round;
	stroke-linejoin: round;
}

.mf-refg-lb .mf-refg-lb__btn:hover,
.mf-refg-lb .mf-refg-lb__btn:focus-visible {
	border-color: var(--mf-accent, #f5b307);
	background: var(--mf-accent, #f5b307);
	color: #151515;
	outline: none;
}

.mf-refg-lb__prev { grid-column: 1; grid-row: 1; justify-self: start; }
.mf-refg-lb__next { grid-column: 3; grid-row: 1; justify-self: end; }
.mf-refg-lb__close { position: absolute; top: 20px; right: 24px; }

body.mf-refg-lb-open { overflow: hidden; }

@media (max-width: 991px) {
	.mf-refg__grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
}

@media (max-width: 600px) {
	.mf-refg__grid { grid-template-columns: 1fr; gap: 14px; }
	.mf-refg__caption { padding: 16px 16px 18px; font-size: 14px; }
	.mf-refg-lb { grid-template-columns: 1fr; padding: 70px 12px 90px; }
	.mf-refg-lb__figure { grid-column: 1; }
	.mf-refg-lb__img { max-height: calc(100svh - 230px); }
	.mf-refg-lb__caption { flex-direction: column; align-items: center; gap: 6px; font-size: 14px; }
	.mf-refg-lb__prev,
	.mf-refg-lb__next { position: absolute; bottom: 24px; grid-row: auto; width: 44px; height: 44px; }
	.mf-refg-lb__prev { left: calc(50% - 56px); }
	.mf-refg-lb__next { right: calc(50% - 56px); }
	.mf-refg-lb__close { top: 14px; right: 12px; width: 44px; height: 44px; }
}

@media (prefers-reduced-motion: reduce) {
	.mf-refg__item,
	.mf-refg__item img,
	.mf-refg__item::after,
	.mf-refg__caption,
	.mf-refg-lb { transition: none; }
}
