/* Cinematic scroll hero (inc/cinematic.php, assets/cinematic.js). Loaded on the homepage only.
   Three layouts, chosen by a class the head script puts on <html> before the first paint:
   - none (no JS, reduced motion, or the script never started): stacked pictures with their text;
   - html.bb-cine-box (mouse or trackpad): a shorter "window" the wheel moves only while the pointer is over it;
   - html.bb-cine-on (touch screens): pinned while the page scrolls, with a "Skip intro" strip. */

.bb-cine {
	--cine-run: .6;                              /* screens of scrolling per scene */
	--cine-bar: clamp(56px, 10svh, 84px);        /* the strip at the bottom: about 10% of the screen */
	--cine-safe: 0px;                            /* room for the phone's fixed Call / Free Quote bar */
	--cine-box-h: clamp(440px, 64svh, 660px);    /* the window layout: short enough that the next section shows below it */
	background: #1a0f1f;
	color: #fff;
}
.entry-content .bb-cine.alignfull { max-width: none; padding: 0; }
.bb-cine .wp-block-group__inner-container { display: contents; }
/* The theme gives blocks a bottom margin; the stage and scenes must fill the screen exactly. */
.bb-cine .bb-cine__stage, .bb-cine .bb-cine__scene { margin: 0 !important; }

/* ---------- Each scene: picture, soft dark side, text on the left ---------- */
.bb-cine__scene {
	position: relative;
	display: flex;
	align-items: center;
	min-height: min(80vh, 720px);
	padding: clamp(48px, 8vw, 96px) max(24px, 6vw);
	overflow: hidden;
	isolation: isolate;
}
.bb-cine__scene::before { /* the first frame of the scene's video, shown until (and instead of) the video */
	content: "";
	position: absolute;
	inset: 0;
	z-index: -3;
	background: var(--cine-poster) center / cover no-repeat;
	transform: scale(calc(1 + var(--f, 0) * .08)); /* a slow push-in even where video isn't loaded */
	transform-origin: 50% 60%;
}
.bb-cine__scene::after { /* keeps the white text readable on any frame: dark on the left, clear on the right */
	content: "";
	position: absolute;
	inset: 0;
	z-index: -1;
	background: linear-gradient(90deg, rgba(20, 10, 25, .82) 0%, rgba(20, 10, 25, .74) 38%, rgba(20, 10, 25, .25) 66%, rgba(20, 10, 25, 0) 85%);
}
.bb-cine__scene > video {
	position: absolute;
	inset: 0;
	z-index: -2;
	width: 100%;
	height: 100%;
	object-fit: cover;
	opacity: 0;
	transition: opacity .5s ease;
}
.bb-cine__scene.has-video > video { opacity: 1; }

.bb-cine__text { position: relative; width: min(100%, 36rem); }
.bb-cine .bb-eyebrow {
	display: inline-block;
	margin: 0 0 1rem;
	padding: .35em 1em;
	border-radius: 999px;
	background: rgba(255, 255, 255, .16);
	color: #fff;
	font-size: .9rem;
	font-weight: 700;
	letter-spacing: .08em;
	text-transform: uppercase;
}
.bb-cine .bb-cine__title {
	margin: 0 0 .35em;
	color: #fff;
	font-size: clamp(2.6rem, 5.6vw, 4.8rem);
	font-weight: 600;
	line-height: 1.02;
	text-transform: uppercase;
	text-shadow: 0 2px 24px rgba(0, 0, 0, .35);
}
.bb-cine .bb-cine__lead {
	margin: 0 0 1.8rem;
	max-width: 34ch;
	color: #fff;
	font-size: clamp(1.05rem, 1.6vw, 1.3rem);
	line-height: 1.55;
}
.bb-cine .bb-cine__actions { gap: 12px; }

/* ---------- JS-only strip: progress, dots, "Skip intro" (built by the script only for the pinned layout) ---------- */
.bb-cine__bar { display: none; }

