/*
 * 3D By Humpf Store: home page [home only]. Loaded on the front page only (functions.php).
 * Hero film, promise ticker, category tiles, made-to-order story and the custom/bulk band.
 *
 * The page is complete without JavaScript and without motion: posters instead of video, a static
 * promise row, all steps lit, every photo shown. Motion is layered on top:
 *   humpf-no-hero    hero video (motion.js), settle-in, turning stamp, scroll-out
 *   humpf-no-ticker  moving promise strip (motion.js)
 *   humpf-no-story   oversized line, steps lighting up, custom band growing in, story/custom video loops
 *   humpf-no-print   layer-by-layer photo reveal (motion.js adds .humpf-print / .is-printed)
 * Scroll-linked effects use CSS view timelines inside @supports; other browsers show the end state.
 * Nothing is pinned and the scroll is never taken over. Reduced motion: none of it runs.
 */

/* =========================================================================
 * Hero film
 * ====================================================================== */

.humpf-hero.wp-block-cover {
	/* Desktop: fill the first screen and leave the promise strip in view below it. */
	min-height: clamp(520px, calc(100svh - var(--humpf-header-h) - var(--wp-admin--admin-bar--height, 0px) - 57px), 940px);
	padding-top: var(--wp--preset--spacing--70);
	padding-bottom: var(--wp--preset--spacing--60);
	background-color: var(--wp--preset--color--base);
	view-timeline: --humpf-hero block;
}

/* Scrim: darker at the bottom and left, where the words sit; the footage stays clear top right. */
.humpf-hero.wp-block-cover > .wp-block-cover__background {
	opacity: 1 !important;
	background:
		linear-gradient(0deg, rgba(13, 13, 13, 0.94) 0%, rgba(13, 13, 13, 0.76) 35%, rgba(13, 13, 13, 0) 78%),
		linear-gradient(90deg, rgba(13, 13, 13, 0.78) 0%, rgba(13, 13, 13, 0.4) 48%, rgba(13, 13, 13, 0) 80%) !important;
}

.humpf-hero.wp-block-cover > :is(.wp-block-cover__image-background, .humpf-film) {
	transform-origin: 50% 35%;
}

/* Darkens as the hero scrolls away (scroll-linked, below). */
.humpf-hero.wp-block-cover::after {
	content: "";
	position: absolute;
	inset: 0;
	z-index: 1;
	min-height: 0;
	background: var(--wp--preset--color--base);
	opacity: 0;
	pointer-events: none;
}

/* The stamp is placed against the whole hero, so the inner container is not a positioning box. */
.humpf-hero.wp-block-cover > .wp-block-cover__inner-container {
	position: static;
}

.humpf-hero .humpf-hero__copy {
	position: relative;
	z-index: 2;
}

.humpf-hero .humpf-hero__copy > * {
	max-width: 40rem;
}

.humpf-hero .humpf-hero__title {
	max-width: none;
	margin-top: var(--wp--preset--spacing--20);
	font-size: clamp(2.5rem, 1rem + 6vw, 6.75rem) !important;
	line-height: 0.96;
	letter-spacing: -0.045em;
	text-wrap: balance;
}

.humpf-hero .humpf-hero__lede {
	max-width: 36rem;
}

/* Dark controls keep their edges visible over every clip. */
.humpf-hero .is-style-outline .wp-block-button__link,
.humpf-hero-links .wp-block-navigation-item__content {
	background: rgba(13, 13, 13, 0.75);
	border-color: var(--wp--preset--color--accent-4);
}

.humpf-hero .humpf-hero__stamp {
	position: absolute;
	z-index: 2;
	top: clamp(1rem, 7vh, 4.5rem);
	right: clamp(1rem, 4vw, 4rem);
	width: clamp(84px, 10vw, 148px);
	max-width: none;
	margin: 0 !important;
	pointer-events: none;
}

.humpf-hero .humpf-hero__stamp img {
	display: block;
	width: 100%;
	height: auto;
}

.humpf-hero .humpf-film-toggle {
	right: clamp(1rem, 4vw, 4rem);
	bottom: var(--wp--preset--spacing--60);
}

/* Keep the hero on the same centered column as the header and shelves on wide screens. */
@media (min-width: 782px) {
	.humpf-hero.wp-block-cover {
		justify-content: center;
		padding-inline: var(--wp--style--root--padding-left) var(--wp--style--root--padding-right);
	}

	.humpf-hero.wp-block-cover > .wp-block-cover__inner-container {
		box-sizing: border-box;
		flex: 1;
		max-width: var(--wp--style--global--wide-size);
		padding-inline: 0;
	}

	.humpf-hero .humpf-hero__stamp,
	.humpf-hero .humpf-film-toggle {
		right: max(var(--wp--style--root--padding-right), calc((100% - var(--wp--style--global--wide-size)) / 2));
	}
}

