/**
 * Галерея WordPress [gallery ids=...]
 * Десктоп и планшет: 3 колонки; мобильные: 2 колонки.
 * Ховер: тёмный полупрозрачный слой между фото и иконкой лупы (Font Awesome).
 * Инлайн-стили WP отключены через use_default_gallery_style.
 */

/* ─── Контейнер: сетка ─── */
[id^='gallery-'],
.entry-content .gallery,
.page-content .gallery {
	display: grid;
	grid-template-columns: repeat(3, minmax(0, 1fr));
	gap: 30px;
	margin: 30px 0 70px;
	width: 100%;
	max-width: 100%;
	padding: 0;
	list-style: none;
}

.entry-content .gallery br,
.page-content .gallery br {
	display: none;
}

/* ─── Плитка ─── */
[id^='gallery-'] .gallery-item,
.entry-content .gallery .gallery-item,
.page-content .gallery .gallery-item {
	float: none;
	width: 100% !important;
	max-width: none !important;
	min-width: 0;
	height: auto;
	margin: 0;
	padding: 0;
	text-align: left;
	position: relative;
	overflow: hidden;
	-webkit-box-sizing: border-box;
	box-sizing: border-box;
}

.gallery .gallery-item > dl,
.gallery .gallery-item > dt,
.gallery .gallery-item > figure {
	display: block;
	margin: 0;
	padding: 0;
	height: 100%;
}

.gallery .gallery-item .gallery-icon,
.gallery figure.gallery-item {
	margin: 0;
	padding: 0;
	line-height: 0;
	width: 100%;
}

.gallery figure.gallery-item {
	display: block;
}

/* Кликабельная область, пропорции 3:2 */
.gallery .gallery-item .gallery-icon a,
.gallery figure.gallery-item > a {
	display: block;
	margin: 0;
	padding: 0;
	position: relative;
	width: 100%;
	aspect-ratio: 3 / 2;
	overflow: hidden;
	line-height: 0;
	background: transparent;
}

.gallery .gallery-item img {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	display: block;
	-o-object-fit: cover;
	object-fit: cover;
	vertical-align: middle;
	z-index: 0;
}

/* Тёмный слой между фото и иконкой */
.gallery .gallery-item .gallery-icon a::before,
.gallery figure.gallery-item > a::before {
	content: '';
	position: absolute;
	inset: 0;
	z-index: 1;
	background: rgba(0, 0, 0, 0.45);
	opacity: 0;
	-webkit-transition: opacity 0.3s;
	-o-transition: opacity 0.3s;
	transition: opacity 0.3s;
	pointer-events: none;
}

.gallery .gallery-item .gallery-icon a:hover::before,
.gallery .gallery-item .gallery-icon a:focus-visible::before,
.gallery figure.gallery-item > a:hover::before,
.gallery figure.gallery-item > a:focus-visible::before {
	opacity: 1;
}

/* Лупа (Font Awesome) — поверх затемнения */
.gallery .gallery-item .gallery-icon a::after,
.gallery figure.gallery-item > a::after {
	content: '\f00e';
	font-family: 'Font Awesome 6 Free', 'Font Awesome 7 Free', 'Font Awesome 5 Free';
	font-weight: 900;
	position: absolute;
	top: 43%;
	left: 47%;
	-webkit-transform: translate(-50%, -50%);
	-ms-transform: translate(-50%, -50%);
	transform: translate(-50%, -50%);
	font-size: 28px;
	color: rgba(255, 255, 255, 0.95);
	opacity: 0;
	z-index: 2;
	-webkit-transition: opacity 0.3s;
	-o-transition: opacity 0.3s;
	transition: opacity 0.3s;
	pointer-events: none;
	line-height: 1;
	text-shadow: 0 2px 8px rgba(0, 0, 0, 0.35);
}

.gallery .gallery-item .gallery-icon a:hover::after,
.gallery .gallery-item .gallery-icon a:focus-visible::after,
.gallery figure.gallery-item > a:hover::after,
.gallery figure.gallery-item > a:focus-visible::after {
	opacity: 1;
}

/* Подпись WP */
.gallery .gallery-item .gallery-caption,
.gallery .gallery-item figcaption.wp-element-caption {
	position: absolute;
	bottom: 0;
	left: 0;
	right: 0;
	z-index: 3;
	margin: 0;
	padding: 8px 10px;
	font-size: 12px;
	line-height: 1.35;
	color: #fff;
	background: rgba(0, 0, 0, 0.55);
	-webkit-box-sizing: border-box;
	box-sizing: border-box;
}

/* ─── Мобильные: две колонки ─── */
@media screen and (max-width: 700px) {
	[id^='gallery-'],
	.entry-content .gallery,
	.page-content .gallery {
		grid-template-columns: repeat(2, minmax(0, 1fr));
		gap: 10px;
		margin-top: 20px;
		margin-bottom: 20px;
	}
}

@media (prefers-reduced-motion: reduce) {
	.gallery .gallery-item .gallery-icon a::before,
	.gallery .gallery-item .gallery-icon a::after,
	.gallery figure.gallery-item > a::before,
	.gallery figure.gallery-item > a::after {
		-webkit-transition-duration: 0.01ms;
		-o-transition-duration: 0.01ms;
		transition-duration: 0.01ms;
	}
}
