/* ==========================================================================
   Embedded video players — TikTok and Instagram.

   WHY THIS IS A SEPARATE FILE: every template stylesheet declares its own
   `aspect-ratio: 16 / 9` on its video frame (.hl-svc__video, .hl-gal-video__frame,
   .hl-pricinfo-video, .hl-la__video, .hl-media-player__frame …) — nine rules
   across eight files. Those are plain class selectors, so an attribute selector
   here ties them on specificity, and main.css loads FIRST, which means the
   template would win and a vertical clip would be squeezed back into a 16:9 box.

   This file is enqueued after the per-template stylesheet (see hl_enqueue_assets
   in functions.php), so it wins on order instead. That keeps the overrides free
   of !important and leaves each template's own 16:9 default untouched for the
   YouTube frames it was written for.
   ========================================================================== */

/* A player embedded straight into its frame fills it; there is no poster
   button in that case, so the iframe IS the content. (Instagram is the
   exception and is sized separately below — its card has to be laid out at a
   fixed width and cropped, not stretched to the frame.) */
[data-video-provider="tiktok"] > iframe,
.hl-video--portrait > iframe {
	display: block;
	width: 100%;
	height: 100%;
	border: 0;
}

/*
   TikTok's player is a bare player — no caption, no action bar — so a 9:16 box
   holds it exactly, which is the shape the clip was filmed in.
*/
[data-video-provider="tiktok"] {
	aspect-ratio: 9 / 16;
	max-width: 330px;
	overflow: hidden;
	background: #000;
}

/*
   Instagram is NOT a bare player: its embed is a post card — a profile row on
   top, then the picture, then an action bar, a "View more on Instagram" link
   and the like count. Only the picture is wanted here.

   This only applies once a visitor presses play: until then the frame shows the
   post's own cover image (hl_video_instagram_thumb), so none of Instagram's
   chrome is on the page at all.

   The iframe is cross-origin, so none of that chrome can be removed from the
   inside; the only way to show the video alone is to lay the card out at full
   height, slide it up by the height of its profile row, and let this frame hide
   what falls outside.

   Width is handled by scaling rather than by sizing the iframe: Instagram
   refuses to render the media below 326px, which is narrower than some of the
   grid columns these sit in, so the card is always laid out at exactly that
   width and then scaled to whatever the frame actually is.
*/
[data-video-provider="instagram"] {
	/*
	   Card geometry, in Instagram's own layout pixels at --hl-ig-base width.
	   Everything but the header was measured off a real embed of three of the
	   practice's reels: the picture sits in a 4:5 box (0.783 measured against
	   0.800 for Instagram's documented portrait ratio) with the 9:16 reel
	   letterboxed inside it, leaving a 46px black bar either side. Cropping to
	   the picture is what makes the frame exactly 9 / 16 below — which in turn
	   is why no runtime measurement is needed.

	   --hl-ig-header is the one value that could not be measured (the screenshot
	   was cropped above it) and so the one worth adjusting: raise it if a strip
	   of the profile row shows along the top, lower it if the picture looks
	   cropped at the top.
	*/
	/* Measured 2026-11-19 on a real reel of the practice's (embed laid out at 326px):
	   picture from y 54 to 461 and x 48 to 277. The earlier 416 / 234 were estimates and
	   left a white strip under the clip and a sliver at each side. */
	--hl-ig-base: 326;     /* Instagram refuses to render the media below this */
	--hl-ig-header: 54;    /* profile row above the picture */
	--hl-ig-media-h: 408;  /* height of the picture box */
	--hl-ig-video-w: 230;  /* width of the picture inside it, bars excluded */

	position: relative;
	width: 100%;
	max-width: 330px;
	aspect-ratio: 9 / 16;
	overflow: hidden;
	background: #000;
}

/*
   The card is always laid out at --hl-ig-base and then scaled to whatever the
   frame is (fitInstagramEmbeds in assets/js/main.js), because the grid columns
   these sit in are often narrower than Instagram's 326px floor. Height is set
   generously so the whole card renders; everything outside the picture — the
   profile row above, the action bar, likes and comment box below, and the black
   bars either side — falls outside this frame and is clipped.
*/
[data-video-provider="instagram"] > iframe {
	position: absolute;
	top: 0;
	left: 0;
	width: 326px;
	height: 760px;
	border: 0;
	transform-origin: top left;
}

/* A vertical frame is narrower than the column it sits in (a testimonials
   player is laid out for a 16:9 film), so it centres rather than hugging the
   left edge and leaving the gap on one side. */
[data-video-provider="tiktok"],
[data-video-provider="instagram"],
.hl-video--portrait {
	margin-inline: auto;
}

/*
   A homepage story card is normally a <button> that swaps itself for a player.
   A directly-embedded clip has no poster to click, so it renders as a plain
   div instead and only needs the card's shape and framing.
*/
.hl-home-stories__card--embed {
	position: relative;
	overflow: hidden;
	border-radius: var(--hl-radius);
	background: var(--hl-navy);
	padding: 0;
	border: 0;
}
