/* ==========================================================================
   Product portfolio
   One composed unit on one grid: heading and intro stacked, ten entries that
   each carry their own ingredient photo, then the further product groups as a
   quieter layer. All spacing comes from the scale in tokens.css.
   ========================================================================== */

.ph-portfolio {
	--ph-sec-muted: rgb(var(--ph-deep-rgb) / 0.78);
	--ph-sec-line: rgb(var(--ph-deep-rgb) / 0.14);
	--ph-sec-line-strong: rgb(var(--ph-deep-rgb) / 0.28);
	--ph-sec-wash: rgb(var(--ph-forest-rgb) / 0.05);
	--ph-thumb: clamp(4.5rem, 3.5rem + 3.5vw, 7rem);

	padding-block: var(--ph-section-space);
	background: var(--ph-ivory);
	color: var(--ph-deep);
}

/* Head
   ========================================================================== */

.ph-portfolio__head {
	display: grid;
	gap: var(--ph-stack-space);
	justify-items: center; /* section heads are centred on the page */
	text-align: center;
	margin-bottom: var(--ph-block-space);
}

.ph-portfolio__title {
	font-size: var(--ph-fs-h2);
	font-weight: var(--ph-fw-display);
	letter-spacing: -0.022em;
	line-height: 1.08;
	text-wrap: balance;
}

.ph-portfolio__intro {
	max-width: 58ch;
	font-size: var(--ph-fs-lead);
	line-height: 1.6;
	color: var(--ph-sec-muted);
	text-wrap: balance;
}

/* Source grid: a large photo and the name, nothing else on the card
   Two even rows of five on desktop keep the 270px source photos near their
   own size; two columns on tablets and phones, one on very small screens.
   ========================================================================== */

.ph-src {
	display: grid;
	align-content: start;
	gap: var(--ph-space-l) var(--ph-space-m);
	margin: 0;
	padding: 0;
	list-style: none;
}

@media (min-width: 30rem) {
	.ph-src {
		grid-template-columns: repeat(2, minmax(0, 1fr));
	}
}

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

.ph-src__item {
	display: grid;
	align-content: start;
	justify-items: start;
	gap: var(--ph-space-3xs);
}

/* One treatment for all ten photos: the same 4:5 crop, softened colour and
   a fine inner hairline. */
.ph-src__photo,
.ph-src__dialog-photo {
	position: relative;
	width: 100%;
	aspect-ratio: 4 / 5;
	overflow: hidden;
	background: var(--ph-sec-wash);
}

.ph-src__photo {
	margin-bottom: var(--ph-space-xs);
}

.ph-src__photo img,
.ph-src__dialog-photo img {
	width: 100%;
	height: 100%;
	object-fit: cover;
	filter: saturate(0.8);
}

.ph-src__photo img {
	transition: transform 1.2s var(--ph-ease-out);
}

.ph-src__photo::after,
.ph-src__dialog-photo::after {
	content: "";
	position: absolute;
	inset: 0;
	box-shadow: inset 0 0 0 1px rgb(var(--ph-deep-rgb) / 0.08);
	pointer-events: none;
}

.ph-src__name {
	font-size: var(--ph-fs-h3);
	font-weight: var(--ph-fw-heading);
	letter-spacing: -0.01em;
	line-height: 1.2;
}

/* "View details +": quiet text, a line grows under it on hover or focus. */
.ph-src__open {
	position: relative;
	display: inline-flex;
	align-items: center;
	gap: var(--ph-space-2xs);
	min-height: var(--ph-tap);
	padding: 0;
	border: 0;
	background: none;
	color: var(--ph-sec-muted);
	font-family: var(--ph-font-body);
	font-size: var(--ph-fs-nav);
	cursor: pointer;
	transition: color var(--ph-dur-base) var(--ph-ease-out);
}

.ph-src__open::after {
	content: "";
	position: absolute;
	left: 0;
	right: 0;
	bottom: var(--ph-space-xs);
	height: 1px;
	background: currentColor;
	transform: scaleX(0);
	transform-origin: left center;
	transition: transform var(--ph-dur-slow) var(--ph-ease-out);
}

.ph-src__plus {
	font-family: var(--ph-font-heading);
	font-size: 1.25em;
	font-weight: var(--ph-fw-display);
	line-height: 1;
	color: var(--ph-forest);
}

.ph-src__open:hover,
.ph-src__open:focus-visible {
	color: var(--ph-deep);
}

.ph-src__open:hover::after,
.ph-src__open:focus-visible::after {
	transform: scaleX(1);
}

/* With JavaScript the photo and name open the details too. */
.ph-src__item.is-clickable .ph-src__photo,
.ph-src__item.is-clickable .ph-src__name {
	cursor: pointer;
}

