.sv-video {
	margin: 0;
}

/* Rounded like other media by default (the site's Corners setting); the element's own Rounded corners win (zero
   specificity here) and the frame takes them. */
:where(.sv-video) {
	border-radius: var(--sv-radius-lg);
}

.sv-video__frame {
	position: relative;
	overflow: hidden;
	aspect-ratio: 16 / 9;
	border-radius: inherit;
	background: var(--sv-color-inverse);
}

.sv-video--aspect-4-3 .sv-video__frame {
	aspect-ratio: 4 / 3;
}

.sv-video--aspect-1-1 .sv-video__frame {
	aspect-ratio: 1 / 1;
}

/* Vertical (phone) videos stay a sensible width, placed by the Alignment setting. */
.sv-video--aspect-9-16 .sv-video__frame {
	display: inline-block;
	inline-size: min(100%, 22rem);
	aspect-ratio: 9 / 16;
	vertical-align: top;
}

/* No video chosen yet: nothing shows on the live site. */
.sv-video__frame:empty {
	display: none;
}

.sv-video__media {
	display: block;
	inline-size: 100%;
	block-size: 100%;
	border: 0;
	object-fit: cover;
}

/* A YouTube or Vimeo video's cover (ADR 0122): its picture with a play button; the player comes when it is pressed. */
.sv-video__cover {
	position: relative;
	display: block;
	block-size: 100%;
	color: var(--sv-color-primary);
}

