/* Dynamic Post Gallery — grid, captions, lightbox */

.dpg-gallery {
	--dpg-cols: 4;
	--dpg-gap: 12px;
	--dpg-radius: 6px;
	--dpg-ratio: 1/1;
}

.dpg-grid {
	display: grid;
	grid-template-columns: repeat(var(--dpg-cols), minmax(0, 1fr));
	gap: var(--dpg-gap);
	list-style: none;
	margin: 0;
	padding: 0;
}

@media (max-width: 960px) {
	.dpg-grid { grid-template-columns: repeat(min(var(--dpg-cols), 3), minmax(0, 1fr)); }
}
@media (max-width: 600px) {
	.dpg-grid { grid-template-columns: repeat(min(var(--dpg-cols), 2), minmax(0, 1fr)); }
}

.dpg-item { margin: 0; padding: 0; list-style: none; }
.dpg-figure { margin: 0; }

.dpg-link {
	position: relative;
	display: block;
	overflow: hidden;
	border-radius: var(--dpg-radius);
	background: rgba(127, 127, 127, 0.15);
	aspect-ratio: var(--dpg-ratio);
	line-height: 0;
	text-decoration: none;
	cursor: pointer;
}
.dpg-ratio-auto .dpg-link { aspect-ratio: auto; }
a.dpg-link:focus-visible {
	outline: 3px solid currentColor;
	outline-offset: 3px;
}
span.dpg-link { cursor: default; }

.dpg-img {
	display: block;
	width: 100%;
	height: 100%;
	max-width: 100%;
	object-fit: cover;
	transition: transform 0.4s ease;
}
.dpg-ratio-auto .dpg-img { height: auto; }
a.dpg-link:hover .dpg-img,
a.dpg-link:focus-visible .dpg-img { transform: scale(1.04); }

/* Captions */
.dpg-caption {
	font-size: 0.875rem;
	line-height: 1.35;
}
.dpg-caption-hover .dpg-caption {
	position: absolute;
	inset: auto 0 0 0;
	padding: 2.5em 0.85em 0.75em;
	color: #fff;
	background: linear-gradient(to top, rgba(0, 0, 0, 0.72), rgba(0, 0, 0, 0));
	opacity: 0;
	transform: translateY(6px);
	transition: opacity 0.25s ease, transform 0.25s ease;
	pointer-events: none;
}
.dpg-caption-hover .dpg-link:hover .dpg-caption,
.dpg-caption-hover a.dpg-link:focus-visible .dpg-caption { opacity: 1; transform: none; }
@media (hover: none) {
	.dpg-caption-hover .dpg-caption { opacity: 1; transform: none; }
}
.dpg-caption--below { margin-top: 0.5em; }

.dpg-empty {
	padding: 1.25em;
	border: 1px dashed currentColor;
	border-radius: 6px;
	opacity: 0.7;
	text-align: center;
}

/* Editor preview: links shouldn't navigate while editing */
.editor-styles-wrapper .dpg-link { pointer-events: none; }

@media (prefers-reduced-motion: reduce) {
	.dpg-img, .dpg-caption, .dpg-lb, .dpg-lb__img { transition: none !important; animation: none !important; }
	a.dpg-link:hover .dpg-img { transform: none; }
}

/* ------------------------------------------------------------------ Lightbox */
html.dpg-lb-open { overflow: hidden; }

.dpg-lb {
	position: fixed;
	inset: 0;
	z-index: 100000;
	display: flex;
	flex-direction: column;
	background: rgba(10, 10, 12, 0.94);
	color: #f2f2f2;
	animation: dpg-fade 0.2s ease;
}
.dpg-lb[hidden] { display: none; }
@keyframes dpg-fade { from { opacity: 0; } to { opacity: 1; } }

.dpg-lb__top {
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 0.75rem 1rem;
	font-size: 0.875rem;
	font-variant-numeric: tabular-nums;
}

.dpg-lb__stage {
	position: relative;
	flex: 1;
	display: flex;
	align-items: center;
	justify-content: center;
	min-height: 0;
	padding: 0 3.5rem;
	touch-action: pan-y;
}

.dpg-lb__img {
	max-width: 100%;
	max-height: 100%;
	object-fit: contain;
	border-radius: 2px;
	opacity: 1;
	transition: opacity 0.2s ease;
	user-select: none;
	-webkit-user-drag: none;
}
.dpg-lb.is-loading .dpg-lb__img { opacity: 0; }
.dpg-lb.is-loading .dpg-lb__stage::after {
	content: "";
	position: absolute;
	width: 28px;
	height: 28px;
	border: 3px solid rgba(255, 255, 255, 0.25);
	border-top-color: #fff;
	border-radius: 50%;
	animation: dpg-spin 0.8s linear infinite;
}
@keyframes dpg-spin { to { transform: rotate(360deg); } }

.dpg-lb__btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 44px;
	height: 44px;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: rgba(255, 255, 255, 0.1);
	color: inherit;
	cursor: pointer;
	transition: background 0.15s ease;
}
.dpg-lb__btn:hover { background: rgba(255, 255, 255, 0.22); }
.dpg-lb__btn:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }
.dpg-lb__btn svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

.dpg-lb__prev, .dpg-lb__next { position: absolute; top: 50%; margin-top: -22px; }
.dpg-lb__prev { left: 0.6rem; }
.dpg-lb__next { right: 0.6rem; }
.dpg-lb.is-single .dpg-lb__prev,
.dpg-lb.is-single .dpg-lb__next,
.dpg-lb.is-single .dpg-lb__count { display: none; }

.dpg-lb__caption {
	padding: 0.85rem 1rem 1.25rem;
	text-align: center;
	font-size: 1rem;
	line-height: 1.4;
	min-height: 3.2rem;
}

@media (max-width: 600px) {
	.dpg-lb__stage { padding: 0 0.5rem; }
	.dpg-lb__prev, .dpg-lb__next { top: auto; bottom: -3.1rem; margin-top: 0; }
	.dpg-lb__prev { left: 1rem; }
	.dpg-lb__next { right: 1rem; }
}
