/* ══════════════════════════════════════════════════════════════════════════════
   Project Gallery Block
   ══════════════════════════════════════════════════════════════════════════ */

/* ── Grid ──────────────────────────────────────────────────────────────────── */

.wdm-pg__grid {
	display: grid;
	gap: 16px;
}

.wdm-pg--cols-4 .wdm-pg__grid { grid-template-columns: repeat(4, 1fr); }
.wdm-pg--cols-3 .wdm-pg__grid { grid-template-columns: repeat(3, 1fr); }

/* Custom px size: auto-fill grid */
.wdm-pg[style*="--pgb-width"] .wdm-pg__grid {
	grid-template-columns: repeat(auto-fill, minmax(var(--pgb-width), 1fr));
}

@media (max-width: 991px) {
	.wdm-pg--cols-4 .wdm-pg__grid,
	.wdm-pg--cols-3 .wdm-pg__grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 768px) {
	.wdm-pg--mobile-cols-1 .wdm-pg__grid,
	.wdm-pg--mobile-cols-1[style*="--pgb-width"] .wdm-pg__grid { grid-template-columns: 1fr; }
	.wdm-pg--mobile-cols-2 .wdm-pg__grid,
	.wdm-pg--mobile-cols-2[style*="--pgb-width"] .wdm-pg__grid { grid-template-columns: repeat(2, 1fr); }

	.wdm-pg .wdm-pg-item {
		width: auto;
		height: auto;
	}
}

/* ── Grid Item ─────────────────────────────────────────────────────────────── */

.wdm-pg-item {
	position: relative;
	border-radius: 12px;
	overflow: hidden;
	cursor: pointer;
	aspect-ratio: var(--pgb-ratio, 1 / 1);
	width: var(--pgb-width, auto);
	max-width: 100%;
	height: var(--pgb-height, auto);
	display: flex;
	align-items: flex-end;
}

.wdm-pg-item__image {
	position: absolute;
	inset: 0;
	z-index: 0;
}

.wdm-pg-item__image img {
	width: 100%;
	height: 100%;
	object-fit: cover;
	display: block;
	transition: transform 0.3s ease;
}

.wdm-pg-item:hover .wdm-pg-item__image img {
	transform: scale(1.05);
}

.wdm-pg-item__title {
	position: relative;
	z-index: 1;
	padding: 16px 20px;
	color: #fff;
	font-size: 13px;
	font-weight: 600;
	letter-spacing: 0.04em;
	line-height: 1.35;
	text-transform: uppercase;
	text-shadow: 0 1px 4px rgba(0,0,0,0.5);
}

/* Gradient overlay for title readability */
.wdm-pg-item::after {
	content: '';
	position: absolute;
	inset: 0;
	background: linear-gradient(to top, rgba(0,0,0,0.55) 0%, rgba(0,0,0,0) 50%);
	z-index: 0;
	pointer-events: none;
}

.wdm-pg-item__title { z-index: 1; position: relative; }

/* ── "Skatīt visus" cell ───────────────────────────────────────────────────── */

.wdm-pg-item--view-all {
	text-decoration: none;
	display: flex;
	align-items: center;
	justify-content: center;
}

.wdm-pg-item--view-all::after {
	background: rgba(0, 48, 87, 0.7);
}

.wdm-pg-item--view-all .wdm-pg-item__image--overlay img {
	filter: none;
}

.wdm-pg-item__view-all-text {
	position: relative;
	z-index: 2;
	color: #fff;
	font-size: 16px;
	font-weight: 600;
	padding: 4px 0px;
	border-bottom: 2px solid rgba(255,255,255,0.8);
	transition: border-color 0.2s;
}

.wdm-pg-item--view-all:hover .wdm-pg-item__view-all-text {
	border-bottom-color: #fff;
}

/* ── Auto-load sentinel ────────────────────────────────────────────────────── */

.wdm-pg__sentinel {
	height: 1px;
	pointer-events: none;
}

.wdm-pg__spinner {
	display: flex;
	justify-content: center;
	padding: 24px 0;
}