@media (hover: hover) {
	.ph-src__item:hover .ph-src__photo img {
		transform: scale(1.025);
	}
}

/* Details dialog
   ========================================================================== */

.ph-src__dialog {
	width: min(100% - var(--ph-gutter) * 2, 56rem);
	max-width: none;
	max-height: calc(100svh - var(--ph-gutter) * 2);
	padding: 0;
	border: 0;
	background: var(--ph-ivory);
	color: var(--ph-deep);
	overflow: auto;
}

.ph-src__dialog::backdrop {
	background: rgb(var(--ph-deep-rgb) / 0.55);
}

.ph-src__dialog[open] {
	animation: ph-src-in 0.9s var(--ph-ease-out);
}

.ph-src__dialog[open]::backdrop {
	animation: ph-src-fade 0.9s var(--ph-ease-out);
}

html:has(.ph-src__dialog[open]) {
	overflow: hidden;
}

.ph-src__panel {
	display: grid;
}

.ph-src__dialog-photo {
	aspect-ratio: 16 / 10;
}

.ph-src__body {
	display: grid;
	align-content: start;
	gap: var(--ph-stack-space);
	padding: var(--ph-space-m);
}

@media (min-width: 40rem) {
	.ph-src__panel {
		grid-template-columns: minmax(0, 5fr) minmax(0, 7fr);
	}

	.ph-src__dialog-photo {
		aspect-ratio: 4 / 5;
	}

	.ph-src__body {
		padding: var(--ph-space-l);
	}
}

.ph-src__close {
	justify-self: end;
	min-height: var(--ph-tap);
	margin: calc(var(--ph-space-xs) * -1) 0 var(--ph-space-xs);
	padding: 0;
	border: 0;
	border-bottom: 1px solid var(--ph-sec-line-strong);
	background: none;
	color: var(--ph-deep);
	font-family: var(--ph-font-body);
	font-size: var(--ph-fs-nav);
	cursor: pointer;
}

.ph-src__close:hover,
.ph-src__close:focus-visible {
	border-bottom-color: var(--ph-deep);
}

.ph-src__title {
	font-family: var(--ph-font-heading);
	font-size: clamp(1.75rem, 1.45rem + 1.2vw, 2.5rem);
	font-weight: var(--ph-fw-display);
	letter-spacing: -0.022em;
	line-height: 1.1;
}

.ph-src__text {
	max-width: 46ch;
	font-size: var(--ph-fs-lead);
	line-height: 1.6;
	color: var(--ph-sec-muted);
}

/* Without JavaScript the details sit under each card as plain text. */
.no-js .ph-src__open,
.no-js .ph-src__close,
.no-js .ph-src__dialog-photo,
.no-js .ph-src__title {
	display: none;
}

.no-js .ph-src__dialog {
	position: static;
	display: block;
	width: auto;
	background: none;
}

.no-js .ph-src__panel {
	display: block;
}

.no-js .ph-src__body {
	padding: 0;
}

.no-js .ph-src__text {
	font-size: var(--ph-fs-text);
}

@keyframes ph-src-in {
	from {
		opacity: 0;
		transform: translateY(6px);
	}

	to {
		opacity: 1;
		transform: none;
	}
}

@keyframes ph-src-fade {
	from {
		opacity: 0;
	}
}

@media (prefers-reduced-motion: reduce) {
	.ph-src__dialog[open],
	.ph-src__dialog[open]::backdrop {
		animation: none;
	}
}

/* Further product groups: the same quiet language as the cards, names on
   a hairline, no panel.
   ========================================================================== */

.ph-groups {
	margin-top: var(--ph-block-space);
}

.ph-groups__title {
	margin-bottom: var(--ph-space-m);
	font-size: clamp(1.375rem, 1.2rem + 0.7vw, 1.75rem);
	font-weight: var(--ph-fw-display);
	letter-spacing: -0.015em;
	line-height: 1.15;
}

.ph-groups__list {
	display: grid;
	gap: var(--ph-space-m);
	margin: 0;
	padding: 0;
	list-style: none;
}

/* align-content keeps every name and description on the same top lines. */
.ph-groups__item {
	display: grid;
	align-content: start;
	gap: var(--ph-space-2xs);
	padding-top: var(--ph-space-s);
	border-top: 1px solid var(--ph-sec-line-strong);
}

.ph-groups__name {
	font-size: var(--ph-fs-h3);
	font-weight: var(--ph-fw-heading);
	letter-spacing: -0.01em;
	line-height: 1.2;
}

.ph-groups__text {
	max-width: 44ch;
	font-size: var(--ph-fs-text);
	line-height: 1.6;
	color: var(--ph-sec-muted);
}

@media (min-width: 64rem) {
	.ph-groups__list {
		grid-template-columns: repeat(3, minmax(0, 1fr));
		column-gap: var(--ph-space-l);
	}
}
