/* ---------- Grid ---------- */
.evh-mg {
	--evh-mg-play-size: 56px;
	--evh-mg-play-color: #fff;
	--evh-mg-play-bg: rgba(0, 0, 0, 0.55);
	--evh-mg-overlay: rgba(0, 0, 0, 0.35);
	display: grid;
	grid-template-columns: repeat(3, minmax(0, 1fr));
	gap: 10px;
}

.evh-mg .evh-mg-item {
	margin: 0;
	padding: 0;
	min-width: 0;
	position: relative;
	display: flex;
	flex-direction: column;
}

.evh-mg-media {
	position: relative;
	display: block;
	width: 100%;
	overflow: hidden;
	background: #111;
	/* <button> reset for inline embeds */
	padding: 0;
	margin: 0;
	border: 0;
	border-radius: 0;
	font: inherit;
	color: inherit;
	cursor: pointer;
	line-height: 0;
}

div.evh-mg-media {
	cursor: default;
}

.evh-mg .evh-mg-media > img,
.evh-mg .evh-mg-media > video {
	display: block;
	width: 100%;
	height: 100%;
	max-width: none;
	object-fit: cover;
	border: 0;
	border-radius: 0;
	box-shadow: none;
	transition: transform 0.4s ease;
}

/* Poster-less video preview: never interactive, the link handles the click */
a.evh-mg-media > video,
button.evh-mg-media > video {
	pointer-events: none;
}

