/*
 * The player, the two in-video call-to-action layers, and the button
 * under it.
 *
 * Everything the theme is expected to decide is read as a custom
 * property with a fallback, so the plugin looks right on a bare
 * WordPress install and takes the theme's colours the moment one
 * declares them. Redshift sets --bvc-btn-* from its Customizer.
 *
 * The button's look is deliberately NOT declared here.
 *
 * Declaring --bvc-btn-* on .bvc-player would look like a harmless
 * default, but a class beats :root — so the theme's settings, which are
 * printed on :root, would lose to this file and the Customizer controls
 * would appear to do nothing. Every property is therefore read where it
 * is used, with the fallback chain written into the var() itself:
 * whatever the theme set, then the theme's generic button colour, then
 * the theme's accent, then ours.
 */
.bvc-player {
	--bvc-radius: 12px;
	--bvc-surface: rgba(10, 12, 18, .86);

	width: 100%;
	margin: 0 0 18px;
}

/*
 * Load-bearing, not tidiness. Both CTA layers are laid out with flex,
 * which beats the browser's own [hidden] { display: none } — so without
 * this the end card covers the video from page load and, sitting above
 * the poster, swallows the click that would have started playback.
 */
.bvc-player [hidden] {
	display: none !important;
}

.bvc-stage {
	position: relative;
	overflow: hidden;
	width: 100%;
	aspect-ratio: 16 / 9;
	border-radius: var(--bvc-radius);
	background: #050505;
}

.bvc-video {
	position: relative;
	z-index: 1;
	display: block;
	width: 100%;
	height: 100%;
	/* Transparent, not black: the film keeps its own shape (contain), and
	   the bands left beside or under it show whatever the stage has behind
	   — the blurred copy of the picture, or the stage's own dark. */
	background: transparent;
	object-fit: contain;
}

/*
 * The blurred copy of the picture, filling whatever the picture or the
 * film does not cover. Flat black bands against a dark page read as a
 * hole between the player and what follows it; this does not.
 */
.bvc-stage__bg {
	position: absolute;
	/* Past the edges, so the blur has something to blur into instead of
	   fading out into transparency at the corners. */
	inset: -8%;
	z-index: 0;
	display: none;
	background-position: center;
	background-repeat: no-repeat;
	background-size: cover;
	/* Dark enough that the picture stands out against it, light enough
	   that it reads as filled space rather than as a hole. */
	filter: blur(26px) saturate(1.3) brightness(.72);
	transform: scale(1.06);
}

.bvc-stage--fit .bvc-stage__bg {
	display: block;
}

/* --- click-to-play poster --- */

.bvc-poster {
	position: absolute;
	inset: 0;
	z-index: 2;
	width: 100%;
	height: 100%;
	padding: 0;
	border: 0;
	/* Transparent, so the blurred layer behind the frame shows in the
	   bands beside a picture that does not fill it. */
	background: transparent;
	cursor: pointer;
}

.bvc-poster img {
	position: relative;
	z-index: 1;
	display: block;
	width: 100%;
	height: 100%;
	object-fit: cover;
}

/*
 * A picture that is not 16/9 — a square, portrait or panoramic featured
 * image — is shown whole rather than cropped to the stage, against the
 * blurred copy of itself behind the whole frame. Nothing is stretched:
 * both layers keep the proportions of the original.
 */
.bvc-stage--fit .bvc-poster img {
	object-fit: contain;
}

.bvc-poster__play {
	position: absolute;
	/* Above the picture, which is itself above the blurred copy. */
	z-index: 2;
	top: 50%;
	left: 50%;
	display: block;
	transform: translate(-50%, -50%);
	transition: transform .18s ease, opacity .18s ease;
	opacity: .92;
}

.bvc-poster:hover .bvc-poster__play,
.bvc-poster:focus-visible .bvc-poster__play {
	transform: translate(-50%, -50%) scale(1.06);
	opacity: 1;
}

/* --- the connection layer --- */

.bvc-status {
	position: absolute;
	inset: 0;
	z-index: 6;
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: 12px;
	padding: 20px;
	background: rgba(5, 5, 5, .82);
	color: #fff;
	font-weight: 700;
	text-align: center;
}

