/*
 * Heckgalerie Frontend.
 *
 * Ein Stylesheet fuer alle zwoelf Vorlagen. Keine Icon-Fonts, keine externen
 * Schriften, kein @import. Bewegung nur dort, wo sie bestellt wurde, und nie
 * bei prefers-reduced-motion.
 *
 * Die Steuerwerte kommen als Custom Properties aus dem Renderer:
 * --hg-gap, --hg-columns, --hg-aspect, --hg-speed, --hg-overlay
 * und je Item --hg-ratio.
 */

.hg {
	--hg-gap: 10px;
	--hg-radius: 4px;
	margin: 1em 0;
}

.hg img {
	max-width: 100%;
	height: auto;
	display: block;
}

.hg-sr-only {
	position: absolute;
	width: 1px;
	height: 1px;
	margin: -1px;
	padding: 0;
	overflow: hidden;
	clip: rect(0 0 0 0);
	white-space: nowrap;
	border: 0;
}

.hg-item {
	margin: 0;
}

.hg-media {
	display: block;
	line-height: 0;
}

.hg-caption {
	font-size: 0.85em;
	line-height: 1.35;
	padding: 6px 2px 0;
	opacity: 0.85;
}

/* --- Raster --------------------------------------------------------- */

.hg--grid {
	display: grid;
	gap: var(--hg-gap);
	grid-template-columns: repeat(var(--hg-columns, auto-fill), minmax(150px, 1fr));
}

.hg--grid .hg-item img {
	width: 100%;
	aspect-ratio: var(--hg-aspect, 4 / 3);
	object-fit: cover;
	border-radius: var(--hg-radius);
}

/* --- Masonry (CSS columns, kein JS-Layouting) ------------------------ */

.hg--masonry {
	columns: var(--hg-columns, 3) 220px;
	column-gap: var(--hg-gap);
}

.hg--masonry .hg-item {
	break-inside: avoid;
	margin-bottom: var(--hg-gap);
}

.hg--masonry .hg-item img {
	width: 100%;
	border-radius: var(--hg-radius);
}

/* --- Justified (Zeilen kommen serverseitig, Breiten macht Flexbox) --- */

.hg--justified .hg-row {
	display: flex;
	gap: var(--hg-gap);
	margin-bottom: var(--hg-gap);
}

.hg--justified .hg-item {
	flex: 1 1 0;
	min-width: 0;
}

.hg--justified .hg-item img {
	width: 100%;
	aspect-ratio: var(--hg-ratio, 1);
	object-fit: cover;
	border-radius: var(--hg-radius);
}

/* --- Album: Kachel je Untergalerie ----------------------------------- */

.hg--album {
	display: grid;
	gap: var(--hg-gap);
	grid-template-columns: repeat(var(--hg-columns, auto-fill), minmax(190px, 1fr));
}

.hg-album-tile {
	position: relative;
	display: block;
	text-decoration: none;
	color: inherit;
	border-radius: var(--hg-radius);
	overflow: hidden;
}

.hg-album-tile img,
.hg-album-empty {
	display: block;
	width: 100%;
	aspect-ratio: var(--hg-aspect, 4 / 3);
	object-fit: cover;
	background: rgba(0, 0, 0, 0.08);
}

.hg-album-caption {
	display: block;
	padding: 8px 2px 0;
	line-height: 1.3;
}

.hg-album-name {
	display: block;
	font-weight: 600;
}

.hg-album-count {
	display: block;
	font-size: 0.85em;
	opacity: 0.75;
}

.hg-album-back {
	margin: 0 0 0.8em;
}





/* --- Logoleisten ----------------------------------------------------- */

.hg-logos .hg-logo {
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: 6px;
	padding: 8px;
	line-height: 0;
	text-decoration: none;
	color: inherit;
}

.hg-logos .hg-logo img {
	max-width: 100%;
	max-height: 90px;
	width: auto;
	object-fit: contain;
}

.hg-logos.is-grayscale .hg-logo img {
	filter: grayscale(1);
	opacity: 0.75;
	transition: filter 0.2s, opacity 0.2s;
}

.hg-logos.is-grayscale .hg-logo:hover img,
.hg-logos.is-grayscale .hg-logo:focus-visible img {
	filter: none;
	opacity: 1;
}

