/*
 * jVideo 1.0.6 - Vorschau-Kacheln und Popup
 * Changes vs. 1.0.5 (Stand 12.11.2026): Knopf .jvideo-ton „Ton einschalten“ wieder entfernt
 * Changes vs. 1.0.4 (Stand 12.11.2026): Popup immer mittig im Browserfenster (fest positioniert, unabhängig von
 *   Template-Regeln für dialog wie margin/top/left), Knopf .jvideo-ton „Ton einschalten“, Zahl .jvideo-aufrufe
 * 1.0.3/1.0.4: keine Änderung an den Regeln
 * Changes vs. 1.0.1 (Stand 12.11.2026): keine Änderung an den Regeln (Version mit dem Paket angehoben)
 * Changes vs. 1.0.0 (Stand 12.11.2026): Vorschau beim Mauszeiger (.jvideo-hover über der Kachel, .jvideo-laeuft)
 * (C) 2026 Computertechnik Brübach - GNU GPL v2 or later
 *
 * Farben lassen sich im Template über die Variablen anpassen, z. B.
 * .jvideo { --jvideo-akzent: #c00; }
 */

.jvideo {
	--jvideo-min: 240px;
	--jvideo-abstand: 1rem;
	--jvideo-radius: .5rem;
	--jvideo-akzent: #e62117;
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(min(var(--jvideo-min), 100%), 1fr));
	gap: var(--jvideo-abstand);
	margin: 0 0 1.5rem;
}

.jvideo-kachel {
	position: relative;
	margin: 0;
	min-width: 0;
}

/* Vorschau beim Mauszeiger: liegt über der Kachel und lässt Klicks zum Knopf darunter durch */
.jvideo-hover {
	position: absolute;
	z-index: 1;
	border-radius: var(--jvideo-radius);
	overflow: hidden;
	background: #000;
	pointer-events: none;
}

.jvideo-hover iframe,
.jvideo-hover video {
	position: absolute;
	inset: 0;
	display: block;
	width: 100%;
	height: 100%;
	border: 0;
	object-fit: cover;
	pointer-events: none;
}

.jvideo-hover-ton {
	position: absolute;
	left: .5rem;
	bottom: .5rem;
	padding: .1rem .4rem;
	border-radius: .25rem;
	background: rgba(0, 0, 0, .6);
	color: #fff;
	font-size: .7rem;
	line-height: 1.4;
}

.jvideo-vorschau.jvideo-laeuft .jvideo-play {
	opacity: 0;
}

.jvideo-vorschau {
	position: relative;
	display: block;
	width: 100%;
	aspect-ratio: 16 / 9;
	padding: 0;
	border: 0;
	border-radius: var(--jvideo-radius);
	overflow: hidden;
	background: #1b1b1b;
	cursor: pointer;
	box-shadow: 0 1px 3px rgba(0, 0, 0, .25);
}

.jvideo-vorschau img,
.jvideo-vorschau video,
.jvideo-ohne-bild {
	position: absolute;
	inset: 0;
	display: block;
	width: 100%;
	height: 100%;
	object-fit: cover;
	pointer-events: none;
	transition: transform .3s ease, filter .3s ease;
}