@media (max-width: 781px) {
	.humpf-hero.wp-block-cover {
		min-height: 560px;
	}
}

@media (max-width: 599px) {
	/* Phones: a shorter hero so the shop starts within the first screen and a half. */
	.humpf-hero.wp-block-cover {
		min-height: clamp(470px, 62svh, 540px);
		padding-top: var(--wp--preset--spacing--50);
		padding-bottom: var(--wp--preset--spacing--50);
	}

	.humpf-hero .humpf-hero__lede {
		display: none;
	}

	.humpf-hero .humpf-hero__copy {
		gap: var(--wp--preset--spacing--30);
	}

	.humpf-hero .humpf-film-toggle {
		bottom: var(--wp--preset--spacing--50);
	}

	/* Keep the secondary action clear of the video control on narrow phones. */
	.humpf-hero .wp-block-buttons {
		max-width: calc(100% - 3rem);
	}

	.humpf-hero .wp-block-button,
	.humpf-custom-work .wp-block-button {
		width: 100%;
	}

	.humpf-hero .wp-block-button__link,
	.humpf-custom-work .wp-block-button__link {
		box-sizing: border-box;
		width: 100%;
		min-height: var(--humpf-tap);
		padding-inline: var(--wp--preset--spacing--30);
	}

	.humpf-story,
	.humpf-custom-work {
		padding-block: var(--wp--preset--spacing--60) !important;
	}
}

@media (prefers-reduced-motion: no-preference) {
	/* The poster settles in once (scale only, so it never waits to paint). */
	body:not(.humpf-no-hero) .humpf-hero > .wp-block-cover__image-background {
		animation: humpf-settle 1.8s var(--humpf-ease-out) both;
	}

	body:not(.humpf-no-hero) .humpf-hero__stamp img {
		animation: humpf-spin 32s linear infinite;
	}

	body:not(.humpf-no-hero) .humpf-hero:is(.is-paused, .is-offscreen) .humpf-hero__stamp img {
		animation-play-state: paused;
	}
}

@keyframes humpf-settle {
	from {
		scale: 1.08;
	}
}

@keyframes humpf-spin {
	to {
		rotate: 1turn;
	}
}

/* =========================================================================
 * Promise ticker
 * ====================================================================== */

.humpf-ticker {
	position: relative;
	overflow: clip;
	border-top: 1px solid var(--wp--preset--color--accent-5);
	border-bottom: 1px solid var(--wp--preset--color--accent-5);
}

/* Soft edges. */
.humpf-ticker::before,
.humpf-ticker::after {
	content: "";
	position: absolute;
	top: 0;
	bottom: 0;
	z-index: 1;
	width: clamp(1.5rem, 5vw, 4rem);
	pointer-events: none;
}

.humpf-ticker::before {
	left: 0;
	background: linear-gradient(90deg, var(--wp--preset--color--accent-3), rgba(26, 26, 26, 0));
}

.humpf-ticker::after {
	right: 0;
	background: linear-gradient(270deg, var(--wp--preset--color--accent-3), rgba(26, 26, 26, 0));
}

/* Static row (no JavaScript, reduced motion): swipe or scroll sideways. */
.humpf-ticker .humpf-ticker__track {
	display: flex;
	flex-wrap: nowrap;
	align-items: center;
	height: 55px;
	margin: 0;
	padding: 0 0 0 clamp(1rem, 4vw, 2.5rem);
	list-style: none;
	overflow-x: auto;
	scrollbar-width: none;
}

.humpf-ticker .humpf-ticker__track li {
	display: flex;
	flex: none;
	align-items: center;
	gap: 1.25rem;
	margin: 0;
	padding-right: 1.25rem;
	color: var(--wp--preset--color--contrast);
	font-size: var(--wp--preset--font-size--small);
	font-weight: 700;
	letter-spacing: 0.12em;
	line-height: 1;
	text-transform: uppercase;
	white-space: nowrap;
}

.humpf-ticker .humpf-ticker__track li::before {
	content: "✦" / "";
	color: var(--wp--preset--color--accent-4);
	font-size: 0.85em;
}

/* Moving strip (motion.js copies the row and adds .is-live and the pause button). The rail takes over
 * the row's left padding, so nothing moves when the strip goes live. */
