/* ==========================================================================
   FW Galerie
   ========================================================================== */

.fwg {
	--fwg-cols: 3;
	--fwg-gap: 12px;
	--fwg-radius: 14px;
	--fwg-ease: cubic-bezier(0.2, 0.75, 0.25, 1);
	--fwg-heart: #ff5470;
	margin-block: 2rem;
}

.fwg__list {
	margin: 0;
	padding: 0;
	list-style: none;
}

/* ---------- Layout: Masonry ---------- */

.fwg--masonry .fwg__list {
	columns: var(--fwg-cols) 160px;
	column-gap: var(--fwg-gap);
}

.fwg--masonry .fwg__item {
	break-inside: avoid;
	margin: 0 0 var(--fwg-gap);
	/* Platz für den Hover-Zoom, damit nichts abgeschnitten wird */
	padding: 2px;
	margin-inline: -2px;
}

/* ---------- Layout: Raster (quadratisch) ---------- */

.fwg--grid .fwg__list {
	display: grid;
	grid-template-columns: repeat(var(--fwg-cols), minmax(0, 1fr));
	gap: var(--fwg-gap);
}

.fwg--grid .fwg__link {
	aspect-ratio: 1;
}

.fwg--grid .fwg__img {
	height: 100% !important;
	object-fit: cover;
}

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

/* ---------- Layout: Slider ---------- */

.fwg-slider {
	position: relative;
	border-radius: var(--fwg-radius);
	outline-offset: 4px;
}

.fwg-slider__track {
	position: relative;
	display: flex;
	align-items: flex-start;
	transition: height 0.35s var(--fwg-ease);
	overflow-x: auto;
	overscroll-behavior-x: contain;
	scroll-snap-type: x mandatory;
	scrollbar-width: none;
}

.fwg-slider__track::-webkit-scrollbar {
	display: none;
}

.fwg--slider .fwg__item {
	display: flex;
	flex: 0 0 100%;
	align-items: center;
	justify-content: center;
	scroll-snap-align: center;
	scroll-snap-stop: always;
}

/* Foto, Pfeile, Herz und Zähler liegen im selben Rasterfeld = im Bild */
.fwg--slider .fwg__figure {
	display: inline-grid;
	grid-template-areas: "img" "cap";
	grid-template-columns: auto;
	max-width: 100%;
	overflow: visible;
	border-radius: 0;
	background: none;
	transform: none !important;
	box-shadow: none !important;
}

.fwg--slider .fwg__link {
	grid-area: img;
	border-radius: var(--fwg-radius);
}

.fwg--slider .fwg__img {
	width: auto !important;
	max-width: 100%;
	height: auto;
	max-height: var(--fwg-slider-h, 75vh);
	margin-inline: auto;
	transform: none;
	transition: none;
}

.fwg--slider .fwg__heart {
	position: static;
	grid-area: img;
	align-self: start;
	justify-self: end;
	margin: 0.75rem;
	opacity: 1;
	transform: none;
}

.fwg-slider__count {
	grid-area: img;
	align-self: start;
	justify-self: start;
	z-index: 2;
	margin: 0.75rem;
	padding: 0.35rem 0.65rem;
	border-radius: 999px;
	background: rgb(0 0 0 / 0.42);
	-webkit-backdrop-filter: blur(6px);
	backdrop-filter: blur(6px);
	color: #fff;
	font: 600 0.75rem/1 system-ui, sans-serif;
	letter-spacing: 0.06em;
	font-variant-numeric: tabular-nums;
	pointer-events: none;
}

.fwg-slider__nav {
	grid-area: img;
	align-self: center;
	z-index: 3;
	display: grid;
	place-items: center;
	width: 2.75rem;
	height: 2.75rem;
	margin: 0 0.75rem;
	padding: 0;
	border: 0;
	border-radius: 999px;
	background: rgb(255 255 255 / 0.88);
	box-shadow: 0 4px 14px -4px rgb(0 0 0 / 0.35);
	color: #1b1b19;
	cursor: pointer;
	transition: transform 0.2s var(--fwg-ease), background 0.2s ease, opacity 0.2s ease;
}

.fwg-slider__prev { justify-self: start; }
.fwg-slider__next { justify-self: end; }

.fwg-slider__nav:hover,
.fwg-slider__nav:focus-visible {
	background: #fff;
	transform: scale(1.08);
}

