/*
 * TileMode home page (templates/home.php). Loaded on the front page only.
 * Shared pieces (.tm-wrap, .tm-btn, .tm-eyebrow) live in tilemode.css.
 */

/* ---- 1. Page frame: let sections run edge to edge ---------------------- */

body.tm-home-page {
	overflow-x: clip;
}

body.tm-home-page :is(.wd-page-title, .page-title-default) {
	display: none;
}

body.tm-home-page :is(.main-page-wrapper, .wd-content-layout, .content-layout-wrapper) {
	padding-top: 0;
	padding-bottom: 0;
}

.tm-home-area {
	grid-column: 1 / -1;
	flex: 0 0 100%;
	width: 100%;
	max-width: none;
	padding: 0;
}

.tm-home {
	width: 100vw;
	margin-inline: calc(50% - 50vw);
	color: var(--tm-text);
}

.tm-home :is(ul, ol) {
	--list-mb: 0;
	--li-mb: 0;
	--li-pl: 0;
	margin: 0;
	padding: 0;
	list-style: none;
}

.tm-home li {
	margin: 0;
}

.tm-home img {
	display: block;
	max-width: 100%;
}

/* ---- 2. Sections and headings ------------------------------------------ */

.tm-sec {
	padding-block: clamp(52px, 6.5vw, 96px);
	background-color: #fff;
}

.tm-sec--alt {
	background-color: var(--tm-porcelain);
}

/* Two white sections in a row read as one; tighten the join. */
.tm-sec:not(.tm-sec--alt):not(.tm-sec--hero):not(.tm-sec--benefits) + .tm-sec:not(.tm-sec--alt) {
	padding-top: 0;
}

.tm-sec__head {
	display: flex;
	align-items: flex-end;
	justify-content: space-between;
	gap: 16px 32px;
	flex-wrap: wrap;
	margin-bottom: clamp(24px, 2.6vw, 36px);
}

.tm-home .tm-sec__title {
	margin: 0;
	color: var(--tm-ink);
	font-size: clamp(26px, 2.6vw, 36px);
	font-weight: 500;
	letter-spacing: -0.02em;
	line-height: 1.12;
}

.tm-sec__intro {
	margin: 8px 0 0;
	color: var(--tm-muted);
	font-size: 16px;
}

.tm-home .tm-sec__all {
	display: inline-flex;
	align-items: center;
	gap: 8px;
	color: var(--tm-ink);
	font-size: 15px;
	font-weight: 500;
	text-decoration: none;
	white-space: nowrap;
}

.tm-sec__all .tm-icon {
	width: 18px;
	height: 18px;
	transition: transform 0.2s ease;
}

.tm-home .tm-sec__all:hover {
	color: var(--tm-red);
}

.tm-sec__all:hover .tm-icon {
	transform: translateX(3px);
}

/* ---- 3. Hero ----------------------------------------------------------- */

.tm-sec--hero {
	padding: 0;
}

.tm-hero {
	position: relative;
	display: flex;
	align-items: center;
	min-height: clamp(500px, 72vh, 740px);
	background-color: var(--tm-ink);
	color: #fff;
	isolation: isolate;
}

.tm-hero__media {
	position: absolute;
	inset: 0;
	z-index: -1;
	overflow: hidden;
}

.tm-hero__media::after {
	content: "";
	position: absolute;
	inset: 0;
	background: linear-gradient(90deg, rgba(20, 23, 25, 0.7) 0%, rgba(20, 23, 25, 0.42) 42%, rgba(20, 23, 25, 0) 78%);
}

.tm-home .tm-hero__img {
	width: 100%;
	height: 100%;
	max-width: none;
	object-fit: cover;
}

.tm-hero__body {
	width: 100%;
	padding-block: clamp(56px, 8vw, 112px);
}

.tm-hero__content {
	max-width: 590px;
}

.tm-hero .tm-eyebrow {
	color: rgba(255, 255, 255, 0.86);
}

