/**
 * Bloc : Vidéo YouTube (ri-video-youtube)
 * Convention : Classe complète sur la section, classes courtes scopées.
 * Utilise les variables globales de root.css (--ri-*)
 */

/* ========================================
   Base
   ======================================== */

.ri-video-youtube {
	width: 100%;
	padding-block: var(--ri-block-padding-xl);
}

/* ========================================
   Titre optionnel
   ======================================== */

.ri-video-youtube .container {
	position: relative;
	z-index: 1;
}

.ri-video-youtube .titre {
	margin: 0 0 var(--ri-space-lg);
	font: 700 1.25rem/1.3 var(--ri-font-1);
	color: var(--ri-color-teal);
	text-align: center;
}

/* ========================================
   Wrapper ratio 16/9
   ======================================== */

.ri-video-youtube .player-wrapper {
	position: relative;
	overflow: hidden;
	height: clamp(160px, 40vw, 600px);
	background-color: var(--ri-color-black);
	cursor: pointer;
}

/* ========================================
   Miniature
   ======================================== */

.ri-video-youtube .thumbnail {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	object-fit: cover;
	transition: transform var(--ri-transition-slow), opacity var(--ri-transition-slow);
}

.ri-video-youtube .player-wrapper:hover .thumbnail,
.ri-video-youtube .player-wrapper:focus-within .thumbnail {
	transform: scale(1.03);
	opacity: 0.85;
}

.ri-video-youtube .player-wrapper::after {
	content: "";
	position: absolute;
	inset: 0;
	background-color: rgba(33, 75, 77, 0.2);
	transition: opacity var(--ri-transition-slow);
	z-index: 1;
	pointer-events: none;
}

.ri-video-youtube .player-wrapper:hover::after,
.ri-video-youtube .player-wrapper:focus-within::after {
	opacity: 0;
}

/* ========================================
   Bouton play
   ======================================== */

.ri-video-youtube .play-btn {
	position: absolute;
	inset: 0;
	display: flex;
	align-items: center;
	justify-content: center;
	background: transparent;
	border: none;
	padding: 0;
	cursor: pointer;
	z-index: 2;
}

.ri-video-youtube .play-btn:focus-visible {
	outline: 3px solid var(--ri-color-yellow);
	outline-offset: -3px;
}

.ri-video-youtube .play-btn img {
	filter: drop-shadow(0 2px 8px rgba(0, 0, 0, 0.4));
	transition: transform var(--ri-transition-base);
}

.ri-video-youtube .play-btn:hover img,
.ri-video-youtube .play-btn:focus-visible img {
	transform: scale(1.12);
}

/* ========================================
   Iframe injecté par JS
   ======================================== */

.ri-video-youtube .player-wrapper iframe {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	border: none;
	z-index: 3;
}

/* ========================================
   Bande blanche quand 1ère section de <main>
   ======================================== */

main > .ri-video-youtube:first-child {
	position: relative;
	padding-block: var(--ri-block-padding-xl) 0;
}

main > .ri-video-youtube:first-child::before {
	content: "";
	position: absolute;
	bottom: 0;
	left: 0;
	right: 0;
	height: 64px;
	background-color: var(--ri-color-white);
	z-index: 0;
}

main > .ri-video-youtube:first-child .container {
	z-index: 1;
}

/* ========================================
   Placeholder (éditeur)
   ======================================== */

.ri-video-youtube.is-placeholder {
	display: flex;
	align-items: center;
	justify-content: center;
	min-height: 150px;
	padding: var(--ri-space-lg);
	background-color: var(--ri-color-grey-light);
	border: 2px dashed var(--ri-color-teal);
	text-align: center;
}

/* ========================================
   Responsive
   ======================================== */

@media (max-width: 782px) {

	main > .ri-video-youtube:first-child {
		padding-top: 60px;
	}

	.ri-video-youtube .titre {
		font-size: 1.1rem;
	}

	.ri-video-youtube .player-wrapper {
		aspect-ratio: 32 / 15;
		margin: auto;
		width: 100%;
		height: auto;
	}

	.ri-video-youtube .play-btn img {
		width: 40px;
		height: 40px;
	}

	main > .ri-video-youtube:first-child::before {
		height: 34px;
	}

}
