/*
 * NORTIA front page collection section (decision D41).
 *
 * Phone: two columns, the whole card is one large tap target.
 * Tablet: three columns. Desktop: four columns with a gentle editorial
 * offset on every second card, instead of a flat row of equal boxes
 * (DESIGN-DNA section 7).
 */

.collection {
	/* PROPOSAL: the color the hero's bottom edge shows at the end of the
	   film (sign scene + the hero's light shade), measured from the
	   last-frame posters: desktop #D9CBBE, phone #DCCEC0. */
	--collection-bridge-from: #DACCBF;

	position: relative;
	padding-block: var(--space-xl) var(--space-2xl);
}

/* Cream bridge: the top of the section starts in the hero's final wall
   tone and melts into the page color, so the edge between the film and
   the collection disappears. Shown only while the film is light or has
   ended: hero.js already sets "in-hero--light" on <html> (read here, no
   hero file changed). Without that class the bridge simply stays hidden.
   Opacity only; it sits behind the section's content. */
.collection::before {
	content: "";
	position: absolute;
	inset-inline: 0;
	inset-block-start: 0;
	block-size: clamp(6rem, 16svh, 11rem);
	background: linear-gradient(to bottom, var(--collection-bridge-from), var(--color-bg));
	opacity: 0;
	transition: opacity var(--duration-slow) var(--ease-out);
	pointer-events: none;
}

.in-hero--light .collection::before {
	opacity: 1;
}

.collection > .container {
	position: relative; /* above the bridge */
}

.collection:focus {
	outline: none; /* jump target of the hero button, not an interactive control */
}

/* The thread above the heading (base.css, "Thread"). */
.collection__thread {
	margin-block-end: var(--space-s);
}

.collection__title {
	margin-block: 0 var(--space-l);
	font-size: var(--text-2xl);
}

.collection__empty {
	margin-block: calc(-1 * var(--space-m)) var(--space-m);
	font-size: var(--text-sm);
	color: var(--color-text-muted);
}

.product-grid {
	display: grid;
	grid-template-columns: repeat(2, minmax(0, 1fr));
	gap: var(--space-l) var(--space-s);
	margin: 0 0 var(--space-l);
	padding: 0;
	list-style: none;
}

.product-card__link {
	display: grid;
	gap: var(--space-3xs);
	color: inherit;
	text-decoration: none;
}

.product-card__link:hover {
	color: inherit;
}

.product-card__media {
	position: relative; /* holds the curtain */
	display: block;
	aspect-ratio: 3 / 4;
	margin-block-end: var(--space-2xs);
	overflow: hidden;
	border-radius: var(--radius-s);
	background: var(--color-surface);
}

/* The whole photo is always shown, never cut: 3:4 photos (the shooting
   ratio) fill the frame exactly; other proportions sit whole on the
   plaster-colored ground of the frame. */
.product-card__image {
	width: 100%;
	height: 100%;
	object-fit: contain; /* the photo never moves, scales or is cut */
}

/* ---- "The wall opens" (assets/js/reveal.js) ---------------------------- */
/* A plaster-colored curtain over the photo, drawn upwards the first time
   the card scrolls into view. It exists only while reveal.js runs (class
   "nortia-reveal" on <html>): without JavaScript or with reduced motion
   the photos are simply visible. Only the curtain moves (transform); it is
   absolutely positioned inside the fixed 3:4 frame, so nothing shifts.

   Light edge: a thin warm line of light rides on the curtain's lower edge,
   like the crack of light in the wall in the film. It is part of the
   curtain's own background, so it costs nothing extra. The curtain slides
   up (translate) rather than shrinking, so the line stays crisp. */
.product-card__curtain {
	--crack-light: #F2D49B; /* PROPOSAL: warm light of the crack in the film's wall */
	position: absolute;
	inset: 0;
	background:
		linear-gradient(to top,
			var(--crack-light) 0,
			var(--crack-light) 1.5px,
			color-mix(in srgb, var(--crack-light) 45%, var(--color-surface)) 1.5px,
			var(--color-surface) 0.75rem);
	transform: translateY(-101%);
	pointer-events: none;
}

.nortia-reveal .product-card--reveal:not(.is-revealed) .product-card__curtain {
	transform: translateY(0);
}

/* Only the opening animates; covering the not-yet-seen cards when the
   page starts is instant (and happens below the screen).
   Phone: shorter and quicker. */
.nortia-reveal .product-card--reveal.is-revealed .product-card__curtain {
	transition: transform 550ms var(--ease-in-out) var(--reveal-delay, 0ms);
}

@media (min-width: 48rem) {
	.nortia-reveal .product-card--reveal.is-revealed .product-card__curtain {
		transition-duration: 750ms;
	}
}

@media (prefers-reduced-motion: reduce) {
	.product-card__curtain {
		display: none;
	}
}

/* Thread underline: a fine line draws itself under the product name from
   left to right, the same thread as above the heading. The photo itself
   never moves or scales. Mouse: on hover. Keyboard: on focus. Touch: while
   the finger is on the card. Transform only. */
.product-card__name {
	position: relative;
	justify-self: start; /* the line is as long as the name */
	font-size: var(--text-sm);
	letter-spacing: var(--tracking-label);
}

.product-card__name::after {
	content: "";
	position: absolute;
	inset-inline: 0;
	inset-block-end: -0.2em;
	block-size: 1px;
	background: currentColor;
	transform: scaleX(0);
	transform-origin: left center;
	transition: transform var(--duration-base) var(--ease-out);
	pointer-events: none;
}

.product-card__link:focus-visible .product-card__name::after,
.product-card__link:active .product-card__name::after {
	transform: scaleX(1);
}

/* Hover only for a real mouse; touch screens get no sticky hover. */
@media (hover: hover) and (pointer: fine) {
	.product-card__link:hover .product-card__name::after {
		transform: scaleX(1);
	}
}

.product-card__price {
	font-size: var(--text-sm);
	color: var(--color-text-muted);
}

/* Placeholder state: shapes only, no invented names, prices or images. */
.product-grid--placeholder .product-card {
	display: grid;
	gap: var(--space-2xs);
}

.product-card__bar {
	display: block;
	width: 70%;
	height: 0.75rem;
	border-radius: var(--radius-s);
	background: var(--color-surface);
}

.product-card__bar--short {
	width: 40%;
}

@media (min-width: 48rem) {
	.product-grid {
		grid-template-columns: repeat(3, minmax(0, 1fr));
		column-gap: var(--space-m);
	}
}

@media (min-width: 64rem) {
	.product-grid {
		grid-template-columns: repeat(4, minmax(0, 1fr));
	}

	.product-grid > :nth-child(even) {
		margin-block-start: var(--space-xl);
	}
}