/* ---------- Pinned layout ---------- */
/* Only the first scene's picture is needed to paint; the others are fetched at the visitor's first scroll or tap, or 5 seconds after the page has loaded (html.bb-cine-loaded, set in cinematic.js). */
:is(.bb-cine-on, .bb-cine-box):not(.bb-cine-loaded) .bb-cine__scene:not(:first-child)::before { background-image: none; }
.bb-cine-on .bb-cine { height: calc(100svh * (1 + var(--cine-n, 4) * var(--cine-run))); }
.bb-cine-on .bb-cine__stage {
	position: sticky;
	top: 0;
	height: 100vh;
	height: 100svh;
	overflow: hidden;
	background: #1a0f1f;
}
:is(.bb-cine-on, .bb-cine-box) .bb-cine__scene {
	position: absolute;
	inset: 0 0 calc(var(--cine-bar) + var(--cine-safe)) 0; /* the pictures take about 90% of the screen; the strip is the rest */
	min-height: 0;
	padding-block: 0;
}
:is(.bb-cine-on, .bb-cine-box) .bb-cine__scene:not(:first-child) { opacity: 0; visibility: hidden; }
:is(.bb-cine-on, .bb-cine-box) .bb-cine__scene.is-on { visibility: visible; }
/* Once the script runs, a scene that is covered (or not yet shown) is hidden from sight, the tab key and screen readers: the first scene too. */
.bb-cine-ready .bb-cine__scene:not(.is-on) { visibility: hidden; }
:is(.bb-cine-on, .bb-cine-box) .bb-cine__text { will-change: opacity, transform; }

