/*
 * 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;
}

/* --- Filterleiste (Pro) ---------------------------------------------- */

.hg-filter {
	display: flex;
	flex-wrap: wrap;
	gap: 6px;
	margin: 0 0 var(--hg-gap, 10px);
}

.hg-chip {
	cursor: pointer;
	font: inherit;
	font-size: 0.9em;
	line-height: 1;
	padding: 8px 14px;
	min-height: 34px;
	border: 1px solid currentColor;
	border-radius: 999px;
	background: transparent;
	color: inherit;
	opacity: 0.7;
}

/*
 * Der gedrueckte Zustand wird ueber Deckkraft und einen zweiten Rand gezeigt,
 * nicht ueber eine Fuellfarbe: Heckgalerie kennt die Theme-Farben nicht, und
 * "currentColor als Hintergrund" heisst Schrift in Hintergrundfarbe.
 */
.hg-chip.is-active {
	opacity: 1;
	box-shadow: inset 0 0 0 1px currentColor;
}

.hg-chip:focus-visible {
	outline: 2px solid currentColor;
	outline-offset: 2px;
}

/* Ein gefiltertes Item ist hidden - manche Themes setzen figure auf block. */
.hg-item[hidden] {
	display: none;
}

/* --- Video-Kachel: Abspielzeichen aus CSS, kein Icon-Font ------------- */

.hg-item.has-video .hg-media {
	position: relative;
}

.hg-item.has-video .hg-media::after {
	content: "";
	position: absolute;
	top: 50%;
	left: 50%;
	width: 0;
	height: 0;
	margin: -11px 0 0 -7px;
	border-style: solid;
	border-width: 11px 0 11px 18px;
	border-color: transparent transparent transparent #fff;
	filter: drop-shadow(0 0 6px rgba(0, 0, 0, 0.7));
	pointer-events: none;
}

.hg-item.has-video .hg-media::before {
	content: "";
	position: absolute;
	top: 50%;
	left: 50%;
	width: 54px;
	height: 54px;
	margin: -27px 0 0 -27px;
	border-radius: 50%;
	background: rgba(0, 0, 0, 0.45);
	pointer-events: none;
}

/* --- Mosaik (Pro): wiederholtes Muster, 1 gross + 4 klein ------------ */

.hg--mosaic {
	display: grid;
	gap: var(--hg-gap);
	grid-template-columns: repeat(4, 1fr);
	grid-auto-rows: 1fr;
}

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

.hg--mosaic .hg-item:nth-child(5n + 1) {
	grid-column: span 2;
	grid-row: span 2;
}

.hg--mosaic .hg-item:nth-child(5n + 1) img {
	aspect-ratio: 1;
}

@media (max-width: 600px) {
	.hg--mosaic {
		grid-template-columns: repeat(2, 1fr);
	}
}

/* --- Filmstreifen (Pro): Scroll-Snap-Reihe --------------------------- */

.hg--filmstrip {
	display: flex;
	gap: var(--hg-gap);
	overflow-x: auto;
	scroll-snap-type: x mandatory;
	scrollbar-width: thin;
	padding-bottom: 6px;
}

.hg--filmstrip .hg-item {
	flex: 0 0 auto;
	width: min(70%, 320px);
	scroll-snap-align: start;
}

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

.hg-strip-nav {
	display: flex;
	justify-content: flex-end;
	gap: 6px;
	margin-top: 6px;
}

/* --- 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;
}

/* Kacheln mit Namen (Pro) */

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

.hg--logos-cards .hg-logo {
	border: 1px solid rgba(0, 0, 0, 0.12);
	border-radius: var(--hg-radius);
	padding: 16px 12px;
	height: 100%;
}

.hg--logos-cards .hg-logo img {
	max-height: 64px;
}

.hg-logo-name {
	font-weight: 600;
	line-height: 1.3;
	text-align: center;
}

.hg-logo-note {
	font-size: 0.85em;
	line-height: 1.35;
	text-align: center;
	opacity: 0.8;
}

/* Laufband (Pro) */

.hg--logos-marquee {
	overflow: hidden;
	-webkit-mask-image: linear-gradient(to right, transparent, #000 6%, #000 94%, transparent);
	mask-image: linear-gradient(to right, transparent, #000 6%, #000 94%, transparent);
}

.hg-marquee-track {
	display: flex;
	align-items: center;
	gap: var(--hg-gap);
	width: max-content;
	padding-right: var(--hg-gap);
	animation: hg-marquee var(--hg-speed, 45s) linear infinite;
}

.hg-marquee-clone {
	display: flex;
	align-items: center;
	gap: var(--hg-gap);
	padding-left: var(--hg-gap);
}

/* Pause bei Hover UND bei Tastaturfokus irgendwo im Band. */
.hg--logos-marquee:hover .hg-marquee-track,
.hg--logos-marquee:focus-within .hg-marquee-track {
	animation-play-state: paused;
}

.hg--logos-marquee .hg-logo {
	flex: 0 0 auto;
	padding: 10px 18px;
}

.hg--logos-marquee .hg-logo img {
	height: 40px;
	width: auto;
	max-width: none;
	max-height: none;
}

@keyframes hg-marquee {
	to {
		transform: translateX(-50%);
	}
}

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

.hg-slider {
	position: relative;
}

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

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

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

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

/* Buehne (Pro) */

.hg--slider-hero .hg-slides {
	aspect-ratio: var(--hg-aspect, 21 / 9);
	border-radius: 0;
}

.hg--slider-hero .hg-slides::after {
	content: "";
	position: absolute;
	inset: 0;
	background: rgba(0, 0, 0, var(--hg-overlay, 0.45));
	pointer-events: none;
}

.hg-hero-text {
	position: absolute;
	inset: auto 0 0 0;
	padding: 6% 8%;
	color: #fff;
	text-shadow: 0 1px 3px rgba(0, 0, 0, 0.6);
	pointer-events: none;
}

.hg-hero-title {
	font-size: clamp(1.4rem, 4vw, 3rem);
	font-weight: 700;
	margin: 0 0 0.3em;
	line-height: 1.15;
}

.hg-hero-sub {
	font-size: clamp(0.95rem, 1.8vw, 1.3rem);
	margin: 0 0 0.8em;
}

.hg-hero-cta {
	display: inline-block;
	pointer-events: auto;
	background: #fff;
	color: #111;
	padding: 10px 20px;
	border-radius: var(--hg-radius);
	text-decoration: none;
	font-weight: 600;
}

/* Karussell (Pro) */

.hg--slider-carousel .hg-slides {
	display: flex;
	gap: var(--hg-gap);
	overflow-x: auto;
	scroll-snap-type: x mandatory;
	scroll-behavior: smooth;
}

.hg--slider-carousel .hg-slide {
	flex: 0 0 auto;
	width: calc((100% - var(--hg-gap) * (var(--hg-columns, 3) - 1)) / var(--hg-columns, 3));
	scroll-snap-align: start;
}

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

@media (max-width: 700px) {
	.hg--slider-carousel .hg-slide {
		width: 80%;
	}
}

/* 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) {
	/* Das Laufband wird zum Einzeiler: keine Animation, kein Umbruch-Chaos. */
	.hg-marquee-track {
		animation: none;
		flex-wrap: wrap;
		width: auto;
		justify-content: center;
	}

	.hg-marquee-clone {
		display: none;
	}

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

	.hg--slider-carousel .hg-slides {
		scroll-behavior: auto;
	}
}
