/*
 * Home page (templates/front-page.html, patterns/home-*.php). The layout of every section.
 * Nothing on the home page moves.
 *
 * Surfaces, top to bottom: the white banner photograph (hero), white (box
 * story), evergreen with the gold trellis (Christmas cards), white (posting dates), damask (collections), white (about), then the night footer with the trellis
 * again.
 * Each section carries its own spacing.
 */

/*
 * The white sections: ink type and the ink focus ring used on every white surface.
 * Posting dates and about hold their text to a column with padding, not a max-width,
 * so the white still runs edge to edge.
 */
.tm-box-story,
.tm-home-posting,
.tm-home-about {
	--tm-focus-ring: var(--tm-ink);
	background-color: var(--tm-white);
	color: var(--tm-ink);
}

.tm-home {
	padding: 0;
}

/* The sections' own surfaces meet edge to edge: no block gap between them. */
.tm-home > * {
	margin-block: 0;
}

/* ---------- Shared section type ---------- */

.tm-home-section__title {
	margin: 0;
	font-family: var(--tm-font-display);
	font-size: var(--wp--preset--font-size--xx-large);
	font-weight: 400;
	line-height: 1.2;
	letter-spacing: 0.05em;
	text-align: center;
}

.tm-home-section__lede {
	max-width: 34rem;
	margin: 1rem auto 0;
	font-family: var(--tm-font-serif-display);
	font-size: var(--wp--preset--font-size--x-large);
	font-style: italic;
	line-height: 1.35;
	text-align: center;
}

.tm-flourish {
	display: block;
	width: min(13rem, 56%);
	height: auto;
	margin-inline: auto;
}

.tm-home-section__flourish {
	margin-block-end: clamp(1.75rem, 3vw, 2.5rem);
}

.tm-home-section__more {
	margin: clamp(3rem, 6vw, 4.5rem) 0 0;
	text-align: center;
}

/* ---------- 1. Hero ---------- */

/*
 * The client's banner: a photograph of a handmade card with white on its left. On a phone the
 * picture comes first, cropped to the card, and the headline and button follow on white. From
 * 64em the picture fills the section and the words sit on its white left side.
 */
.tm-hero {
	position: relative;
	isolation: isolate;
	background-color: var(--tm-white);
	color: var(--tm-ink);
	--tm-focus-ring: var(--tm-ink);
}

.tm-hero__bg {
	display: block;
	width: 100%;
	height: auto;
	aspect-ratio: 4 / 5;
	object-fit: cover;
}

.tm-hero__inner {
	box-sizing: border-box;
	padding: clamp(2rem, 6vw, 3rem) var(--tm-gutter) clamp(3rem, 8vw, 4rem);
	text-align: center;
}

.tm-hero__text {
	display: grid;
	justify-items: center;
	gap: 1.75rem;
}

.tm-hero__title {
	max-width: 14em;
	margin: 0;
	font-family: var(--tm-font-serif-display);
	font-size: clamp(2.25rem, 8vw, 3.25rem);
	font-style: italic;
	font-weight: 500;
	line-height: 1.1;
	letter-spacing: 0;
}

.tm-hero__button {
	min-width: 17rem;
}

@media (min-width: 64em) {
	.tm-hero {
		display: grid;
		align-items: center;
		box-sizing: border-box;
		/* Full width: with a max-height, an aspect-ratio alone would shrink the box and leave a strip. */
		width: 100%;
		aspect-ratio: 2560 / 1067;
		min-height: 26rem;
		max-height: 44rem;
	}

	.tm-hero__bg {
		position: absolute;
		inset: 0;
		z-index: -1;
		height: 100%;
		aspect-ratio: auto;
		object-position: right center;
	}

	.tm-hero__inner {
		padding: 2rem var(--tm-gutter) 2rem max(var(--tm-gutter), 4vw);
		text-align: start;
	}

	.tm-hero__text {
		justify-items: start;
		gap: 2rem;
		width: min(33%, 30rem);
	}

	.tm-hero__title {
		max-width: none;
		font-size: clamp(2.25rem, 2.2vw + 1.1rem, 3.5rem);
	}
}

/* ---------- 2. The box story: three steps side by side ---------- */

.tm-box-story__stage {
	box-sizing: border-box;
	display: grid;
	gap: clamp(3rem, 7vw, 4.5rem);
	max-width: 72rem;
	margin-inline: auto;
	padding: clamp(5rem, 11vw, 8.5rem) var(--tm-gutter);
}