.fwg-slider__nav svg {
	width: 1.3rem;
	height: 1.3rem;
	fill: none;
	stroke: currentColor;
	stroke-width: 1.8;
	stroke-linecap: round;
	stroke-linejoin: round;
}

.fwg--slider .fwg__figure[data-wm]::after {
	grid-area: img;
	position: static;
	align-self: end;
	justify-self: end;
	margin: 0 0.9rem 0.75rem 0;
	opacity: 1 !important;
}

/* Bildunterschrift unter dem Foto */
.fwg--slider .fwg__caption {
	grid-area: cap;
	position: static;
	padding: 0.7rem 0.25rem 0;
	background: none;
	color: inherit;
	font-size: 0.9rem;
	text-align: center;
	opacity: 0.8;
	transform: none;
	pointer-events: auto;
}

/* Vorschaubilder */
.fwg-slider__thumbs {
	display: flex;
	gap: 0.5rem;
	margin-top: 1rem;
	padding: 0.25rem 0.1rem 0.4rem;
	overflow-x: auto;
	scrollbar-width: thin;
	justify-content: safe center;
}

.fwg-slider__thumb {
	flex: 0 0 auto;
	width: 4.5rem;
	height: 4.5rem;
	padding: 0;
	border: 2px solid transparent;
	border-radius: calc(var(--fwg-radius) * 0.6);
	background: none;
	overflow: hidden;
	cursor: pointer;
	opacity: 0.55;
	transition: opacity 0.2s ease, border-color 0.2s ease, transform 0.2s var(--fwg-ease);
}

.fwg-slider__thumb img {
	display: block;
	width: 100%;
	height: 100%;
	object-fit: cover;
	border-radius: calc(var(--fwg-radius) * 0.6 - 2px);
}

.fwg-slider__thumb:hover {
	opacity: 0.85;
	transform: translateY(-2px);
}

.fwg-slider__thumb.is-active {
	opacity: 1;
	border-color: currentColor;
}

@media (max-width: 600px) {
	.fwg-slider__nav {
		width: 2.4rem;
		height: 2.4rem;
		margin: 0 0.5rem;
	}
	.fwg-slider__thumb {
		width: 3.5rem;
		height: 3.5rem;
	}
}

/* ---------- Kachel ---------- */

.fwg__item {
	position: relative;
	margin: 0;
}

.fwg__figure {
	position: relative;
	margin: 0;
	border-radius: var(--fwg-radius);
	overflow: hidden;
	isolation: isolate;
	background: rgb(0 0 0 / 0.05);
	transition: transform 0.45s var(--fwg-ease), box-shadow 0.45s var(--fwg-ease);
}

.fwg__link {
	display: block;
	overflow: hidden;
	border-radius: inherit;
	cursor: zoom-in;
	outline-offset: 3px;
}

.fwg__img {
	display: block;
	width: 100% !important;
	height: auto;
	max-width: none;
	border-radius: inherit;
	transition: transform 0.7s var(--fwg-ease), opacity 0.4s ease;
}

/* Hover: Kachel hebt sich leicht und wird etwas größer */
.fwg--hover .fwg__item:hover {
	z-index: 2;
}

.fwg--hover .fwg__item:hover .fwg__figure,
.fwg--hover .fwg__item:focus-within .fwg__figure {
	transform: scale(1.035);
	box-shadow: 0 16px 34px -14px rgb(0 0 0 / 0.4);
}

.fwg--hover .fwg__item:hover .fwg__img {
	transform: scale(1.04);
}

/* ---------- Ken Burns ---------- */

/* Kacheln: langsames Hineinzoomen mit Schwenk, solange die Maus darauf ist */
.fwg--kenburns:not(.fwg--slider) .fwg__item:hover .fwg__img {
	transform: scale(1.14) translate(-2%, -1.5%);
	transition: transform 9s cubic-bezier(0.25, 0.6, 0.3, 1);
}

.fwg--kenburns:not(.fwg--slider) .fwg__item:nth-child(2n):hover .fwg__img {
	transform: scale(1.14) translate(2%, -1%);
}

.fwg--kenburns:not(.fwg--slider) .fwg__item:nth-child(3n):hover .fwg__img {
	transform: scale(1.14) translate(-1%, 2%);
}

/* Slider: das gezeigte Foto bewegt sich wie in einer Diashow */
.fwg--kenburns.fwg--slider .fwg__item.is-current .fwg__img {
	animation: fwg-kb-a 14s ease-out forwards;
}