.humpf-ticker.is-live .humpf-ticker__rail {
	display: flex;
	width: max-content;
	padding-left: clamp(1rem, 4vw, 2.5rem);
}

.humpf-ticker.is-live .humpf-ticker__track {
	padding-left: 0;
	overflow: visible;
}

.humpf-ticker .humpf-film-toggle {
	top: calc(50% - 22px);
	right: 0.5rem;
	bottom: auto;
	z-index: 2;
	width: var(--humpf-tap);
	height: var(--humpf-tap);
	background: var(--wp--preset--color--accent-3);
	border-color: var(--wp--preset--color--accent-6);
}

@media (prefers-reduced-motion: no-preference) {
	body:not(.humpf-no-ticker) .humpf-ticker.is-live .humpf-ticker__rail {
		animation: humpf-ticker var(--humpf-ticker-dur, 40s) linear infinite;
	}

	body:not(.humpf-no-ticker) .humpf-ticker:is(:hover, :focus-within, .is-paused, .is-offscreen) .humpf-ticker__rail {
		animation-play-state: paused;
	}
}

@keyframes humpf-ticker {
	to {
		transform: translateX(var(--humpf-ticker-shift, -50%));
	}
}

/* A preference change also restores the static, scrollable row without reloading. */
@media (prefers-reduced-motion: reduce) {
	.humpf-ticker.is-live .humpf-ticker__rail {
		display: block;
		width: auto;
		padding-left: 0;
	}

	.humpf-ticker.is-live .humpf-ticker__track {
		padding-left: clamp(1rem, 4vw, 2.5rem);
		overflow-x: auto;
	}

	.humpf-ticker__track[aria-hidden="true"],
	.humpf-ticker .humpf-film-toggle {
		display: none;
	}

	.humpf-print {
		clip-path: none;
	}
}

/* =========================================================================
 * Shop by Category: even shelves on larger screens, one swipeable row on phones
 * ====================================================================== */

/* Keep the heading and its compact action aligned, including on narrow phones. */
main > .wp-block-group:has(> .humpf-shelves) .humpf-section-head {
	align-items: flex-end;
	flex-wrap: nowrap;
}

main > .wp-block-group:has(> .humpf-shelves) .humpf-more-link {
	flex-shrink: 0;
	white-space: nowrap;
}

@media (min-width: 600px) and (max-width: 1023px) {
	.humpf-shelves .wp-block-term-template {
		grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
	}

	.humpf-shelves .wc-block-featured-category {
		aspect-ratio: 16 / 9 !important;
	}

	.humpf-shelves .wp-block-woocommerce-category-title {
		font-size: var(--wp--preset--font-size--large) !important;
	}
}

/* Tablets have room for four compact shelves; avoid four oversized rows before arrivals. */
@media (min-width: 782px) and (max-width: 1023px) {
	.humpf-shelves .wp-block-term-template {
		grid-template-columns: repeat(4, minmax(0, 1fr)) !important;
	}

	.humpf-shelves .wc-block-featured-category {
		aspect-ratio: 1 !important;
	}

	/* Home collections contain four products, so keep the whole selection on one row. */
	.home .wp-block-woocommerce-product-template.humpf-grid:has(> :nth-child(4)):not(:has(> :nth-child(5))) {
		grid-template-columns: repeat(4, minmax(0, 1fr)) !important;
	}
}

@media (min-width: 1024px) {
	.humpf-shelves .wp-block-term-template {
		grid-template-columns: repeat(4, minmax(0, 1fr)) !important;
	}

	.humpf-shelves .wc-block-featured-category {
		aspect-ratio: 4 / 3 !important;
	}
}

