/**
 * Collections Grid block (blocks/content/collections-grid.php)
 *
 * Centered header + a full-width row of collection cards (image + gradient +
 * italic name + arrow). Cards fade/stagger in via GSAP; hover is CSS (image
 * zoom + arrow nudge).
 */

.dm-collections {
	padding-block: clamp(3rem, 6vw, 5.5rem);
}

/* ---- Header --------------------------------------------------------- */
.dm-collections__head {
	text-align: center;
	padding-inline: 16px;
	margin-bottom: clamp(1.5rem, 3vw, 2rem);
}

.dm-collections__heading {
	margin: 0;
	color: var(--dm-fg-default-primary);                      /* Semantics/fg/default/primary */
	font-family: var(--font-display, "IM Fell Double Pica", serif);
	font-weight: 400;
	font-style: normal;                  /* roman, per mockup */
	font-size: clamp(2.25rem, 4.2vw, 3.25rem); /* caps at Figma 52px */
	line-height: 1.1;                    /* 110% */
	letter-spacing: -0.02em;             /* -1.04px at 52px */
}

.dm-collections__intro {
	margin: 1.75rem auto 0;             /* slightly more space after the heading */
	max-width: 34rem;
	color: var(--dm-fg-default-primary);
	font-family: var(--font-display, "IM Fell Double Pica", serif);
	font-size: 20px;                     /* heading/h6 */
	font-weight: 400;
	line-height: 1.2;                    /* 120% → 24px */
}

/* ---- Cards row (full-width) ----------------------------------------- */
.dm-collections__grid {
	display: grid;
	grid-template-columns: repeat(4, 1fr);
	gap: clamp(0.75rem, 1.2vw, 1.25rem);
	padding-inline: 16px;                /* container gutter, matches other sections */
}

.dm-collections__card {
	position: relative;
	display: block;
	overflow: hidden;
	aspect-ratio: 354 / 443;             /* Figma card ratio; height stays auto */
	border-radius: 0.375rem;
	background: var(--color-forest, var(--dm-bg-default-tertiary));
	text-decoration: none;
	isolation: isolate;
}

.dm-collections__card-img {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	object-fit: cover;
	object-position: center;
	z-index: 0;
	transition: transform 0.6s cubic-bezier(0.22, 0.61, 0.36, 1);
}

/* Hover: the photo gives way to the collection's Zapotec pattern panel
   (assets/images/card-patterns/). The pattern colour cycles through the four
   panels by position, matching the `color` variant on the Figma card. */
.dm-collections__card::before {
	content: "";
	position: absolute;
	inset: 0;
	z-index: 1;
	background-image: var(--dm-card-pattern);
	background-size: cover;
	background-position: center;
	opacity: 0;
	transition: opacity 0.45s cubic-bezier(0.22, 0.61, 0.36, 1);
	pointer-events: none;
}

.dm-collections__card:nth-child(4n + 1) { --dm-card-pattern: url("../images/card-patterns/green.webp"); }
.dm-collections__card:nth-child(4n + 2) { --dm-card-pattern: url("../images/card-patterns/yellow.webp"); }
.dm-collections__card:nth-child(4n + 3) { --dm-card-pattern: url("../images/card-patterns/pink.webp"); }
.dm-collections__card:nth-child(4n + 4) { --dm-card-pattern: url("../images/card-patterns/blue.webp"); }

/* Gradient: transparent up top → dark at the base so the name/arrow read. */
.dm-collections__card-overlay {
	position: absolute;
	inset: 0;
	z-index: 2;
	pointer-events: none;
	background: linear-gradient(
		180deg,
		transparent 38%,
		color-mix(in srgb, var(--dm-ext-black) 28%, transparent) 62%,
		color-mix(in srgb, var(--dm-ext-black) 72%, transparent) 100%
	);
	transition: background 0.4s ease;
}

.dm-collections__card-footer {
	position: absolute;
	inset: auto 0 0 0;
	z-index: 3;
	display: flex;
	align-items: flex-end;
	justify-content: space-between;
	gap: 0.75rem;
	padding: clamp(1rem, 1.6vw, 1.5rem);
	color: var(--dm-fg-default-white);
}

.dm-collections__card-name {
	font-family: var(--font-display, "IM Fell Double Pica", serif);
	font-style: italic;                  /* heading/h5 italic */
	font-weight: 400;
	font-size: 24px;                     /* Figma 24px */
	line-height: 1.2;                    /* 120% → 28.8px */
	text-shadow: 0 1px 10px color-mix(in srgb, var(--dm-ext-black) 45%, transparent);
}

.dm-collections__card-arrow {
	flex: 0 0 auto;
	margin-bottom: 0.15rem;
	transition: transform 0.28s cubic-bezier(0.22, 0.61, 0.36, 1);
}