.fwg--kenburns.fwg--slider .fwg__item.is-current:nth-child(2n) .fwg__img {
	animation-name: fwg-kb-b;
}

.fwg--kenburns.fwg--slider .fwg__item.is-current:nth-child(3n) .fwg__img {
	animation-name: fwg-kb-c;
}

@keyframes fwg-kb-a {
	from { transform: scale(1) translate(0, 0); }
	to   { transform: scale(1.12) translate(-2%, -1.5%); }
}

@keyframes fwg-kb-b {
	from { transform: scale(1.12) translate(2%, 1%); }
	to   { transform: scale(1) translate(0, 0); }
}

@keyframes fwg-kb-c {
	from { transform: scale(1) translate(0, 0); }
	to   { transform: scale(1.12) translate(1.5%, -2%); }
}

/* Bildunterschrift */
.fwg__caption {
	position: absolute;
	inset: auto 0 0 0;
	z-index: 1;
	margin: 0;
	padding: 2.25rem 0.9rem 0.75rem;
	background: linear-gradient(to top, rgb(0 0 0 / 0.7), rgb(0 0 0 / 0));
	color: #fff;
	font-size: 0.8125rem;
	line-height: 1.35;
	opacity: 0;
	transform: translateY(6px);
	transition: opacity 0.3s ease, transform 0.3s var(--fwg-ease);
	pointer-events: none;
}

.fwg__item:hover .fwg__caption,
.fwg__item:focus-within .fwg__caption {
	opacity: 1;
	transform: none;
}

/* ---------- Herz ---------- */

.fwg__heart {
	position: absolute;
	top: 0.6rem;
	right: 0.6rem;
	z-index: 3;
	display: inline-flex;
	align-items: center;
	gap: 0.3rem;
	min-width: 2.25rem;
	height: 2.25rem;
	padding: 0 0.6rem;
	border: 0;
	border-radius: 999px;
	background: rgb(0 0 0 / 0.42);
	-webkit-backdrop-filter: blur(6px);
	backdrop-filter: blur(6px);
	color: #fff;
	font: 600 0.8125rem/1 system-ui, sans-serif;
	cursor: pointer;
	opacity: 0;
	transform: scale(0.85);
	transition: opacity 0.25s ease, transform 0.25s var(--fwg-ease), background 0.2s ease;
}

.fwg__heart svg {
	width: 1.05rem;
	height: 1.05rem;
	fill: none;
	stroke: currentColor;
	stroke-width: 1.8;
	transition: fill 0.2s ease, stroke 0.2s ease;
}

.fwg__count:empty {
	display: none;
}

.fwg__item:hover .fwg__heart,
.fwg__item:focus-within .fwg__heart,
.fwg__heart[aria-pressed="true"] {
	opacity: 1;
	transform: none;
}

.fwg__heart:hover {
	background: rgb(0 0 0 / 0.6);
}

.fwg__heart[aria-pressed="true"] svg,
.fwg-lb__heart[aria-pressed="true"] svg {
	fill: var(--fwg-heart);
	stroke: var(--fwg-heart);
}

.fwg__heart.is-pop svg,
.fwg-lb__heart.is-pop svg {
	animation: fwg-pop 0.45s var(--fwg-ease);
}

@keyframes fwg-pop {
	0% { transform: scale(1); }
	35% { transform: scale(1.45); }
	100% { transform: scale(1); }
}

@media (hover: none) {
	.fwg__heart {
		opacity: 1;
		transform: none;
	}
}

/* ---------- Wasserzeichen ---------- */

.fwg__figure[data-wm]::after,
.fwg-lb__frame[data-wm]::after {
	content: attr(data-wm);
	position: absolute;
	right: 0.75em;
	bottom: 0.6em;
	z-index: 2;
	color: rgb(255 255 255 / 0.55);
	font: 600 0.75rem/1 system-ui, sans-serif;
	letter-spacing: 0.06em;
	text-shadow: 0 1px 3px rgb(0 0 0 / 0.5);
	pointer-events: none;
}

.fwg-lb__frame[data-wm]::after {
	font-size: clamp(0.8rem, 1.4vw, 1.1rem);
}