.bvc-status button {
	padding: 10px 18px;
	border: 0;
	border-radius: var(--bvc-btn-radius, var(--rs-cta-radius, 8px));
	background: var(--bvc-btn-bg, var(--rs-cta-bg, var(--rs-accent, #e01b2d)));
	color: var(--bvc-btn-fg, var(--rs-cta-fg, #fff));
	font: inherit;
	font-weight: 700;
	cursor: pointer;
}

/* --- the call to action, inside the video --- */

.bvc-cta__link {
	display: flex;
	align-items: center;
	gap: 10px;
	color: inherit;
	text-decoration: none;
}

.bvc-cta__text {
	font-weight: 600;
	line-height: 1.35;
}

/* A bar along the bottom, clear of the native control strip so it never
   covers the scrubber. */
.bvc-cta--overlay {
	position: absolute;
	right: 14px;
	bottom: 56px;
	left: 14px;
	z-index: 3;
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 10px;
	padding: 11px 12px 11px 14px;
	border: 1px solid rgba(255, 255, 255, .22);
	border-radius: var(--bvc-radius);
	background: var(--bvc-surface);
	box-shadow: 0 6px 26px rgba(0, 0, 0, .45);
	color: #fff;
	backdrop-filter: blur(6px);
	animation: bvc-rise .28s ease both;
}

@keyframes bvc-rise {
	from { opacity: 0; transform: translateY(8px); }
	to   { opacity: 1; transform: translateY(0); }
}

@media (prefers-reduced-motion: reduce) {
	.bvc-cta--overlay { animation: none; }
}

.bvc-cta__close {
	flex-shrink: 0;
	width: 30px;
	height: 30px;
	border: 0;
	border-radius: 50%;
	background: rgba(255, 255, 255, .12);
	color: #fff;
	font-size: 17px;
	line-height: 1;
	cursor: pointer;
	transition: background .15s ease;
}

.bvc-cta__close:hover { background: rgba(255, 255, 255, .24); }

/* The card at the end of the preview. */
.bvc-cta--end {
	position: absolute;
	inset: 0;
	z-index: 5;
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: 16px;
	padding: 28px;
	background: rgba(6, 9, 16, .9);
	color: #fff;
	text-align: center;
	backdrop-filter: blur(5px);
}

.bvc-cta--end .bvc-cta__link {
	flex-direction: column;
	gap: 14px;
}

.bvc-cta--end .bvc-cta__text {
	font-size: clamp(1rem, 2.4vw, 1.35rem);
	font-weight: 700;
}

.bvc-replay {
	position: absolute;
	/* Above the native control strip, which is still there under the card
	   and would otherwise have this sitting on top of the scrubber. */
	bottom: 52px;
	left: 50%;
	transform: translateX(-50%);
	padding: 6px 10px;
	border: 0;
	background: transparent;
	color: rgba(255, 255, 255, .82);
	text-decoration: underline;
	cursor: pointer;
}

.bvc-replay:hover { color: #fff; }

/* --- the button, under the player and inside the CTA ------------------
   One class, no inline styles: the whole reason the Shortcodes Ultimate
   button is being replaced is that its colours were baked into the
   content of every post and could not be changed from one place. */

.bvc-btn {
	display: inline-block;
	padding: var(--bvc-btn-padding, var(--rs-cta-padding, 12px 22px));
	border: var(--bvc-btn-border, var(--rs-cta-border, 0));
	border-radius: var(--bvc-btn-radius, var(--rs-cta-radius, 8px));
	background: var(--bvc-btn-bg, var(--rs-cta-bg, var(--rs-accent, #e01b2d)));
	color: var(--bvc-btn-fg, var(--rs-cta-fg, var(--rs-accent-ink, #fff)));
	font-size: var(--bvc-btn-size, var(--rs-cta-size, .95rem));
	font-weight: var(--bvc-btn-weight, 700);
	line-height: 1.2;
	text-align: center;
	text-decoration: none;
	text-transform: var(--bvc-btn-transform, var(--rs-cta-transform, none));
	letter-spacing: .01em;
	cursor: pointer;
	transition: background .18s ease, filter .18s ease, transform .18s ease;
}

.bvc-btn:hover,
.bvc-btn:focus-visible {
	background: var(--bvc-btn-bg-hover, var(--rs-cta-bg-hover, var(--rs-accent, #e01b2d)));
	color: var(--bvc-btn-fg-hover, var(--rs-cta-fg-hover, var(--rs-accent-ink, #fff)));
	filter: brightness(1.08);
	transform: translateY(-1px);
}

/* Inside the overlay sentence the button is the last word, so it is
   smaller and cannot be squeezed out by a long line of text. */
.bvc-btn--inline {
	flex-shrink: 0;
	padding: 7px 16px;
	font-size: 14px;
}

.bvc-actions {
	display: flex;
	justify-content: center;
	margin: 14px 0 0;
}

.bvc-btn--wide {
	min-width: min(420px, 100%);
}

@media (max-width: 640px) {
	.bvc-cta--overlay {
		right: 8px;
		bottom: 48px;
		left: 8px;
		padding: 9px 9px 9px 12px;
	}
	.bvc-cta__text { font-size: .9rem; }
	.bvc-btn--inline { padding: 6px 12px; font-size: 13px; }
	.bvc-btn--wide { width: 100%; }
}

/* --- the control bar --------------------------------------------------
   Built by the script, which also takes the browser's own controls off —
   so a visitor whose JavaScript never arrives keeps a working player
   rather than a video with no way to start it. Touch devices are left on
   the native controls on purpose: their fullscreen, picture-in-picture
   and lock-screen handling is built in, and a hand-made bar loses all of
   it for the sake of looking tidier. */

.bvc-player--custom .bvc-video { cursor: pointer; }

.bvc-controls {
	position: absolute;
	right: 0;
	bottom: 0;
	left: 0;
	z-index: 4;
	display: flex;
	align-items: center;
	gap: 10px;
	padding: 34px 14px 12px;
	color: #fff;
	/* The gradient is what keeps white controls legible over a bright
	   frame, without a bar that boxes the picture in. */
	background: linear-gradient(to top, rgba(0, 0, 0, .78) 0%, rgba(0, 0, 0, .45) 45%, rgba(0, 0, 0, 0) 100%);
	opacity: 1;
	transition: opacity .25s ease, transform .25s ease;
}

/* Out of the way while the film is playing and the pointer is still. */
.bvc-player--custom.is-idle .bvc-controls {
	opacity: 0;
	transform: translateY(6px);
	pointer-events: none;
}
.bvc-player--custom.is-idle .bvc-video { cursor: none; }

.bvc-ctl {
	flex-shrink: 0;
	display: grid;
	place-items: center;
	width: 34px;
	height: 34px;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: transparent;
	color: #fff;
	cursor: pointer;
	transition: background .15s ease, transform .15s ease;
}
.bvc-ctl:hover { background: rgba(255, 255, 255, .16); }
.bvc-ctl:active { transform: scale(.94); }
.bvc-ctl:focus-visible { outline: 2px solid var(--bvc-btn-bg, var(--rs-cta-bg, #e01b2d)); outline-offset: 2px; }

/* One button, two icons: which one shows is the play state. */
.bvc-icon-pause,
.bvc-player--custom.is-playing .bvc-icon-play { display: none; }
.bvc-player--custom.is-playing .bvc-icon-pause { display: block; }

.bvc-icon-muted,
.bvc-player--custom.is-muted .bvc-icon-loud { display: none; }
.bvc-player--custom.is-muted .bvc-icon-muted { display: block; }

.bvc-time {
	flex-shrink: 0;
	min-width: 42px;
	font-size: 12.5px;
	font-variant-numeric: tabular-nums;
	letter-spacing: .01em;
	opacity: .92;
}
.bvc-time--total { opacity: .7; }

/* The seek bar. A generous invisible hit area around a thin line, so it
   is easy to grab without being a slab across the picture. */
.bvc-seek {
	flex: 1 1 auto;
	min-width: 0;
	height: 22px;
	display: flex;
	align-items: center;
	cursor: pointer;
	touch-action: none;
}
.bvc-seek:focus-visible { outline: 2px solid var(--bvc-btn-bg, var(--rs-cta-bg, #e01b2d)); outline-offset: 3px; border-radius: 4px; }

.bvc-seek__track {
	position: relative;
	width: 100%;
	height: 5px;
	border-radius: 999px;
	background: rgba(255, 255, 255, .26);
	transition: height .15s ease;
}
.bvc-seek:hover .bvc-seek__track,
.bvc-seek:focus-visible .bvc-seek__track { height: 7px; }

.bvc-seek__buffer,
.bvc-seek__fill {
	position: absolute;
	top: 0;
	left: 0;
	height: 100%;
	border-radius: inherit;
}
/* What has been downloaded, behind what has been watched — the thing the
   old player never showed, and the thing that tells you whether a pause
   is the connection or the film. */
.bvc-seek__buffer { background: rgba(255, 255, 255, .3); }

/*
 * The played part takes the theme's accent, NOT the button's background.
 * A button may legitimately be transparent — that is what an outline or
 * ghost button is — and a progress bar painted in it disappears: the
 * whole track reads as one flat grey line and there is no telling how
 * much has been watched. `--bvc-seek-fill` overrides it directly.
 */
.bvc-seek__fill { background: var(--bvc-seek-fill, var(--rs-accent, #e01b2d)); }

/*
 * Visible whenever the bar itself is visible.
 *
 * It used to be scaled to nothing until the pointer was over the seek
 * strip — copied from the big players, and wrong here: the bar already
 * hides itself while the film runs, so by the time anyone sees it they
 * are looking for where they are, and a line with no marker on it reads
 * as a decoration rather than as something you can grab. Hovering now
 * makes it bigger instead of making it exist.
 */
.bvc-seek__knob {
	position: absolute;
	top: 50%;
	width: 12px;
	height: 12px;
	margin-left: -6px;
	border-radius: 50%;
	background: #fff;
	transform: translateY(-50%) scale(1);
	transition: transform .15s ease;
	box-shadow: 0 1px 4px rgba(0, 0, 0, .5);
}
.bvc-seek:hover .bvc-seek__knob,
.bvc-seek:focus-visible .bvc-seek__knob { transform: translateY(-50%) scale(1.3); }
.bvc-seek:active .bvc-seek__knob { transform: translateY(-50%) scale(1.15); }

.bvc-volume {
	flex-shrink: 0;
	width: 0;
	height: 4px;
	padding: 0;
	opacity: 0;
	appearance: none;
	-webkit-appearance: none;
	border-radius: 999px;
	background: rgba(255, 255, 255, .28);
	cursor: pointer;
	transition: width .2s ease, opacity .2s ease;
}
/* The slider unrolls when the sound is being touched, rather than taking
   up room in the bar all the time. */
.bvc-controls:hover .bvc-volume,
.bvc-volume:focus-visible { width: 72px; opacity: 1; }

.bvc-volume::-webkit-slider-thumb {
	appearance: none;
	-webkit-appearance: none;
	width: 12px; height: 12px;
	border: 0;
	border-radius: 50%;
	background: #fff;
}
.bvc-volume::-moz-range-thumb {
	width: 12px; height: 12px;
	border: 0;
	border-radius: 50%;
	background: #fff;
}

/* The call to action sits above the bar rather than under it. */
.bvc-player--custom .bvc-cta--overlay { bottom: 64px; }
.bvc-player--custom .bvc-replay { bottom: 64px; }

.bvc-player--custom.is-full .bvc-stage {
	height: 100%;
	aspect-ratio: auto;
	border-radius: 0;
}
.bvc-player--custom.is-full { margin: 0; }

@media (max-width: 640px) {
	.bvc-controls { gap: 6px; padding: 28px 8px 8px; }
	.bvc-time { min-width: 36px; font-size: 11.5px; }
	.bvc-volume, .bvc-controls:hover .bvc-volume { width: 0; opacity: 0; }
}

@media (prefers-reduced-motion: reduce) {
	.bvc-controls, .bvc-seek__track, .bvc-seek__knob, .bvc-volume, .bvc-ctl { transition: none; }
}

/* The player as a whole is focusable, so the keyboard shortcuts work
   without clicking first. That deserves a visible ring of its own. */
.bvc-player--custom:focus-visible {
	outline: 2px solid var(--bvc-btn-bg, var(--rs-cta-bg, var(--rs-accent, #e01b2d)));
	outline-offset: 3px;
	border-radius: var(--bvc-radius);
}