/* ---- Hover (CSS) ---------------------------------------------------- */
@media (hover: hover) {
	.dm-collections__card:hover::before,
	.dm-collections__card:focus-visible::before {
		opacity: 1;
	}

	.dm-collections__card:hover .dm-collections__card-img,
	.dm-collections__card:focus-visible .dm-collections__card-img {
		transform: scale(1.06);
	}

	.dm-collections__card:hover .dm-collections__card-arrow,
	.dm-collections__card:focus-visible .dm-collections__card-arrow {
		transform: translateX(5px);
	}

	.dm-collections__card:hover .dm-collections__card-overlay,
	.dm-collections__card:focus-visible .dm-collections__card-overlay {
		background: linear-gradient(
			180deg,
			transparent 30%,
			color-mix(in srgb, var(--dm-ext-black) 34%, transparent) 58%,
			color-mix(in srgb, var(--dm-ext-black) 78%, transparent) 100%
		);
	}
}

/* ---- Slider controls (progress + arrows) --------------------------- *
 * Hidden on desktop, where the section is a static grid. Shown on mobile,
 * where the grid becomes a horizontal peek-slider (see the mobile block). */
.dm-collections__controls {
	display: none;                       /* revealed at <=767px */
	align-items: center;
	justify-content: space-between;
	gap: 1.25rem;
	margin-top: 2rem;
	padding-inline: 16px;
}

.dm-collections__progress {
	position: relative;
	flex: 0 1 45%;
	height: 2px;
	background: color-mix(in srgb, var(--color-forest) 18%, transparent);
	border-radius: 2px;
	overflow: hidden;
}

.dm-collections__progress-thumb {
	position: absolute;
	top: 0;
	left: 0;
	height: 100%;
	width: 30%;                          /* set by JS from the visible fraction */
	background: var(--dm-bg-default-tertiary);
	border-radius: 2px;
	transition: left 0.15s ease, width 0.15s ease;
}

.dm-collections__arrows {
	display: flex;
	gap: 0.75rem;
	flex: 0 0 auto;
}

.dm-collections__arrow {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 52px;
	height: 52px;
	border: 1px solid var(--dm-border-default-dark-strong);
	border-radius: 999px;
	background: transparent;
	color: var(--dm-fg-default-primary);
	cursor: pointer;
}

/* ---- Responsive ----------------------------------------------------- */
/* Tablet: two-up grid (controls stay hidden). */
@media (min-width: 768px) and (max-width: 1024px) {
	.dm-collections__grid {
		grid-template-columns: repeat(2, 1fr);
		gap: 1rem;
	}
}

/* Mobile: horizontal peek-slider (one card + a peek of the next). */
@media (max-width: 767px) {
	.dm-collections {
		padding-top: 6rem;               /* more air above on mobile */
		padding-bottom: 4rem;            /* tighter below */
	}

	.dm-collections__grid {
		display: flex;
		grid-template-columns: none;     /* drop the grid; flex track instead */
		gap: 1rem;
		overflow-x: auto;
		overflow-y: hidden;
		scroll-snap-type: x mandatory;
		scroll-padding-left: 16px;
		scrollbar-width: none;           /* hide native scrollbar (Firefox) */
		-ms-overflow-style: none;
	}

	.dm-collections__grid::-webkit-scrollbar {
		display: none;                   /* hide native scrollbar (WebKit) */
	}

	.dm-collections__card {
		flex: 0 0 84%;                   /* one card + a peek of the next */
		scroll-snap-align: start;
	}

	.dm-collections__controls {
		display: flex;
	}

	/* Header aligns left on mobile (centered only on desktop). */
	.dm-collections__head {
		text-align: left;
		margin-bottom: clamp(2.2rem, 3vw, 2rem);
	}

	.dm-collections__intro {
		margin: 0.95rem auto 0;          /* tighter gap under the heading */
	}
}

/* ---- Small desktop (1280+): match the Figma board -------------------- *
 * Figma "Home Page - Small Desktop" > featured-products-container
 * (1987:16225): px-100 py-80, gap 40 between header and card row; header
 * gap 24 with a 500px intro; cards gap 16, radius 4, padding 24.
 * At 1280 that resolves to four 258px cards across the 1080 container.
 *
 * Must stay at the end of the file: a media query adds no specificity, so the
 * base rules above would otherwise win on source order. */
@media (min-width: 1024px) and (max-width: 1280.98px) {
	.dm-collections {
		padding-block: 80px;
	}

	.dm-collections__head {
		/* The capped 1080 container already provides Figma's 100px gutter. */
		padding-inline: 0;
		margin-bottom: 40px;
	}

	.dm-collections__intro {
		margin-top: 24px;
		max-width: 500px;
	}

	.dm-collections__grid {
		padding-inline: 0;
		gap: 16px;
	}

	.dm-collections__card {
		border-radius: 4px;             /* radius/r-xs */
	}

	.dm-collections__card-footer {
		gap: 16px;
		padding: 24px;
	}
}
