/**
 * Card row block.
 *
 * Figma: PAC-Page-Designs, page "Home Page"
 *   1440px  node 2001:1574   section 1440 x 763.78, three cards of 410.67
 *   1199px  node 2001:1732   section 1199 x 752.22, three cards of 330.33
 *    768px  node 2001:1890   section  768 x 922,    cards stacked, full width
 *    390px  node 2001:2049   section  390 x 1579,   cards stacked, full width
 *
 * Small-screen first. Padding comes from the shared section scale in the
 * theme stylesheet, and the eyebrow and heading from .pchs-eyebrow and
 * .pchs-heading-2 there - only their colour is set here, because those
 * elements sit on dark backgrounds in this section and light ones elsewhere.
 */

.pchs-card-row {
	position: relative;
	display: flex;
	flex-direction: column;
	align-items: flex-start;
	gap: var(--wp--preset--spacing--40);
	/* Plus the gutter, so that past 1440 the cards 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));
	/* Contains the pattern's stacking, so it cannot slide behind
	   or in front of neighbouring sections. */
	isolation: isolate;
}


/* ------------------------------------------------------------
   The four bands

   blue  the home page's: the gradient is on the SECTION and the
         cards are pale
   white the Grants page's: the section is plain and the gradient
         is on the CARDS, which is the near inverse of blue
   pale  Holistic Nursing's programme options: the section is
         plain and the cards are gray-300, the quietest of the
         four - a white card on a white band would not read
   gold  Holistic Nursing's accreditations: a yellow gradient
         band with cream cards and a blue disc

   The setting names the band, and the cards contrast with it -
   the card's own colourway is in blocks/card, written against
   the row's class, so a card is never told which band it is on.
   ------------------------------------------------------------ */

.pchs-card-row--bg-blue {
	background-image: linear-gradient(
		90.245deg,
		var(--wp--preset--color--blue-300) 0%,
		var(--wp--preset--color--blue-500) 49.971%,
		var(--wp--preset--color--blue-800) 100%
	);
}

.pchs-card-row--bg-white,
.pchs-card-row--bg-pale {
	background-color: var(--wp--preset--color--white);
}

/*
 * Figma 2934:27257. A plain left-to-right gradient with no texture over
 * it - checked rather than assumed, by sampling the frame's own export:
 * the midpoint reads #e0c894, which is exactly halfway between the two
 * stops, and a texture would have pushed it off that. The Faculty band
 * on the same page looks similar and is NOT this; it carries the wave.
 */
.pchs-card-row--bg-gold {
	background-image: linear-gradient(
		90deg,
		var(--wp--preset--color--yellow-300) 0%,
		var(--wp--preset--color--yellow-500) 100%
	);
}

/* The decorative line pattern across the top of the section.
   On a pseudo-element rather than a second background layer,
   because it is drawn at 60% opacity over the gradient and a
   background layer cannot carry its own opacity. The image
   itself is chosen per section in the editor. */
.pchs-card-row::before {
	position: absolute;
	z-index: 0;
	content: "";
	inset: 0;
	background-image: var(--pchs-card-row-pattern, none);
	background-repeat: no-repeat;
	background-position: center top;
	background-size: contain;
	opacity: 0.6;
	pointer-events: none;
}

/* Everything real sits above the pattern. */
.pchs-card-row__info,
.pchs-card-row__items {
	position: relative;
	z-index: 1;
	width: 100%;
}

.pchs-card-row__info {
	display: flex;
	max-width: 868px;
	flex-direction: column;
	align-items: flex-start;
	gap: var(--wp--preset--spacing--12);
}

/* Reversed out of the blue band; on the plain one they are the ordinary
   blue the rest of the site uses, which .pchs-eyebrow and .pchs-heading-2
   already give them. */
.pchs-card-row--bg-blue .pchs-card-row__eyebrow,
.pchs-card-row--bg-blue .pchs-card-row__heading {
	color: var(--wp--preset--color--white);
}

/*
 * 20 below the heading, where the eyebrow sits 12 above it. One flex gap
 * cannot be two values, so the larger of the two is a margin instead of
 * widening the gap and clawing it back from the eyebrow.
 *
 * Two classes, not one: .pchs-section-intro in the theme stylesheet sets
 * `margin: 0` on this same element with the same specificity, and loads
 * after the block's own sheet - so a single class loses and the section
 * came out 8px short of its frame.
 */
.pchs-card-row .pchs-card-row__body {
	margin: calc(var(--wp--preset--spacing--20) - var(--wp--preset--spacing--12)) 0 0;
}

/* Stacked on small screens, with a tighter gap than the row
   uses - 20px here against 40px once the cards sit side by
   side. */
.pchs-card-row__items {
	display: flex;
	flex-direction: column;
	gap: var(--wp--preset--spacing--20);
}


/* ------------------------------------------------------------
   The swipe layout
   Figma nodes 2847:3978 (768, two cards and two dots) and
   2843:796 (390, one card and three dots).

   An overflowing row with snap points, until there is width for
   all three at 1024. Everything about swiping it is the
   browser's: touch, trackpad, shift-wheel, arrow keys and a
   screen reader's own navigation all work with nothing written
   for them, and the row still scrolls if view.js never arrives.
   Only the dots are script's doing.
   ------------------------------------------------------------ */

