/**
 * CS Live Player — stile
 *
 * Barra comandi ispirata alle convenzioni dei player per dirette:
 * riga superiore con la timeline, riga inferiore con play, tempo,
 * indicatore LIVE, volume e, a destra, PiP e schermo intero.
 *
 * Nessun font viene caricato: il player eredita la tipografia del tema.
 */

.cslp {
	--cslp-fondo: #1e1512;
	--cslp-testo: #f5efe7;
	--cslp-ottone: #c08a3e;
	--cslp-onda: #c0472f;
	--cslp-velo: rgba( 18, 12, 10, 0.82 );
	--cslp-traccia: rgba( 255, 255, 255, 0.3 );
	/* Colore di icone e cursori della barra comandi. */
	--cslp-comandi: #ffffff;
	/* Colore del riempimento del cursore volume. */
	--cslp-progresso: #ffffff;
	--cslp-ratio: 16/9;

	position: relative;
	width: 100%;
	margin: 0 0 1.5rem;
}

.cslp__cornice {
	position: relative;
	width: 100%;
	aspect-ratio: var( --cslp-ratio );
	background-color: var( --cslp-fondo );
	overflow: hidden;
	border-radius: 6px;
}

@supports not ( aspect-ratio: 16/9 ) {
	.cslp__cornice { height: 0; padding-bottom: 56.25%; }
}

.cslp__video {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	object-fit: contain;
	display: block;
	background-color: var( --cslp-fondo );
}

/* A schermo intero la cornice riempie lo schermo. */
.cslp__cornice:fullscreen { border-radius: 0; }
.cslp__cornice:fullscreen .cslp__video { object-fit: contain; }

/* Stato per lettori di schermo e etichette dei pulsanti. */
.cslp__stato,
.cslp__sr {
	position: absolute !important;
	width: 1px; height: 1px;
	padding: 0; margin: -1px;
	overflow: hidden;
	clip: rect( 0 0 0 0 );
	clip-path: inset( 50% );
	white-space: nowrap;
	border: 0;
}

/* ------------------------------------------------------------------ */
/* Caricamento                                                         */
/* ------------------------------------------------------------------ */

/*
 * Sovrapposizione mostrata finché il primo fotogramma non arriva, e di
 * nuovo quando il video si ferma per ricaricare il buffer.
 */
.cslp__attesa {
	position: absolute;
	inset: 0;
	z-index: 3;
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: 12px;
	pointer-events: none;
	opacity: 1;
	transition: opacity 0.25s ease;
}

/* Nascosta senza display:none, così l'animazione non riparte da capo
   a ogni breve interruzione del buffer. */
.cslp--pronto .cslp__attesa {
	opacity: 0;
}

/*
 * Anello disegnato in SVG. Rispetto a una GIF: trasparenza reale senza
 * riquadro, bordi nitidi a ogni dimensione, colore ereditato dal tema
 * e nessun byte da scaricare.
 *
 * La circonferenza con raggio 20 vale circa 125,7: i valori di
 * stroke-dasharray sotto lavorano su quella misura.
 */
.cslp__anello {
	width: 48px;
	height: 48px;
	display: block;
	color: var( --cslp-comandi );
	animation: cslp-ruota 1.5s linear infinite;
}

.cslp__anello-traccia,
.cslp__anello-arco {
	fill: none;
	stroke-width: 4;
	stroke-linecap: round;
	transform-origin: center;
}

/* Solco di fondo, appena percepibile. */
.cslp__anello-traccia {
	stroke: currentColor;
	opacity: 0.18;
}

/* Arco che si allunga e si accorcia mentre l'insieme ruota. */
.cslp__anello-arco {
	stroke: currentColor;
	stroke-dasharray: 1 126;
	stroke-dashoffset: 0;
	animation: cslp-arco 1.5s ease-in-out infinite;
}

@keyframes cslp-ruota {
	to { transform: rotate( 360deg ); }
}

@keyframes cslp-arco {
	0%   { stroke-dasharray: 1 126;  stroke-dashoffset: 0; }
	50%  { stroke-dasharray: 88 126; stroke-dashoffset: -28; }
	100% { stroke-dasharray: 88 126; stroke-dashoffset: -125; }
}

.cslp__attesa-testo {
	margin: 0;
	color: var( --cslp-comandi );
	font-size: 13px;
	letter-spacing: 0.02em;
	text-shadow: 0 1px 3px rgba( 0, 0, 0, 0.6 );
}

/* ------------------------------------------------------------------ */
/* Avviso di indisponibilità                                           */
/* ------------------------------------------------------------------ */

