/**
 * Framed Video — frontend styles.
 * Per-instance theming comes from CSS custom properties set by Elementor's
 * control `selectors` on the widget wrapper (see class-framed-video-widget.php);
 * this file only ever reads them via var(--fv-x, fallback).
 */

/*
 * Elementor's control `selectors` set --fv-* on {{WRAPPER}}, which is the
 * ancestor of .framed-video. Declaring the same properties here would shadow
 * those inherited values and make the Style controls appear dead, so defaults
 * are applied only as var() fallbacks at each use site instead.
 *
 * --fv-bezel is derived once and referenced flat: nested calc() chained off a
 * custom property makes Blink skip the repaint until an unrelated style recalc
 * (e.g. :hover) forces it, which reads as "only updates when I hover".
 */
.framed-video {
	--fv-bezel: calc(
		var(--fv-frame-thickness, 16px) + var(--fv-frame-padding, 8px)
	);

	position: relative;
	box-sizing: border-box;
}

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

.framed-video__unit {
	position: relative;
	width: 100%;
	max-width: 100%;
}

/* -------------------------------------------------------------------
 * Frame chrome (shared)
 * ----------------------------------------------------------------- */

.framed-video__frame {
	position: relative;
	background: var(--fv-frame-color, #1a1a1a);
	padding: var(--fv-bezel);
	border-radius: 6px;
}

.framed-video--frame-none .framed-video__frame {
	background: transparent;
	padding: 0;
	border-radius: 0;
}

.framed-video__screen {
	position: relative;
	width: 100%;
	padding-top: var(--fv-aspect-ratio, 56.25%);
	overflow: hidden;
	background: #000;
	border-radius: 2px;
}

.framed-video__glare {
	position: absolute;
	inset: 0;
	pointer-events: none;
	background: linear-gradient(115deg, rgba(255, 255, 255, 0.16) 0%, rgba(255, 255, 255, 0.05) 24%, rgba(255, 255, 255, 0) 45%);
	z-index: 3;
}

/* -------------------------------------------------------------------
 * Media: poster, play button, injected iframe/video
 * ----------------------------------------------------------------- */

.framed-video__media {
	position: absolute;
	inset: 0;
	display: flex;
	align-items: center;
	justify-content: center;
	background: #000;
}

.framed-video__poster {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	object-fit: cover;
	display: block;
}

.framed-video__play {
	position: relative;
	z-index: 2;
	width: var(--fv-play-size, 72px);
	height: var(--fv-play-size, 72px);
	border: 0;
	border-radius: 50%;
	background: rgba(0, 0, 0, 0.45);
	color: var(--fv-play-color, #ffffff);
	display: flex;
	align-items: center;
	justify-content: center;
	cursor: pointer;
	transition: color 0.15s ease, transform 0.15s ease, background-color 0.15s ease;
}

.framed-video__play:hover,
.framed-video__play:focus-visible {
	color: var(--fv-play-hover-color, #ff5a3c);
	transform: scale(1.06);
}

.framed-video__play:focus-visible {
	outline: 3px solid var(--fv-play-hover-color, #ff5a3c);
	outline-offset: 4px;
}

.framed-video__play-icon {
	width: 42%;
	height: 42%;
	margin-left: 8%; /* optically center the triangle */
}

.framed-video__media.is-loaded .framed-video__poster,
.framed-video__media.is-loaded .framed-video__play {
	display: none;
}

.framed-video__iframe,
.framed-video__video {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	border: 0;
}

.framed-video__video {
	object-fit: cover;
}

/* -------------------------------------------------------------------
 * TV frame
 * ----------------------------------------------------------------- */

.framed-video--frame-tv .framed-video__frame {
	padding-bottom: calc(var(--fv-bezel) + 22px);
	border-radius: 14px;
	margin-bottom: 30px; /* reserves room for the stand, which protrudes below via absolute positioning */
	box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35), inset 0 0 0 1px rgba(255, 255, 255, 0.06);
}

.framed-video__tv-bezel {
	position: absolute;
	top: calc(var(--fv-bezel) / 2);
	right: calc(var(--fv-bezel) + 6px);
	display: flex;
	gap: 7px;
	z-index: 2;
}

.framed-video__tv-dial {
	width: 9px;
	height: 9px;
	border-radius: 50%;
	background: radial-gradient(circle at 35% 35%, rgba(255, 255, 255, 0.55), rgba(255, 255, 255, 0.12) 70%);
	box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.25);
}

.framed-video__tv-scrubber {
	position: absolute;
	left: var(--fv-bezel);
	right: var(--fv-bezel);
	bottom: 10px;
	height: 4px;
	border-radius: 2px;
	background: rgba(255, 255, 255, 0.18);
	overflow: hidden;
}

.framed-video__tv-scrubber-fill {
	display: block;
	width: 0;
	height: 100%;
	background: var(--fv-play-hover-color, #ff5a3c);
}

.framed-video__tv-stand {
	position: absolute;
	left: 50%;
	bottom: -30px;
	transform: translateX(-50%);
	display: flex;
	flex-direction: column;
	align-items: center;
	filter: drop-shadow(0 6px 4px rgba(0, 0, 0, 0.35));
}

.framed-video__tv-stand-neck {
	width: 16px;
	height: 22px;
	background: var(--fv-frame-color, #1a1a1a);
	filter: brightness(0.7);
}

.framed-video__tv-stand-base {
	width: 90px;
	max-width: 40%;
	height: 10px;
	border-radius: 5px;
	background: var(--fv-frame-color, #1a1a1a);
	filter: brightness(0.55);
	margin-top: -2px;
}

/* -------------------------------------------------------------------
 * TV Retro frame — chunky 80s/90s CRT box TV
 * ----------------------------------------------------------------- */

.framed-video--frame-tv-retro .framed-video__frame {
	padding: calc(var(--fv-bezel) + 14px);
	padding-right: calc(var(--fv-bezel) + 38px);
	border-radius: 22px;
	margin-bottom: 34px; /* reserves room for the pedestal, which protrudes below via absolute positioning */
	box-shadow: 0 14px 34px rgba(0, 0, 0, 0.4), inset 0 0 0 2px rgba(255, 255, 255, 0.05);
}

.framed-video--frame-tv-retro .framed-video__screen {
	border-radius: 20px;
}

.framed-video__retro-bezel {
	position: absolute;
	top: 50%;
	right: calc(var(--fv-bezel) / 2);
	transform: translateY(-50%);
	display: flex;
	flex-direction: column;
	gap: 16px;
	z-index: 2;
}

.framed-video__retro-knob {
	width: 20px;
	height: 20px;
	border-radius: 50%;
	background: radial-gradient(circle at 35% 30%, rgba(255, 255, 255, 0.5), rgba(0, 0, 0, 0.25) 75%);
	box-shadow: 0 1px 2px rgba(0, 0, 0, 0.5), inset 0 0 0 2px rgba(0, 0, 0, 0.3);
}

.framed-video__retro-stand {
	position: absolute;
	left: 50%;
	bottom: -30px;
	transform: translateX(-50%);
	width: 46%;
	max-width: 150px;
	min-width: 90px;
	height: 22px;
	border-radius: 6px;
	background: var(--fv-frame-color, #1a1a1a);
	filter: brightness(0.6);
	box-shadow: 0 8px 10px rgba(0, 0, 0, 0.35);
}

/* -------------------------------------------------------------------
 * Browser frame
 * ----------------------------------------------------------------- */

.framed-video--frame-browser .framed-video__frame {
	padding-top: 0;
	border-radius: 8px;
	box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
}

.framed-video__browser-bar {
	display: flex;
	align-items: center;
	gap: 10px;
	padding: 10px var(--fv-bezel);
	background: rgba(255, 255, 255, 0.06);
}

.framed-video__browser-dot {
	width: 10px;
	height: 10px;
	border-radius: 50%;
	flex: 0 0 auto;
}

.framed-video__browser-dot--a {
	background: #ff5f56;
}

.framed-video__browser-dot--b {
	background: #ffbd2e;
}

.framed-video__browser-dot--c {
	background: #27c93f;
}

.framed-video__browser-url {
	flex: 1 1 auto;
	min-width: 0;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
	font-size: 12px;
	color: rgba(255, 255, 255, 0.7);
	background: rgba(255, 255, 255, 0.08);
	border-radius: 999px;
	padding: 3px 12px;
}

.framed-video--frame-browser .framed-video__screen {
	border-radius: 0 0 4px 4px;
}

/* -------------------------------------------------------------------
 * Phone frame — fixed portrait 9:16, notch + home bar
 * ----------------------------------------------------------------- */

.framed-video--frame-phone {
	max-width: 320px;
	margin-left: auto;
	margin-right: auto;
}

.framed-video--frame-phone .framed-video__frame {
	border-radius: 34px;
	padding: calc(var(--fv-bezel) + 10px) var(--fv-bezel);
	box-shadow: 0 12px 32px rgba(0, 0, 0, 0.4);
}

.framed-video--frame-phone .framed-video__screen {
	padding-top: 177.78%;
	border-radius: 18px;
}

.framed-video__phone-notch {
	position: absolute;
	top: 6px;
	left: 50%;
	transform: translateX(-50%);
	width: 40%;
	height: 18px;
	border-radius: 0 0 12px 12px;
	background: var(--fv-frame-color, #1a1a1a);
	z-index: 2;
}

.framed-video__phone-notch::before {
	content: '';
	position: absolute;
	inset: 0;
	margin: auto;
	width: 40px;
	height: 6px;
	border-radius: 3px;
	background: rgba(255, 255, 255, 0.15);
}

.framed-video__phone-home-bar {
	position: absolute;
	bottom: 10px;
	left: 50%;
	transform: translateX(-50%);
	width: 36%;
	height: 4px;
	border-radius: 2px;
	background: rgba(255, 255, 255, 0.35);
}

/* -------------------------------------------------------------------
 * Poster frame — ruled card + small-caps label row
 * ----------------------------------------------------------------- */

.framed-video--frame-poster .framed-video__frame {
	background: #f6f3ea;
	border: 3px solid var(--fv-frame-color, #1a1a1a);
	padding: calc(var(--fv-bezel) + 4px);
	border-radius: 2px;
	box-shadow: 0 6px 20px rgba(0, 0, 0, 0.18);
	background-image: repeating-linear-gradient(
		to bottom,
		transparent,
		transparent 27px,
		rgba(0, 0, 0, 0.06) 28px
	);
}

.framed-video__poster-label {
	display: flex;
	align-items: baseline;
	justify-content: space-between;
	gap: 12px;
	padding: 0 2px 8px;
	font-size: 11px;
	letter-spacing: 0.08em;
	text-transform: uppercase;
	color: #3a3a38;
}

.framed-video__poster-title {
	font-weight: 700;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.framed-video__poster-duration {
	flex: 0 0 auto;
	opacity: 0.65;
}

.framed-video--frame-poster .framed-video__screen {
	border-radius: 1px;
}

/* -------------------------------------------------------------------
 * Meta: title / caption
 * ----------------------------------------------------------------- */

.framed-video__meta {
	margin-top: 14px;
}

.framed-video__title {
	margin: 0 0 4px;
}

.framed-video__caption {
	margin: 0;
	opacity: 0.8;
}

.framed-video__caption p {
	margin: 0;
}

/* -------------------------------------------------------------------
 * Background hero mode
 * ----------------------------------------------------------------- */

.framed-video--mode-background {
	height: 100%;
	min-height: 480px;
}

.framed-video__hero {
	position: relative;
	width: 100%;
	height: 100%;
	min-height: inherit;
	overflow: hidden;
}

.framed-video__hero-media {
	position: absolute;
	inset: 0;
}

.framed-video__hero-fallback {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	object-fit: cover;
	transition: opacity 0.4s ease;
}

.framed-video__hero-media.is-loaded .framed-video__hero-fallback {
	opacity: 0;
}

.framed-video__hero-embed {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	border: 0;
	object-fit: cover;
}

.framed-video__overlay {
	position: absolute;
	inset: 0;
	background: var(--fv-overlay-color, rgba(0, 0, 0, 0.45));
	opacity: var(--fv-overlay-opacity, 1);
	pointer-events: none;
}

.framed-video__hero-content {
	position: relative;
	z-index: 2;
	height: 100%;
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	text-align: center;
	gap: 12px;
	padding: 32px;
	color: #fff;
}

.framed-video__mute-toggle {
	width: 44px;
	height: 44px;
	border-radius: 50%;
	border: 0;
	background: rgba(0, 0, 0, 0.45);
	color: #fff;
	display: flex;
	align-items: center;
	justify-content: center;
	cursor: pointer;
}

.framed-video__mute-toggle:focus-visible {
	outline: 3px solid #fff;
	outline-offset: 3px;
}

.framed-video__mute-icon {
	width: 50%;
	height: 50%;
}

/* -------------------------------------------------------------------
 * Gallery mode
 * ----------------------------------------------------------------- */

.framed-video__gallery-main .framed-video__gallery-slot[hidden] {
	display: none;
}

.framed-video__gallery-rail {
	display: flex;
	gap: 10px;
	margin-top: 14px;
	overflow-x: auto;
	scroll-snap-type: x proximity;
	padding-bottom: 4px;
}

.framed-video__rail-item {
	position: relative;
	flex: 0 0 auto;
	width: 120px;
	aspect-ratio: 16 / 9;
	border: 2px solid transparent;
	border-radius: 6px;
	overflow: hidden;
	padding: 0;
	background: #000;
	cursor: pointer;
	scroll-snap-align: start;
}

.framed-video__rail-item img {
	width: 100%;
	height: 100%;
	object-fit: cover;
	display: block;
}

.framed-video__rail-item-title {
	position: absolute;
	left: 0;
	right: 0;
	bottom: 0;
	padding: 4px 6px;
	font-size: 11px;
	line-height: 1.2;
	color: #fff;
	background: linear-gradient(to top, rgba(0, 0, 0, 0.75), transparent);
	text-align: left;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.framed-video__rail-item--active {
	border-color: var(--fv-play-hover-color, #ff5a3c);
}

.framed-video__rail-item:focus-visible {
	outline: 3px solid var(--fv-play-hover-color, #ff5a3c);
	outline-offset: 2px;
}

/* -------------------------------------------------------------------
 * Responsive
 * ----------------------------------------------------------------- */

@media (max-width: 767px) {
	.framed-video__hero-embed {
		display: none;
	}

	.framed-video__hero-media .framed-video__hero-fallback {
		opacity: 1;
	}
}

@media (max-width: 480px) {
	.framed-video--frame-tv .framed-video__tv-stand {
		display: none;
	}

	.framed-video--frame-tv .framed-video__frame {
		padding-bottom: var(--fv-bezel);
		margin-bottom: 0;
	}

	.framed-video--frame-tv-retro .framed-video__retro-stand {
		display: none;
	}

	.framed-video--frame-tv-retro .framed-video__frame {
		margin-bottom: 0;
	}

	.framed-video__rail-item {
		width: 92px;
	}
}

/* -------------------------------------------------------------------
 * Reduced motion
 * ----------------------------------------------------------------- */

@media (prefers-reduced-motion: reduce) {
	.framed-video *,
	.framed-video *::before,
	.framed-video *::after {
		animation-duration: 0.001ms !important;
		animation-iteration-count: 1 !important;
		transition-duration: 0.001ms !important;
		scroll-behavior: auto !important;
	}
}