.tm-box-story__title {
	max-width: 18em;
	margin: 0 auto;
	font-family: var(--tm-font-display);
	font-size: var(--wp--preset--font-size--xx-large);
	font-weight: 400;
	line-height: 1.2;
	letter-spacing: 0.05em;
	text-align: center;
}

.tm-box-story__beats {
	display: grid;
	grid-template-columns: minmax(0, 1fr);
	gap: clamp(3.5rem, 9vw, 5rem);
}

.tm-beat {
	display: grid;
	grid-template-rows: auto 1fr;
	justify-items: center;
	gap: 2rem;
	text-align: center;
}

.tm-beat__media {
	width: min(68vw, 20rem);
	margin: 0;
	/* Softer than it would need on a dark surface: on white a heavy shadow reads as a smudge. */
	filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.16)) drop-shadow(0 18px 36px rgba(0, 0, 0, 0.18));
}

.tm-beat__img {
	--tm-cartouche-r: 16px;
	display: block;
	width: 100%;
	height: auto;
	aspect-ratio: 5 / 7;
	object-fit: cover;
	background-color: var(--tm-moss);
}

.tm-beat__text {
	max-width: 24rem;
}

.tm-beat__title {
	margin: 0 0 1rem;
	font-family: var(--tm-font-serif-display);
	font-size: var(--wp--preset--font-size--x-large);
	font-style: italic;
	font-weight: 500;
	line-height: 1.25;
	letter-spacing: 0;
}

.tm-beat__text p {
	margin: 0;
}

@media (min-width: 56em) {
	.tm-box-story__beats {
		grid-template-columns: repeat(3, minmax(0, 1fr));
		align-items: start;
		gap: clamp(2rem, 4vw, 3.5rem);
	}

	.tm-beat__media {
		width: 100%;
	}
}

/* ---------- 3. Christmas cards ---------- */

/* The gold trellis (.pattern-bg, base.css) lines the section behind the cards. */
.tm-home-christmas {
	position: relative;
	isolation: isolate;
	padding-block: clamp(5rem, 11vw, 8.5rem);
	background-color: var(--tm-evergreen);
}

.tm-home-christmas .tm-grid {
	max-width: 62rem;
	margin-block-start: clamp(3.5rem, 7vw, 5.5rem);
}

/* Collection pages show three across; the home page's six Christmas cards stay at two. */
@media (min-width: 64em) {
	.tm-home-christmas .tm-grid--grid .tm-pieces {
		grid-template-columns: repeat(2, minmax(0, 1fr));
		column-gap: clamp(3rem, 6vw, 6rem);
	}
}

/*
 * Until any Christmas card has a photo: four placeholders in a small, plain two by two grid
 * (two across on phones too, with the titles a size smaller), so the section does not read
 * as a wall of empty frames.
 */
.tm-home-christmas--waiting .tm-grid {
	max-width: calc(52rem + 2 * var(--tm-gutter));
}

.tm-home-christmas--waiting .tm-pieces {
	grid-template-columns: repeat(2, minmax(0, 1fr));
	column-gap: clamp(1rem, 5vw, 4rem);
}

@media (max-width: 39.99em) {
	.tm-home-christmas--waiting .tm-piece__title {
		margin-block-start: 1rem;
		font-size: 1.1875rem;
	}
}

/* ---------- 4. Posting dates ---------- */

.tm-home-posting {
	box-sizing: border-box;
	padding: clamp(5rem, 11vw, 8.5rem) max(var(--tm-gutter), (100% - 38rem) / 2);
}

.tm-home-posting .wp-block-tm-posting-dates {
	margin-block-start: clamp(2rem, 4vw, 3rem);
}

.tm-posting-dates {
	width: 100%;
	/* Separate borders, so WebKit draws every rule as one whole gold pixel. */
	border-collapse: separate;
	border-spacing: 0;
	font-size: var(--wp--preset--font-size--body);
}

/*
 * Every row is a whole number of pixels tall (fixed line heights, rem padding), so each gold
 * rule lands on the same part of a pixel and they all draw alike.
 */
.tm-posting-dates th,
.tm-posting-dates td {
	padding: 1rem 0.25rem;
	line-height: 2rem;
	border-bottom: 1px solid var(--tm-gold);
	font-weight: 400;
	text-align: start;
	vertical-align: baseline;
}

.tm-posting-dates thead th {
	padding-block-start: 0;
	font-family: var(--tm-font-display);
	font-size: 1rem;
	letter-spacing: 0.08em;
}

.tm-posting-dates td,
.tm-posting-dates thead th:last-child {
	text-align: end;
}

