/*
 * Homepage Posters row (inc/posters.php, placed right under the hero by patterns/home-posters.php): the owner's posters
 * in one row inside the content column. Every poster keeps its own shape at the row's height (240 px on phones, 280 px
 * from 600 px, 320 px from 900 px; inc/posters.php gives the pictures matching sizes) and is never wider than the
 * column, with the rounded corners and soft shadow of the site's cards.
 *
 * Two posters or more loop at every screen width (owner, 2026-11-11; assets/js/22-posters.js adds .is-looping, a
 * duration for an even speed and as many aria-hidden copies of the list as the column needs): the track is one list
 * wide and moves by its own width, the copies follow it one list apart, and the row fades out at the column's edges
 * (not the window's). Hover or a tap on a touch screen pauses it; keyboard focus stops it and leaves a still row the
 * keyboard scrolls. One poster stands still in the middle of the column. With reduced motion, or without the script,
 * it is a still row you scroll by hand.
 */

.dolphin-home .dh-posters {
	--dh-posters-h: 240px;
	--dh-posters-gap: 12px;
	--dh-posters-speed: 32; /* Pixels per second, read by the script: the Reviews row's pace. */
	padding-top: 20px;
}

/* Vertical room inside the clipped viewport for the shadows and the hover lift (as the Reviews row). */
.dolphin-home .dh-posters__viewport {
	container-type: inline-size;
	margin: -20px 0 -36px;
	padding: 20px 0 36px;
	overflow-x: auto;
	overflow-y: hidden;
	scrollbar-width: none;
}

.dolphin-home .dh-posters__viewport:focus-visible {
	outline: 3px solid var(--wp--preset--color--orange-600);
	outline-offset: -3px;
}

/* At least as wide as the column, so a list that fits sits in its middle (auto margins). */
.dolphin-home .dh-posters__track {
	display: flex;
	width: max-content;
	min-width: 100%;
}

.dolphin-home .dh-posters__list {
	display: flex;
	align-items: center;
	margin: 0 auto;
	padding: 0;
	list-style: none;
}

.dolphin-home .dh-posters__list--copy {
	display: none;
}

.dolphin-home .dh-posters__item {
	flex: none;
	margin: 0;
	margin-inline-end: var(--dh-posters-gap);
}

.dolphin-home .dh-posters__item:last-child {
	margin-inline-end: 0;
}

/*
 * The poster's frame: its shape (--dh-poster-r, width ÷ height, set on the item) at the row's height, at most the
 * column's width (100cqi: the viewport is the container). The first width is for browsers without container units.
 */