.tm-home .tm-hero__title {
	margin: 0 0 18px;
	color: #fff;
	font-size: clamp(38px, 5.2vw, 68px);
	font-weight: 500;
	letter-spacing: -0.025em;
	line-height: 1.03;
	text-wrap: balance;
}

.tm-hero__text {
	max-width: 480px;
	margin: 0 0 30px;
	color: rgba(255, 255, 255, 0.9);
	font-size: clamp(16px, 1.3vw, 18px);
	line-height: 1.55;
}

.tm-hero--plain .tm-hero__body {
	padding-block: clamp(72px, 10vw, 140px);
}

/* Popular searches under the hero. */
.tm-hero__chips {
	border-bottom: 1px solid var(--tm-grout);
	background-color: #fff;
}

.tm-hero__chips .tm-wrap {
	display: flex;
	align-items: center;
	gap: 18px;
	padding-block: 14px;
}

.tm-hero__chips-label {
	flex: none;
	margin: 0;
	color: var(--tm-muted);
	font-size: 14px;
}

.tm-hero__chips ul {
	display: flex;
	gap: 8px;
	overflow-x: auto;
	scrollbar-width: none;
}

.tm-hero__chips ul::-webkit-scrollbar {
	display: none;
}

.tm-home .tm-hero__chips a {
	display: inline-flex;
	align-items: center;
	height: 36px;
	padding-inline: 14px;
	border: 1px solid var(--tm-grout);
	color: var(--tm-ink);
	font-size: 14px;
	text-decoration: none;
	white-space: nowrap;
	transition: border-color 0.15s ease, background-color 0.15s ease;
}

.tm-home .tm-hero__chips a:hover {
	border-color: var(--tm-ink);
	background-color: var(--tm-porcelain);
}

/* ---- 4. Benefits strip ------------------------------------------------- */

.tm-sec--benefits {
	padding-block: 0;
	border-bottom: 1px solid var(--tm-grout);
}

.tm-benefits {
	display: grid;
	grid-auto-columns: minmax(0, 1fr);
	grid-auto-flow: column;
}

.tm-benefits > li + li {
	border-left: 1px solid var(--tm-grout);
}

.tm-home .tm-benefit {
	display: flex;
	align-items: flex-start;
	gap: 14px;
	height: 100%;
	padding: 24px clamp(14px, 2vw, 28px);
	color: var(--tm-ink);
	text-decoration: none;
}

.tm-benefits > li:first-child .tm-benefit {
	padding-left: 0;
}

.tm-benefit .tm-icon {
	flex: none;
	width: 26px;
	height: 26px;
	color: var(--tm-red);
}

.tm-benefit__body {
	display: flex;
	flex-direction: column;
	gap: 2px;
}

.tm-benefit__title {
	font-size: 15px;
	font-weight: 600;
	line-height: 1.3;
}

.tm-benefit__text {
	color: var(--tm-muted);
	font-size: 14px;
	line-height: 1.4;
}

.tm-home a.tm-benefit:hover .tm-benefit__title {
	color: var(--tm-red);
}

/* ---- 5. Photo tiles ---------------------------------------------------- */

.tm-tiles {
	--tm-gap: clamp(12px, 1.4vw, 20px);
	display: grid;
	grid-template-columns: repeat(var(--tm-cols, 4), minmax(0, 1fr));
	gap: calc(var(--tm-gap) * 1.6) var(--tm-gap);
}

.tm-home .tm-tile {
	display: block;
	color: var(--tm-ink);
	text-decoration: none;
}

.tm-tile__media {
	display: block;
	overflow: hidden;
	aspect-ratio: 1 / 1;
	background-color: var(--tm-grout);
}

.tm-sec--alt .tm-tile__media {
	background-color: #e6e8e9;
}

.tm-tiles--portrait .tm-tile__media {
	aspect-ratio: 4 / 5;
}

.tm-tiles--landscape .tm-tile__media {
	aspect-ratio: 3 / 2;
}

.tm-home .tm-tile__img {
	width: 100%;
	height: 100%;
	object-fit: cover;
	transition: transform 0.6s cubic-bezier(0.2, 0.7, 0.2, 1);
}