.wdm-pg__spinner::after {
	content: '';
	width: 32px;
	height: 32px;
	border: 3px solid #e0e0e0;
	border-top-color: var(--wp--preset--color--primary-blue, #005CA9);
	border-radius: 50%;
	animation: wdm-pg-spin 0.7s linear infinite;
}

@keyframes wdm-pg-spin {
	to { transform: rotate(360deg); }
}

/* ══════════════════════════════════════════════════════════════════════════════
   Modal Popup
   ══════════════════════════════════════════════════════════════════════════ */

.wdm-pg-modal {
	position: fixed;
	inset: 0;
	z-index: 100000;
	display: flex;
	align-items: center;
	justify-content: center;
	opacity: 0;
	visibility: hidden;
	transition: opacity 0.25s, visibility 0.25s;
}

.wdm-pg-modal[aria-hidden="false"] {
	opacity: 1;
	visibility: visible;
}

.wdm-pg-modal__backdrop {
	position: absolute;
	inset: 0;
	background: rgba(0,0,0,0.6);
}

.wdm-pg-modal__dialog {
	position: relative;
	z-index: 1;
	background: #fff;
	border-radius: 12px;
	width: 90vw;
	max-width: 640px;
	max-height: 90vh;
	overflow-y: auto;
	box-shadow: 0 20px 60px rgba(0,0,0,0.3);
	display: flex;
	flex-direction: column;
}

.wdm-pg-modal__close {
	position: absolute;
	top: 12px;
	right: 12px;
	z-index: 10;
	width: 36px;
	height: 36px;
	display: flex;
	align-items: center;
	justify-content: center;
	font-size: 24px;
	line-height: 1;
	background: rgba(255,255,255,0.85);
	border: none;
	border-radius: 4px;
	cursor: pointer;
	color: #323232;
	transition: background 0.2s;
}

.wdm-pg-modal__close:hover {
	background: #fff;
}

/* ── Slider ────────────────────────────────────────────────────────────────── */

.wdm-pg-modal__slider {
	position: relative;
	width: 100%;
	aspect-ratio: 16 / 10;
	overflow: hidden;
	border-radius: 12px 12px 0 0;
	background: #f0f0f0;
	flex-shrink: 0;
}

.wdm-pg-modal__slides {
	display: flex;
	height: 100%;
	transition: transform 0.35s ease;
}

.wdm-pg-modal__slides img {
	width: 100%;
	height: 100%;
	object-fit: cover;
	flex-shrink: 0;
}

.wdm-pg-modal__slider-counter {
	position: absolute;
	bottom: 16px;
	right: 112px;
	color: #fff;
	font-size: 14px;
	line-height: 48px;
	padding: 0 14px;
	background: rgba(0,0,0,0.35);
	-webkit-backdrop-filter: blur(10px);
	backdrop-filter: blur(10px);
	border-radius: 8px;
	z-index: 2;
}

.wdm-pg-modal__arrow {
	position: absolute;
	bottom: 16px;
	width: 48px;
	height: 48px;
	display: flex;
	align-items: center;
	justify-content: center;
	background: #fff;
	border: none;
	border-radius: 8px;
	font-size: 22px;
	cursor: pointer;
	transition: background 0.2s;
	z-index: 2;
}

.wdm-pg-modal__arrow:hover { background: #f0f0f0; }
.wdm-pg-modal__arrow--prev { right: 60px; }
.wdm-pg-modal__arrow--next { right: 8px; }

/* ── Body ──────────────────────────────────────────────────────────────────── */

.wdm-pg-modal__body {
	padding: 24px 28px 28px;
}

.wdm-pg-modal__title {
	font-size: 20px;
	font-weight: 700;
	color: #323232;
	margin: 0 0 12px;
	text-transform: uppercase;
}

.wdm-pg-modal__description {
	font-size: 14px;
	line-height: 1.65;
	color: #5a5a5a;
	margin-bottom: 20px;
}

.wdm-pg-modal__description:empty { display: none; }

/* ── Products ──────────────────────────────────────────────────────────────── */

.wdm-pg-modal__products {
	margin-bottom: 20px;
}

.wdm-pg-modal__products:empty,
.wdm-pg-modal__products[hidden] { display: none; }

.wdm-pg-modal__products-label {
	display: block;
	font-size: 13px;
	font-weight: 700;
	color: #323232;
	margin-bottom: 12px;
	text-transform: uppercase;
}

.wdm-pg-modal__products-list {
	display: flex;
	flex-wrap: wrap;
	gap: 24px;
}

.wdm-pg-modal__product {
	display: flex;
	align-items: flex-start;
	gap: 12px;
	text-decoration: none;
	color: #323232;
	font-size: 13px;
	font-weight: 600;
	line-height: 1.3;
}

.wdm-pg-modal__product img {
	width: 80px;
	height: 80px;
	object-fit: contain;
	border-radius: 4px;
	flex-shrink: 0;
}

.wdm-pg-modal__product:hover {
	color: var(--wp--preset--color--primary-blue, #005CA9);
}

/* ── Link ──────────────────────────────────────────────────────────────────── */

.wdm-pg-modal__link {
	display: inline-block;
	font-size: 14px;
	font-weight: 600;
	color: var(--wp--preset--color--primary-blue, #005CA9);
	text-decoration: underline;
}

.wdm-pg-modal__link:empty,
.wdm-pg-modal__link[hidden] { display: none; }

/* ── Loading ───────────────────────────────────────────────────────────────── */

.wdm-pg-modal__loading {
	display: none;
	padding: 60px 20px;
	text-align: center;
	font-size: 14px;
	color: #878484;
}

.wdm-pg-modal--loading .wdm-pg-modal__slider,
.wdm-pg-modal--loading .wdm-pg-modal__body { display: none; }
.wdm-pg-modal--loading .wdm-pg-modal__loading { display: block; }

/* ── Body scroll lock ──────────────────────────────────────────────────────── */

body.wdm-pg-modal-open {
	overflow: hidden;
}

/* ── Modal Mobile (≤ 768px) ────────────────────────────────────────────────── */

@media (max-width: 768px) {
	.wdm-pg-modal__dialog {
		width: 100vw;
		max-width: 100vw;
		max-height: 100vh;
		border-radius: 0;
	}

	.wdm-pg-modal__slider {
		aspect-ratio: auto;
		border-radius: 0;
	}

	.wdm-pg-modal__slides {
		height: auto;
	}

	.wdm-pg-modal__slides img {
		height: auto;
		object-fit: contain;
	}
}
