/* =========================================================================
 * Homepage category tiles — «قاب گالری»
 * =========================================================================
 * The two tiles under the homepage heading. Front page only; loaded through
 * inc/assets.php behind is_front_page(), because the markup renders nowhere
 * else. The behaviour half of this feature lives in inc/home-tiles.php.
 *
 * The design. A tile stops being a bare photograph and becomes a framed
 * print: the photo sits inside a white matte, a hairline draws the frame, and
 * a second hairline separates the photo from its name. It reads as "gallery"
 * because the shop is one — and, more practically, the matte gives the label
 * a fixed white zone no matter whether the photo behind it is dark or bright.
 * The two product photos here are at opposite ends of that range, so any
 * design that puts text or shapes straight on the image changes shape from
 * one card to the other.
 *
 * Type. The name moves from the body face to the display face (Arad) and up
 * to 19px: it is the only piece of copy in this block and it was the smallest
 * text on the page. On phones it stays at the project's 15px floor.
 *
 * Hover / focus. Two signals, no more: the frame's hairline darkens, and the
 * rule above the name grows out from the centre to the full width. No zoom on
 * the photo — the parent theme's markup has no clipping wrapper around the
 * image, so a scaled photo would spill over the name. Motions stop under
 * prefers-reduced-motion.
 *
 * Specificity. Every rule is scoped `.tiles .tile …`, one class deeper than
 * the parent's `.tile …` rules, so it wins on specificity alone and this file
 * needs no !important anywhere.
 * ========================================================================= */

/* --- the frame ------------------------------------------------------- */
.tiles .tile {
	display: block;
	padding: 10px;
	border: 1px solid var(--line, #e9e9e9);
	background: var(--bg, #fff);
	transition: border-color .3s ease;
}

.tiles .tile figure {
	display: block;
	margin: 0;
}

/* --- the photograph -------------------------------------------------- */
/* aspect-ratio and object-fit repeat the parent's values on purpose: the
 * frame now changes the box the photo lives in, and this keeps the square.
 *
 * object-position anchors the square crop to the TOP of a portrait photo.
 * The browser default (centre) cut the collar and the jacket's shoulders off
 * and, on the knit shot — a journal page rather than a product shot — pulled
 * its printed caption into the tile. Both tiles are 3:4 or taller, so the top
 * of the frame is where the garment actually starts.
 *
 * Scoped to the tile on purpose: `object-position` is a property of this one
 * box, so the same attachment keeps its own framing everywhere else it is
 * used (product galleries, the journal) with no edit to the file itself. */
.tiles .tile img {
	display: block;
	width: 100%;
	aspect-ratio: 1;
	object-fit: cover;
	object-position: 50% 0;
}

/* --- the name plate -------------------------------------------------- */
.tiles .tile figcaption {
	position: relative;
	margin-top: 14px;
	padding: 16px 0 4px;
	border-top: 1px solid var(--line, #e9e9e9);
	font-family: var(--mg-font-display, inherit);
	font-size: 19px;
	font-weight: 500;
	line-height: 1.4;
	letter-spacing: 0;
	text-align: center;
	color: var(--ink, #0a0a0a);
}

/* The drawn rule sits exactly on the hairline and grows from the centre.
 * Symmetric, so it behaves identically in RTL and LTR. */
.tiles .tile figcaption::after {
	content: "";
	position: absolute;
	top: -1px;
	inset-inline-start: 50%;
	inset-inline-end: 50%;
	height: 1px;
	background: var(--ink, #0a0a0a);
	transition: inset-inline-start .38s cubic-bezier(.2, .7, .2, 1),
	            inset-inline-end .38s cubic-bezier(.2, .7, .2, 1);
}

.tiles .tile:hover,
.tiles .tile:focus-visible {
	border-color: #d2d2d2;
}

.tiles .tile:hover figcaption::after,
.tiles .tile:focus-visible figcaption::after {
	inset-inline-start: 0;
	inset-inline-end: 0;
}

.tiles .tile:focus-visible {
	outline: 2px solid var(--ink, #0a0a0a);
	outline-offset: 3px;
}

/* --- phones ---------------------------------------------------------- */
/* The matte narrows so the photo keeps its size; the name stays on the 15px
 * floor. Two columns are kept down to 320px — the same layout the site has
 * today, only framed. */
@media (max-width: 767px) {
	.tiles .tile {
		padding: 6px;
	}

	/* The photo keeps more of its own proportions on a phone, but not all of
	 * them.
	 *
	 * Measured at 390px: the two sources are 390x520 (3:4) and 390x551, and the
	 * square box was 161x161 — it showed only the top 41% of a portrait shot,
	 * so every garment was cut at the chest. A 3:4 box was the obvious answer
	 * and the wrong one: at 3:4 the first source is shown whole, and that image
	 * is a journal page whose printed caption «Salana Half-Zip — Forest» sits
	 * along its bottom edge. The caption came back into the tile — exactly what
	 * the square crop above is documented to prevent.
	 *
	 * 4:5 is the balance: with a top-anchored cover crop it trims the bottom
	 * ~6% (removing that caption) while showing roughly 94% of the height
	 * instead of the square's 75%. It is also the ratio the product cards use,
	 * so the homepage finally speaks one proportion. */
	.tiles .tile img {
		aspect-ratio: 4 / 5;
	}

	.tiles .tile figcaption {
		margin-top: 8px;
		padding: 10px 0 2px;
		font-size: 15px;
	}
}

@media (prefers-reduced-motion: reduce) {
	.tiles .tile,
	.tiles .tile figcaption::after {
		transition: none;
	}
}