.jvideo-ohne-bild {
	background: linear-gradient(135deg, #2a2a2a, #111);
}

.jvideo-play {
	position: absolute;
	top: 50%;
	left: 50%;
	width: 4rem;
	height: 2.8rem;
	transform: translate(-50%, -50%);
	border-radius: .8rem;
	background: rgba(20, 20, 20, .75);
	transition: background-color .2s ease, transform .2s ease;
}

.jvideo-play::after {
	content: "";
	position: absolute;
	top: 50%;
	left: 54%;
	transform: translate(-50%, -50%);
	border-style: solid;
	border-width: .65rem 0 .65rem 1.1rem;
	border-color: transparent transparent transparent #fff;
}

.jvideo-marke {
	position: absolute;
	right: .5rem;
	bottom: .5rem;
	padding: .1rem .4rem;
	border-radius: .25rem;
	background: rgba(0, 0, 0, .6);
	color: #fff;
	font-size: .7rem;
	line-height: 1.4;
	pointer-events: none;
}

.jvideo-vorschau:hover img,
.jvideo-vorschau:hover video,
.jvideo-vorschau:focus-visible img,
.jvideo-vorschau:focus-visible video {
	transform: scale(1.04);
	filter: brightness(.85);
}

.jvideo-vorschau:hover .jvideo-play,
.jvideo-vorschau:focus-visible .jvideo-play {
	background: var(--jvideo-akzent);
	transform: translate(-50%, -50%) scale(1.08);
}

.jvideo-vorschau:focus-visible {
	outline: 3px solid var(--jvideo-akzent);
	outline-offset: 2px;
}

.jvideo-kachel figcaption {
	padding: .4rem .1rem 0;
	line-height: 1.35;
}

.jvideo-titel {
	display: block;
	font-weight: 600;
}

.jvideo-text {
	margin-top: .25rem;
	font-size: .9em;
	opacity: .85;
}

.jvideo-text > :last-child {
	margin-bottom: 0;
}

/* ---------- Popup ---------- */

/* 1.0.5: immer mittig im Fenster - auch wenn das Template dialog-Elemente anders platziert (margin: 0, top/left, transform) */
dialog.jvideo-dialog,
dialog.jvideo-dialog[open] {
	position: fixed !important;
	inset: 0 !important;
	top: 0 !important;
	right: 0 !important;
	bottom: 0 !important;
	left: 0 !important;
	margin: auto !important;
	transform: none !important;
	height: fit-content !important;
	translate: none !important;
	float: none !important;
}

.jvideo-dialog {
	box-sizing: border-box;
	width: min(1100px, 94vw, calc((94vh - 3.25rem) * 16 / 9));
	max-width: none;
	max-height: 94vh;
	padding: 0;
	border: 0;
	border-radius: var(--jvideo-radius, .5rem);
	background: #000;
	color: #fff;
	overflow: visible;
}

.jvideo-dialog::backdrop {
	background: rgba(0, 0, 0, .85);
}

.jvideo-dialog-kopf {
	display: flex;
	align-items: center;
	gap: 1rem;
	padding: .5rem .5rem .5rem 1rem;
	background: #111;
	border-radius: var(--jvideo-radius, .5rem) var(--jvideo-radius, .5rem) 0 0;
}

.jvideo-dialog-titel {
	flex: 1;
	margin: 0;
	font-size: 1rem;
	font-weight: 600;
	line-height: 1.3;
	color: #fff;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.jvideo-zu {
	flex: none;
	width: 2.25rem;
	height: 2.25rem;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: transparent;
	color: #fff;
	font-size: 1.75rem;
	line-height: 1;
	cursor: pointer;
}

.jvideo-zu:hover,
.jvideo-zu:focus-visible {
	background: rgba(255, 255, 255, .15);
	outline: none;
}

.jvideo-buehne {
	position: relative;
	aspect-ratio: 16 / 9;
	max-height: calc(94vh - 3.25rem);
	margin: 0 auto;
	background: #000;
	border-radius: 0 0 var(--jvideo-radius, .5rem) var(--jvideo-radius, .5rem);
	overflow: hidden;
}

.jvideo-buehne iframe,
.jvideo-buehne video {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	border: 0;
	background: #000;
}

.jvideo-hinweis {
	position: absolute;
	inset: 0;
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: 1rem;
	padding: 1.5rem;
	text-align: center;
	background: #000 center / cover no-repeat;
}

.jvideo-hinweis::before {
	content: "";
	position: absolute;
	inset: 0;
	background: rgba(0, 0, 0, .7);
}

.jvideo-hinweis > * {
	position: relative;
	max-width: 36rem;
	margin: 0;
}

.jvideo-hinweis a {
	color: #fff;
	text-decoration: underline;
}

.jvideo-los {
	padding: .6rem 1.4rem;
	border: 0;
	border-radius: 2rem;
	background: #e62117;
	color: #fff;
	font-size: 1rem;
	font-weight: 600;
	cursor: pointer;
}

.jvideo-los:hover,
.jvideo-los:focus-visible {
	background: #b5170f;
	outline: 2px solid #fff;
	outline-offset: 2px;
}


/* 1.0.5: Aufrufe unter der Kachel */
.jvideo-aufrufe {
	display: block;
	font-size: .8em;
	opacity: .75;
}

.jvideo-fehler {
	position: absolute;
	inset: 0;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 1rem;
	text-align: center;
}

@media (prefers-reduced-motion: reduce) {
	.jvideo-vorschau img,
	.jvideo-vorschau video,
	.jvideo-play {
		transition: none;
	}
}
