/**
 * [homewood_team] — the team member slider.
 *
 * The track is a scroll-snap row rather than a scripted carousel, so it scrolls
 * by touch, trackpad and keyboard on its own. assets/js/slider.js only adds
 * the arrow buttons, and only when there is more to see than fits.
 *
 * @package homewood_theme
 */

.hw-team {
	--hw-member-width: clamp(14rem, 21vw, 23rem);
	--hw-member-min: 300px;
	--hw-member-max: 330px;
	--hw-member-aspect: 7 / 9;
	--hw-member-radius: 5px;
	--hw-member-gap: clamp(0.875rem, 1.4vw, 1.5rem);
	--hw-member-bleed: 5em;

	--hw-member-border: var(--wp--preset--color--bronze, #896d44);
	--hw-member-ground: var(--wp--preset--color--sand, #e9e4d4);
	--hw-member-name: #ffffff;
	--hw-member-role: var(--wp--preset--color--wheat, #c3a87f);

	--hw-member-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-team__track {
	display: flex;
	gap: var(--hw-member-gap);
	margin: 0 calc(var(--hw-member-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-team {
		--hw-member-bleed: 0px;
	}
}

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

.hw-team__member {
	flex: 0 0 auto;
	width: var(--hw-member-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-member-min);
	max-width: var(--hw-member-max);
	scroll-snap-align: start;
}

.hw-team__link {
	position: relative;
	display: block;
	aspect-ratio: var(--hw-member-aspect);
	overflow: hidden;
	border: 2px solid var(--hw-member-border);
	border-radius: var(--hw-member-radius);
	background: var(--hw-member-ground);
	text-decoration: none;
}

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

.hw-team__photo {
	display: block;
	width: 100%;
	height: 100%;
	object-fit: cover;
}

/* -- Name and position ---------------------------------------------------- */

.hw-team__caption {
	position: absolute;
	inset: auto 0 0 0;
	display: flex;
	flex-direction: column;
	gap: 0.125rem;

	/*
	 * The padding is what the gradient fades across, so the top of it has room
	 * to reach transparent well above the text.
	 */
	padding: 4.5rem 1.75rem 1.5rem;
	background: linear-gradient(
		to top,
		rgba(0, 0, 0, 0.85) 0%,
		rgba(0, 0, 0, 0.65) 35%,
		rgba(0, 0, 0, 0) 100%
	);
}

.hw-team__name {
	color: var(--hw-member-name);
	font-size: 1.375rem;
	font-weight: 600;
	line-height: 1.2;
}

.hw-team__role {
	color: var(--hw-member-role);
	font-size: 1.0625rem;
	line-height: 1.3;
}

/*
 * Shown outright wherever hovering is not a thing — a touch screen gets no
 * hover state, and a caption that never appears is a caption nobody reads.
 */
@media (hover: hover) {
	.hw-team__caption {
		opacity: 0;
		transition: opacity var(--hw-member-speed) ease;
	}

	.hw-team__link:hover .hw-team__caption,
	.hw-team__link:focus-visible .hw-team__caption {
		opacity: 1;
	}
}

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

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

/*
 * slider.js hides the arrows by setting the hidden attribute, and this rule is
 * what lets it: a display of its own in an author stylesheet outranks the
 * browser's own [hidden] rule whatever its specificity, so without this the
 * arrows stay on screen for a row that fits.
 */
.hw-team__nav[hidden] {
	display: none;
}

.hw-team__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-member-border);
	border-radius: 50%;
	color: var(--wp--preset--color--ink, #252b23);
	cursor: pointer;
	transition:
		background-color var(--hw-member-speed) ease,
		color var(--hw-member-speed) ease,
		opacity var(--hw-member-speed) ease;
}

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

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

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

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

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

.has-ink-background-color .hw-team,
.has-forest-background-color .hw-team,
.has-sage-background-color .hw-team {
	--hw-member-border: var(--wp--preset--color--wheat, #c3a87f);
}

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