/* ==========================================================================
   Product tile
   Converted from design-reference/showroom-floor.css §8.

   The tile name renders in the body face at `sub`, not the display face the
   reference used. CLAUDE.md reserves the display face for H1 and H2 and sets a
   28px floor beneath which display type never renders; a 20px tile name breaks
   both. theme.json's own H3 definition is exactly this, so the heading needs
   no type override at all.
   ========================================================================== */

.tfs-product-tile {
	position: relative;
	display: block;
	color: var(--wp--preset--color--ink);
}

.tfs-product-tile__media {
	position: relative;
	overflow: hidden;
	aspect-ratio: var(--wp--custom--aspect--tile);
	background-color: var(--wp--preset--color--surface);
	border: var(--wp--custom--hairline);
	border-radius: var(--wp--custom--radius);
}

.tfs-product-tile__image {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	object-fit: cover;
	background-color: var(--wp--preset--color--placeholder);
	transition: transform var(--wp--custom--motion--duration) var(--wp--custom--motion--easing);
}

/* The only thing that moves on hover. */
.tfs-product-tile:hover .tfs-product-tile__image,
.tfs-product-tile:focus-within .tfs-product-tile__image {
	transform: scale(var(--wp--custom--motion--tile-scale));
}

.tfs-product-tile__badge {
	position: absolute;
	left: var(--wp--custom--step--12);
	top: var(--wp--custom--step--12);
	z-index: 2;
}

/* Hidden until hover on pointer devices, but never removed from the tab order —
   revealing it on :focus-within is what keeps it reachable by keyboard. */
.tfs-product-tile__save {
	position: absolute;
	right: var(--wp--custom--step--12);
	top: var(--wp--custom--step--12);
	z-index: 2;
	opacity: 0;
	transition:
		opacity var(--wp--custom--motion--duration) var(--wp--custom--motion--easing),
		background-color var(--wp--custom--motion--duration) var(--wp--custom--motion--easing),
		border-color var(--wp--custom--motion--duration) var(--wp--custom--motion--easing),
		color var(--wp--custom--motion--duration) var(--wp--custom--motion--easing);
}

.tfs-product-tile:hover .tfs-product-tile__save,
.tfs-product-tile:focus-within .tfs-product-tile__save,
.tfs-product-tile__save:focus-visible,
.tfs-product-tile__save[aria-pressed="true"] {
	opacity: 1;
}

.tfs-product-tile__save[aria-pressed="true"] {
	background-color: var(--wp--preset--color--accent);
	border-color: var(--wp--preset--color--accent);
	color: var(--wp--preset--color--surface);
}

/* Touch devices have no hover to reveal it, so it is always visible and always
   a full tap target. */
@media (hover: none) {
	.tfs-product-tile__save {
		opacity: 1;
		min-height: var(--wp--custom--control--tap-target-minimum);
	}
}

.tfs-product-tile__body {
	display: grid;
	gap: var(--wp--custom--step--4);
	padding-top: var(--wp--preset--spacing--20);
}

.tfs-product-tile__collection,
.tfs-product-tile__brand,
.tfs-product-tile__price,
.tfs-product-tile__availability,
.tfs-product-tile__name {
	margin: 0;
}

/* The brand and the collection share one eyebrow slot — a mattress has a maker
   and everything else has a collection, and nothing has both. They take the
   same treatment because they occupy the same line and a reader should not have
   to notice which one they are looking at. `saddle` is not used here: CLAUDE.md
   reserves it for provenance and collection tags, and a resold brand is the
   opposite of provenance. */
.tfs-product-tile__collection,
.tfs-product-tile__brand {
	font-size: var(--wp--preset--font-size--utility);
	text-transform: uppercase;
	letter-spacing: var(--wp--custom--tracking--utility);
	line-height: 1.4;
	color: var(--wp--preset--color--muted);
}

.tfs-product-tile__name {
	font-size: var(--wp--preset--font-size--sub);
	line-height: var(--wp--custom--line-height--body);
}

/* A product name is not a link affordance, so it does not take link colour. */
.tfs-product-tile__link {
	color: var(--wp--preset--color--ink);
	text-decoration: none;
}

.tfs-product-tile__link:hover {
	color: var(--wp--preset--color--ink);
	text-decoration: none;
}

/* Whole-tile click target, kept beneath the save control's z-index. */
.tfs-product-tile__link::after {
	content: "";
	position: absolute;
	inset: 0;
	z-index: 1;
}

.tfs-product-tile__link:focus-visible {
	outline: var(--wp--custom--focus--width) solid var(--wp--preset--color--accent);
	outline-offset: var(--wp--custom--focus--offset);
}

/* Where :has() is available the ring moves to the whole tile, which reads far
   better than a ring around the name alone. The replacement ring is defined in
   the same block, so the focus indicator is never removed without one. */
@supports selector(:has(*)) {
	.tfs-product-tile__link:focus-visible {
		outline: none;
	}

	.tfs-product-tile:has(.tfs-product-tile__link:focus-visible) {
		outline: var(--wp--custom--focus--width) solid var(--wp--preset--color--accent);
		outline-offset: var(--wp--custom--focus--offset);
	}
}

.tfs-product-tile__price {
	font-size: var(--wp--preset--font-size--small);
	color: var(--wp--preset--color--muted);
}

.tfs-product-tile__availability {
	margin-top: var(--wp--custom--step--4);
}

@media (prefers-reduced-motion: reduce) {
	.tfs-product-tile:hover .tfs-product-tile__image,
	.tfs-product-tile:focus-within .tfs-product-tile__image {
		transform: none;
	}
}