:is(.bb-cine-on, .bb-cine-box) .bb-cine__bar {
	position: absolute;
	left: 0;
	right: 0;
	bottom: var(--cine-safe);
	z-index: 6;
	display: grid;
	grid-template-columns: 1fr auto 1fr;
	align-items: center;
	height: var(--cine-bar);
	padding: 0 max(16px, 4vw);
	background: #fff;
	border-top: 1px solid var(--bb-border, #d9c6db);
	color: var(--bb-night, #2a1630);
}
.bb-cine__bar::before { /* how far through the scenes you are */
	content: "";
	position: absolute;
	left: 0;
	top: -1px;
	height: 3px;
	width: calc(var(--p, 0) * 100%);
	background: var(--bb-purple, #7b4380);
}
.bb-cine__dots { grid-column: 2; grid-row: 1; }
.bb-cine__skip { grid-column: 3; grid-row: 1; }
.bb-cine__dots { display: flex; justify-self: center; }
.bb-cine__dots button {
	display: grid;
	place-items: center;
	width: 44px;
	height: 44px;
	padding: 0;
	border: 0;
	background: none;
	cursor: pointer;
}
.bb-cine__dots button::before {
	content: "";
	width: 10px;
	height: 10px;
	border: 2px solid var(--bb-purple, #7b4380);
	border-radius: 50%;
	background: transparent;
	transition: background-color .25s, transform .25s;
}
.bb-cine__dots button[aria-current="true"]::before { background: var(--bb-purple, #7b4380); transform: scale(1.25); }
.bb-cine__dots button:focus-visible { outline: 3px solid var(--bb-purple, #7b4380); outline-offset: -4px; border-radius: 8px; }
.bb-cine__skip {
	justify-self: end;
	display: inline-flex;
	align-items: center;
	gap: 8px;
	min-height: 44px;
	padding: 0 20px;
	border-radius: 999px;
	background: var(--bb-yellow, #fed800);
	color: #2a1630;
	font-weight: 700;
	text-decoration: none;
	transition: background-color .2s, color .2s;
}
.bb-cine__skip:hover, .bb-cine__skip:focus-visible { background: var(--bb-purple, #7b4380); color: #fff; }

.bb-cine__cue { /* a small "scroll" hint under the first scene's buttons; fades out with the text */
	display: none;
	margin-top: 2rem;
	font-size: .85rem;
	font-weight: 700;
	letter-spacing: .14em;
	text-transform: uppercase;
	color: #fff;
}
:is(.bb-cine-on, .bb-cine-box) .bb-cine__cue { display: flex; align-items: center; gap: 10px; }
.bb-cine__cue::after {
	content: "";
	width: 10px;
	height: 10px;
	border-right: 2px solid currentColor;
	border-bottom: 2px solid currentColor;
	transform: rotate(45deg);
	animation: bb-cine-cue 1.8s ease-in-out infinite;
}
@keyframes bb-cine-cue { 0%, 100% { translate: 0 -3px; opacity: .5; } 50% { translate: 0 4px; opacity: 1; } }

/* ---------- Window layout (mouse): the hero is a shorter box, so the page's next section shows below it ---------- */
.bb-cine-box .bb-cine { height: var(--cine-box-h); }
.bb-cine-box .bb-cine__stage { position: relative; height: 100%; overflow: hidden; background: #1a0f1f; }
.bb-cine-box .bb-cine__scene { inset: 0; padding: 24px max(24px, 6vw) 72px; } /* the strip overlays the picture's bottom */
.bb-cine-box .bb-cine .bb-eyebrow { margin-bottom: .7rem; }
.bb-cine-box .bb-cine .bb-cine__title { font-size: clamp(2.2rem, 4vw, 3.6rem); }
.bb-cine-box .bb-cine .bb-cine__lead { margin-bottom: 1.2rem; font-size: clamp(1rem, 1.3vw, 1.15rem); }
.bb-cine-box .bb-cine__cue { display: none; }
.bb-cine-box .bb-cine__bar {
	bottom: 0;
	height: 72px;
	align-items: end;
	padding-bottom: 10px;
	background: linear-gradient(0deg, rgba(20, 10, 25, .78), rgba(20, 10, 25, 0));
	border-top: 0;
	color: #fff;
}
.bb-cine-box .bb-cine__bar::before { top: auto; bottom: 0; background: var(--bb-yellow, #fed800); } /* progress, along the bottom edge */
.bb-cine-box .bb-cine__dots button::before { border-color: #fff; }
.bb-cine-box .bb-cine__dots button[aria-current="true"]::before { background: var(--bb-yellow, #fed800); border-color: var(--bb-yellow, #fed800); }
.bb-cine-box .bb-cine__dots button:focus-visible { outline-color: var(--bb-yellow, #fed800); }

/* ---------- Phones: smaller picture files, text low on the screen, dark from the bottom ---------- */
@media (max-width: 760px) {
	.bb-cine__scene { align-items: flex-end; padding: 48px 24px 14svh; min-height: 78svh; }
	.bb-cine__scene::before { background-image: var(--cine-poster-m, var(--cine-poster)); }
	.bb-cine__scene::after { background: linear-gradient(0deg, rgba(20, 10, 25, .88) 0%, rgba(20, 10, 25, .74) 45%, rgba(20, 10, 25, .2) 80%, rgba(20, 10, 25, 0) 100%); }
	.bb-cine .bb-cine__title { font-size: clamp(2.2rem, 11vw, 3rem); }
	:is(.bb-cine-on, .bb-cine-box) .bb-cine__scene { padding-bottom: 6svh; }
	:is(.bb-cine-on, .bb-cine-box) .bb-cine__bar { grid-template-columns: auto auto; justify-content: space-between; padding: 0 8px 0 4px; }
	.bb-cine__dots { grid-column: 1; }
	.bb-cine__skip { grid-column: 2; }
}
@media (max-width: 767px) {
	.bb-cine {
		--cine-safe: calc(64px + env(safe-area-inset-bottom)); /* the Call / Free Quote bar is 64px */
		--cine-run: .3; /* a shorter scroll per scene on phones, so the page content is not 3+ screens away */
	}
}

@media (prefers-reduced-motion: reduce) {
	.bb-cine__cue::after { animation: none; }
	.bb-cine__scene > video { transition: none; }
}

/* Jumping with the dots: a short dissolve (the script adds the class for about 0.8 s). Scenes stay visible during it so the old
   one is still there while the new one fades in. */
@media (prefers-reduced-motion: no-preference) {
	.bb-cine-jump .bb-cine__scene { transition: opacity .6s ease; visibility: visible !important; }
	.bb-cine-jump .bb-cine__text { transition: opacity .5s ease, transform .5s ease; }
}
