/* =========================================================================
   TP Bildergalerie – loftmynd.ch

   Alle Farben kommen aus den globalen Elementor-Farben
   (Elementor → Website-Einstellungen → Globale Farben):
     Primär   → Strich bei der Bildunterschrift
     Sekundär → Zähler «1/7», Pfeile, X
     Text     → Bildunterschrift (Fotonachweis/inaktive Pfeile als Abstufung)
     Weiss    → Hintergrund
   Die Werte nach dem Komma gelten nur, falls Elementor einmal fehlt.
   ========================================================================= */

:root {
	--tpb-accent: var(--e-global-color-secondary, #485A71);  /* Zähler          */
	--tpb-icons:  var(--e-global-color-secondary, #485A71);  /* Pfeile und X    */
	--tpb-line:   var(--e-global-color-primary, #7896BD);    /* Strich Legende  */
	--tpb-text:   var(--e-global-color-text, #000000);       /* Bildunterschrift */
	--tpb-bg:     var(--e-global-color-d9ad6fa, #FFFFFF);    /* Hintergrund     */

	/* Abstufungen – folgen automatisch den Farben oben */
	--tpb-muted: #8a8a8a;
	--tpb-muted: color-mix(in srgb, var(--tpb-text) 50%, var(--tpb-bg));
	--tpb-disabled: #c4c4c4;
	--tpb-disabled: color-mix(in srgb, var(--tpb-icons) 25%, var(--tpb-bg));
	--tpb-hover: rgba(0, 0, 0, .05);
	--tpb-hover: color-mix(in srgb, var(--tpb-icons) 8%, transparent);

	--tpb-maxwidth: 960px;   /* maximale Breite der Bildstrecke */
}

/* =========================================================================
   Im Artikel: TP Bildergalerie in Textbreite
   ========================================================================= */
.tpb {
	--tpb-inline-maxheight: 75vh;   /* Galerie höchstens so hoch wie 75 % des Bildschirms */
	margin: 1.6em 0;
	color: var(--tpb-text);
}
.tpb .tpb-data { display: none; }

.tpb .tpb__track {
	display: flex;
	aspect-ratio: var(--tpb-ratio, 1.5);      /* vom Plugin pro Galerie berechnet */
	max-height: var(--tpb-inline-maxheight);
	overflow-x: auto;
	overflow-y: hidden;
	scroll-snap-type: x mandatory;
	overscroll-behavior-x: contain;
	scrollbar-width: none;
	outline: none;
}
.tpb .tpb__track::-webkit-scrollbar { display: none; }
.tpb .tpb__track:focus-visible { box-shadow: 0 0 0 3px #4d90fe; }

.tpb .tpb__slide {
	flex: 0 0 100%;
	min-width: 0;
	scroll-snap-align: start;
	scroll-snap-stop: always;
	height: 100%;
	display: flex;
	align-items: flex-end;      /* Bild steht immer direkt über dem Zähler */
	justify-content: center;
}

/* Bild in voller Textbreite – nie verzogen, keine Ränder */
.tpb .tpb__slide img {
	display: block;
	/* Bild füllt immer die ganze Fläche, unabhängig von der geladenen Bildgrösse.
	   object-fit: contain = Seitenverhältnis bleibt, nichts wird verzogen oder
	   abgeschnitten; Hochformate stehen mittig mit weissem Rand. */
	width: 100%;
	height: 100%;
	max-width: none;
	max-height: none;
	object-fit: contain;
	object-position: 50% 100%;   /* unten bündig, direkt über dem Zähler */
	margin: 0;
	border: 0;
	border-radius: 0;
	box-shadow: none;
	cursor: zoom-in;
}

.tpb .tpb__bar {
	display: flex;
	align-items: center;
	justify-content: space-between;
	margin-top: 10px;
}
.tpb .tpb__counter {
	color: var(--tpb-accent);
	font-size: 20px;
	font-weight: 800;
	line-height: 1;
	font-variant-numeric: tabular-nums;
}
.tpb .tpb__nav { display: flex; gap: 4px; }

/* Knöpfe gegen Theme-Stile abgesichert */
.tpb .tpb__btn {
	appearance: none;
	-webkit-appearance: none;
	display: flex;
	align-items: center;
	justify-content: center;
	width: 40px;
	height: 40px;
	margin: 0;
	padding: 0;
	border: 0;
	border-radius: 4px;
	background: transparent;
	color: var(--tpb-icons);
	box-shadow: none;
	cursor: pointer;
	line-height: 1;
}
@media (hover: hover) {
	.tpb .tpb__btn:hover { background: var(--tpb-hover); }
}
.tpb .tpb__btn:hover,
.tpb .tpb__btn:focus { color: var(--tpb-icons); }
.tpb .tpb__btn:focus:not(:focus-visible) { background: transparent; }
.tpb .tpb__btn:focus-visible { outline: 3px solid #4d90fe; outline-offset: 1px; }
.tpb .tpb__btn svg { width: 26px; height: 26px; display: block; }

/* Nur ein Bild: kein Zähler, keine Pfeile */
.tpb.tpb--single .tpb__bar { display: none; }

.tpb .tpb__metabox {
	display: grid;            /* alle Bildunterschriften im selben Feld übereinander */
	margin-top: 10px;
}
.tpb .tpb__meta {
	grid-area: 1 / 1;
	align-self: start;
	padding: 2px 0 2px 12px;
	border-left: 2px solid var(--tpb-line);
	visibility: hidden;
}
.tpb .tpb__meta.is-active { visibility: visible; }
.tpb .tpb__meta.is-empty { border-left-color: transparent; }   /* kein Strich ohne Text */
.tpb .tpb__meta p { margin: 0; }
.tpb .tpb__caption { font-size: .9em; line-height: 1.45; color: var(--tpb-text); }
.tpb .tpb__caption a { color: inherit; text-decoration: underline; }
.tpb .tpb__credit { margin-top: 3px; font-size: .8em; color: var(--tpb-muted); }
.tpb .tpb__meta p:empty { display: none; }

@media (max-width: 600px) {
	.tpb { --tpb-inline-maxheight: 65vh; }
	.tpb .tpb__counter { font-size: 18px; }
}

/* =========================================================================
   Geöffnete Bildstrecke
   ========================================================================= */
html.tpb-lock,
html.tpb-lock body { overflow: hidden; }

.tpb-fs {
	position: fixed;
	inset: 0;
	z-index: 2147483000;
	background: var(--tpb-bg);
	color: var(--tpb-text);
	font-family: inherit;
	overflow-y: auto;
	overscroll-behavior: contain;
}
.tpb-fs[hidden] { display: none; }

.tpb-fs__inner {
	box-sizing: border-box;
	width: 100%;
	max-width: calc(var(--tpb-maxwidth) + 32px);
	min-height: 100%;
	margin: 0 auto;
	padding: 64px 16px 24px;
	display: flex;
	flex-direction: column;
	justify-content: flex-start;   /* von oben aufbauen: Pfeile bleiben an fester Stelle,
	                                  egal wie lang die Bildunterschrift ist */
}

/* ---- Bilder ---------------------------------------------------------- */
.tpb-fs__track {
	display: flex;
	overflow-x: auto;
	overflow-y: hidden;
	scroll-snap-type: x mandatory;
	overscroll-behavior-x: contain;
	scrollbar-width: none;
	outline: none;
}
.tpb-fs__track::-webkit-scrollbar { display: none; }

.tpb-fs__slide {
	flex: 0 0 100%;
	min-width: 0;
	scroll-snap-align: start;
	scroll-snap-stop: always;
	display: flex;
	align-items: flex-end;      /* Bild steht immer direkt über dem Zähler */
	justify-content: center;
}

/* Bild wird ins Feld eingepasst – nie verzogen, keine Ränder */
.tpb-fs .tpb-fs__slide img {
	display: block;
	width: auto;
	height: auto;
	max-width: 100%;
	max-height: calc(100vh - 210px);     /* Platz für Zähler und Legende */
	max-height: calc(100dvh - 210px);
	object-fit: contain;
	margin: 0;
	border: 0;
	border-radius: 0;
	box-shadow: none;
}

/* ---- Zeile mit Zähler und Pfeilen ----------------------------------- */
.tpb-fs__bar {
	display: flex;
	align-items: center;
	justify-content: space-between;
	margin-top: 12px;
}

.tpb-fs__counter {
	color: var(--tpb-accent);
	font-size: 22px;
	font-weight: 800;
	line-height: 1;
	font-variant-numeric: tabular-nums;
}

.tpb-fs__nav { display: flex; gap: 6px; }

/* Knöpfe gegen Theme-Stile abgesichert */
.tpb-fs .tpb-fs__btn {
	appearance: none;
	-webkit-appearance: none;
	display: flex;
	align-items: center;
	justify-content: center;
	width: 40px;
	height: 40px;
	margin: 0;
	padding: 0;
	border: 0;
	border-radius: 4px;
	background: transparent;
	color: var(--tpb-icons);
	box-shadow: none;
	cursor: pointer;
	line-height: 1;
}
@media (hover: hover) {
	.tpb-fs .tpb-fs__btn:hover { background: var(--tpb-hover); }
}
.tpb-fs .tpb-fs__btn:hover,
.tpb-fs .tpb-fs__btn:focus { color: var(--tpb-icons); }
.tpb-fs .tpb-fs__btn:focus:not(:focus-visible) { background: transparent; }
.tpb-fs .tpb-fs__btn:focus-visible { outline: 3px solid #4d90fe; outline-offset: 1px; }
.tpb-fs .tpb-fs__btn[disabled] {
	visibility: hidden;
	color: var(--tpb-disabled);
	background: transparent;
	cursor: default;
}
.tpb-fs .tpb-fs__btn svg { width: 28px; height: 28px; display: block; }

.tpb-fs .tpb-fs__close {
	position: fixed;
	top: 8px;
	right: 8px;
	width: 44px;
	height: 44px;
	z-index: 1;
}

/* ---- Legende und Fotonachweis --------------------------------------- */
.tpb-fs__meta {
	margin-top: 12px;
	padding: 2px 0 2px 12px;
	border-left: 2px solid var(--tpb-line);
}
.tpb-fs__meta:not(:has(p:not(:empty))),
.tpb-fs .tpb-fs__meta.is-empty { display: none; }   /* kein Strich ohne Text */
.tpb-fs .tpb-fs__meta p { margin: 0; }
.tpb-fs .tpb-fs__caption { font-size: 15px; line-height: 1.5; color: var(--tpb-text); }
.tpb-fs .tpb-fs__caption a { color: inherit; text-decoration: underline; }
.tpb-fs .tpb-fs__credit { margin-top: 4px; font-size: 13px; color: var(--tpb-muted); }
.tpb-fs .tpb-fs__meta p:empty { display: none; }

@media (max-width: 600px) {
	.tpb-fs__inner { padding: 52px 12px 20px; }
	/* Handy: Bild höchstens 58 % der Höhe, der Rest bleibt für Zähler und Bildunterschrift */
	.tpb-fs .tpb-fs__slide img { max-height: 58vh; max-height: 58dvh; }
	.tpb-fs__counter { font-size: 20px; }
	.tpb-fs .tpb-fs__caption { font-size: 14px; }
}
