/* Video Tutorial Gallery – Frontend v1.3.0
   Badge Play discreto + sfondo chiaro/elegante (niente nero). */

/* ============================================================
   Sezione gallery
   ============================================================ */
.vtg-gallery {
	--vtg-gap: 1.75rem;
	--vtg-radius: 16px;
	--vtg-shadow: 0 6px 24px rgba(15, 23, 42, 0.08);
	--vtg-shadow-hover: 0 14px 40px rgba(15, 23, 42, 0.14);
	--vtg-accent: #3b82f6;

	position: relative;
	width: 100%;
	max-width: 100%;
	box-sizing: border-box;

	padding: 3.5rem 1.5rem 4rem;
	margin: 2rem 0;

	/* Sfondo chiaro elegante (niente nero) */
	background:
		radial-gradient(ellipse 80% 55% at 15% 15%, rgba(59, 130, 246, 0.08) 0%, transparent 55%),
		radial-gradient(ellipse 70% 50% at 85% 85%, rgba(139, 92, 246, 0.07) 0%, transparent 50%),
		linear-gradient(165deg, #f8fafc 0%, #f1f5f9 45%, #eef2ff 100%);
	color: #0f172a;
	border-radius: 0;
	overflow: hidden;
}

/* Texture molto leggera */
.vtg-gallery::before {
	content: "";
	position: absolute;
	inset: 0;
	background-image:
		radial-gradient(circle at 1px 1px, rgba(15, 23, 42, 0.035) 1px, transparent 0);
	background-size: 28px 28px;
	pointer-events: none;
	opacity: 0.7;
}

.vtg-gallery > * {
	position: relative;
	z-index: 1;
}

/* ============================================================
   Grid
   ============================================================ */
.vtg-grid {
	display: grid;
	gap: var(--vtg-gap);
	grid-template-columns: 1fr;
	width: 100%;
	max-width: 100%;
	box-sizing: border-box;
}

.vtg-cols-2 { grid-template-columns: repeat(2, 1fr); }
.vtg-cols-3 { grid-template-columns: repeat(3, 1fr); }
.vtg-cols-4 { grid-template-columns: repeat(4, 1fr); }

@media (max-width: 1100px) {
	.vtg-cols-4 { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 900px) {
	.vtg-cols-3,
	.vtg-cols-4 { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 560px) {
	.vtg-cols-2,
	.vtg-cols-3,
	.vtg-cols-4 { grid-template-columns: 1fr; }
	.vtg-gallery {
		padding: 2.5rem 1.1rem 3rem;
	}
}

/* ============================================================
   Card
   ============================================================ */
.vtg-card {
	border-radius: var(--vtg-radius);
	overflow: hidden;
	box-shadow: var(--vtg-shadow);
	transition: transform 0.3s cubic-bezier(0.22, 1, 0.36, 1), box-shadow 0.3s ease;
	cursor: pointer;
	background: #fff;
	border: 1px solid rgba(15, 23, 42, 0.06);
	width: 100%;
	max-width: 100%;
	box-sizing: border-box;
}

.vtg-card:hover {
	transform: translateY(-5px);
	box-shadow: var(--vtg-shadow-hover);
	border-color: rgba(15, 23, 42, 0.1);
}

.vtg-card-media {
	position: relative;
	aspect-ratio: 16 / 9;
	overflow: hidden;
	width: 100%;
	background: #e2e8f0;
}

.vtg-card-media img {
	width: 100%;
	height: 100%;
	object-fit: cover;
	display: block;
	transition: transform 0.45s cubic-bezier(0.22, 1, 0.36, 1);
}

.vtg-card:hover .vtg-card-media img {
	transform: scale(1.04);
}

.vtg-placeholder {
	width: 100%;
	height: 100%;
	display: flex;
	align-items: center;
	justify-content: center;
	background: linear-gradient(135deg, #e2e8f0, #cbd5e1);
	color: #64748b;
}

.vtg-placeholder .dashicons {
	font-size: 48px;
	width: 48px;
	height: 48px;
}

/* Overlay: titolo a sinistra, badge Play a destra */
.vtg-card-overlay {
	position: absolute;
	left: 0;
	right: 0;
	bottom: 0;
	padding: 2.4rem 1rem 0.85rem;
	background: linear-gradient(
		to top,
		rgba(15, 23, 42, 0.78) 0%,
		rgba(15, 23, 42, 0.35) 55%,
		transparent 100%
	);
	pointer-events: none;
	display: flex;
	align-items: flex-end;
	justify-content: space-between;
	gap: 0.75rem;
}

.vtg-card-title {
	flex: 1;
	min-width: 0;
	margin: 0;
	font-size: 1rem;
	font-weight: 600;
	line-height: 1.3;
	color: #fff;
	text-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
	display: -webkit-box;
	-webkit-line-clamp: 2;
	-webkit-box-orient: vertical;
	overflow: hidden;
}

@media (min-width: 900px) {
	.vtg-card-title {
		font-size: 1.1rem;
	}
	.vtg-card-overlay {
		padding: 2.8rem 1.15rem 1rem;
	}
}

/* Piccola etichetta Play in basso a destra */
.vtg-play-badge {
	flex-shrink: 0;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	padding: 0.28rem 0.7rem;
	font-size: 0.7rem;
	font-weight: 700;
	letter-spacing: 0.06em;
	text-transform: uppercase;
	color: #fff;
	border-radius: 999px;
	background: linear-gradient(135deg, #3b82f6 0%, #8b5cf6 55%, #6366f1 100%);
	box-shadow: 0 2px 8px rgba(59, 130, 246, 0.35);
	line-height: 1.2;
}

.vtg-card:hover .vtg-play-badge {
	background: linear-gradient(135deg, #2563eb 0%, #7c3aed 55%, #4f46e5 100%);
	box-shadow: 0 3px 12px rgba(59, 130, 246, 0.45);
}

/* Empty state */
.vtg-empty {
	text-align: center;
	padding: 4rem 1rem;
	color: #64748b;
	font-size: 1.1rem;
}

/* ============================================================
   Pagination
   ============================================================ */
.vtg-pagination {
	margin-top: 2.75rem;
	display: flex;
	justify-content: center;
}

.vtg-pagination ul {
	display: flex;
	flex-wrap: wrap;
	gap: 0.5rem;
	list-style: none;
	margin: 0;
	padding: 0;
}

.vtg-pagination a,
.vtg-pagination span {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-width: 2.75rem;
	height: 2.75rem;
	padding: 0 0.85rem;
	border-radius: 10px;
	font-size: 0.95rem;
	font-weight: 500;
	text-decoration: none;
	color: #334155;
	background: #fff;
	border: 1px solid rgba(15, 23, 42, 0.1);
	transition: background 0.2s, color 0.2s, border-color 0.2s, box-shadow 0.2s;
}

.vtg-pagination a:hover {
	background: var(--vtg-accent);
	border-color: var(--vtg-accent);
	color: #fff;
	box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

.vtg-pagination .current {
	background: var(--vtg-accent);
	border-color: var(--vtg-accent);
	color: #fff;
}


/* ============================================================
   Modal playlist – desktop: player + sidebar
   Mobile: player full + solo prossimo video
   Sopra header del tema (z-index alto)
   ============================================================ */
.vtg-modal {
	position: fixed !important;
	top: 0 !important;
	left: 0 !important;
	right: 0 !important;
	bottom: 0 !important;
	width: 100vw !important;
	height: 100vh !important;
	height: 100dvh !important;
	max-width: none !important;
	margin: 0 !important;
	padding: 0 !important;
	z-index: 2147483000 !important;
	display: flex;
	align-items: stretch;
	justify-content: stretch;
	background: #000;
	box-sizing: border-box;
	overflow: hidden;
	/* Evita che header fissi del tema restino sopra */
	transform: translateZ(0);
	isolation: isolate;
}

.vtg-modal[hidden] {
	display: none !important;
}

.vtg-modal *,
.vtg-modal *::before,
.vtg-modal *::after {
	box-sizing: border-box;
}

.vtg-modal-dialog {
	position: relative;
	width: 100%;
	height: 100%;
	max-width: none;
	margin: 0;
	background: #000;
	display: flex;
	flex-direction: column;
	overflow: hidden;
}

.vtg-modal-close {
	position: absolute;
	top: max(10px, env(safe-area-inset-top, 0px));
	right: max(10px, env(safe-area-inset-right, 0px));
	z-index: 40;
	width: 44px;
	height: 44px;
	border: none;
	border-radius: 50%;
	background: rgba(0, 0, 0, 0.55);
	color: #fff;
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	transition: background 0.2s;
}

.vtg-modal-close:hover {
	background: rgba(0, 0, 0, 0.8);
}

.vtg-modal-layout {
	display: flex;
	flex: 1 1 auto;
	min-height: 0;
	width: 100%;
	height: 100%;
	overflow: hidden;
}

.vtg-modal-main {
	flex: 1 1 auto;
	min-width: 0;
	min-height: 0;
	display: flex;
	flex-direction: column;
	background: #000;
	overflow: hidden;
	position: relative;
}

/* Player: tutto lo spazio disponibile */
.vtg-modal-player {
	flex: 1 1 auto;
	position: relative;
	min-height: 0;
	width: 100%;
	background: #000;
	overflow: hidden;
}

.vtg-modal-player video {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	object-fit: contain;
	object-position: center center;
	background: #000;
	display: block;
	z-index: 1;
}

/* Titolo sovrapposto in basso sul video (non ruba altezza) */
.vtg-modal-caption {
	position: absolute;
	left: 0;
	right: 0;
	bottom: 0;
	z-index: 2;
	padding: 2.5rem 1.25rem 0.85rem;
	padding-right: 3.5rem;
	background: linear-gradient(to top, rgba(0, 0, 0, 0.85) 0%, rgba(0, 0, 0, 0.4) 55%, transparent 100%);
	pointer-events: none;
}

.vtg-modal-title {
	margin: 0 0 0.15rem;
	font-size: 1.05rem;
	font-weight: 600;
	line-height: 1.3;
	color: #fff;
	text-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
	word-wrap: break-word;
	overflow-wrap: anywhere;
}

.vtg-modal-meta {
	margin: 0;
	font-size: 0.8rem;
	color: rgba(255, 255, 255, 0.75);
}

/* Mobile next: nascosto su desktop */
.vtg-mobile-next {
	display: none;
}

/* Sidebar playlist – solo desktop */
.vtg-modal-sidebar {
	width: min(360px, 34vw);
	flex: 0 0 auto;
	display: flex;
	flex-direction: column;
	background: #0f172a;
	border-left: 1px solid rgba(255, 255, 255, 0.1);
	min-height: 0;
	max-height: 100%;
	overflow: hidden;
}

.vtg-playlist-header {
	flex: 0 0 auto;
	padding: 1rem 1.1rem;
	font-size: 0.95rem;
	font-weight: 600;
	color: #e2e8f0;
	border-bottom: 1px solid rgba(255, 255, 255, 0.08);
	display: flex;
	align-items: center;
	gap: 0.5rem;
}

.vtg-playlist-count {
	font-weight: 500;
	color: #94a3b8;
	font-size: 0.85rem;
}

.vtg-playlist {
	flex: 1 1 auto;
	overflow-y: auto;
	overflow-x: hidden;
	padding: 0.5rem;
	-webkit-overflow-scrolling: touch;
	min-height: 0;
}

.vtg-playlist-item {
	display: flex;
	align-items: flex-start;
	gap: 0.75rem;
	width: 100%;
	padding: 0.55rem;
	margin: 0 0 0.35rem;
	border: none;
	border-radius: 10px;
	background: transparent;
	color: #e2e8f0;
	text-align: left;
	cursor: pointer;
	transition: background 0.15s;
}

.vtg-playlist-item:hover {
	background: rgba(255, 255, 255, 0.06);
}

.vtg-playlist-item.is-active {
	background: rgba(59, 130, 246, 0.2);
	box-shadow: inset 0 0 0 1px rgba(59, 130, 246, 0.4);
}

.vtg-playlist-thumb {
	flex-shrink: 0;
	width: 112px;
	aspect-ratio: 16 / 9;
	border-radius: 6px;
	overflow: hidden;
	background: #1e293b;
}

.vtg-playlist-thumb img {
	width: 100%;
	height: 100%;
	object-fit: cover;
	display: block;
}

.vtg-playlist-placeholder {
	width: 100%;
	height: 100%;
	background: linear-gradient(135deg, #1e293b, #0f172a);
}

.vtg-playlist-body {
	flex: 1;
	min-width: 0;
	display: flex;
	flex-direction: column;
	gap: 0.2rem;
	padding-top: 0.1rem;
}

.vtg-playlist-num {
	font-size: 0.7rem;
	font-weight: 600;
	color: #64748b;
}

.vtg-playlist-item.is-active .vtg-playlist-num {
	color: #93c5fd;
}

.vtg-playlist-title {
	font-size: 0.85rem;
	font-weight: 500;
	line-height: 1.35;
	color: #f1f5f9;
	display: -webkit-box;
	-webkit-line-clamp: 3;
	-webkit-box-orient: vertical;
	overflow: hidden;
	word-wrap: break-word;
	overflow-wrap: anywhere;
}

/* ========== MOBILE ========== */
@media (max-width: 900px) {
	/* Playlist completa nascosta */
	.vtg-modal-sidebar {
		display: none !important;
	}

	.vtg-modal-layout {
		flex-direction: column;
	}

	.vtg-modal-main {
		flex: 1 1 auto;
		height: 100%;
	}

	/* Video quasi a tutto schermo */
	.vtg-modal-player {
		flex: 1 1 auto;
		min-height: 0;
	}

	.vtg-modal-caption {
		padding: 2rem 1rem 0.7rem;
		padding-right: 3rem;
	}

	.vtg-modal-title {
		font-size: 0.95rem;
	}

	/* Barra "Prossimo" in coda – compatta */
	.vtg-mobile-next {
		display: none; /* mostrato via JS se c'è un prossimo */
		flex: 0 0 auto;
		align-items: center;
		gap: 0.75rem;
		width: 100%;
		padding: 0.65rem 0.9rem;
		padding-bottom: max(0.65rem, env(safe-area-inset-bottom, 0px));
		border: none;
		border-top: 1px solid rgba(255, 255, 255, 0.12);
		background: #0f172a;
		color: #f1f5f9;
		text-align: left;
		cursor: pointer;
	}

	.vtg-mobile-next.is-visible {
		display: flex;
	}

	.vtg-mobile-next:active {
		background: #1e293b;
	}

	.vtg-mobile-next-label {
		flex-shrink: 0;
		font-size: 0.65rem;
		font-weight: 700;
		letter-spacing: 0.06em;
		text-transform: uppercase;
		color: #93c5fd;
		padding: 0.2rem 0.45rem;
		border-radius: 4px;
		background: rgba(59, 130, 246, 0.2);
	}

	.vtg-mobile-next-thumb {
		flex-shrink: 0;
		width: 72px;
		aspect-ratio: 16 / 9;
		border-radius: 4px;
		overflow: hidden;
		background: #1e293b;
	}

	.vtg-mobile-next-thumb img {
		width: 100%;
		height: 100%;
		object-fit: cover;
		display: block;
	}

	.vtg-mobile-next-title {
		flex: 1;
		min-width: 0;
		font-size: 0.85rem;
		font-weight: 500;
		line-height: 1.3;
		display: -webkit-box;
		-webkit-line-clamp: 2;
		-webkit-box-orient: vertical;
		overflow: hidden;
	}
}

@media (prefers-reduced-motion: reduce) {
	.vtg-card,
	.vtg-card-media img {
		transition: none;
	}
}
