/* ==========================================================================
   Front page — Autotelic Objects
   Modelled on loewe.com's home: a column of "stories" (image, then a small
   title, two or three lines, and ▸ links) alternating with product shelves
   whose title bar sticks while you scroll through them. Images touch — no
   gaps between them — and the type stays small so the photographs lead.

   --ao-ink, --ao-paper and --ao-gutter come from header.css, so every edge
   lines up with the menu bar and the wordmark.
   ========================================================================== */

.ao-home {
	--ao-clay: #d5c9c4;
	--ao-small: 14px;
	--ao-title: 22px;
	--ao-story-gap: 96px;   /* space after each story / shelf */
	--ao-head-h: 72px;      /* sticky shelf bar, same height as the menu bar */

	/* Full width, as the header is: cancel the page padding, then use the
	   header's own gutter. */
	margin: 0 calc(-1 * var(--ao-page-pad, 24px));
	color: var(--ao-ink, #000);
	font-size: var(--ao-small);
	line-height: 1.4;
}

/* The hero starts flush under the menu bar, with the wordmark over it */
body.home .wp-site-blocks > .wp-block-template-part + *,
body.home .wp-site-blocks > main { margin-block-start: 0; }

/* TT5's flow layout puts a 24px top margin on every block; this page sets
   its own rhythm. */
body .ao-home,
body .ao-home * { margin-block: 0; }

.ao-home a { color: inherit; text-decoration: none; }

/* ---------- Images ---------- */

.ao-home .wp-block-image { margin: 0; }
.ao-home .wp-block-image a { display: block; }
.ao-home .wp-block-image img {
	display: block;
	width: 100%;
	height: auto;
	aspect-ratio: 4 / 5; /* product photography is shot 4:5 */
	object-fit: cover;
	background: var(--ao-clay);
}

/* ---------- Story ---------- */

.ao-story,
.ao-shelf { margin-bottom: var(--ao-story-gap) !important; }

.ao-media {
	display: grid;
	grid-template-columns: minmax(0, 1fr);
	padding: 0 var(--ao-gutter);
	align-items: start;
}

/* Hero: the wide picture at its own proportion; the tall one on phones */
.ao-media--full .wp-block-image img { aspect-ratio: 2275 / 1440; }
.ao-hero__tall { display: none; }

/* Caption under a story */
.ao-caption { padding: 24px var(--ao-gutter) 0; }
.ao-caption p { max-width: 22rem; }
.ao-caption p + p { margin-top: 0.75em !important; }
.ao-caption--about { padding-top: 48px; }
.ao-caption--about p { max-width: 34rem; }

.ao-home .ao-title {
	font-family: inherit;
	font-size: var(--ao-title);
	font-weight: 400;
	line-height: 1.2;
	letter-spacing: normal;
}
.ao-caption .ao-title { margin-bottom: 14px !important; }

/* ▸ links */
.ao-links {
	list-style: none;
	padding: 0;
	margin-top: 14px !important;
}
.ao-links li { margin: 0 0 4px !important; }
.ao-links a {
	position: relative;
	display: inline-block;
	padding-left: 14px;
}
.ao-links a::before {          /* small solid triangle */
	content: '';
	position: absolute;
	left: 0;
	top: 50%;
	width: 5px;
	height: 7px;
	background: currentColor;
	clip-path: polygon(0 0, 100% 50%, 0 100%);
	transform: translateY(-60%);
}
.ao-links a::after,             /* underline draws in, as in the header */
.ao-card__name::after,
.ao-tile__label a::after {
	content: '';
	position: absolute;
	left: 14px;
	right: 0;
	bottom: -1px;
	height: 1px;
	background: currentColor;
	transform: scaleX(0);
	transform-origin: left;
	transition: transform 0.15s cubic-bezier(0, 0, 0.58, 1);
}
.ao-links a:hover::after,
.ao-card a:hover .ao-card__name::after,
.ao-tile__label a:hover::after { transform: scaleX(1); }

/* ---------- Shelf ---------- */

.ao-shelf { padding: 0 var(--ao-gutter); }

.ao-shelf__head {
	position: sticky;
	top: var(--wp-admin--admin-bar--height, 0px);
	z-index: 10; /* under the header (50): it slides back over this */
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 24px;
	min-height: var(--ao-head-h);
	margin: 0 calc(-1 * var(--ao-gutter)) !important;
	padding: 0 var(--ao-gutter);
	background: var(--ao-paper, #f8e9e5);
}
.ao-shelf__head .ao-links {
	display: flex;
	gap: 24px;
	margin: 0 !important;
}
.ao-shelf__head .ao-links li { margin: 0 !important; }

/* Product grid: four across, touching */
.ao-products {
	list-style: none;
	padding: 0;
	display: grid;
	grid-template-columns: repeat(4, minmax(0, 1fr));
}
.ao-card a { display: block; }
.ao-card__media { display: block; overflow: hidden; }
.ao-card__img {
	display: block;
	width: 100%;
	height: auto;
	aspect-ratio: 4 / 5;
	object-fit: cover;
	background: var(--ao-clay);
}
.ao-card__name,
.ao-card__price { display: block; padding-right: 12px; }
.ao-card__name { position: relative; width: fit-content; margin-top: 10px !important; }
.ao-card__name::after { left: 0; }
.ao-card__price .woocommerce-Price-currencySymbol { margin: 0; }
.ao-card__price del { opacity: 0.6; }
.ao-card__price ins { text-decoration: none; }

/* Lead image + products (Loewe's "At home" row): image two-sixths, then
   four products at one-sixth each, top-aligned */
.ao-shelf--lead .ao-shelf__body {
	display: grid;
	grid-template-columns: minmax(0, 2fr) minmax(0, 4fr);
	align-items: start;
}

/* ---------- Closing pair ---------- */

.ao-tile__label { margin-top: 10px !important; }
.ao-tile__label a { position: relative; display: inline-block; }
.ao-tile__label a::after { left: 0; }

/* =========================================================================
   Desktop
   ========================================================================= */

@media (min-width: 1024px) {
	.ao-media--split   { grid-template-columns: minmax(0, 1fr) minmax(0, 2fr); }
	.ao-media--reverse { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
	.ao-media--pair    { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* =========================================================================
   Mobile & tablet — same breakpoint as the header
   ========================================================================= */

@media (max-width: 1023px) {
	.ao-home {
		--ao-title: 20px;
		--ao-story-gap: 64px;
		--ao-head-h: 56px;
	}

	.ao-hero__wide { display: none; }
	.ao-hero__tall { display: block; }
	.ao-media--full .wp-block-image img { aspect-ratio: 4 / 5; }

	/* On phones the images run edge to edge, as on the reference */
	.ao-media { padding: 0; }
	.ao-media--pair { grid-template-columns: repeat(2, minmax(0, 1fr)); }
	.ao-caption { padding-top: 18px; }

	.ao-shelf__head .ao-links { gap: 16px; font-size: 13px; }

	/* Products scroll sideways, two and a bit in view, snapping */
	.ao-products {
		grid-template-columns: none;
		grid-auto-flow: column;
		grid-auto-columns: 44%;
		overflow-x: auto;
		overscroll-behavior-x: contain;
		scroll-snap-type: x mandatory;
		scroll-padding-inline: var(--ao-gutter);
		scrollbar-width: none;
		margin: 0 calc(-1 * var(--ao-gutter)) !important;
		padding: 0 var(--ao-gutter);
	}
	.ao-products::-webkit-scrollbar { display: none; }
	.ao-card { scroll-snap-align: start; }

	.ao-shelf--lead .ao-shelf__body { grid-template-columns: minmax(0, 1fr); }
	.ao-shelf__lead { margin: 0 calc(-1 * var(--ao-gutter)) 0 !important; }
	.ao-shelf--lead .ao-products { margin-top: 0 !important; }
}

@media (prefers-reduced-motion: reduce) {
	.ao-home *, .ao-home *::after { transition: none !important; }
}