.tm-tile:hover .tm-tile__img {
	transform: scale(1.04);
}

.tm-tile__body {
	display: flex;
	align-items: baseline;
	justify-content: space-between;
	gap: 8px;
	padding-top: 12px;
}

.tm-tile__name {
	font-size: 17px;
	font-weight: 500;
	line-height: 1.25;
}

.tm-tile:hover .tm-tile__name {
	color: var(--tm-red);
}

.tm-tile__count {
	flex: none;
	color: var(--tm-muted);
	font-size: 13px;
	font-variant-numeric: tabular-nums;
}

/* Compact thumbnails (Shop by look). */
.tm-tiles--small {
	grid-template-columns: repeat(auto-fill, minmax(132px, 168px));
	gap: 24px 20px;
}

.tm-tiles--small .tm-tile__body {
	flex-direction: column;
	gap: 2px;
	padding-top: 10px;
}

.tm-tiles--small .tm-tile__name {
	font-size: 15px;
}

/* Zoomed crop: fills the frame with the tile surface, no white border. */
.tm-home .tm-tiles--zoom .tm-tile__img {
	transform: scale(var(--tm-zoom, 2));
}

.tm-home .tm-tiles--zoom .tm-tile:hover .tm-tile__img {
	transform: scale(calc(var(--tm-zoom, 2) * 1.06));
}

/* ---- 6. Products (Woodmart product grid) -------------------------------- */

.tm-products .woocommerce,
.tm-products .products {
	margin-bottom: 0;
}

.tm-products .woocommerce-pagination,
.tm-products .wd-loop-footer {
	display: none;
}

/* ---- 7. Banners -------------------------------------------------------- */

.tm-banner {
	display: grid;
	grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
	background-color: var(--tm-porcelain);
}

.tm-sec--alt .tm-banner {
	background-color: #fff;
}

.tm-banner--reverse .tm-banner__media {
	order: 2;
}

.tm-banner--plain {
	grid-template-columns: minmax(0, 1fr);
}

.tm-banner__media {
	position: relative;
	min-height: 360px;
	overflow: hidden;
	background-color: var(--tm-grout);
}

.tm-home .tm-banner__img {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	object-fit: cover;
}

.tm-banner__body {
	display: flex;
	flex-direction: column;
	justify-content: center;
	padding: clamp(36px, 5.5vw, 84px);
}

.tm-home .tm-banner__title {
	margin: 0 0 14px;
	color: var(--tm-ink);
	font-size: clamp(26px, 2.7vw, 38px);
	font-weight: 500;
	letter-spacing: -0.02em;
	line-height: 1.12;
	text-wrap: balance;
}

.tm-banner__text {
	max-width: 460px;
	margin: 0 0 28px;
	color: var(--tm-text);
	font-size: 16px;
	line-height: 1.6;
}

/* ---- 8. Browse (sizes, colors, materials) ------------------------------ */

.tm-browse {
	display: grid;
	grid-template-columns: minmax(0, 1.5fr) minmax(0, 1.2fr) minmax(0, 0.8fr);
	gap: clamp(28px, 4vw, 56px);
}

.tm-home .tm-browse__title {
	margin: 0 0 14px;
	color: var(--tm-ink);
	font-size: 15px;
	font-weight: 600;
	letter-spacing: 0.01em;
}

.tm-chips {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
}

.tm-home .tm-chip {
	display: inline-flex;
	align-items: center;
	gap: 9px;
	min-height: 42px;
	padding: 6px 16px;
	border: 1px solid var(--tm-grout);
	background-color: #fff;
	color: var(--tm-ink);
	font-size: 15px;
	font-variant-numeric: tabular-nums;
	text-decoration: none;
	transition: border-color 0.15s ease;
}

.tm-home .tm-chip:hover {
	border-color: var(--tm-ink);
	color: var(--tm-ink);
}

.tm-chip__swatch {
	width: 18px;
	height: 18px;
	background-color: var(--tm-swatch, var(--tm-grout));
	box-shadow: inset 0 0 0 1px rgba(31, 35, 38, 0.18);
}