.sv-video__play {
	position: absolute;
	inset: 0;
	inline-size: 4.5rem;
	block-size: 4.5rem;
	margin: auto;
	border-radius: 50%;
	background: color-mix(in srgb, #fff 92%, transparent);
	box-shadow: 0 6px 20px -6px rgb(0 0 0 / 35%);
}

/* The triangle points right in every language (a play sign), a little past the middle so it looks centered. */
.sv-video__play::before {
	position: absolute;
	inset: 0;
	inline-size: 34%;
	block-size: 38%;
	margin: auto;
	background: currentColor;
	clip-path: polygon(0 0, 100% 50%, 0 100%);
	content: "";
	translate: 12% 0;
}

.sv-video__cover:hover .sv-video__play {
	background: var(--sv-color-primary);
	color: var(--sv-color-on-primary, #fff);
}

.sv-video__cover:focus-visible {
	outline: none;
}

/* A ring that shows on any picture: the focus color around a ring of the page's color. */
.sv-video__cover:focus-visible .sv-video__play {
	outline: 2px solid var(--sv-focus, var(--sv-color-text));
	outline-offset: 3px;
	box-shadow: 0 0 0 3px var(--sv-color-background, #fff);
}

/* The video's name, for screen readers: the link's words. */
.sv-video__name {
	position: absolute;
	inline-size: 1px;
	block-size: 1px;
	overflow: hidden;
	clip-path: inset(50%);
	white-space: nowrap;
}

@media (prefers-reduced-motion: no-preference) {
	.sv-video__play {
		transition: background-color 0.2s ease, color 0.2s ease, scale 0.2s ease;
	}

	.sv-video__cover:hover .sv-video__play {
		scale: 1.06;
	}
}

@media (max-width: 767px) {
	.sv-video__play {
		inline-size: 3.5rem;
		block-size: 3.5rem;
	}
}

/*
 * Words and card (ADR 0189). The words are Heading & text's (its classes, heading-text/style.css), above or below the
 * video. The space between them follows Space inside: the site's Small space, or the card's room in a card.
 */
.sv-video {
	--sv-video-room: 0px;
	--sv-video-radius: var(--sv-radius-lg);
	--sv-video-gap: var(--sv-space-sm);
}

.sv-video__words + .sv-video__frame,
.sv-video__frame + .sv-video__words {
	margin-block-start: var(--sv-video-gap);
}

/*
 * Words next to the video: no room of their own, unless the card gives them some. The label, heading and text sit
 * close together, as one caption (Heading & text's Small space between heading and text).
 */
.sv-video .sv-video__words {
	gap: 0.375rem;
	padding-inline: var(--sv-video-words, 0px);
}

.sv-video__words:first-child {
	padding-block-start: var(--sv-video-words, 0px);
}

.sv-video__words:last-child {
	padding-block-end: var(--sv-video-words, 0px);
}

/*
 * In a card (the shared Background) the video sits 0.4rem from its edge with corners that follow the card's (the
 * photo-card rule, ADR 0049); the words keep a little more room. A chosen Space inside is the room around both.
 */
.sv-video:is(.sv-card-soft, .sv-card-light, .sv-card-dark, .sv-card-outlined, .sv-card-primary, .sv-card-secondary) {
	--sv-video-radius: var(--sv-radius-md);
	--sv-video-gap: max(var(--sv-space-xs), var(--sv-video-room));
}

.sv-video:is(.sv-card-soft, .sv-card-light, .sv-card-dark, .sv-card-outlined, .sv-card-primary, .sv-card-secondary):not(.sv-inset-none, .sv-inset-sm, .sv-inset-md, .sv-inset-lg, .sv-inset-xl, .sv-inset-custom) {
	--sv-video-room: 0.4rem;
	--sv-video-words: 0.6rem;
	--sv-video-gap: 1rem;
	padding: var(--sv-video-room);
}

/* Never squarer than the site's Small corners while the card is rounded (a large Space inside would square them). */
.sv-video:is(.sv-card-soft, .sv-card-light, .sv-card-dark, .sv-card-outlined, .sv-card-primary, .sv-card-secondary) .sv-video__frame {
	border-radius: max(min(var(--sv-video-radius), var(--sv-radius-sm)), calc(var(--sv-video-radius) - var(--sv-video-room)));
}

/* The card's corners and room as variables: what the video's corners and the gap follow. */
.sv-video.sv-round-none { --sv-video-radius: 0px; }
.sv-video.sv-round-sm { --sv-video-radius: var(--sv-radius-sm); }
.sv-video.sv-round-md { --sv-video-radius: var(--sv-radius-md); }
.sv-video.sv-round-lg { --sv-video-radius: var(--sv-radius-lg); }
.sv-video.sv-round-custom { --sv-video-radius: var(--sv-custom-round); }
.sv-video.sv-inset-none { --sv-video-room: 0px; }
.sv-video.sv-inset-sm { --sv-video-room: var(--sv-space-step-sm, var(--sv-space-sm)); }
.sv-video.sv-inset-md { --sv-video-room: var(--sv-space-step-md, var(--sv-space-md)); }
.sv-video.sv-inset-lg { --sv-video-room: var(--sv-space-step-lg, var(--sv-space-lg)); }
.sv-video.sv-inset-xl { --sv-video-room: var(--sv-space-step-xl, var(--sv-space-xl)); }
.sv-video.sv-inset-custom { --sv-video-room: var(--sv-custom-inset); }

/* A vertical video keeps its words and card as wide as itself, placed by the Alignment. */
.sv-video--aspect-9-16:is(:has(> .sv-video__words), .sv-card-soft, .sv-card-light, .sv-card-dark, .sv-card-outlined, .sv-card-primary, .sv-card-secondary) {
	max-inline-size: calc(22rem + 2 * var(--sv-video-room));
	margin-inline: var(--sv-line-margin, 0);
}

/* Space inside per screen size (ADR 0120): the device's room (--sv-inset-d) around the video and its words. */
@media (max-width: 1024px) {
	.sv-video:is(.sv-card-soft, .sv-card-light, .sv-card-dark, .sv-card-outlined, .sv-card-primary, .sv-card-secondary):is(.sv-t-inset-none, .sv-t-inset-sm, .sv-t-inset-md, .sv-t-inset-lg, .sv-t-inset-xl, .sv-t-inset-custom) {
		--sv-video-room: var(--sv-inset-d);
		--sv-video-words: 0px;
		--sv-video-gap: max(var(--sv-space-xs), var(--sv-inset-d));
		padding: var(--sv-inset-d);
	}
}

@media (max-width: 767px) {
	.sv-video:is(.sv-card-soft, .sv-card-light, .sv-card-dark, .sv-card-outlined, .sv-card-primary, .sv-card-secondary):is(.sv-t-inset-none, .sv-t-inset-sm, .sv-t-inset-md, .sv-t-inset-lg, .sv-t-inset-xl, .sv-t-inset-custom, .sv-m-inset-none, .sv-m-inset-sm, .sv-m-inset-md, .sv-m-inset-lg, .sv-m-inset-xl, .sv-m-inset-custom) {
		--sv-video-room: var(--sv-inset-d);
		--sv-video-words: 0px;
		--sv-video-gap: max(var(--sv-space-xs), var(--sv-inset-d));
		padding: var(--sv-inset-d);
	}
}

.sv-video__frame > .sv-editor-placeholder {
	block-size: 100%;
	min-block-size: 0;
}
