/**
 * Zemen Media Library - front-end styles.
 * Uses CSS custom properties (with fallbacks) so Elementor Style controls
 * can update colors instantly via inline custom properties on .zml-widget.
 */

.zml-widget {
	--zml-tab-color: #3a3a3a;
	--zml-tab-bg: #f0f0f0;
	--zml-tab-color-hover: #1a1a1a;
	--zml-tab-bg-hover: #e2e2e2;
	--zml-tab-color-active: #ffffff;
	--zml-tab-bg-active: #2563eb;
	--zml-card-bg: #ffffff;
	--zml-duration-color: #ffffff;
	--zml-duration-bg: rgba(0, 0, 0, 0.65);
	--zml-accent: #2563eb;
	--zml-audio-bg: #f5f6f8;
	--zml-play-btn-color: #ffffff;
	--zml-play-btn-size: 40px;
	--zml-time-color: #6b7280;

	box-sizing: border-box;
}

.zml-widget *,
.zml-widget *::before,
.zml-widget *::after {
	box-sizing: border-box;
}

/* Filter Tabs */

.zml-tabs {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	justify-content: center;
	gap: 10px;
	margin-block-end: 24px;
	list-style: none;
	padding: 0;
}

.zml-tab {
	appearance: none;
	cursor: pointer;
	border: none;
	font: inherit;
	color: var(--zml-tab-color);
	background-color: var(--zml-tab-bg);
	padding: 8px 20px;
	border-radius: 30px;
	transition: color 0.2s ease, background-color 0.2s ease, transform 0.15s ease;
	white-space: nowrap;
}

.zml-tab:hover {
	color: var(--zml-tab-color-hover);
	background-color: var(--zml-tab-bg-hover);
}

.zml-tab:focus-visible {
	outline: 2px solid var(--zml-accent);
	outline-offset: 2px;
}

.zml-tab.is-active {
	color: var(--zml-tab-color-active);
	background-color: var(--zml-tab-bg-active);
}

.zml-tab__count {
	opacity: 0.75;
	font-size: 0.9em;
	margin-inline-start: 2px;
}

/* Grid */

.zml-grid {
	display: grid;
	grid-template-columns: repeat(3, 1fr);
	column-gap: 24px;
	row-gap: 24px;
}

/* Card */

.zml-card {
	background-color: var(--zml-card-bg);
	display: flex;
	flex-direction: column;
	overflow: hidden;
	transition: opacity 0.25s ease, transform 0.25s ease;
}

.zml-card.zml-is-hidden {
	display: none;
}

.zml-card.zml-is-filtering-out {
	opacity: 0;
	transform: scale(0.94);
}

.zml-card.zml-is-filtering-in {
	animation: zml-card-in 0.3s ease forwards;
}

@keyframes zml-card-in {
	from {
		opacity: 0;
		transform: scale(0.94);
	}
	to {
		opacity: 1;
		transform: scale(1);
	}
}

.zml-card__media {
	position: relative;
	inline-size: 100%;
}

.zml-card__thumb {
	display: block;
	inline-size: 100%;
	aspect-ratio: 16 / 9;
	object-fit: cover;
}

.zml-card__thumb--placeholder {
	display: flex;
	align-items: center;
	justify-content: center;
	aspect-ratio: 16 / 9;
	background-color: var(--zml-audio-bg);
	color: var(--zml-tab-bg-active);
	font-size: 32px;
}

.zml-card__duration {
	position: absolute;
	inset-block-end: 8px;
	inset-inline-end: 8px;
	color: var(--zml-duration-color);
	background-color: var(--zml-duration-bg);
	padding: 2px 8px;
	border-radius: 4px;
	font-size: 12px;
	line-height: 1.6;
}

.zml-card__body {
	padding: 16px;
	display: flex;
	flex-direction: column;
	gap: 6px;
	flex: 1;
}

.zml-card__category {
	font-size: 12px;
	text-transform: uppercase;
	letter-spacing: 0.04em;
	opacity: 0.65;
}

.zml-card__title {
	margin: 0;
	font-size: 18px;
	line-height: 1.35;
	transition: color 0.2s ease;
}

.zml-card__description {
	margin: 0;
	font-size: 14px;
	line-height: 1.6;
	opacity: 0.8;
}

/* Empty state */

.zml-empty-state {
	padding: 40px 20px;
	text-align: center;
	border: 1px dashed rgba(0, 0, 0, 0.2);
	border-radius: 8px;
	opacity: 0.75;
}

/* Audio Player */

.zml-audio-player {
	display: flex;
	align-items: center;
	gap: 12px;
	margin-block-start: 8px;
	padding: 8px 12px;
	background-color: var(--zml-audio-bg);
	border-radius: 30px;
}

.zml-audio-player__button {
	flex: 0 0 auto;
	inline-size: var(--zml-play-btn-size);
	block-size: var(--zml-play-btn-size);
	border-radius: 50%;
	border: none;
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	background-color: var(--zml-accent);
	color: var(--zml-play-btn-color);
	transition: transform 0.15s ease;
}

.zml-audio-player__button:hover {
	transform: scale(1.05);
}

.zml-audio-player__button svg {
	inline-size: 45%;
	block-size: 45%;
}

.zml-audio-player__timeline {
	flex: 1 1 auto;
	min-inline-size: 0;
}

.zml-audio-player__progress {
	position: relative;
	block-size: 6px;
	border-radius: 3px;
	background-color: rgba(0, 0, 0, 0.1);
	cursor: pointer;
}

.zml-audio-player__progress-bar {
	position: absolute;
	inset-inline-start: 0;
	inset-block-start: 0;
	block-size: 100%;
	inline-size: 0%;
	border-radius: 3px;
	background-color: var(--zml-accent);
	pointer-events: none;
}

.zml-audio-player__time {
	margin-block-start: 4px;
	font-size: 12px;
	color: var(--zml-time-color);
}

/* Video */

.zml-video-embed {
	position: relative;
	inline-size: 100%;
}

.zml-video-embed__frame-wrap {
	position: relative;
	inline-size: 100%;
	padding-block-start: 56.25%;
	background-color: #000;
	overflow: hidden;
}

.zml-video-embed__poster {
	position: absolute;
	inset: 0;
	inline-size: 100%;
	block-size: 100%;
	object-fit: cover;
}

.zml-video-embed__poster--placeholder {
	background-color: var(--zml-audio-bg);
}

.zml-video-embed__play {
	position: absolute;
	inset: 0;
	margin: auto;
	inline-size: 64px;
	block-size: 64px;
	border-radius: 50%;
	border: none;
	cursor: pointer;
	background-color: rgba(0, 0, 0, 0.55);
	color: #fff;
	display: flex;
	align-items: center;
	justify-content: center;
	transition: background-color 0.2s ease, transform 0.2s ease;
}

.zml-video-embed__play:hover {
	background-color: var(--zml-accent);
	transform: scale(1.08);
}

.zml-video-embed__frame-wrap iframe,
.zml-video-embed__frame-wrap video {
	position: absolute;
	inset: 0;
	inline-size: 100%;
	block-size: 100%;
	border: none;
}

/* Responsive fallback (used if Elementor responsive controls are absent) */

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

@media (max-width: 767px) {
	.zml-grid {
		grid-template-columns: repeat(1, 1fr);
	}
}
