/**
 * Video row block.
 *
 * Figma: PAC-Page-Designs, page "Home Page", "Youtube widget"
 *   1440px  node 2001:1707   section 1440 x 701.59
 *   1199px  node 2001:1865   section 1199 x 701.59
 *    768px  node 2001:2023   section  768 x 659.59
 *    390px  node 2001:2130   section  390 x 659.59
 *
 * The row of videos is drawn at the same size in all four frames - 1697px
 * wide, whatever the page is - so it always runs off the right-hand edge.
 * A card's own size and shape are in blocks/video-card/style.css.
 */

.pchs-video-row {
	position: relative;
	display: flex;
	flex-direction: column;
	align-items: flex-start;
	gap: var(--wp--preset--spacing--20); /* 20px */
	/* Plus the gutter, so that past 1440 the contents line up with the rest
	   of the page while the background still fills the screen. */
	padding: var(--pchs-section-py) calc(var(--pchs-section-px) + var(--pchs-page-gutter));
	background-color: var(--wp--preset--color--white);
}

/*
 * The optional drawing, in the empty space to the right of the row.
 *
 * Hung from the bottom right at its own size: node 2005:3778 draws it
 * running off both the right edge and the top of the band, so scaling it
 * would be the one thing certain to be wrong. Behind the cards, which the
 * row scrolls over it, and at its own weight - the file is already as pale
 * as the design draws it, nine per cent ink at its darkest.
 */
.pchs-video-row::after {
	position: absolute;
	z-index: 0;
	content: "";
	inset: 0;
	background-image: var(--pchs-video-row-pattern, none);
	background-repeat: no-repeat;
	background-position: right bottom;
	pointer-events: none;
}

/* Over the drawing. Without this the heading and the cards are painted
   under it. */
.pchs-video-row__info,
.pchs-video-row__track,
.pchs-video-row__arrows {
	position: relative;
	z-index: 1;
}

/* The 20px below is on top of the section's own 20px gap, making 40px between
   the heading and the row - which is what the phone frame measures, where the
   three wider frames all measure 20. Whether that is deliberate or a stray
   20px in the Figma file is not something the file says; it is matched here
   because the frame is the reference. */
.pchs-video-row__info {
	width: 100%;
	padding-bottom: var(--wp--preset--spacing--20); /* 20px */
}

@media (min-width: 768px) {

	.pchs-video-row__info {
		padding-bottom: 0;
	}
}

.pchs-video-row__heading {
	color: var(--wp--preset--color--blue-500);
}


/* ------------------------------------------------------------
   The row itself

   An ordinary scrolling list. Everything below either makes it
   reach the edge of the screen or stops it cutting the cards'
   shadows off - a scrolling box clips BOTH directions, even
   though only one of them scrolls, so a shadow that falls
   outside it simply disappears.

   The pattern throughout is the same: add padding to make room,
   then take the same amount back as a negative margin, so the
   section ends up exactly as tall and as wide as its frame.
   ------------------------------------------------------------ */

.pchs-video-row__track {
	display: flex;
	/*
	 * stretch, NOT width: 100%.
	 *
	 * The section is a column of flex items aligned to its left edge, so an
	 * item is only as wide as its contents unless it is told otherwise.
	 * width: 100% looks like the way to say that and is not: it pins the row
	 * to the width of the text column, and the negative margins below then
	 * slide that fixed width sideways rather than widening it - which left
	 * the row stopping 64px short of the screen with a band of white beside
	 * it. Stretching measures the width AFTER the margins, which is what is
	 * wanted here.
	 */
	align-self: stretch;
	gap: var(--wp--preset--spacing--20); /* 20px */
	margin: 0;
	padding: 0;
	list-style: none;
	overflow-x: auto;
	/* Stop a sideways swipe that reaches the end of the row from
	   going on to swipe the browser back a page. */
	overscroll-behavior-x: contain;
	scroll-snap-type: x proximity;
	/* No scrollbar: the designs do not draw one, and the arrows,
	   a swipe and the arrow keys all move the row. */
	scrollbar-width: none;

	/* Reach the right edge of the screen. The negative margin
	   cancels the section's padding on that side; the padding
	   puts the same space back at the END of the row, so the
	   last card is not flush against the screen once a visitor
	   scrolls that far. */
	margin-right: calc(-1 * (var(--pchs-section-px) + var(--pchs-page-gutter)));
	padding-right: calc(var(--pchs-section-px) + var(--pchs-page-gutter));

	/* Room above and below for the shadow, which reaches 36px
	   under a card (12px down, 24px of blur). */
	padding-block: 36px;
	margin-block: -36px;

	/* And the same on the left, where the first card sits inside
	   the page rather than against the screen edge.
	   scroll-padding keeps the snapping honest: without it a card
	   would snap 24px to the left of where it belongs. */
	padding-left: 24px;
	margin-left: -24px;
	scroll-padding-left: 24px;
}

