/* =================================================================
   THE YOUTUBE SECTION
   =================================================================
   The channel's latest videos as facades: a still, a title and a play
   button. The player is built on click — see assets/js/youtube.js and
   the header of inc/youtube.php for why.

   PALETTE
   -------
   The site's, not YouTube's. #17A2B8 is --themeht-primary-color, the
   colour of the logo and the header. YouTube red appears in exactly
   two places — the small channel mark and the play button — because
   those are the only two things that mean "this is YouTube". Painting
   the section red would make a surgeon's page look like a media
   channel.
   ================================================================= */

.cb-yt {
	--brand:      #17A2B8;
	--brand-deep: #0D7C8E;
	--brand-wash: #EAF7F9;

	--ink:        #0A2A33;
	--ink-soft:   #55686F;
	--line:       #DFE9EC;
	--paper:      #FFFFFF;
	--ground:     #F7FBFC;

	--yt-red:     #FF0033;

	position: relative;
	background: var(--ground);
	color: var(--ink);
}

.cb-yt__inner {
	max-width: 1320px;
	margin-inline: auto;
	padding: 96px 24px;
}


/* -----------------------------------------------------------------
   THE HEADING
   ----------------------------------------------------------------- */

.cb-yt__head {
	max-width: 720px;
	margin: 0 0 44px;
}

.cb-yt .cb-yt__eyebrow {
	display: inline-flex;
	align-items: center;
	gap: 9px;
	margin: 0 0 16px;
	padding: 7px 14px 7px 11px;
	border: 1px solid var(--line);
	border-radius: 999px;
	background: var(--paper);
	font-size: 13.5px;
	font-weight: 700;
	line-height: 1;
	color: var(--ink);
}

.cb-yt__eyebrow svg { color: var(--yt-red); flex: 0 0 auto; }

/*
 * The section class is on the type rules because the theme ships
 * `.entry-content h2` at 28px/600 and `html[dir="rtl"] h1, h2
 * { line-height: 1.45 }`, both (0,1,1), which beat a plain class at
 * (0,1,0). The same collision resized every heading in the hero.
 */
.cb-yt .cb-yt__title {
	margin: 0 0 14px;
	font-size: clamp(26px, 3vw, 40px);
	font-weight: 800;
	line-height: 1.3;
	color: var(--ink);
	text-wrap: balance;
}

.cb-yt .cb-yt__sub {
	margin: 0;
	font-size: 16.5px;
	line-height: 1.9;
	color: var(--ink-soft);
}


/* -----------------------------------------------------------------
   THE GRID
   ----------------------------------------------------------------- */

.cb-yt__grid {
	display: grid;
	grid-template-columns: repeat(3, minmax(0, 1fr));
	gap: 28px;
	margin: 0;
	padding: 0;
	list-style: none;
}

.cb-yt__item { display: flex; min-width: 0; }

/*
 * The whole card is one button.
 *
 * Buttons carry a pile of user-agent styling — font, padding, border,
 * background, text-align — none of which is wanted, and `text-align:
 * start` is the one people forget: without it every title on an RTL
 * page is centred inside its own card.
 */
.cb-yt__card {
	display: flex;
	flex-direction: column;
	width: 100%;
	margin: 0;
	padding: 0;
	border: 1px solid var(--line);
	border-radius: 14px;
	background: var(--paper);
	font: inherit;
	color: inherit;
	text-align: start;
	overflow: hidden;
	cursor: pointer;
	transition: border-color .25s ease, box-shadow .25s ease, transform .25s ease;
}

.cb-yt__card:hover,
.cb-yt__card:focus-visible {
	border-color: var(--brand);
	transform: translateY(-3px);

	/* Three layers rather than one wide blur: a contact shadow, a mid
	   spread and a soft far one, which is how a real object is lit. */
	box-shadow:
		0 1px 2px rgba(10, 42, 51, .05),
		0 8px 18px -8px rgba(10, 42, 51, .10),
		0 26px 50px -24px rgba(10, 42, 51, .24);
}

.cb-yt__card:focus-visible {
	outline: 2px solid var(--brand-deep);
	outline-offset: 3px;
}

.cb-yt__thumb {
	position: relative;
	display: block;
	background: #0A2A33;
	overflow: hidden;
}

/*
 * 16:9 on the IMAGE, and object-fit to crop.
 *
 * YouTube's hqdefault is a 4:3 file with the frame letterboxed inside
 * it, so shown at its own ratio every card carries two black bars.
 * Cropping to 16:9 removes them.
 *
 * The ratio is on the img rather than on its wrapper for the reason
 * that cost time in the services grid: a percentage height resolves
 * against the containing block's height, and a block sized only by
 * aspect-ratio does not provide one.
 */
.cb-yt .cb-yt__thumb img {
	display: block;
	width: 100%;
	height: auto;
	aspect-ratio: 16 / 9;
	object-fit: cover;
	transition: transform .5s cubic-bezier(.22, .61, .36, 1), opacity .25s ease;
}

