/**
 * «Галерея» page — template-parts/page/gallery.php (inside the information
 * page layout, info-page.css). Logic: inc/gallery.php, JS: gallery.js.
 * Mobile First. Breakpoints: 576 / 992 / 1200.
 */

/* ---------- Hero: lead + photo count ---------- */
.cncgc-gallery-hero {
	min-width: 0;
}

.cncgc-gallery-hero__lead {
	max-width: 62ch;
	margin: 12px 0 0;
	font-size: 1rem;
	line-height: 1.55;
	color: var(--cncgc-text-muted);
}

.cncgc-gallery-hero__meta {
	display: flex;
	flex-wrap: wrap;
	gap: 8px 20px;
	margin: 20px 0 0;
	padding: 0;
	list-style: none;
	font-size: 0.8125rem;
	color: var(--cncgc-text-muted);
}

.cncgc-gallery-hero__meta strong {
	font-weight: 600;
	color: var(--cncgc-black);
}

.cncgc-gallery-hero__hint {
	display: none;
}

@media (min-width: 576px) {
	.cncgc-gallery-hero__hint {
		display: block;
		padding-left: 20px;
		border-left: 1px solid var(--cncgc-border-strong);
	}
}

/* ---------- Grid ---------- */
.cncgc-gallery__grid {
	display: grid;
	grid-template-columns: repeat(2, minmax(0, 1fr));
	gap: 8px;
	margin: 0;
	padding: 0;
	list-style: none;
}

@media (min-width: 576px) {
	.cncgc-gallery__grid {
		grid-template-columns: repeat(3, minmax(0, 1fr));
		gap: 12px;
	}
}

@media (min-width: 1200px) {
	.cncgc-gallery__grid {
		grid-template-columns: repeat(4, minmax(0, 1fr));
		gap: 16px;
	}
}

.cncgc-gallery__item {
	position: relative;
	min-width: 0;
	margin: 0;
}

.cncgc-gallery__link {
	position: relative;
	display: block;
	aspect-ratio: 4 / 3;
	overflow: hidden;
	background: var(--cncgc-bg-muted);
	color: #fff;
}

/* Skeleton shimmer until the image has loaded (class set by gallery.js). */
.cncgc-gallery__link::before {
	content: "";
	position: absolute;
	inset: 0;
	background: linear-gradient(100deg, transparent 30%, rgba(255, 255, 255, 0.55) 50%, transparent 70%) var(--cncgc-bg-muted);
	background-size: 200% 100%;
	animation: cncgc-gallery-shimmer 1.4s linear infinite;
}

.cncgc-gallery__link.is-loaded::before {
	display: none;
}

@keyframes cncgc-gallery-shimmer {
	from {
		background-position: 150% 0;
	}

	to {
		background-position: -50% 0;
	}
}

.cncgc-gallery__link img {
	position: relative;
	display: block;
	width: 100%;
	height: 100%;
	max-height: none;
	object-fit: cover;
	transition: opacity 0.35s ease, transform 0.5s ease;
}

/* Fade-in only when JS is there to reveal the image again. */
.cncgc-gallery.is-enhanced .cncgc-gallery__link:not(.is-loaded) img {
	opacity: 0;
}

.cncgc-gallery__zoom {
	position: absolute;
	top: 10px;
	right: 10px;
	display: grid;
	place-items: center;
	width: 36px;
	height: 36px;
	border-radius: var(--cncgc-radius);
	background: rgba(17, 17, 17, 0.72);
	opacity: 0;
	transform: translateY(-4px);
	transition: opacity var(--cncgc-transition), transform var(--cncgc-transition);
}

.cncgc-gallery__zoom svg {
	width: 18px;
	height: 18px;
}

/* Caption: title of the product / post the photo is attached to. */
.cncgc-gallery__caption {
	position: absolute;
	right: 0;
	bottom: 0;
	left: 0;
	display: none;
	padding: 28px 12px 10px;
	font-size: 0.75rem;
	font-weight: 500;
	line-height: 1.35;
	background: linear-gradient(to top, rgba(17, 17, 17, 0.85), rgba(17, 17, 17, 0));
}

.cncgc-gallery__link:focus-visible {
	outline: 2px solid var(--cncgc-black);
	outline-offset: 2px;
}