.pchs-card-row--swipe .pchs-card-row__items {
	display: grid;
	grid-auto-flow: column;
	/* One card's width per stop, which is what makes the number of dots
	   come out as the frames draw it: three cards one at a time is three
	   stops, two at a time is two. */
	grid-auto-columns: 100%;
	gap: var(--wp--preset--spacing--40);
	overflow-x: auto;
	scroll-snap-type: x mandatory;
	/* Room for the shadow the cards cast, which a scrolling box would
	   otherwise clip off. */
	padding-bottom: 24px;
	margin-bottom: -24px;
	scrollbar-width: none;
}

/* The bar is noise next to the dots, which say the same thing. The box
   still scrolls every way it did. */
.pchs-card-row--swipe .pchs-card-row__items::-webkit-scrollbar {
	display: none;
}

.pchs-card-row--swipe .pchs-card-row__items:focus-visible {
	outline: 2px solid var(--wp--preset--color--blue-300);
	outline-offset: 4px;
}

.pchs-card-row--swipe .pchs-card-row__items > * {
	scroll-snap-align: start;
}

/* Built by view.js, because how many there are depends on how many cards
   fit - and a dot that did nothing because the script had not loaded
   would be worse than no dot at all. */
/*
 * 20 below the cards, which is what the frames draw - the section stacks
 * its parts 40 apart, so the difference is taken back here rather than
 * the gap being given up for everything.
 */
.pchs-card-row__pips {
	display: flex;
	align-self: center;
	justify-content: center;
	gap: var(--wp--preset--spacing--8);
	margin: calc(var(--wp--preset--spacing--20) - var(--wp--preset--spacing--40)) 0 0;
	padding: 0;
	list-style: none;
}

.pchs-card-row__pip {
	display: block;
	width: 12px;
	height: 12px;
	padding: 0;
	border: 1px solid var(--wp--preset--color--blue-500);
	border-radius: var(--wp--custom--radius--full);
	background-color: transparent;
	cursor: pointer;
}

.pchs-card-row__pip[aria-current="true"] {
	background-color: var(--wp--preset--color--blue-500);
}

.pchs-card-row__pip:focus-visible {
	outline: 2px solid var(--wp--preset--color--blue-300);
	outline-offset: 2px;
}

/* On the blue band the dots have to read against it. */
.pchs-card-row--bg-blue .pchs-card-row__pip {
	border-color: var(--wp--preset--color--white);
}

.pchs-card-row--bg-blue .pchs-card-row__pip[aria-current="true"] {
	background-color: var(--wp--preset--color--white);
}


/* ------------------------------------------------------------
   768px and up, swiping only
   Figma node 2847:3978: two cards to a view, so two stops and
   two dots.
   ------------------------------------------------------------ */

@media (min-width: 768px) {

	.pchs-card-row--swipe .pchs-card-row__items {
		grid-auto-columns: calc((100% - var(--wp--preset--spacing--40)) / 2);
	}
}


/* ------------------------------------------------------------
   1024px and up
   Figma nodes 2001:1574 and 2001:1732.

   The cards move into a row and share the width equally. Below
   this they stay stacked, which is why there is no 768px rule
   for them here - the change at 768 happens inside the card,
   not in this row.
   ------------------------------------------------------------ */

@media (min-width: 1024px) {

	.pchs-card-row__info {
		/* Keeps the heading clear of the right edge. Measured:
		   the info frame is 868 wide and its text 788. */
		padding-right: var(--wp--preset--spacing--80);
	}

	.pchs-card-row__items {
		flex-direction: row;
		flex-wrap: wrap;
		align-items: stretch;
		gap: var(--wp--preset--spacing--40);
	}

	/*
	 * Three to a row at most, and the row fills the width whatever
	 * it holds.
	 *
	 * The basis is a third of the width rather than 0, and that is
	 * the part that does the work: with a basis of 0 the cards
	 * simply divide whatever space there is, so a fourth squeezes
	 * onto the same line instead of starting a new one. Sized at a
	 * third, a fourth cannot fit and wraps.
	 *
	 * flex-grow stays at 1, so a row holding fewer than three
	 * still spreads across the full width - including the last row
	 * of an uneven set. Four cards therefore read as three across
	 * and one full-width beneath, not as three and a stranded
	 * third-width card. Every row behaves the same way; it is the
	 * same rule applied to each.
	 */
	.pchs-card-row__items > * {
		min-width: 272px;
		flex: 1 1 calc((100% - 2 * var(--wp--preset--spacing--40)) / 3);
	}

	/*
	 * There is nothing left to scroll here, so a swiping row becomes the
	 * same three-across row as a stacking one and its dots go. This is
	 * also what makes a fourth card start a new row rather than squeeze
	 * all four thinner - the basis above does that for both layouts.
	 */
	.pchs-card-row--swipe .pchs-card-row__items {
		display: flex;
		overflow-x: visible;
		padding-bottom: 0;
		margin-bottom: 0;
	}

	.pchs-card-row__pips {
		display: none;
	}
}


/* Past 1440 the section keeps its background but its contents stop
   travelling outwards, matching the rest of the page. That is handled by
   --pchs-page-gutter in the padding above, which needs no breakpoint. */
