/*
 * photo-cards block (PublicContentPhotoCardsBlock). Layouts: scroll (scroll-snap row on every width; the buttons and
 * position bar appear when js/public-content-photo-cards.js runs and the row overflows), grid and overlay (stacked on
 * phones), collage (photo mosaic). Photo boxes have a fixed aspect ratio (no layout shift).
 */
/* Head: heading on the first row, intro below; on wide screens heading | intro. */
.public-content .content-photo-cards-head {
	display: grid;
	grid-template-columns: minmax(0, 1fr);
	align-items: end;
	gap: .75rem 1.5rem;
	margin-bottom: 1.25rem;
}
.public-content .content-photo-cards-head h2 { margin: 0; grid-column: 1; }
.public-content .content-photo-cards-intro {
	grid-column: 1 / -1;
	max-width: 36rem;
	color: var(--content-text);
	font-size: .95rem;
}
.public-content .content-photo-cards-intro p:last-child { margin-bottom: 0; }
/* Scroll row with prev/next (shared .content-nav-button, public-content.css): the buttons sit over the row's left and
   right edge at the vertical middle of the card photos. With scripting the row gets an inline gutter (track padding and
   scroll padding) of arrow inset + arrow size + a small gap, so a snapped card starts just right of the left arrow and
   the arrows overlap the partly visible neighbours, not the current card (the first card too: the loop copies sit to
   its left). A card photo is 4:3 and as wide as the card, so its middle is 3/8 of the card width below the row's top
   (plus the row's 3px padding and the card border). --photo-cards-card is the card width in container units and
   follows the scroll flex-basis in each breakpoint below (keep both in step); without container units the buttons sit
   at the middle of the row. The buttons keep their place while inactive (before the script runs or while nothing
   overflows): no layout shift. */
.public-content .content-photo-cards-viewport {
	position: relative;
	container-type: inline-size;
	--content-nav-inset: .75rem;
	--photo-cards-gutter: 3px;
	/* the track's content box: the viewport plus the row's -3px margins, minus the gutters */
	--photo-cards-track: calc(100cqi + 6px - 2 * var(--photo-cards-gutter));
	--photo-cards-card: calc(var(--photo-cards-track) * .82);
}
@media (scripting: enabled) {
	.public-content .content-photo-cards-viewport { --photo-cards-gutter: calc(var(--content-nav-inset) + 2.5rem + .5rem); }
	.public-content .content-photo-cards--scroll .content-photo-cards-viewport .content-photo-cards-list {
		padding-inline: var(--photo-cards-gutter);
		scroll-padding-inline: var(--photo-cards-gutter);
	}
}
@supports (width: 1cqi) {
	.public-content .content-photo-cards-viewport { --content-nav-top: calc(4px + var(--photo-cards-card) * .375); }
}
.public-content .content-photo-cards-controls { position: absolute; inset: 0; pointer-events: none; }
.public-content .content-photo-cards-controls .content-nav-button { pointer-events: auto; }
.public-content .content-photo-cards-controls:not(.is-active) { visibility: hidden; }

.public-content .content-photo-cards-list {
	margin: 0;
	padding: 0;
	list-style: none;
	display: grid;
	gap: 1.25rem;
	grid-template-columns: minmax(0, 1fr);
}
.public-content .content-photo-cards-item { display: flex; min-width: 0; }

/* Card (scroll and grid layouts) */
.public-content .content-photo-card {
	display: flex;
	flex-direction: column;
	width: 100%;
	background: var(--content-card);
	border: 1px solid var(--content-border);
	border-radius: var(--content-radius);
	box-shadow: var(--content-shadow);
	overflow: hidden;
}
.public-content .content-photo-card-media {
	aspect-ratio: 4 / 3;
	overflow: hidden;
	background: var(--content-surface);
}
.public-content .content-photo-card-media img {
	display: block;
	width: 100%;
	height: 100%;
	object-fit: cover;
}
.public-content .content-photo-card-body { padding: 1rem 1rem .5rem; flex: 1 1 auto; }
.public-content .content-photo-card-title { margin: 0 0 .4rem; }
.public-content .content-photo-card-text { font-size: .925rem; color: var(--content-muted); }
.public-content .content-photo-card-text p { margin-bottom: .5rem; }
.public-content .content-photo-card-footer {
	margin: 0 1rem;
	padding: .75rem 0 1rem;
	border-top: 1px solid var(--content-border);
	font-size: .8rem;
	font-weight: 600;
	letter-spacing: .04em;
	text-transform: uppercase;
}
.public-content .content-photo-card-label { color: var(--content-muted); }
.public-content .content-photo-card-link { text-decoration: none; }
.public-content .content-photo-card-link:hover { text-decoration: underline; }
.public-content .content-photo-card-link:focus-visible { outline: 2px solid var(--content-primary); outline-offset: 2px; }