.cslp__avviso {
	position: absolute;
	inset: 0;
	z-index: 5;
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: 14px;
	padding: 20px;
	text-align: center;
	background-color: rgba( 18, 12, 10, 0.6 );
	color: var( --cslp-testo );
}

.cslp__avviso[ hidden ] { display: none; }

/* Unico comando quando manca la playlist di riserva. */
.cslp__riprova {
	appearance: none;
	cursor: pointer;
	border: 1px solid rgba( 255, 255, 255, 0.45 );
	border-radius: 3px;
	background: transparent;
	color: var( --cslp-comandi );
	font-size: 12px;
	font-weight: 600;
	letter-spacing: 0.04em;
	padding: 8px 18px;
	opacity: 0.85;
	transition: opacity 0.18s ease, background-color 0.18s ease;
}

.cslp__riprova:hover,
.cslp__riprova:focus-visible {
	opacity: 1;
	background-color: rgba( 255, 255, 255, 0.14 );
}

.cslp__riprova:focus-visible {
	outline: 2px solid var( --cslp-comandi );
	outline-offset: 2px;
}

/* ------------------------------------------------------------------ */
/* Playlist YouTube di riserva                                         */
/* ------------------------------------------------------------------ */

/*
 * Occupa esattamente lo spazio del video: le proporzioni sono gia'
 * riservate dalla cornice, quindi il passaggio non sposta la pagina.
 */
.cslp__riserva {
	position: absolute;
	inset: 0;
	z-index: 6;
	background-color: #000000;
}

.cslp__riserva[ hidden ] { display: none; }

.cslp__riserva iframe,
.cslp__riserva > div {
	display: block;
	width: 100%;
	height: 100%;
	border: 0;
}

/* Con la playlist in onda i comandi del player non servono:
   YouTube ha i suoi. */
.cslp--riserva .cslp__barra,
.cslp--riserva .cslp__attesa,
.cslp--riserva .cslp__avviso {
	display: none;
}

.cslp--riserva .cslp__cornice { cursor: auto; }

/* ------------------------------------------------------------------ */
/* Barra comandi                                                       */
/* ------------------------------------------------------------------ */

.cslp__barra {
	position: absolute;
	left: 0;
	right: 0;
	bottom: 0;
	z-index: 4;
	padding: 20px 10px 8px;
	background: linear-gradient( to top, rgba( 12, 8, 7, 0.88 ) 0%, rgba( 12, 8, 7, 0.55 ) 55%, transparent 100% );
	opacity: 1;
	transform: none;
	transition: opacity 0.24s ease, transform 0.24s ease;
}

/* I comandi si ritirano quando il video è in riproduzione e il
   puntatore è fermo. Su touch li riporta un tocco sul video. */
.cslp--nascondi .cslp__barra {
	opacity: 0;
	transform: translateY( 6px );
	pointer-events: none;
}

.cslp--nascondi .cslp__cornice { cursor: none; }

.cslp__comandi {
	display: flex;
	align-items: center;
	gap: 4px;
}

.cslp__spazio { flex: 1 1 auto; }

.cslp__btn {
	appearance: none;
	cursor: pointer;
	border: 0;
	background: transparent;
	padding: 7px;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	color: var( --cslp-comandi );
	border-radius: 3px;
	line-height: 1;
	opacity: 0.88;
	transition: opacity 0.15s ease, background-color 0.15s ease;
}

.cslp__btn:hover,
.cslp__btn:focus-visible {
	opacity: 1;
	background-color: rgba( 255, 255, 255, 0.14 );
}

.cslp__btn:focus-visible {
	outline: 2px solid var( --cslp-comandi );
	outline-offset: 1px;
}

.cslp__i {
	width: 19px;
	height: 19px;
	display: block;
	background-color: currentColor;
	-webkit-mask-position: center;
	mask-position: center;
	-webkit-mask-repeat: no-repeat;
	mask-repeat: no-repeat;
	-webkit-mask-size: contain;
	mask-size: contain;
}

/* Icone */

.cslp__muto .cslp__i {
	-webkit-mask-image: url( "data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M11 5 6 9H2v6h4l5 4V5z'/%3E%3Cpath d='M15.5 8.5a5 5 0 0 1 0 7M18 6a9 9 0 0 1 0 12' fill='none' stroke='black' stroke-width='2'/%3E%3C/svg%3E" );
	mask-image: url( "data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M11 5 6 9H2v6h4l5 4V5z'/%3E%3Cpath d='M15.5 8.5a5 5 0 0 1 0 7M18 6a9 9 0 0 1 0 12' fill='none' stroke='black' stroke-width='2'/%3E%3C/svg%3E" );
}