@media (max-width: 599px) {
	/* Phones: a single row of tiles keeps New Arrivals within the first screen and a half. */
	main > .wp-block-group:has(> .humpf-shelves) {
		padding-top: var(--wp--preset--spacing--60) !important;
		padding-bottom: var(--wp--preset--spacing--40) !important;
	}

	.humpf-shelves .wp-block-term-template {
		display: flex !important;
		gap: var(--wp--preset--spacing--30) !important;
		box-sizing: border-box;
		width: calc(100% + var(--wp--style--root--padding-left) + var(--wp--style--root--padding-right));
		max-width: none;
		margin-inline: calc(-1 * var(--wp--style--root--padding-left));
		padding-inline: var(--wp--style--root--padding-left) max(var(--wp--style--root--padding-right), 2rem);
		padding-block: var(--wp--preset--spacing--10);
		overflow-x: auto;
		overscroll-behavior-x: contain;
		scroll-snap-type: x mandatory;
		scroll-padding-inline: var(--wp--style--root--padding-left, 1rem);
		scrollbar-width: none;
		mask-image: linear-gradient(90deg, transparent, #000 12px, #000 calc(100% - 24px), transparent);
	}

	.humpf-shelves .wp-block-term-template > li {
		flex: 0 0 52%;
		scroll-snap-align: start;
	}

	.humpf-shelves .wc-block-featured-category {
		aspect-ratio: 1 !important;
	}
}

/* =========================================================================
 * Layer-by-layer reveal (motion.js marks photos that start below the fold)
 * ====================================================================== */

.humpf-story__media,
.humpf-custom-work__media {
	position: relative;
	overflow: clip;
	border-radius: var(--wp--preset--border-radius--lg);
}

.humpf-print {
	clip-path: inset(100% 0 0 0);
}

/* A bright "nozzle" line rides the top edge of the printed part. */
.humpf-print::after {
	content: "";
	position: absolute;
	inset: 0;
	z-index: 3;
	background: linear-gradient(180deg, rgba(244, 241, 234, 0.95) 0 2px, rgba(244, 241, 234, 0.22) 2px 14px, rgba(244, 241, 234, 0) 14px);
	opacity: 0;
	pointer-events: none;
	transform: translateY(100%);
}

.humpf-print.is-printed {
	clip-path: inset(0);
	transition: clip-path 1.1s steps(18, end) var(--humpf-delay, 0ms);
}

.humpf-print.is-printed::after {
	animation: humpf-nozzle 1.1s steps(18, end) var(--humpf-delay, 0ms) both;
}

@keyframes humpf-nozzle {
	0% {
		opacity: 1;
		transform: translateY(100%);
	}

	90% {
		opacity: 1;
	}

	100% {
		opacity: 0;
		transform: translateY(0);
	}
}

/* =========================================================================
 * Made to Order story
 * ====================================================================== */

.humpf-story {
	position: relative;
	overflow: clip;
	view-timeline: --humpf-story block;
}

/* Oversized line that slides sideways as the section passes (decorative, hidden from screen readers). */
.humpf-story::before {
	content: "Made to Order ✦ Made to Order ✦ Made to Order ✦" / "";
	display: block;
	margin-bottom: var(--wp--preset--spacing--60);
	color: rgba(244, 241, 234, 0.06);
	-webkit-text-stroke: 1px rgba(230, 221, 207, 0.32);
	font-family: var(--wp--preset--font-family--manrope);
	font-size: clamp(4rem, 8vw, 7rem);
	font-weight: 800;
	letter-spacing: -0.04em;
	line-height: 0.9;
	text-transform: uppercase;
	white-space: nowrap;
}

.humpf-story .humpf-story__lede {
	max-width: 34rem;
}

/* Steps from order to door: numbered dots on a rail. */
.humpf-story .humpf-steps {
	position: relative;
	display: grid;
	gap: var(--wp--preset--spacing--40);
	margin: var(--wp--preset--spacing--20) 0 0;
	padding: 0;
	list-style: none;
	counter-reset: humpf-step;
	view-timeline: --humpf-steps block;
}

.humpf-story .humpf-steps::before,
.humpf-story .humpf-steps::after {
	content: "";
	position: absolute;
	top: 1.375rem;
	bottom: 1.375rem;
	left: calc(1.375rem - 1px);
	width: 2px;
	border-radius: 2px;
	background: var(--wp--preset--color--accent-6);
}

.humpf-story .humpf-steps::after {
	background: var(--wp--preset--color--accent-2);
	transform-origin: 50% 0;
}

.humpf-story .humpf-steps li {
	position: relative;
	z-index: 1;
	min-height: 2.75rem;
	margin: 0;
	padding-left: 4rem;
	color: var(--wp--preset--color--accent-4);
	counter-increment: humpf-step;
	view-timeline: --humpf-step block;
}

.humpf-story .humpf-steps li::before {
	content: counter(humpf-step, decimal-leading-zero);
	position: absolute;
	top: 0;
	left: 0;
	display: grid;
	place-items: center;
	box-sizing: border-box;
	width: 2.75rem;
	height: 2.75rem;
	border: 1px solid var(--wp--preset--color--accent-2);
	border-radius: 50%;
	background: var(--wp--preset--color--accent-2);
	color: var(--wp--preset--color--base);
	font-family: var(--wp--preset--font-family--fira-code);
	font-size: var(--wp--preset--font-size--x-small);
	font-weight: 600;
}

.humpf-story .humpf-steps strong {
	display: block;
	margin-bottom: 0.15rem;
	color: var(--wp--preset--color--contrast);
	font-size: var(--wp--preset--font-size--x-large);
	font-weight: 800;
	letter-spacing: -0.02em;
	line-height: 1.15;
}

/* =========================================================================
 * Custom and bulk band
 * ====================================================================== */

.humpf-custom-work {
	view-timeline: --humpf-band block;
}

/* Stacked sections need less decoration and shorter media on phones and tablets. */
@media (max-width: 781px) {
	.humpf-story::before {
		display: none;
	}

	.humpf-story .humpf-story__media img {
		aspect-ratio: 16 / 9 !important;
	}

	.humpf-story .humpf-steps strong {
		font-size: var(--wp--preset--font-size--large);
	}

	.humpf-story .wp-block-heading,
	.humpf-custom-work .wp-block-heading {
		text-wrap: balance;
	}
}

/* Join the trust strip to the footer without the default template-part gap. */
.wp-site-blocks > footer.wp-block-template-part {
	margin-top: 0;
}

/* =========================================================================
 * Scroll-linked moments (supporting browsers, motion allowed, effect switched on)
 * ====================================================================== */

@supports (animation-timeline: view()) {
	@media (prefers-reduced-motion: no-preference) {
		/* Hero: the footage drifts and darkens as the hero scrolls away; the words lift off. */
		body:not(.humpf-no-hero) .humpf-hero > .wp-block-cover__image-background {
			animation: humpf-settle 1.8s var(--humpf-ease-out) both, humpf-hero-media linear both;
			animation-timeline: auto, --humpf-hero;
			animation-range: normal, exit 0% exit 100%;
		}

		body:not(.humpf-no-hero) .humpf-hero > .humpf-film {
			animation: humpf-hero-media linear both;
			animation-timeline: --humpf-hero;
			animation-range: exit 0% exit 100%;
		}

		body:not(.humpf-no-hero) .humpf-hero.wp-block-cover::after {
			animation: humpf-fade-in linear both;
			animation-timeline: --humpf-hero;
			animation-range: exit 0% exit 90%;
		}

		body:not(.humpf-no-hero) .humpf-hero .humpf-hero__copy {
			animation: humpf-lift-off linear both;
			animation-timeline: --humpf-hero;
			animation-range: exit 5% exit 75%;
		}

		/* Story: the oversized line slides the whole time the section is on screen. */
		body:not(.humpf-no-story) .humpf-story::before {
			animation: humpf-slide linear both;
			animation-timeline: --humpf-story;
			animation-range: cover 0% cover 100%;
		}

		/* Step dots light up one after another; text stays at full contrast. */
		body:not(.humpf-no-story) .humpf-story .humpf-steps::after {
			animation: humpf-grow linear both;
			animation-timeline: --humpf-steps;
			animation-range: entry 60% cover 62%;
		}

		body:not(.humpf-no-story) .humpf-story .humpf-steps li::before {
			animation: humpf-step-dot linear both;
			animation-timeline: --humpf-step;
			animation-range: entry 100% cover 45%;
		}

		/* Custom band: grows from an inset card to the full width as it comes in. */
		body:not(.humpf-no-story) .humpf-custom-work {
			animation: humpf-band linear both;
			animation-timeline: --humpf-band;
			animation-range: entry 0% entry 80%;
		}
	}
}

@keyframes humpf-hero-media {
	to {
		transform: translateY(16%) scale(1.08);
	}
}

@keyframes humpf-fade-in {
	to {
		opacity: 0.75;
	}
}

@keyframes humpf-lift-off {
	to {
		transform: translateY(-3rem);
	}
}

@keyframes humpf-slide {
	from {
		transform: translateX(6%);
	}

	to {
		transform: translateX(-42%);
	}
}

@keyframes humpf-grow {
	from {
		transform: scaleY(0);
	}
}

/* The dot switches on halfway, like a light, so its number stays readable throughout. */
@keyframes humpf-step-dot {
	0%,
	49.9% {
		background: var(--wp--preset--color--accent-5);
		border-color: var(--wp--preset--color--accent-6);
		color: var(--wp--preset--color--accent-4);
	}

	50%,
	100% {
		background: var(--wp--preset--color--accent-2);
		border-color: var(--wp--preset--color--accent-2);
		color: var(--wp--preset--color--base);
	}
}

@keyframes humpf-band {
	from {
		clip-path: inset(0 5% 0 5% round 2rem);
	}

	to {
		clip-path: inset(0 0 0 0 round 0);
	}
}