/* scroll: one snap row; cards keep a fixed share of the width so the next one peeks in. */
.public-content .content-photo-cards--scroll .content-photo-cards-list {
	display: flex;
	overflow-x: auto;
	scroll-snap-type: x mandatory;
	scroll-behavior: smooth;
	overscroll-behavior-x: contain;
	scrollbar-width: thin;
	/* room for the card shadow and the focus outline inside the scroller; the scroll padding keeps that room when a
	   card snaps to the start, so the row starts at scroll position 0 */
	padding: 3px 3px .75rem;
	margin: -3px -3px 0;
	scroll-padding-inline: 3px;
}
/* With scripting the buttons and progress bar replace the scrollbar; decided in CSS so nothing shifts when the script runs. */
@media (scripting: enabled) {
	.public-content .content-photo-cards--scroll .content-photo-cards-list { scrollbar-width: none; }
	.public-content .content-photo-cards--scroll .content-photo-cards-list::-webkit-scrollbar { display: none; }
}
.public-content .content-photo-cards--scroll .content-photo-cards-list:focus-visible { outline: 2px solid var(--content-primary); outline-offset: 2px; }
.public-content .content-photo-cards--scroll .content-photo-cards-item {
	flex: 0 0 82%;
	scroll-snap-align: start;
}
/* Position bar under the row, as wide as the cards: a visible rail with a thumb whose width is the visible share of
   the row and whose offset is the scrolled share (both set by the script). */
.public-content .content-photo-cards-progress {
	position: relative;
	height: .25rem;
	margin-top: .5rem;
	border-radius: 999px;
	background: var(--content-border);
	overflow: hidden;
}
/* Reserved like the buttons, so showing it shifts nothing. */
.public-content .content-photo-cards-progress:not(.is-active) { visibility: hidden; }
.public-content .content-photo-cards-progress-bar {
	position: absolute;
	top: 0;
	bottom: 0;
	left: 0;
	width: 100%;
	border-radius: inherit;
	background: var(--content-primary);
	transition: transform .2s ease;
}