.cslp--muto .cslp__muto .cslp__i {
	-webkit-mask-image: url( "data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M11 5 6 9H2v6h4l5 4V5z'/%3E%3Cpath d='M22 9l-6 6M16 9l6 6' fill='none' stroke='black' stroke-width='2'/%3E%3C/svg%3E" );
	mask-image: url( "data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M11 5 6 9H2v6h4l5 4V5z'/%3E%3Cpath d='M22 9l-6 6M16 9l6 6' fill='none' stroke='black' stroke-width='2'/%3E%3C/svg%3E" );
}

.cslp__pip .cslp__i {
	-webkit-mask-image: url( "data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Crect x='2' y='4' width='20' height='16' rx='2' fill='none' stroke='black' stroke-width='2'/%3E%3Crect x='12' y='11' width='8' height='7' rx='1'/%3E%3C/svg%3E" );
	mask-image: url( "data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Crect x='2' y='4' width='20' height='16' rx='2' fill='none' stroke='black' stroke-width='2'/%3E%3Crect x='12' y='11' width='8' height='7' rx='1'/%3E%3C/svg%3E" );
}

.cslp__fs .cslp__i {
	-webkit-mask-image: url( "data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M4 9V4h5M20 9V4h-5M4 15v5h5M20 15v5h-5' fill='none' stroke='black' stroke-width='2'/%3E%3C/svg%3E" );
	mask-image: url( "data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M4 9V4h5M20 9V4h-5M4 15v5h5M20 15v5h-5' fill='none' stroke='black' stroke-width='2'/%3E%3C/svg%3E" );
}

.cslp--schermo-intero .cslp__fs .cslp__i {
	-webkit-mask-image: url( "data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M9 4v5H4M15 4v5h5M9 20v-5H4M15 20v-5h5' fill='none' stroke='black' stroke-width='2'/%3E%3C/svg%3E" );
	mask-image: url( "data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M9 4v5H4M15 4v5h5M9 20v-5H4M15 20v-5h5' fill='none' stroke='black' stroke-width='2'/%3E%3C/svg%3E" );
}

/* ------------------------------------------------------------------ */
/* Cursore del volume                                                  */
/* ------------------------------------------------------------------ */

.cslp__cursore {
	appearance: none;
	-webkit-appearance: none;
	width: 100%;
	height: 16px;
	background: transparent;
	cursor: pointer;
	margin: 0;
	display: block;
}

.cslp__cursore::-webkit-slider-runnable-track {
	height: 4px;
	border-radius: 2px;
	background: linear-gradient( to right,
		var( --cslp-progresso ) 0%,
		var( --cslp-progresso ) var( --cslp-riempi, 0% ),
		var( --cslp-traccia ) var( --cslp-riempi, 0% ),
		var( --cslp-traccia ) 100% );
}

.cslp__cursore::-moz-range-track {
	height: 4px;
	border-radius: 2px;
	background: linear-gradient( to right,
		var( --cslp-progresso ) 0%,
		var( --cslp-progresso ) var( --cslp-riempi, 0% ),
		var( --cslp-traccia ) var( --cslp-riempi, 0% ),
		var( --cslp-traccia ) 100% );
}

.cslp__cursore::-webkit-slider-thumb {
	-webkit-appearance: none;
	width: 12px;
	height: 12px;
	margin-top: -4px;
	border-radius: 50%;
	background: #fff;
	border: 0;
	box-shadow: 0 0 3px rgba( 0, 0, 0, 0.5 );
}

.cslp__cursore::-moz-range-thumb {
	width: 12px;
	height: 12px;
	border-radius: 50%;
	background: #fff;
	border: 0;
}

.cslp__cursore:focus-visible {
	outline: 2px solid var( --cslp-comandi );
	outline-offset: 2px;
	border-radius: 3px;
}



/* Volume: il cursore si apre al passaggio del mouse sul gruppo. */
/*
 * Il pulsante audio e il suo cursore devono stare sulla stessa linea
 * ottica. Assegnando a entrambi la stessa altezza, l'allineamento non
 * dipende piu' da come i singoli browser posizionano la traccia
 * dell'input range al proprio interno.
 */
.cslp__volume {
	display: flex;
	align-items: center;
	gap: 2px;
}

/* Icona audio piu' grande delle altre: e' il comando piu' usato. */
.cslp__muto .cslp__i {
	width: 25px;
	height: 25px;
}

.cslp__muto {
	padding: 6px 8px;
}

.cslp__vol {
	height: 25px;
	vertical-align: middle;
}

.cslp__vol {
	width: 0;
	opacity: 0;
	transition: width 0.2s ease, opacity 0.2s ease;
}