/* Wasserzeichen ausblenden, solange die Bildunterschrift sichtbar ist */
.fwg__item:hover .fwg__figure[data-wm]::after,
.fwg__item:focus-within .fwg__figure[data-wm]::after {
	opacity: 0;
}

.fwg__figure[data-wm]::after {
	transition: opacity 0.25s ease;
}

/* ---------- Bildschutz ---------- */

.fwg--protect .fwg__img,
.fwg-lb.is-protect .fwg-lb__img {
	-webkit-user-select: none;
	user-select: none;
	-webkit-user-drag: none;
	-webkit-touch-callout: none;
}

/* ---------- ZIP-Download ---------- */

.fwg__zip {
	margin: 1.25rem 0 0;
	text-align: center;
}

.fwg__zip a {
	display: inline-flex;
	align-items: center;
	gap: 0.5rem;
	padding: 0.7rem 1.2rem;
	border: 1px solid currentColor;
	border-radius: 999px;
	color: inherit;
	font-size: 0.875rem;
	text-decoration: none;
	opacity: 0.8;
	transition: opacity 0.2s ease, transform 0.2s ease;
}

.fwg__zip a:hover {
	opacity: 1;
	transform: translateY(-1px);
}

.fwg__zip svg {
	width: 1.1rem;
	height: 1.1rem;
	fill: none;
	stroke: currentColor;
	stroke-width: 1.8;
	stroke-linecap: round;
	stroke-linejoin: round;
}

/* ---------- Passwort-Formular ---------- */

.fwg .screen-reader-text {
	position: absolute !important;
	width: 1px;
	height: 1px;
	overflow: hidden;
	clip: rect(1px, 1px, 1px, 1px);
	clip-path: inset(50%);
	white-space: nowrap;
}

.fwg-lock {
	display: grid;
	justify-items: center;
	gap: 0.6rem;
	max-width: 30rem;
	margin: 0 auto;
	padding: 2.5rem 1.5rem;
	border: 1px solid rgb(127 127 127 / 0.3);
	border-radius: var(--fwg-radius);
	text-align: center;
}

.fwg-lock__icon {
	width: 2.25rem;
	height: 2.25rem;
	fill: none;
	stroke: currentColor;
	stroke-width: 1.5;
	stroke-linecap: round;
	opacity: 0.7;
}

.fwg-lock p {
	margin: 0;
}

.fwg-lock__title {
	font-size: 1.15rem;
	font-weight: 600;
}

.fwg-lock__text {
	opacity: 0.7;
	font-size: 0.9rem;
}

.fwg-lock__error {
	color: #ff6b6b;
	font-size: 0.9rem;
}

.fwg-lock__row {
	display: flex;
	gap: 0.5rem;
	width: 100%;
	margin-top: 0.5rem;
}

.fwg-lock input[type="password"] {
	flex: 1;
	min-width: 0;
	padding: 0.65rem 0.9rem;
	border: 1px solid rgb(127 127 127 / 0.45);
	border-radius: calc(var(--fwg-radius) * 0.6);
	background: transparent;
	color: inherit;
	font: inherit;
}