/* overlay: text over the darkened bottom of the photo. */
.public-content .content-photo-card--overlay {
	position: relative;
	display: block;
	color: #fff;
	text-decoration: none;
}
.public-content .content-photo-card--overlay .content-photo-card-media { aspect-ratio: 3 / 2; background: var(--content-text); }
.public-content .content-photo-card--overlay .content-photo-card-media img { transition: transform .3s ease; }
.public-content .content-photo-card-overlay {
	position: absolute;
	inset: auto 0 0 0;
	padding: 3rem 1.25rem 1.1rem;
	background: linear-gradient(to top, rgba(0, 0, 0, .78), rgba(0, 0, 0, .45) 55%, rgba(0, 0, 0, 0));
}
.public-content .content-photo-card--overlay .content-photo-card-title { color: #fff; margin: 0; }
.public-content .content-photo-card--overlay .content-photo-card-text {
	margin: .35rem 0 0;
	color: rgba(255, 255, 255, .9);
	font-size: .875rem;
	line-height: 1.45;
}
.public-content a.content-photo-card--linked:hover,
.public-content a.content-photo-card--linked:focus { color: #fff; }
.public-content a.content-photo-card--linked:hover .content-photo-card-media img { transform: scale(1.03); }
.public-content a.content-photo-card--linked:focus-visible { outline: 3px solid var(--content-primary); outline-offset: 3px; }

/*
 * collage (at most five photos, PublicContentPhotoCardsBlock::COLLAGE_MAX_PHOTOS): phones two columns, the first photo
 * (and a last photo left alone in its row) full width; from 48rem a fixed-ratio 4 x 2 mosaic with the first photo large.
 * Every box gets its size from CSS only, so nothing shifts while the photos load. Captions reuse the overlay style.
 */
.public-content .content-photo-cards--collage .content-photo-cards-list { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .5rem; }
.public-content .content-photo-cards--collage .content-photo-card-media { aspect-ratio: 1 / 1; }
.public-content .content-photo-cards--collage .content-photo-cards-item:first-child,
.public-content .content-photo-cards--collage .content-photo-cards-item:nth-child(even):last-child { grid-column: 1 / -1; }
.public-content .content-photo-cards--collage .content-photo-cards-item:first-child .content-photo-card-media,
.public-content .content-photo-cards--collage .content-photo-cards-item:nth-child(even):last-child .content-photo-card-media { aspect-ratio: 16 / 9; }
.public-content .content-photo-cards--collage .content-photo-card-overlay { padding: 2rem .85rem .7rem; }
.public-content .content-photo-cards--collage .content-photo-card-title { font-size: 1rem; }
.public-content .content-photo-cards--collage .content-photo-card-text { font-size: .8rem; }

/* Phones: the arrows sit at the row's edge (smaller gutter), so the current card keeps most of the width. */
@media (max-width: 35.98rem) {
	.public-content .content-photo-cards-viewport { --content-nav-inset: 0rem; }
}
@media (min-width: 36rem) {
	.public-content .content-photo-cards--scroll .content-photo-cards-item { flex-basis: 60%; }
	.public-content .content-photo-cards-viewport { --photo-cards-card: calc(var(--photo-cards-track) * .6); }
}
@media (min-width: 48rem) {
	.public-content .content-photo-cards-head { grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr); }
	.public-content .content-photo-cards-intro { grid-column: 2; grid-row: 1; justify-self: end; }
	/* grid and overlay wrap as centered rows, so an incomplete last row sits in the middle instead of leaving a gap. */
	.public-content .content-photo-cards--grid .content-photo-cards-list,
	.public-content .content-photo-cards--overlay .content-photo-cards-list { display: flex; flex-wrap: wrap; justify-content: center; }
	.public-content .content-photo-cards--grid .content-photo-cards-item,
	.public-content .content-photo-cards--overlay .content-photo-cards-item { flex: 0 0 calc((100% - 1.25rem) / 2); }
	.public-content .content-photo-cards--scroll .content-photo-cards-item { flex-basis: calc((100% - 1.25rem) / 2.3); }
	.public-content .content-photo-cards-viewport { --photo-cards-card: calc((var(--photo-cards-track) - 1.25rem) / 2.3); }
}
@media (min-width: 48rem) {
	.public-content .content-photo-cards--collage .content-photo-cards-list {
		grid-template-columns: repeat(4, minmax(0, 1fr));
		grid-template-rows: repeat(2, minmax(0, 1fr));
		aspect-ratio: 5 / 2;
		gap: .75rem;
	}
	.public-content .content-photo-cards--collage .content-photo-cards-item:nth-child(even):last-child { grid-column: auto; }
	.public-content .content-photo-cards--collage .content-photo-cards-item:first-child { grid-column: span 2; grid-row: span 2; }
	.public-content .content-photo-cards--collage .content-photo-cards-item:only-child { grid-column: 1 / -1; }
	/* Fewer than five photos: the smaller tiles widen so the mosaic stays closed. */
	.public-content .content-photo-cards--collage .content-photo-cards-item:first-child:nth-last-child(2) ~ .content-photo-cards-item { grid-column: span 2; grid-row: span 2; }
	.public-content .content-photo-cards--collage .content-photo-cards-item:first-child:nth-last-child(3) ~ .content-photo-cards-item,
	.public-content .content-photo-cards--collage .content-photo-cards-item:first-child:nth-last-child(4) + .content-photo-cards-item { grid-column: span 2; }
	.public-content .content-photo-cards--collage .content-photo-card { height: 100%; }
	/* :nth-child(n) outweighs the phone rules for the first and a lone last photo. */
	.public-content .content-photo-cards--collage .content-photo-cards-item:nth-child(n) .content-photo-card-media { aspect-ratio: auto; height: 100%; }
}
@media (min-width: 62rem) {
	.public-content .content-photo-cards--grid .content-photo-cards-item,
	.public-content .content-photo-cards--overlay .content-photo-cards-item { flex-basis: calc((100% - 2 * 1.25rem) / 3); }
	.public-content .content-photo-cards--scroll .content-photo-cards-item { flex-basis: calc((100% - 2 * 1.25rem) / 3.3); }
	.public-content .content-photo-cards-viewport { --photo-cards-card: calc((var(--photo-cards-track) - 2 * 1.25rem) / 3.3); }
}
@media (prefers-reduced-motion: reduce) {
	.public-content .content-photo-cards--scroll .content-photo-cards-list { scroll-behavior: auto; }
	.public-content .content-photo-cards-progress-bar,
	.public-content .content-photo-card--overlay .content-photo-card-media img { transition: none; }
	.public-content a.content-photo-card--linked:hover .content-photo-card-media img { transform: none; }
}

/* Background `soft`: a full-width light-blue band (the colour of the link band), content kept at the page width. */
.public-content .content-block--photo-cards:has(> .content-photo-cards--band) { width: 100%; }
.public-content .content-photo-cards--band {
	background: var(--content-primary-soft);
	border-top: 1px solid var(--content-border);
	border-bottom: 1px solid var(--content-border);
	padding: var(--content-band-padding) max(1rem, (100% - var(--content-width)) / 2);
}