.pchs-video-row__track::-webkit-scrollbar {
	display: none;
}


/* ------------------------------------------------------------
   Arrows
   Figma I2001:1707;6092:301 - 40px circles, 10px apart, right
   aligned, with a 2px border.

   Colour is set once, on the button, and the arrow inside takes
   it through currentColor - so the disabled state is a single
   declaration rather than two that could fall out of step.
   ------------------------------------------------------------ */

.pchs-video-row__arrows {
	display: flex;
	width: 100%;
	align-items: center;
	justify-content: flex-end;
	gap: var(--wp--preset--spacing--10); /* 10px */
}

/* view.js hides this when every video already fits, which is what the
   Holistic Nursing frames draw. The declaration is needed because
   `display: flex` above beats the browser's own rule for [hidden]. */
.pchs-video-row__arrows[hidden] {
	display: none;
}

.pchs-video-row__arrow {
	display: inline-flex;
	width: 40px;
	height: 40px;
	align-items: center;
	justify-content: center;
	padding: 0;
	border: 2px solid currentColor;
	border-radius: var(--wp--custom--radius--full);
	background-color: var(--wp--preset--color--white);
	color: var(--wp--preset--color--blue-500);
	cursor: pointer;
	transition: color 0.2s ease;
}

.pchs-video-row__arrow[disabled] {
	color: var(--wp--preset--color--gray-500);
	cursor: default;
}


/* ------------------------------------------------------------
   The player

   A <dialog>, so the browser handles covering the page, keeping
   the keyboard inside and closing on Escape.
   ------------------------------------------------------------ */

.pchs-video-row__lightbox {
	display: flex;
	width: 100%;
	max-width: none;
	height: 100%;
	max-height: none;
	align-items: center;
	justify-content: center;
	margin: 0;
	padding: var(--wp--preset--spacing--20);
	border: 0;
	background-color: transparent;
}

/* The rule above sets display on the dialog whether it is open or
   not, which would leave it on screen permanently. The browser's
   own "closed means hidden" rule is restated here because our
   display declaration overrides it. */
.pchs-video-row__lightbox:not( [open] ) {
	display: none;
}

.pchs-video-row__lightbox::backdrop {
	background-color: rgba( 0, 32, 51, 0.9 ); /* blue-800 at 90% */
}

/* Sized by width, with the height following from the shape, and
   the width capped so a tall video cannot grow past the screen.
   Vertical is the default because that is what this section is
   for; a widescreen video would otherwise sit in a tall box with
   black above and below it. */
.pchs-video-row__player[data-pchs-shape="vertical"] {
	width: min( 100%, calc( 86vh * 9 / 16 ) );
	aspect-ratio: 9 / 16;
}

.pchs-video-row__player[data-pchs-shape="widescreen"] {
	width: min( 100%, 1280px, calc( 86vh * 16 / 9 ) );
	aspect-ratio: 16 / 9;
}

.pchs-video-row__player iframe {
	display: block;
	width: 100%;
	height: 100%;
	border: 0;
	border-radius: var(--wp--custom--radius--md); /* 20px, as the cards */
}

.pchs-video-row__close {
	position: absolute;
	top: var(--wp--preset--spacing--20);
	right: var(--wp--preset--spacing--20);
	display: inline-flex;
	width: 40px;
	height: 40px;
	align-items: center;
	justify-content: center;
	padding: 0;
	border: 2px solid currentColor;
	border-radius: var(--wp--custom--radius--full);
	background-color: var(--wp--preset--color--white);
	color: var(--wp--preset--color--blue-500);
	cursor: pointer;
}


/* ------------------------------------------------------------
   1024px and up
   Figma nodes 2001:1865 (1199) and 2001:1707 (1440).

   The heading stops short of the full width, as in the other
   sections, so a long one does not run the whole way across.
   ------------------------------------------------------------ */

@media (min-width: 1024px) {

	.pchs-video-row__info {
		max-width: 868px;
		padding-right: var(--wp--preset--spacing--80);
	}
}