.fwg-lock button {
	padding: 0.65rem 1.1rem;
	border: 0;
	border-radius: calc(var(--fwg-radius) * 0.6);
	background: var(--wp--preset--color--contrast, #1b1b19);
	color: var(--wp--preset--color--base, #fff);
	cursor: pointer;
	font: inherit;
	font-weight: 600;
}

/* ==========================================================================
   Pop-up – Foto im Kasten mit Schließen-X oben rechts
   ========================================================================== */

.fwg-lb {
	--fwg-radius: 14px;
	--fwg-ease: cubic-bezier(0.2, 0.75, 0.25, 1);
	--fwg-heart: #ff5470;
	position: fixed;
	inset: 0;
	z-index: 100001;
	display: grid;
	place-items: center;
	color: var(--wp--preset--color--contrast, #1b1b19);
	font-family: system-ui, sans-serif;
	visibility: hidden;
	pointer-events: none;
}

.fwg-lb.is-open {
	visibility: visible;
	pointer-events: auto;
}

.fwg-lb__backdrop {
	position: absolute;
	inset: 0;
	background: rgb(27 27 25 / 0.55);
	-webkit-backdrop-filter: blur(6px);
	backdrop-filter: blur(6px);
	opacity: 0;
	transition: opacity 0.3s ease;
}

.fwg-lb.is-open .fwg-lb__backdrop {
	opacity: 1;
}

.fwg-lb__box {
	position: relative;
	z-index: 1;
	display: grid;
	gap: 0.6rem;
	padding: 0.75rem;
	border-radius: calc(var(--fwg-radius) + 0.5rem);
	background: var(--wp--preset--color--base, #fff);
	box-shadow: 0 30px 90px -20px rgb(0 0 0 / 0.45);
	will-change: transform;
}

.fwg-lb__top {
	display: flex;
	align-items: center;
	gap: 0.4rem;
	min-height: 2.5rem;
	padding-left: 0.4rem;
}

.fwg-lb__count {
	margin-right: auto;
	font-size: 0.8125rem;
	letter-spacing: 0.06em;
	font-variant-numeric: tabular-nums;
	opacity: 0.65;
}

.fwg-lb__bottom {
	padding: 0 0.4rem 0.2rem;
	font-size: 0.875rem;
}

.fwg-lb__caption {
	max-width: 60rem;
}

.fwg-lb__stage {
	position: relative;
	display: grid;
	place-items: center;
	touch-action: pan-y;
}

.fwg-lb__frame {
	position: relative;
	overflow: hidden;
	border-radius: var(--fwg-radius);
	cursor: zoom-in;
}

.fwg-lb__frame.is-zoomed {
	cursor: zoom-out;
}

.fwg-lb__img {
	display: block;
	width: 100%;
	height: 100%;
	max-width: none;
	object-fit: cover;
	transform-origin: var(--fwg-ox, 50%) var(--fwg-oy, 50%);
	transition: transform 0.35s var(--fwg-ease);
}

.fwg-lb__frame.is-zoomed .fwg-lb__img {
	transform: scale(2.2);
	transition: transform 0.35s var(--fwg-ease), transform-origin 0.08s linear;
}

.fwg-lb__btn {
	display: inline-grid;
	place-items: center;
	width: 2.5rem;
	height: 2.5rem;
	padding: 0;
	border: 0;
	border-radius: 999px;
	background: rgb(0 0 0 / 0.06);
	color: inherit;
	text-decoration: none;
	cursor: pointer;
	transition: background 0.2s ease, transform 0.2s var(--fwg-ease), opacity 0.2s ease;
}

.fwg-lb__btn:hover,
.fwg-lb__btn:focus-visible {
	background: rgb(0 0 0 / 0.12);
	transform: scale(1.06);
}

.fwg-lb__btn svg {
	width: 1.25rem;
	height: 1.25rem;
	fill: none;
	stroke: currentColor;
	stroke-width: 1.7;
	stroke-linecap: round;
	stroke-linejoin: round;
}

.fwg-lb__heart {
	width: auto;
	min-width: 2.5rem;
	gap: 0.35rem;
	padding: 0 0.8rem;
	display: inline-flex;
	align-items: center;
	font-size: 0.8125rem;
	font-weight: 600;
}

.fwg-lb__heart .fwg__count:empty {
	display: none;
}

/* Blättern: runde Knöpfe auf dem Foto */
.fwg-lb__nav {
	position: absolute;
	top: 50%;
	z-index: 3;
	background: rgb(255 255 255 / 0.88);
	color: #1b1b19;
	box-shadow: 0 4px 14px -4px rgb(0 0 0 / 0.35);
	transform: translateY(-50%);
	opacity: 0;
}

.fwg-lb__prev { left: 0.75rem; }
.fwg-lb__next { right: 0.75rem; }

.fwg-lb__stage:hover .fwg-lb__nav,
.fwg-lb__nav:focus-visible {
	opacity: 1;
}

.fwg-lb__nav:hover,
.fwg-lb__nav:focus-visible {
	background: #fff;
	transform: translateY(-50%) scale(1.06);
}

.fwg-lb.is-single .fwg-lb__nav,
.fwg-lb.is-single .fwg-lb__count {
	visibility: hidden;
}

.fwg-lb [hidden] {
	display: none !important;
}

@media (hover: none) {
	.fwg-lb__nav { opacity: 1; }
}

@media (max-width: 700px) {
	.fwg-lb__box { padding: 0.5rem; }
}

html.fwg-lock-scroll,
html.fwg-lock-scroll body {
	overflow: hidden;
}

@media (prefers-reduced-motion: reduce) {
	.fwg *,
	.fwg-lb * {
		transition-duration: 0.01ms !important;
		animation: none !important;
	}
}