.cslp__volume:hover .cslp__vol,
.cslp__volume:focus-within .cslp__vol {
	width: 72px;
	opacity: 1;
	margin-right: 6px;
}

/* ------------------------------------------------------------------ */
/* Pulsante grande "Attiva audio"                                      */
/* ------------------------------------------------------------------ */

/*
 * Compare solo quando il browser ha impedito l'audio automatico, cioe'
 * quasi sempre su telefono. Almeno 48 px di altezza: la misura minima
 * consigliata per un bersaglio da toccare con il dito.
 */
.cslp__audio-on {
	display: none;
	position: absolute;
	left: 50%;
	top: 50%;
	z-index: 5;
	transform: translate( -50%, -50% );
	align-items: center;
	gap: 10px;
	min-height: 48px;
	padding: 12px 22px;
	border: 1px solid rgba( 255, 255, 255, 0.55 );
	border-radius: 999px;
	background-color: rgba( 12, 8, 7, 0.72 );
	color: #ffffff;
	font-size: 15px;
	font-weight: 700;
	letter-spacing: 0.04em;
	text-transform: uppercase;
	line-height: 1;
	cursor: pointer;
	-webkit-tap-highlight-color: transparent;
	touch-action: manipulation;
	box-shadow: 0 2px 12px rgba( 0, 0, 0, 0.4 );
}

.cslp--audio-negato.cslp--muto.cslp--pronto .cslp__audio-on { display: inline-flex; }
.cslp--riserva .cslp__audio-on { display: none !important; }

.cslp__audio-on:hover,
.cslp__audio-on:focus-visible { background-color: rgba( 12, 8, 7, 0.88 ); }

.cslp__audio-on:focus-visible {
	outline: 2px solid #ffffff;
	outline-offset: 2px;
}

.cslp__audio-on-i {
	width: 22px;
	height: 22px;
	flex: 0 0 auto;
	background-color: currentColor;
	-webkit-mask: url( "data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M11 5 6 9H2v6h4l5 4V5z'/%3E%3Cpath d='M15.5 8.5a5 5 0 0 1 0 7M18 6a9 9 0 0 1 0 12' fill='none' stroke='black' stroke-width='2'/%3E%3C/svg%3E" ) center / contain no-repeat;
	mask: url( "data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M11 5 6 9H2v6h4l5 4V5z'/%3E%3Cpath d='M15.5 8.5a5 5 0 0 1 0 7M18 6a9 9 0 0 1 0 12' fill='none' stroke='black' stroke-width='2'/%3E%3C/svg%3E" ) center / contain no-repeat;
}

/* Tutti i comandi: niente ritardo del doppio tocco su mobile. */
.cslp__btn { touch-action: manipulation; -webkit-tap-highlight-color: transparent; }

/* ------------------------------------------------------------------ */
/* Schermi piccoli                                                     */
/* ------------------------------------------------------------------ */

@media ( max-width: 560px ) {
	.cslp__barra { padding: 18px 6px 6px; }
	.cslp__btn { padding: 6px; }
	.cslp__anello { width: 40px; height: 40px; }
	.cslp__muto .cslp__i { width: 24px; height: 24px; }
	/* Bersaglio di almeno 48x48 px per il dito. */
	.cslp__muto,
	.cslp__fs { min-width: 48px; min-height: 48px; }
	.cslp__audio-on { font-size: 13px; padding: 10px 18px; }
	.cslp__vol { height: 22px; }
	.cslp__attesa-testo { font-size: 12px; }
	.cslp__i { width: 17px; height: 17px; }


	.cslp__pip { display: none; }

	/* Su touch il cursore volume resta chiuso: si usa il pulsante muto. */
	.cslp__volume:hover .cslp__vol { width: 0; opacity: 0; margin-right: 0; }
}

/* Su dispositivi touch il pulsante audio e' sempre grande. */
@media ( hover: none ) and ( pointer: coarse ) {
	.cslp__muto,
	.cslp__fs { min-width: 48px; min-height: 48px; }
}

@media ( prefers-reduced-motion: reduce ) {
	.cslp__barra,
	.cslp__btn,
	.cslp__vol,
	.cslp__attesa {
		transition: none;
	}

	/* Niente rotazione: resta un respiro appena accennato. */
	.cslp__anello {
		animation: cslp-respiro 2s ease-in-out infinite;
	}

	.cslp__anello-arco {
		stroke-dasharray: 60 126;
		animation: none;
	}

	@keyframes cslp-respiro {
		0%, 100% { opacity: 1; }
		50%      { opacity: 0.5; }
	}
}