.hg-logos.is-inverted .hg-logo img {
	filter: grayscale(1) invert(1) brightness(2);
}

.hg-logos.is-inverted .hg-logo:hover img,
.hg-logos.is-inverted .hg-logo:focus-visible img {
	filter: invert(1) brightness(2);
}

.hg--logos-grid {
	display: grid;
	gap: var(--hg-gap);
	grid-template-columns: repeat(var(--hg-columns, auto-fill), minmax(130px, 1fr));
	align-items: center;
}

.hg--logos-row {
	display: flex;
	flex-wrap: nowrap;
	align-items: center;
	justify-content: center;
	gap: var(--hg-gap);
	overflow-x: auto;
}

.hg--logos-row .hg-logo {
	flex: 0 0 auto;
}

.hg--logos-row .hg-logo img {
	max-height: 48px;
}



/* --- Slider ----------------------------------------------------------- */

.hg-slider {
	position: relative;
}

.hg--slider-fade .hg-slides {
	position: relative;
	aspect-ratio: var(--hg-aspect, 3 / 2);
	overflow: hidden;
	border-radius: var(--hg-radius);
}

.hg--slider-fade .hg-slide {
	position: absolute;
	inset: 0;
	opacity: 0;
	transition: opacity 0.6s;
}

.hg--slider-fade .hg-slide.is-active {
	opacity: 1;
}

.hg--slider-fade .hg-slide img {
	width: 100%;
	height: 100%;
	object-fit: cover;
}



/* Bedienelemente */

.hg-slider-nav {
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 10px;
	margin-top: 8px;
}

.hg-arrow,
.hg-dot {
	cursor: pointer;
	border: 1px solid rgba(0, 0, 0, 0.25);
	background: rgba(255, 255, 255, 0.9);
	color: #111;
	border-radius: var(--hg-radius);
	line-height: 1;
}

.hg-arrow {
	font-size: 20px;
	padding: 4px 12px;
	min-width: 44px;
	min-height: 34px;
}

.hg-dots {
	display: flex;
	gap: 6px;
}

.hg-dot {
	width: 12px;
	height: 12px;
	padding: 0;
	border-radius: 50%;
	background: rgba(0, 0, 0, 0.2);
}

.hg-dot.is-active {
	background: currentColor;
}

.hg-arrow:focus-visible,
.hg-dot:focus-visible,
.hg-media:focus-visible,
.hg-logo:focus-visible {
	outline: 2px solid currentColor;
	outline-offset: 2px;
}

/* --- Lightbox --------------------------------------------------------- */

dialog.hg-lightbox {
	border: 0;
	padding: 0;
	background: transparent;
	max-width: 96vw;
	max-height: 96vh;
	color: #fff;
}

dialog.hg-lightbox::backdrop {
	background: rgba(0, 0, 0, 0.88);
}

dialog.hg-lightbox img,
dialog.hg-lightbox video {
	max-width: 92vw;
	max-height: 84vh;
	display: block;
	margin: 0 auto;
}

dialog.hg-lightbox iframe {
	display: block;
	margin: 0 auto;
	border: 0;
	width: 92vw;
	max-width: 1280px;
	aspect-ratio: 16 / 9;
	height: auto;
}

.hg-lb-exif {
	margin: 4px 0 0;
	font-size: 0.8rem;
	opacity: 0.7;
	text-align: center;
}

.hg-lb-bar {
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 12px;
	padding: 10px 4px 0;
	font-size: 0.9rem;
}

dialog.hg-lightbox button {
	background: rgba(0, 0, 0, 0.55);
	color: #fff;
	border: 1px solid rgba(255, 255, 255, 0.35);
	font-size: 22px;
	line-height: 1;
	padding: 8px 14px;
	min-width: 44px;
	min-height: 44px;
	cursor: pointer;
	border-radius: var(--hg-radius, 4px);
}

dialog.hg-lightbox .hg-lb-close {
	position: fixed;
	top: 14px;
	right: 14px;
	font-size: 18px;
}

/* --- Bewegung aus ----------------------------------------------------- */

@media (prefers-reduced-motion: reduce) {

	.hg--slider-fade .hg-slide {
		transition: none;
	}

}
