/*
 * PD Instagram Feed – Frontend
 *
 * Alle Maße kommen als CSS-Variablen aus dem Shortcode, damit mehrere Feeds
 * auf einer Seite unterschiedlich aussehen können, ohne dass für jeden ein
 * eigener Style-Block ausgegeben werden muss.
 */

.pdig {
	position: relative;
	--pdig-cols-desktop: 3;
	--pdig-cols-tablet: 3;
	--pdig-cols-mobile: 2;
	--pdig-cols: var(--pdig-cols-desktop);
	--pdig-gap: 8px;
	--pdig-radius: 6px;
	--pdig-accent: #c13584;
	--pdig-aspect: 1/1;
}

/* --- Kopfzeile --- */

.pdig__head {
	margin: 0 0 calc(var(--pdig-gap) + 4px);
}

.pdig__handle {
	display: inline-flex;
	align-items: center;
	gap: 8px;
	text-decoration: none;
	color: inherit;
	font-weight: 600;
	line-height: 1.2;
}

.pdig__handle:hover {
	color: var(--pdig-accent);
}

.pdig__handle .pdig__icon {
	flex: 0 0 auto;
}

/* --- Raster --- */

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

/* --- Masonry --- */

.pdig--masonry .pdig__items {
	display: block;
	column-count: var(--pdig-cols);
	column-gap: var(--pdig-gap);
}

.pdig--masonry .pdig__item {
	display: block;
	break-inside: avoid;
	-webkit-column-break-inside: avoid;
	margin: 0 0 var(--pdig-gap);
}

/* --- Slider --- */

.pdig--slider .pdig__viewport {
	overflow-x: auto;
	overflow-y: hidden;
	scroll-snap-type: x mandatory;
	scroll-behavior: smooth;
	-webkit-overflow-scrolling: touch;
	scrollbar-width: none;
	-ms-overflow-style: none;
}

.pdig--slider .pdig__viewport::-webkit-scrollbar {
	display: none;
}

.pdig--slider .pdig__items {
	display: flex;
	grid-template-columns: none;
}

.pdig--slider .pdig__item {
	flex: 0 0 calc((100% - (var(--pdig-cols) - 1) * var(--pdig-gap)) / var(--pdig-cols));
	scroll-snap-align: start;
}

.pdig__nav {
	position: absolute;
	top: 50%;
	transform: translateY(-50%);
	z-index: 2;
	display: flex;
	align-items: center;
	justify-content: center;
	width: 40px;
	height: 40px;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: #fff;
	color: #1d2327;
	box-shadow: 0 1px 6px rgba(0, 0, 0, .22);
	cursor: pointer;
}

.pdig__nav:hover {
	color: var(--pdig-accent);
}

.pdig__nav[hidden] {
	display: none;
}

.pdig__nav--prev {
	left: -8px;
}

.pdig__nav--next {
	right: -8px;
}

/* --- Einzelner Beitrag --- */

.pdig__item {
	display: block;
	text-decoration: none;
	color: inherit;
	box-shadow: none;
}

.pdig__frame {
	position: relative;
	display: block;
	overflow: hidden;
	border-radius: var(--pdig-radius);
	background: #f0f0f1;
	aspect-ratio: var(--pdig-aspect);
}

.pdig__frame img {
	display: block;
	width: 100%;
	height: 100%;
	object-fit: cover;
	margin: 0;
	border-radius: 0;
	transition: transform .45s ease;
}

.pdig--aspect-auto .pdig__frame img {
	height: auto;
	object-fit: initial;
}

.pdig__item:hover .pdig__frame img {
	transform: scale(1.04);
}

.pdig__badge {
	position: absolute;
	top: 8px;
	right: 8px;
	display: flex;
	color: #fff;
	filter: drop-shadow(0 1px 2px rgba(0, 0, 0, .6));
	pointer-events: none;
}

.pdig__overlay {
	position: absolute;
	inset: 0;
	display: flex;
	align-items: flex-end;
	padding: 12px;
	background: linear-gradient(to top, rgba(0, 0, 0, .68), rgba(0, 0, 0, 0) 62%);
	opacity: 0;
	transition: opacity .25s ease;
}

.pdig__item:hover .pdig__overlay,
.pdig__item:focus-visible .pdig__overlay {
	opacity: 1;
}

.pdig__overlay-text {
	color: #fff;
	font-size: 13px;
	line-height: 1.4;
	display: -webkit-box;
	-webkit-line-clamp: 4;
	-webkit-box-orient: vertical;
	overflow: hidden;
}

.pdig__caption {
	display: block;
	margin-top: 8px;
	font-size: 13px;
	line-height: 1.45;
}

.pdig__item:focus-visible .pdig__frame {
	outline: 2px solid var(--pdig-accent);
	outline-offset: 2px;
}

/* --- Lightbox --- */

.pdig-lb {
	position: fixed;
	inset: 0;
	z-index: 999999;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 24px;
	background: rgba(15, 15, 16, .92);
	opacity: 0;
	transition: opacity .18s ease;
}

.pdig-lb.is-open {
	opacity: 1;
}

.pdig-lb__figure {
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 12px;
	max-width: min(860px, 100%);
	max-height: 100%;
	margin: 0;
}

.pdig-lb__figure img {
	display: block;
	max-width: 100%;
	max-height: 72vh;
	width: auto;
	height: auto;
	border-radius: 4px;
	object-fit: contain;
}

.pdig-lb__caption {
	max-width: 720px;
	max-height: 18vh;
	overflow-y: auto;
	color: #f0f0f1;
	font-size: 14px;
	line-height: 1.5;
	text-align: center;
	white-space: pre-line;
}

.pdig-lb__link {
	display: inline-flex;
	align-items: center;
	gap: 8px;
	color: #fff;
	font-size: 13px;
	font-weight: 600;
	text-decoration: none;
	border-bottom: 1px solid rgba(255, 255, 255, .45);
	padding-bottom: 2px;
}

.pdig-lb__link:hover {
	border-bottom-color: #fff;
}

.pdig-lb__btn {
	position: absolute;
	display: flex;
	align-items: center;
	justify-content: center;
	width: 44px;
	height: 44px;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: rgba(255, 255, 255, .12);
	color: #fff;
	font-size: 24px;
	line-height: 1;
	cursor: pointer;
}

.pdig-lb__btn:hover {
	background: rgba(255, 255, 255, .24);
}

.pdig-lb__close {
	top: 16px;
	right: 16px;
}

.pdig-lb__prev {
	left: 16px;
	top: 50%;
	transform: translateY(-50%);
}

.pdig-lb__next {
	right: 16px;
	top: 50%;
	transform: translateY(-50%);
}

.pdig-lb__btn[hidden] {
	display: none;
}

html.pdig-lb-open {
	overflow: hidden;
}

/* --- Kleinere Bildschirme --- */

@media (max-width: 1024px) {
	.pdig {
		--pdig-cols: var(--pdig-cols-tablet);
	}
}

@media (max-width: 640px) {
	.pdig {
		--pdig-cols: var(--pdig-cols-mobile);
	}

	.pdig__nav--prev {
		left: 4px;
	}

	.pdig__nav--next {
		right: 4px;
	}

	.pdig-lb {
		padding: 16px;
	}
}

@media (prefers-reduced-motion: reduce) {
	.pdig__frame img,
	.pdig__overlay,
	.pdig-lb {
		transition: none;
	}

	.pdig__item:hover .pdig__frame img {
		transform: none;
	}

	.pdig--slider .pdig__viewport {
		scroll-behavior: auto;
	}
}