.tm-posting-dates time {
	font-family: var(--tm-font-serif-display);
	font-size: var(--wp--preset--font-size--large);
	font-style: italic;
	font-weight: 500;
	line-height: 2rem;
	white-space: nowrap;
}

/* On a phone each service takes a line, with its date beneath, rather than squeezing both. */
@media (max-width: 29.99em) {
	.tm-posting-dates thead {
		position: absolute;
		width: 1px;
		height: 1px;
		overflow: hidden;
		clip: rect(0 0 0 0);
		white-space: nowrap;
	}

	.tm-posting-dates tr {
		display: block;
		padding-block: 1rem;
		border-bottom: 1px solid var(--tm-gold);
	}

	.tm-posting-dates tbody th,
	.tm-posting-dates td {
		display: block;
		padding: 0;
		border: 0;
		text-align: start;
	}

	.tm-posting-dates tbody th,
	.tm-posting-dates td,
	.tm-posting-dates time {
		display: block;
		height: 1.75rem;
		line-height: 1.75rem;
	}
}

.tm-home-posting__note {
	margin: 1.75rem 0 0;
	text-align: center;
}

/* ---------- 6. The other collections, over the damask ---------- */

.tm-home-collections {
	position: relative;
	isolation: isolate;
	padding: clamp(5rem, 11vw, 8.5rem) var(--tm-gutter);
}

.tm-home-collections__inner {
	max-width: 70rem;
	margin-inline: auto;
}

.tm-home-collections__grid {
	display: grid;
	grid-template-columns: repeat(2, minmax(0, 1fr));
	gap: clamp(2.25rem, 5vw, 4rem) clamp(1rem, 3vw, 3rem);
	margin: clamp(3rem, 6vw, 4.5rem) 0 0;
	padding: 0;
	list-style: none;
}

.tm-home-collections__link {
	display: block;
	color: var(--tm-white);
	text-align: center;
	text-decoration: none;
}

.tm-home-collections__link:focus-visible {
	outline-offset: 8px;
}

.tm-home-collections__media {
	display: block;
	filter: drop-shadow(0 2px 3px rgba(0, 0, 0, 0.35)) drop-shadow(0 16px 32px rgba(0, 0, 0, 0.35));
}

.tm-home-collections__img {
	--tm-cartouche-r: 12px;
	display: block;
	width: 100%;
	height: auto;
	aspect-ratio: 4 / 5;
	object-fit: cover;
	background-color: var(--tm-moss);
}

.tm-home-collections__name {
	display: block;
	margin-block-start: 1.1rem;
	font-family: var(--tm-font-display);
	font-size: 1.1875rem;
	line-height: 1.3;
	letter-spacing: 0.05em;
	text-decoration-line: underline;
	text-decoration-color: transparent;
	text-decoration-thickness: 1px;
	text-underline-offset: 0.3em;
	transition: text-decoration-color 160ms ease;
}

.tm-home-collections__link:hover .tm-home-collections__name,
.tm-home-collections__link:focus-visible .tm-home-collections__name {
	text-decoration-color: var(--tm-gold);
}

/* An odd number of collections on a phone: the last one sits centred under the pairs. */
@media (max-width: 39.99em) {
	.tm-home-collections__item:last-child:nth-child(odd) {
		grid-column: 1 / -1;
		justify-self: center;
		width: calc(50% - clamp(1rem, 3vw, 3rem) / 2);
	}
}

@media (min-width: 40em) {
	.tm-home-collections__grid {
		grid-template-columns: repeat(3, minmax(0, 1fr));
	}
}

@media (min-width: 64em) {
	.tm-home-collections__name {
		font-size: var(--wp--preset--font-size--large);
	}
}

/* ---------- 7. About ---------- */

.tm-home-about {
	box-sizing: border-box;
	padding: clamp(5rem, 11vw, 8.5rem) max(var(--tm-gutter), (100% - 42rem) / 2);
	text-align: center;
}

.tm-home-about__text {
	margin-block-start: clamp(2rem, 4vw, 2.75rem);
}

.tm-home-about__text p {
	margin: 0 0 1.25rem;
}

.tm-home-about__lead {
	font-family: var(--tm-font-serif-display);
	font-size: var(--wp--preset--font-size--x-large);
	font-style: italic;
	font-weight: 500;
	line-height: 1.4;
}

.tm-home-about .tm-home-section__more {
	margin-block-start: 2rem;
}

.tm-home-about__link {
	display: inline-flex;
	align-items: center;
	min-height: 44px;
	font-family: var(--tm-font-display);
	letter-spacing: 0.08em;
	text-decoration-color: var(--tm-gold);
}