.tm-chip__swatch--multi {
	background: conic-gradient(#c62127, #d8c8a9, #7d9373, #5f86a8, #1f2326, #c62127);
}

/* ---- 8b. Instagram ----------------------------------------------------- */

.tm-insta {
	display: grid;
	grid-template-columns: repeat(5, minmax(0, 1fr));
	gap: 8px;
}

.tm-insta__item {
	display: block;
	overflow: hidden;
	aspect-ratio: 1 / 1;
	background-color: var(--tm-grout);
}

.tm-home .tm-insta__img {
	width: 100%;
	height: 100%;
	object-fit: cover;
	transition: transform 0.6s cubic-bezier(0.2, 0.7, 0.2, 1), opacity 0.2s ease;
}

.tm-home a.tm-insta__item:hover .tm-insta__img {
	transform: scale(1.05);
	opacity: 0.9;
}

/* ---- 9. Steps ---------------------------------------------------------- */

.tm-steps {
	display: grid;
	grid-template-columns: repeat(3, minmax(0, 1fr));
	gap: clamp(24px, 3.5vw, 48px);
	counter-reset: none;
}

.tm-step {
	padding-top: 20px;
	border-top: 1px solid var(--tm-ink);
}

.tm-step__num {
	display: block;
	margin-bottom: 14px;
	color: var(--tm-red);
	font-size: 14px;
	font-weight: 600;
	font-variant-numeric: tabular-nums;
	letter-spacing: 0.04em;
}

.tm-home .tm-step__title {
	margin: 0 0 8px;
	color: var(--tm-ink);
	font-size: 20px;
	font-weight: 500;
}

.tm-step__text {
	margin: 0;
	color: var(--tm-muted);
	font-size: 15px;
	line-height: 1.6;
}

/* ---- 10. Blog posts ---------------------------------------------------- */

.tm-posts {
	display: grid;
	grid-template-columns: repeat(3, minmax(0, 1fr));
	gap: clamp(24px, 2.6vw, 36px);
}

.tm-post__media {
	display: block;
	overflow: hidden;
	aspect-ratio: 3 / 2;
	margin-bottom: 16px;
	background-color: var(--tm-grout);
}

.tm-home .tm-post__img {
	width: 100%;
	height: 100%;
	object-fit: cover;
	transition: transform 0.6s cubic-bezier(0.2, 0.7, 0.2, 1);
}

.tm-post:hover .tm-post__img {
	transform: scale(1.04);
}

.tm-post__date {
	display: block;
	margin-bottom: 6px;
	color: var(--tm-muted);
	font-size: 13px;
}

.tm-home .tm-post__title {
	margin: 0 0 8px;
	font-size: 19px;
	font-weight: 500;
	line-height: 1.3;
}

.tm-home .tm-post__title a {
	color: var(--tm-ink);
	text-decoration: none;
}

.tm-home .tm-post__title a:hover {
	color: var(--tm-red);
}

.tm-post__excerpt {
	margin: 0;
	color: var(--tm-muted);
	font-size: 15px;
	line-height: 1.6;
}

/* ---- 11. Tablet -------------------------------------------------------- */

@media (max-width: 1024px) {
	.tm-tiles {
		grid-template-columns: repeat(min(var(--tm-cols, 4), 3), minmax(0, 1fr));
	}

	/* Even counts split evenly (4 -> 2 x 2) instead of leaving an orphan. */
	.tm-tiles[style*="--tm-cols:4"],
	.tm-tiles[style*="--tm-cols:2"] {
		grid-template-columns: repeat(2, minmax(0, 1fr));
	}

	.tm-benefits {
		grid-auto-flow: row;
		grid-template-columns: repeat(2, minmax(0, 1fr));
	}

	.tm-insta {
		grid-template-columns: repeat(4, minmax(0, 1fr));
	}

	.tm-insta > li:nth-child(n + 9) {
		display: none;
	}

	.tm-benefits > li {
		border-left: 0;
		border-top: 1px solid var(--tm-grout);
	}

	.tm-benefits > li + li {
		border-left: 0;
	}

	.tm-benefits > li:nth-child(-n + 2) {
		border-top: 0;
	}

	.tm-benefits > li:nth-child(even) {
		border-left: 1px solid var(--tm-grout);
	}

	.tm-home .tm-benefits > li:nth-child(odd) .tm-benefit {
		padding-left: 0;
	}

	.tm-browse {
		grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
	}

	.tm-browse__group:first-child {
		grid-column: 1 / -1;
	}
}

/* ---- 12. Phone --------------------------------------------------------- */

@media (max-width: 767px) {
	.tm-hero {
		align-items: flex-end;
		min-height: 560px;
	}

	.tm-hero__media::after {
		background: linear-gradient(0deg, rgba(20, 23, 25, 0.82) 0%, rgba(20, 23, 25, 0.5) 48%, rgba(20, 23, 25, 0.08) 100%);
	}

	.tm-hero__body {
		padding-block: 40px 36px;
	}

	.tm-hero__chips-label {
		display: none;
	}

	.tm-hero__chips ul {
		margin-inline: calc(-1 * var(--tm-gutter));
		padding-inline: var(--tm-gutter);
	}

	/* Tiles become a swipeable rail. */
	.tm-tiles {
		grid-auto-flow: column;
		grid-auto-columns: 68%;
		grid-template-columns: none;
		margin-inline: calc(-1 * var(--tm-gutter));
		padding-inline: var(--tm-gutter);
		padding-bottom: 6px;
		overflow-x: auto;
		overscroll-behavior-x: contain;
		scroll-snap-type: x mandatory;
		scroll-padding-inline: var(--tm-gutter);
		scrollbar-width: none;
	}

	.tm-tiles::-webkit-scrollbar {
		display: none;
	}

	.tm-tiles--portrait {
		grid-auto-columns: 44%;
	}

	.tm-tiles--small {
		grid-auto-columns: 34%;
	}

	.tm-insta {
		grid-template-columns: repeat(3, minmax(0, 1fr));
		gap: 4px;
	}

	.tm-insta > li:nth-child(n + 7) {
		display: none;
	}

	.tm-tiles > li {
		scroll-snap-align: start;
	}

	.tm-tile__body {
		flex-direction: column;
		gap: 2px;
	}

	.tm-benefits {
		grid-template-columns: minmax(0, 1fr);
	}

	.tm-benefits > li,
	.tm-benefits > li:nth-child(even) {
		border-left: 0;
		border-top: 1px solid var(--tm-grout);
	}

	.tm-benefits > li:first-child {
		border-top: 0;
	}

	.tm-home .tm-benefits .tm-benefit {
		align-items: center;
		padding: 16px 0;
	}

	.tm-benefit__body {
		flex-direction: row;
		flex-wrap: wrap;
		column-gap: 8px;
	}

	.tm-banner,
	.tm-browse,
	.tm-steps,
	.tm-posts {
		grid-template-columns: minmax(0, 1fr);
	}

	.tm-banner {
		margin-inline: calc(-1 * var(--tm-gutter));
	}

	.tm-banner--reverse .tm-banner__media {
		order: 0;
	}

	.tm-banner__media {
		min-height: 0;
		aspect-ratio: 4 / 3;
	}

	.tm-banner__body {
		padding: 32px var(--tm-gutter) 40px;
	}

	.tm-sec__head {
		align-items: flex-start;
		flex-direction: column;
	}
}

/* ---- 13. Motion -------------------------------------------------------- */

@media (prefers-reduced-motion: reduce) {
	.tm-home .tm-tile__img,
	.tm-home .tm-post__img,
	.tm-home .tm-insta__img,
	.tm-sec__all .tm-icon {
		transition: none;
	}

	.tm-home .tm-tile:hover .tm-tile__img,
	.tm-home .tm-post:hover .tm-post__img,
	.tm-home a.tm-insta__item:hover .tm-insta__img {
		transform: none;
	}

	.tm-home .tm-tiles--zoom .tm-tile:hover .tm-tile__img {
		transform: scale(var(--tm-zoom, 2));
	}
}