.dolphin-home .dh-posters__poster {
	position: relative;
	display: block;
	box-sizing: border-box;
	width: calc(var(--dh-posters-h) * var(--dh-poster-r, 1));
	width: min(calc(var(--dh-posters-h) * var(--dh-poster-r, 1)), 100cqi);
	aspect-ratio: var(--dh-poster-r, 1);
	overflow: hidden;
	border-radius: var(--wp--custom--radius--card, 16px);
	background: var(--wp--preset--color--sand);
	box-shadow: 0 1px 3px rgba(15, 61, 50, 0.08);
	transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.dolphin-home .dh-posters__img {
	display: block;
	width: 100%;
	height: 100%;
	max-width: none;
	object-fit: cover;
}

/*
 * Keyboard focus: an orange ring with a white one inside it, drawn inside the poster (so the clipped viewport never
 * cuts it off) and seen on any picture. The transparent outline is what Windows' high-contrast mode draws instead.
 */
.dolphin-home .dh-posters__link:focus-visible {
	outline: 3px solid transparent;
	outline-offset: -3px;
}

.dolphin-home .dh-posters__link:focus-visible::after {
	content: "";
	position: absolute;
	inset: 0;
	border-radius: inherit;
	box-shadow: inset 0 0 0 3px var(--wp--preset--color--orange-600), inset 0 0 0 5px var(--wp--preset--color--white);
	pointer-events: none;
}

/* ---------- The loop (two posters or more; assets/js/22-posters.js) ---------- */

.dolphin-home .dh-posters.is-looping .dh-posters__viewport {
	overflow: hidden;
	-webkit-mask-image: linear-gradient(90deg, transparent, #000 6%, #000 94%, transparent);
	mask-image: linear-gradient(90deg, transparent, #000 6%, #000 94%, transparent);
}

/*
 * The track is as wide as the real list alone (the copies are placed out of the flow), so moving it by its own width
 * puts each copy exactly where the one before it started: a seamless loop. The script sets the duration (an even
 * speed) and a negative delay (the loop starts with the posters where the still row had them).
 */
.dolphin-home .dh-posters.is-looping .dh-posters__track {
	position: relative;
	min-width: 0;
	animation: dh-posters-scroll var(--dh-posters-duration, 40s) linear var(--dh-posters-delay, 0s) infinite;
}

[dir="rtl"] .dolphin-home .dh-posters.is-looping .dh-posters__track {
	animation-name: dh-posters-scroll-rtl;
}

.dolphin-home .dh-posters.is-looping .dh-posters__list {
	margin: 0;
}

/* Copy n (--dh-posters-copy, set by the script; the page's own copy is the first) starts n lists after the list. */
.dolphin-home .dh-posters.is-looping .dh-posters__list--copy {
	position: absolute;
	inset-block-start: 0;
	inset-inline-start: calc(var(--dh-posters-copy, 1) * 100%);
	display: flex;
	width: max-content;
}

/* Each list ends with one gap, so the copy follows the last poster at the usual distance. */
.dolphin-home .dh-posters.is-looping .dh-posters__item:last-child {
	margin-inline-end: var(--dh-posters-gap);
}

.dolphin-home .dh-posters.is-paused .dh-posters__track {
	animation-play-state: paused;
}

@keyframes dh-posters-scroll {
	to {
		transform: translateX(-100%);
	}
}

@keyframes dh-posters-scroll-rtl {
	to {
		transform: translateX(100%);
	}
}

@media (hover: hover) {
	.dolphin-home .dh-posters__viewport:hover .dh-posters__track {
		animation-play-state: paused;
	}

	.dolphin-home .dh-posters__link:hover {
		transform: translateY(-4px);
		box-shadow: 0 12px 28px rgba(15, 61, 50, 0.14);
	}
}

/* ---------- Staff only: the dashed box shown while no poster is published ---------- */

.dolphin-home .dh-posters__placeholder {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	justify-content: space-between;
	gap: 8px 20px;
	padding: 14px 18px;
	border: 2px dashed var(--wp--preset--color--line-strong);
	border-radius: var(--wp--custom--radius--card, 16px);
	color: var(--wp--preset--color--muted);
	font-size: 14px;
	line-height: 1.5;
}

.dolphin-home .dh-posters__placeholder p {
	flex: 1 1 320px;
	max-width: 760px;
	margin: 0;
}

.dolphin-home .dh-posters__add,
.dolphin-home .dh-posters__add:visited {
	flex: none;
	color: var(--wp--preset--color--forest);
	font-weight: 600;
	text-decoration: underline;
	text-underline-offset: 3px;
}

.dolphin-home .dh-posters__add:hover {
	color: var(--wp--preset--color--orange-700);
}

/* ---------- Larger screens ---------- */

@media (min-width: 600px) {
	.dolphin-home .dh-posters {
		--dh-posters-h: 280px;
		--dh-posters-gap: 16px;
	}
}

@media (min-width: 900px) {
	.dolphin-home .dh-posters {
		--dh-posters-h: 320px;
		--dh-posters-gap: 24px;
		--dh-posters-speed: 40;
		padding-top: 40px;
	}

	.dolphin-home .dh-posters.is-looping .dh-posters__viewport {
		-webkit-mask-image: linear-gradient(90deg, transparent, #000 7%, #000 93%, transparent);
		mask-image: linear-gradient(90deg, transparent, #000 7%, #000 93%, transparent);
	}

	.dolphin-home .dh-posters__poster {
		border-radius: 20px;
	}

	.dolphin-home .dh-posters__placeholder {
		padding: 18px 24px;
	}
}

/* Reduced motion: never looped by the script; a still row you scroll by hand, with a thin scrollbar, without lifts. */
@media (prefers-reduced-motion: reduce) {
	.dolphin-home .dh-posters__viewport {
		scrollbar-width: thin;
	}

	.dolphin-home .dh-posters__poster,
	.dolphin-home .dh-posters__link:hover {
		transition: none;
		transform: none;
	}
}