.evh-mg-noimg {
	display: block;
	width: 100%;
	height: 100%;
	min-height: 120px;
	background: linear-gradient(135deg, #222, #444);
}

.evh-mg-media:focus-visible {
	outline: 3px solid #5b9dd9;
	outline-offset: 2px;
}

/* ---------- Hover effects (prefix_class on the widget wrapper) ---------- */
.evh-mg-media::after {
	content: "";
	position: absolute;
	inset: 0;
	background: var(--evh-mg-overlay);
	opacity: 0;
	transition: opacity 0.3s ease;
	pointer-events: none;
}

.evh-mg-hover-zoom a.evh-mg-media:hover > img,
.evh-mg-hover-zoom button.evh-mg-media:hover > img,
.evh-mg-hover-both a.evh-mg-media:hover > img,
.evh-mg-hover-both button.evh-mg-media:hover > img {
	transform: scale(1.06);
}

.evh-mg-hover-darken a.evh-mg-media:hover::after,
.evh-mg-hover-darken button.evh-mg-media:hover::after,
.evh-mg-hover-both a.evh-mg-media:hover::after,
.evh-mg-hover-both button.evh-mg-media:hover::after {
	opacity: 1;
}

/* ---------- Play icon ---------- */
.evh-mg-play {
	position: absolute;
	top: 50%;
	left: 50%;
	z-index: 2;
	width: var(--evh-mg-play-size);
	height: var(--evh-mg-play-size);
	transform: translate(-50%, -50%);
	display: flex;
	align-items: center;
	justify-content: center;
	border-radius: 50%;
	background: var(--evh-mg-play-bg);
	color: var(--evh-mg-play-color);
	transition: transform 0.25s ease, background-color 0.25s ease;
	pointer-events: none;
}

.evh-mg-play svg {
	width: 45%;
	height: 45%;
	fill: currentColor;
	margin-inline-start: 6%;
}

.evh-mg-media:hover .evh-mg-play {
	transform: translate(-50%, -50%) scale(1.1);
}

/* ---------- Captions ---------- */
.evh-mg-caption {
	font-size: 0.875em;
	line-height: 1.4;
	padding: 6px 2px;
}

.evh-mg--caption-overlay .evh-mg-caption {
	position: absolute;
	inset-inline: 0;
	bottom: 0;
	z-index: 3;
	padding: 10px 12px;
	color: #fff;
	background: linear-gradient(to top, rgba(0, 0, 0, 0.75), rgba(0, 0, 0, 0));
	pointer-events: none;
}

/* ---------- Inline embed (Link: None) ---------- */
.evh-mg-inline--playing {
	aspect-ratio: 16 / 9;
	cursor: default;
}

.evh-mg-inline--playing iframe {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	border: 0;
}

.evh-mg-placeholder {
	padding: 30px;
	text-align: center;
	border: 2px dashed #c9ccd1;
	color: #6d7882;
}

/* ---------- Lightbox ---------- */
html.evh-lb-open,
html.evh-lb-open body {
	overflow: hidden;
}

.evh-lb {
	--evh-lb-bg: rgba(10, 10, 10, 0.94);
	--evh-lb-color: #fff;
	position: fixed;
	inset: 0;
	z-index: 999999;
	display: grid;
	grid-template-columns: 64px minmax(0, 1fr) 64px;
	grid-template-rows: 56px minmax(0, 1fr) auto;
	grid-template-areas:
		"counter . close"
		"prev stage next"
		"caption caption caption";
	background: var(--evh-lb-bg);
	color: var(--evh-lb-color);
	animation: evh-lb-in 0.2s ease;
}

.evh-lb[hidden] {
	display: none;
}

@keyframes evh-lb-in {
	from { opacity: 0; }
	to { opacity: 1; }
}

.evh-lb__stage {
	grid-area: stage;
	display: flex;
	align-items: center;
	justify-content: center;
	min-height: 0;
	padding: 8px;
}

.evh-lb__media {
	display: block;
	max-width: 100%;
	max-height: 100%;
	object-fit: contain;
	box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
}

video.evh-lb__media {
	background: #000;
}

.evh-lb__embed {
	position: relative;
	/* biggest 16:9 box that fits the stage */
	width: min(100%, calc((100vh - 160px) * 16 / 9));
	aspect-ratio: 16 / 9;
	background: #000;
}

.evh-lb__embed iframe {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	border: 0;
}

.evh-lb__btn {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 48px;
	height: 48px;
	margin: auto;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: transparent;
	color: inherit;
	cursor: pointer;
	opacity: 0.8;
	transition: opacity 0.2s ease, background-color 0.2s ease;
}

.evh-lb__btn:hover,
.evh-lb__btn:focus-visible {
	opacity: 1;
	background: rgba(255, 255, 255, 0.12);
}

.evh-lb__btn:focus-visible {
	outline: 2px solid currentColor;
	outline-offset: 2px;
}

.evh-lb__btn svg {
	width: 28px;
	height: 28px;
	fill: currentColor;
}

.evh-lb__close { grid-area: close; }
.evh-lb__prev { grid-area: prev; }
.evh-lb__next { grid-area: next; }

/* Arrows point the reading direction */
[dir="rtl"] .evh-lb__prev svg,
[dir="rtl"] .evh-lb__next svg {
	transform: scaleX(-1);
}

.evh-lb__counter {
	grid-area: counter;
	align-self: center;
	justify-self: center;
	font-size: 14px;
	opacity: 0.8;
	font-variant-numeric: tabular-nums;
	direction: ltr;
}

.evh-lb__caption {
	grid-area: caption;
	padding: 10px 20px 20px;
	text-align: center;
	font-size: 15px;
	line-height: 1.5;
}

.evh-lb__caption[hidden] {
	display: none;
}

.evh-lb--single .evh-lb__prev,
.evh-lb--single .evh-lb__next {
	visibility: hidden;
}

@media (max-width: 767px) {
	.evh-lb {
		grid-template-columns: 44px minmax(0, 1fr) 44px;
	}

	.evh-lb__stage {
		padding: 0;
	}

	.evh-lb__btn {
		width: 40px;
		height: 40px;
	}
}

@media (prefers-reduced-motion: reduce) {
	.evh-mg-media > img,
	.evh-mg-play,
	.evh-lb {
		transition: none;
		animation: none;
	}
}