.cncgc-gallery__link:focus-visible .cncgc-gallery__zoom {
	opacity: 1;
	transform: none;
}

/* Tiles large enough for a caption: always shown on touch screens. */
@media (min-width: 576px) {
	.cncgc-gallery__caption {
		display: -webkit-box;
		overflow: hidden;
		-webkit-line-clamp: 2;
		-webkit-box-orient: vertical;
	}
}

@media (min-width: 576px) and (hover: hover) and (pointer: fine) {
	.cncgc-gallery__caption {
		transform: translateY(100%);
		transition: transform var(--cncgc-transition);
	}

	.cncgc-gallery__link:hover .cncgc-gallery__caption,
	.cncgc-gallery__link:focus-visible .cncgc-gallery__caption {
		transform: none;
	}
}

@media (hover: hover) and (pointer: fine) {
	.cncgc-gallery__link:hover img {
		transform: scale(1.04);
	}

	.cncgc-gallery__link:hover .cncgc-gallery__zoom {
		opacity: 1;
		transform: none;
	}
}

/* ---------- Loading controls ---------- */
.cncgc-gallery__footer {
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 16px;
	margin-top: 32px;
}

.cncgc-gallery__progress {
	width: min(280px, 100%);
	height: 2px;
	overflow: hidden;
	background: var(--cncgc-border);
}

.cncgc-gallery__progress span {
	display: block;
	height: 100%;
	background: var(--cncgc-black);
	transition: width 0.4s ease;
}

.cncgc-gallery__status {
	margin: 0;
	font-size: 0.8125rem;
	color: var(--cncgc-text-muted);
}

.cncgc-gallery__btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 10px;
	min-width: 220px;
	min-height: 48px;
	padding: 0 24px;
	border: 1px solid var(--cncgc-black);
	border-radius: var(--cncgc-radius);
	background: transparent;
	color: var(--cncgc-black);
	font: inherit;
	font-size: 0.875rem;
	font-weight: 500;
	cursor: pointer;
	transition: background var(--cncgc-transition), color var(--cncgc-transition);
}

.cncgc-gallery__btn[hidden] {
	display: none;
}

.cncgc-gallery__btn:focus-visible {
	outline: 2px solid var(--cncgc-black);
	outline-offset: 2px;
}

@media (hover: hover) and (pointer: fine) {
	.cncgc-gallery__btn:hover {
		background: var(--cncgc-black);
		color: #fff;
	}
}

.cncgc-gallery__btn.is-loading {
	pointer-events: none;
	opacity: 0.7;
}

.cncgc-gallery__btn.is-loading::after {
	content: "";
	width: 14px;
	height: 14px;
	border: 2px solid currentcolor;
	border-right-color: transparent;
	border-radius: 50%;
	animation: cncgc-gallery-spin 0.7s linear infinite;
}

@keyframes cncgc-gallery-spin {
	to {
		transform: rotate(360deg);
	}
}

.cncgc-gallery__pagination[hidden] {
	display: none;
}

.cncgc-gallery__sentinel {
	height: 1px;
}

.cncgc-gallery__empty {
	margin: 0;
	color: var(--cncgc-text-muted);
}

/* ---------- PhotoSwipe (WooCommerce-bundled) caption ---------- */
.cncgc-gallery-page .pswp__caption__center {
	max-width: 720px;
	font-family: var(--cncgc-font);
	font-size: 0.875rem;
	text-align: center;
}

.cncgc-gallery-page .pswp__caption__center a {
	color: #fff;
	text-decoration: underline;
	text-underline-offset: 3px;
}

.cncgc-gallery-page .pswp__caption__center small {
	display: block;
	margin-top: 4px;
	font-size: 0.75rem;
	color: #bbb;
}

@media (prefers-reduced-motion: reduce) {
	.cncgc-gallery__link::before,
	.cncgc-gallery__btn.is-loading::after {
		animation: none;
	}

	.cncgc-gallery__link img,
	.cncgc-gallery__caption,
	.cncgc-gallery__zoom,
	.cncgc-gallery__progress span {
		transition: none;
	}

	.cncgc-gallery__link:hover img {
		transform: none;
	}
}