.cb-yt__card:hover .cb-yt__thumb img { transform: scale(1.05); }

.cb-yt__play {
	position: absolute;
	inset-block-end: 14px;
	inset-inline-start: 14px;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 52px;
	height: 52px;
	border-radius: 50%;
	background: var(--yt-red);
	color: #fff;
	box-shadow: 0 6px 18px -6px rgba(0, 0, 0, .55);
	transition: transform .25s ease, background-color .25s ease;
}

/* The triangle is drawn from its own left edge, so it sits visibly
   off-centre in a circle unless it is nudged back. */
.cb-yt__play svg { margin-inline-start: 3px; }

/* Never mirrored. A play triangle points at the timeline, which runs
   left to right in every player on earth, including Arabic ones. */
[dir="rtl"] .cb-yt__play svg { transform: none; }

.cb-yt__card:hover .cb-yt__play,
.cb-yt__card:focus-visible .cb-yt__play {
	transform: scale(1.08);
	background: #E60028;
}

.cb-yt__meta {
	display: flex;
	flex-direction: column;
	gap: 8px;
	flex: 1 1 auto;
	padding: 18px 20px 20px;
}

.cb-yt .cb-yt__name {
	font-size: 16.5px;
	font-weight: 700;
	line-height: 1.6;
	color: var(--ink);

	/* Two lines, cut by the browser with an ellipsis, so a long Arabic
	   title cannot make one card twice the height of its neighbours. */
	display: -webkit-box;
	-webkit-line-clamp: 2;
	-webkit-box-orient: vertical;
	overflow: hidden;
}

.cb-yt .cb-yt__date {
	margin-block-start: auto;
	font-size: 13.5px;
	font-weight: 600;
	color: var(--ink-soft);
}


/* -----------------------------------------------------------------
   THE PLAYER, ONCE IT EXISTS
   ----------------------------------------------------------------- */

.cb-yt__card.is-playing {
	cursor: default;
	transform: none;
}

.cb-yt__card.is-playing:hover { transform: none; }

.cb-yt__card.is-playing .cb-yt__thumb {
	aspect-ratio: 16 / 9;
}

.cb-yt__card.is-playing iframe {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	border: 0;
}


/* -----------------------------------------------------------------
   THE CHANNEL LINK
   ----------------------------------------------------------------- */

.cb-yt__foot {
	margin: 44px 0 0;
}

.cb-yt__btn {
	display: inline-flex;
	align-items: center;
	gap: 9px;
	min-height: 54px;
	padding: 0 30px;
	border: 1px solid var(--brand);
	border-radius: 8px;
	background: var(--brand);
	font-size: 16px;
	font-weight: 700;
	text-decoration: none;
	transition: background-color .22s ease, border-color .22s ease, color .22s ease, gap .22s ease;
}

/*
 * :visited stated, and not optional — base.css ships
 * `a, a:visited { color: var(--themeht-text-color) }` at (0,1,1),
 * which beats a plain class and turns the label dark navy on teal for
 * anyone who has opened the channel before.
 */
.cb-yt .cb-yt__btn,
.cb-yt .cb-yt__btn:visited { color: var(--paper); }

.cb-yt .cb-yt__btn:hover,
.cb-yt .cb-yt__btn:focus-visible {
	background: var(--brand-deep);
	border-color: var(--brand-deep);
	color: var(--paper);
	gap: 14px;
}

.cb-yt__btn:focus-visible {
	outline: 2px solid var(--brand-deep);
	outline-offset: 3px;
}

/* Not mirrored: this arrow means "onward", and onward in Arabic is
   leftward — the direction the path is already drawn in. */


/* -----------------------------------------------------------------
   REDUCED MOTION
   ----------------------------------------------------------------- */

@media (prefers-reduced-motion: reduce) {

	.cb-yt__card,
	.cb-yt .cb-yt__thumb img,
	.cb-yt__play,
	.cb-yt__btn {
		transition: none;
	}

	.cb-yt__card:hover,
	.cb-yt__card:focus-visible { transform: none; }

	.cb-yt__card:hover .cb-yt__thumb img { transform: none; }

	.cb-yt__card:hover .cb-yt__play,
	.cb-yt__card:focus-visible .cb-yt__play { transform: none; }
}


/* =================================================================
   BREAKPOINTS
   ================================================================= */

@media (max-width: 1024px) {

	.cb-yt__inner { padding: 72px 24px; }

	.cb-yt__grid {
		grid-template-columns: repeat(2, minmax(0, 1fr));
		gap: 20px;
	}
}

@media (max-width: 767px) {

	.cb-yt__inner { padding: 56px 20px; }

	.cb-yt__head { margin-block-end: 32px; }

	.cb-yt__grid {
		grid-template-columns: minmax(0, 1fr);
		gap: 18px;
	}

	.cb-yt__play {
		width: 46px;
		height: 46px;
	}

	.cb-yt__foot { margin-block-start: 32px; }

	.cb-yt__btn {
		display: flex;
		justify-content: center;
	}
}
