/**
 * [homewood_properties_preview] — the scrolling row of properties.
 *
 * The same slider as the team row: a scroll-snap track that scrolls by touch,
 * trackpad and keyboard on its own, with assets/js/slider.js adding arrows
 * when there is more to see than fits.
 *
 * Where it parts company with the team row is the card. A team member is a
 * link, so their name can wait behind a hover; a property is not, and a
 * caption nothing can reveal is a caption nobody reads. The address and the
 * type sit under the photograph, in view all the time.
 *
 * @package homewood_theme
 */

.hw-properties-preview {
	--hw-preview-width: clamp(13rem, 19vw, 20rem);
	--hw-preview-min: 300px;
	--hw-preview-aspect: 7 / 9;
	--hw-preview-radius: 5px;
	--hw-preview-gap: clamp(0.875rem, 1.4vw, 1.5rem);
	--hw-preview-bleed: 5em;

	--hw-preview-border: var(--wp--preset--color--wheat, #c3a87f);
	--hw-preview-photo-border: var(--wp--preset--color--bronze, #896d44);
	--hw-preview-ground: var(--wp--preset--color--sand, #e9e4d4);
	--hw-preview-text: var(--wp--preset--color--ink, #252b23);
	--hw-preview-type: var(--wp--preset--color--sage, #4b5649);
	--hw-preview-house: var(--wp--preset--color--bronze, #896d44);

	--hw-preview-speed: 0.35s;

	position: relative;
}

/*
 * The track runs wider than the text above it, pushing out into the padding of
 * the group it sits in — the same bleed the property grid takes, so a row and a
 * grid of cards line up with each other down the page. The arrows stay on the
 * text measure: they are a control, not part of the row.
 *
 * The bleed has to stay smaller than that padding, or the page scrolls
 * sideways alongside the track.
 */
.hw-properties-preview__track {
	display: flex;
	gap: var(--hw-preview-gap);
	margin: 0 calc(var(--hw-preview-bleed) * -1);
	padding: 2px;
	list-style: none;
	overflow-x: auto;
	overscroll-behavior-x: contain;
	scroll-snap-type: x mandatory;
	scrollbar-width: thin;
}

/*
 * Below this there is no longer enough padding either side to bleed into, so
 * the row reaches the edge of the screen instead of the edge of its own
 * padding. It gives the bleed up and stays inside the container.
 *
 * 0px rather than 0: the margin is a calc() multiplying this by -1, and a
 * unitless zero would come out of that a number rather than a length, which is
 * not something a margin will take.
 */
@media (max-width: 1300px) {
	.hw-properties-preview {
		--hw-preview-bleed: 0px;
	}
}

@media (prefers-reduced-motion: no-preference) {
	.hw-properties-preview__track {
		scroll-behavior: smooth;
	}
}

.hw-properties-preview__item {
	flex: 0 0 auto;
	width: var(--hw-preview-width);
	/*
	 * A floor for the card, not for the picture inside it: the photo is a
	 * width of its card, so holding the img itself to 300px would have it
	 * overflow a narrower one rather than widen it.
	 */
	min-width: var(--hw-preview-min);
	scroll-snap-align: start;
}

.hw-properties-preview__card {
	margin: 0;
}

.hw-properties-preview__photo {
	display: block;
	width: 100%;
	height: auto;
	aspect-ratio: var(--hw-preview-aspect);
	object-fit: cover;
	border: 2px solid var(--hw-preview-photo-border);
	border-radius: var(--hw-preview-radius);
	background: var(--hw-preview-ground);
}

/* No photograph, and no view of the address from the street either. The house
   itself is sized in properties.css, which loads alongside this. */
.hw-properties-preview__photo--none {
	display: flex;
	align-items: center;
	justify-content: center;
	border-style: dashed;
	color: var(--hw-preview-house);
}

.hw-properties-preview__caption {
	display: flex;
	flex-direction: column;
	gap: 0.125rem;
	margin-top: 0.75em;
}

.hw-properties-preview__address {
	color: var(--hw-preview-text);
	font-weight: 600;
	line-height: 1.3;
}

.hw-properties-preview__type {
	color: var(--hw-preview-type);
	font-size: 0.9375rem;
	line-height: 1.3;
	text-transform: uppercase;
	letter-spacing: 0.08em;
}

/* -- Arrows --------------------------------------------------------------- */

.hw-properties-preview__nav {
	display: flex;
	justify-content: flex-end;
	gap: 0.5rem;
	margin-top: 1rem;
}

.hw-properties-preview__button {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 2.75rem;
	height: 2.75rem;
	padding: 0;
	background: transparent;
	border: 2px solid var(--hw-preview-border);
	border-radius: 50%;
	color: var(--wp--preset--color--ink, #252b23);
	cursor: pointer;
	transition:
		background-color var(--hw-preview-speed) ease,
		color var(--hw-preview-speed) ease,
		opacity var(--hw-preview-speed) ease;
}

.hw-properties-preview__button svg {
	width: 1.25rem;
	height: 1.25rem;
}

.hw-properties-preview__button:hover:not(:disabled),
.hw-properties-preview__button:focus-visible {
	background: var(--hw-preview-border);
	color: var(--wp--preset--color--cream, #f6f1ea);
}

.hw-properties-preview__button:focus-visible {
	outline: 2px solid var(--wp--preset--color--ink, #252b23);
	outline-offset: 3px;
}

.hw-properties-preview__button:disabled {
	opacity: 0.35;
	cursor: default;
}

/* -- On dark sections ----------------------------------------------------- */

.has-ink-background-color .hw-properties-preview,
.has-forest-background-color .hw-properties-preview,
.has-sage-background-color .hw-properties-preview {
	--hw-preview-border: var(--wp--preset--color--wheat, #c3a87f);
	--hw-preview-photo-border: var(--wp--preset--color--wheat, #c3a87f);
	--hw-preview-text: var(--wp--preset--color--cream, #f6f1ea);
	--hw-preview-type: var(--wp--preset--color--wheat, #c3a87f);
	--hw-preview-house: var(--wp--preset--color--wheat, #c3a87f);
}

.has-ink-background-color .hw-properties-preview__button,
.has-forest-background-color .hw-properties-preview__button,
.has-sage-background-color .hw-properties-preview__button {
	color: var(--wp--preset--color--cream, #f6f1ea);
}
