/**
 * Radio Jasper Player.
 * Colors and fonts come from the Elementor Kit; the fallbacks keep the plugin
 * usable with any theme.
 */

.rjp,
.rjp-bar,
.rjp-popup-page {
	--rjp-dark: var(--e-global-color-rjdark, #3d5da1);
	--rjp-accent: var(--e-global-color-accent, #3d5da1);
	--rjp-decor: var(--e-global-color-secondary, #f1e300);
	--rjp-highlight: var(--e-global-color-rjpinkondark, #f1e300);
	--rjp-on-dark: var(--e-global-color-rjondark, #e8ecf5);
	--rjp-white: var(--e-global-color-rjwhite, #fff);
	--rjp-font-heading: var(--e-global-typography-primary-font-family, "Questrial"), sans-serif;
	--rjp-font-label: var(--e-global-typography-secondary-font-family, "Montserrat"), sans-serif;
	--rjp-bar-height: 56px;
}

.rjp__sr {
	position: absolute !important;
	width: 1px;
	height: 1px;
	margin: -1px;
	padding: 0;
	overflow: hidden;
	clip: rect(0, 0, 0, 0);
	white-space: nowrap;
	border: 0;
}

/* --------------------------------------------------------------------------
 * Shared pieces
 * ----------------------------------------------------------------------- */
.rjp {
	box-sizing: border-box;
	color: var(--rjp-white);
	font-family: var(--rjp-font-heading);
}

.rjp *,
.rjp *::before,
.rjp *::after {
	box-sizing: inherit;
}

.rjp p {
	margin: 0;
}

.rjp :focus-visible {
	outline: 3px solid var(--rjp-highlight);
	outline-offset: 2px;
}

/* Scoped under .rjp to beat the Kit's global "button" and link styles. */
.rjp .rjp__toggle {
	position: relative;
	display: inline-flex;
	flex: none;
	align-items: center;
	justify-content: center;
	width: 48px;
	height: 48px;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: var(--rjp-white);
	color: var(--rjp-accent);
	cursor: pointer;
	transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.rjp .rjp__toggle:hover,
.rjp .rjp__toggle:focus {
	transform: scale(1.05);
	background: var(--rjp-white);
	color: var(--rjp-accent);
}

.rjp__icon {
	width: 55%;
	height: 55%;
	fill: currentColor;
}

.rjp__icon--pause,
.rjp__spinner {
	display: none;
}

.rjp[data-rjp-state="playing"] .rjp__icon--play,
.rjp[data-rjp-state="connecting"] .rjp__icon--play {
	display: none;
}

.rjp[data-rjp-state="playing"] .rjp__icon--pause {
	display: block;
}

.rjp[data-rjp-state="connecting"] .rjp__spinner {
	display: block;
	width: 50%;
	height: 50%;
	border: 3px solid currentColor;
	border-right-color: transparent;
	border-radius: 50%;
	animation: rjp-spin 0.8s linear infinite;
}

@keyframes rjp-spin {
	to {
		transform: rotate(360deg);
	}
}

.rjp__info {
	min-width: 0;
	flex: 1 1 auto;
}

.rjp__title {
	margin-bottom: 4px;
	font-family: var(--rjp-font-heading);
	font-size: 1.25rem;
	line-height: 1.2;
}

.rjp__status {
	display: flex;
	align-items: center;
	gap: 10px;
	min-width: 0;
}

.rjp__live {
	display: inline-flex;
	flex: none;
	align-items: center;
	gap: 6px;
	color: var(--rjp-highlight);
	font-family: var(--rjp-font-label);
	font-size: 0.75rem;
	font-weight: 600;
	letter-spacing: 0.5px;
	text-transform: uppercase;
}

.rjp__live::before {
	content: "";
	width: 8px;
	height: 8px;
	border-radius: 50%;
	background: var(--rjp-highlight);
}

.rjp[data-rjp-state="playing"] .rjp__live::before {
	background: var(--rjp-highlight);
	animation: rjp-pulse 1.6s ease-in-out infinite;
}

@keyframes rjp-pulse {
	50% {
		opacity: 0.3;
	}
}

.rjp__station {
	overflow: hidden;
	color: var(--rjp-white);
	font-size: 1rem;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.rjp__now {
	overflow: hidden;
	color: var(--rjp-on-dark);
	font-size: 0.875rem;
	line-height: 1.4;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.rjp__now:empty {
	display: none;
}

.rjp[data-rjp-state="error"] .rjp__now {
	color: var(--rjp-highlight);
	white-space: normal;
}

.rjp__volume {
	display: none;
	flex: none;
	align-items: center;
}

.rjp__volume input[type="range"] {
	width: 96px;
	accent-color: var(--rjp-highlight);
	cursor: pointer;
}

.rjp .rjp__popup {
	display: inline-flex;
	flex: none;
	align-items: center;
	justify-content: center;
	gap: 6px;
	min-width: 44px;
	min-height: 44px;
	color: var(--rjp-on-dark);
	font-family: var(--rjp-font-label);
	font-size: 0.75rem;
	font-weight: 600;
	letter-spacing: 0.5px;
	text-decoration: none;
	text-transform: uppercase;
}

.rjp .rjp__popup:hover,
.rjp .rjp__popup:focus {
	color: var(--rjp-highlight);
}

.rjp__popup .rjp__icon {
	width: 20px;
	height: 20px;
}

/* --------------------------------------------------------------------------
 * Variant: hero (home block)
 * ----------------------------------------------------------------------- */
.rjp--hero,
.rjp--popup {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 16px 20px;
	padding: 20px;
	background: var(--rjp-dark);
}

.rjp.rjp--hero .rjp__toggle,
.rjp.rjp--popup .rjp__toggle {
	width: 64px;
	height: 64px;
	box-shadow: 0 0 0 8px rgba(255, 255, 255, 0.08), 0 0 0 16px rgba(255, 255, 255, 0.04);
}

.rjp--hero .rjp__station,
.rjp--popup .rjp__station {
	font-size: 1.125rem;
	white-space: normal;
	line-height: 1.3;
}

/* Home player: LIVE big, then the programme, then the hosts (three lines). */
.rjp__hosts {
	display: none;
}

.rjp--hero .rjp__status {
	flex-direction: column;
	align-items: flex-start;
	gap: 4px;
}

.rjp--hero .rjp__live {
	gap: 10px;
	font-size: clamp(2rem, 5vw, 2.75rem);
	font-weight: 700;
	letter-spacing: 1px;
	line-height: 1;
}

.rjp--hero .rjp__live::before {
	width: 14px;
	height: 14px;
}

.rjp--hero .rjp__station {
	font-size: clamp(1.25rem, 3vw, 1.5rem);
	line-height: 1.2;
}

.rjp--hero .rjp__hosts {
	display: block;
	margin-top: 2px;
	color: var(--rjp-highlight);
	font-size: 1.0625rem;
	line-height: 1.3;
}

.rjp--hero .rjp__hosts:empty,
.rjp--hero .rjp__now {
	display: none;
}

.rjp--hero .rjp__popup-text {
	position: absolute;
	width: 1px;
	height: 1px;
	overflow: hidden;
	clip: rect(0, 0, 0, 0);
	white-space: nowrap;
}

@media (min-width: 768px) {
	.rjp--hero {
		flex-wrap: nowrap;
		padding: 28px 32px;
	}

	.rjp.rjp--hero .rjp__toggle {
		width: 80px;
		height: 80px;
	}

	.rjp--hero .rjp__volume {
		display: flex;
	}

	.rjp--hero .rjp__popup-text {
		position: static;
		width: auto;
		height: auto;
		clip: auto;
	}
}

/* --------------------------------------------------------------------------
 * Variant: button (header "Ascolta live")
 * ----------------------------------------------------------------------- */
.rjp.rjp--button .rjp__toggle {
	gap: 8px;
	width: auto;
	height: auto;
	min-height: 44px;
	padding: 10px 16px;
	border-radius: 0;
	background: var(--rjp-decor);
	color: var(--rjp-accent);
	font-family: var(--rjp-font-label);
	font-size: 0.8125rem;
	font-weight: 600;
	letter-spacing: 0.5px;
	line-height: 1;
	text-transform: uppercase;
	white-space: nowrap;
}

.rjp.rjp--button .rjp__toggle:hover,
.rjp.rjp--button .rjp__toggle:focus {
	transform: none;
	background: var(--rjp-dark);
	/* Yellow edge: the button stays visible on blue boxes too. */
	box-shadow: inset 0 0 0 2px var(--rjp-decor);
	color: var(--rjp-white);
}

.rjp--button .rjp__icon,
.rjp--button .rjp__spinner {
	width: 18px;
	height: 18px;
}

.rjp--button[data-rjp-state="connecting"] .rjp__spinner {
	border-width: 2px;
}

/* --------------------------------------------------------------------------
 * Variant: bar (sticky, every page)
 * ----------------------------------------------------------------------- */
.rjp-bar {
	position: fixed;
	z-index: 9990;
	right: 0;
	bottom: 0;
	left: 0;
	padding-bottom: env(safe-area-inset-bottom, 0);
	border-top: 3px solid var(--rjp-decor);
	background: var(--rjp-dark);
}

.rjp--bar {
	display: flex;
	align-items: center;
	gap: 12px;
	max-width: 1200px;
	height: var(--rjp-bar-height);
	margin: 0 auto;
	padding: 0 16px;
}

.rjp.rjp--bar .rjp__toggle {
	width: 40px;
	height: 40px;
}

.rjp--bar .rjp__info {
	display: flex;
	flex-direction: column;
	justify-content: center;
}

.rjp--bar .rjp__now {
	font-size: 0.8125rem;
}

/* Phones: the programme and its hosts may need two lines, and the song line
   (it repeats the episode title) is left out; both come back from tablet up. */
.rjp--bar .rjp__station {
	display: -webkit-box;
	-webkit-box-orient: vertical;
	-webkit-line-clamp: 2;
	line-height: 1.25;
	white-space: normal;
}

.rjp--bar .rjp__now {
	display: none;
}

.rjp--bar .rjp__popup-text {
	position: absolute;
	width: 1px;
	height: 1px;
	overflow: hidden;
	clip: rect(0, 0, 0, 0);
	white-space: nowrap;
}

/* Space reserved for the bar; themes can reuse --rjp-bar-space (e.g. inside their footer). */
body.rjp-has-bar {
	--rjp-bar-space: calc(56px + 3px + env(safe-area-inset-bottom, 0px));
	padding-bottom: var(--rjp-bar-space);
}

@media (min-width: 768px) {
	.rjp-bar {
		--rjp-bar-height: 64px;
	}

	body.rjp-has-bar {
		--rjp-bar-space: calc(64px + 3px + env(safe-area-inset-bottom, 0px));
	}

	.rjp--bar {
		gap: 20px;
		padding: 0 24px;
	}

	.rjp--bar .rjp__info {
		flex-direction: row;
		justify-content: flex-start;
		align-items: center;
		gap: 20px;
	}

	.rjp--bar .rjp__station {
		display: block;
		white-space: nowrap;
	}

	.rjp--bar .rjp__now:not(:empty) {
		display: block;
		flex: 1 1 auto;
	}

	.rjp--bar .rjp__volume {
		display: flex;
	}

	.rjp--bar .rjp__popup-text {
		position: static;
		width: auto;
		height: auto;
		clip: auto;
	}
}

/* --------------------------------------------------------------------------
 * Popup mini-player page
 * ----------------------------------------------------------------------- */
.rjp-popup-page {
	display: grid;
	min-height: 100vh;
	margin: 0;
	place-items: center;
	background: var(--rjp-dark);
}

.rjp-popup-page main {
	width: 100%;
}

.rjp--popup {
	flex-wrap: nowrap;
}

.rjp--popup .rjp__volume {
	display: flex;
}

@media (prefers-reduced-motion: reduce) {
	.rjp__toggle,
	.rjp[data-rjp-state="playing"] .rjp__live::before,
	.rjp[data-rjp-state="connecting"] .rjp__spinner {
		animation: none;
		transition: none;
	}
}
