/*
 * Beauty 09 — product catalogues (/cataloghi/ and /cataloghi/<slug>/).
 *
 * Markup: beauty09-core/includes/catalogs.php. Colours and fonts come from
 * the theme (theme.json presets), so a brand change travels by itself.
 * Screen first (mobile-first), then the A4 print / "Salva come PDF" layout.
 */

/* --- Page frame ----------------------------------------------------------
   The block layout's first-child rule zeroed a plain .b09-cat margin, so the
   cover sat on the header (audit 2026-11-17 B4-10). Same air as /news/. */
.b09-cat {
	margin-bottom: 1rem;
}
main.b09-cat-main > .b09-cat.alignwide {
	margin-block-start: var(--wp--preset--spacing--60);
}

/* --- Cover ----------------------------------------------------------------
   No cover image: a clean brand cover (logo, title, pink tint of the theme).
   With an image (chosen by the owner): the image sits beside the text. */
.b09-cat-cover {
	display: grid;
	gap: 1.75rem;
	align-items: center;
	padding: 2.5rem 1.25rem 2.25rem;
	border-radius: 28px;
	background:
		radial-gradient(40rem 24rem at 100% 0%, #fbd9e6 0%, rgba(251, 217, 230, 0) 70%),
		var(--wp--preset--color--accent-soft);
	text-align: center;
	overflow: hidden;
}
.b09-cat-cover-text {
	display: flex;
	flex-direction: column;
	align-items: center;
	min-width: 0;
}
.b09-cat-logo {
	display: block;
	width: 150px;
	max-width: 60%;
	height: auto;
	margin: 0 0 1.5rem;
}
/* The logo belongs to the printed cover: on screen it repeated the header's
   one, 110px lower (B4-14). Print rules below still show it. */
@media screen {
	.b09-cat-logo {
		display: none;
	}
}
.b09-cat-title {
	margin: 0;
	font-family: var(--wp--preset--font-family--heading);
	font-size: var(--wp--preset--font-size--xx-large); /* same H1 as every page (B4-15) */
	font-weight: 600;
	line-height: 1.1;
	overflow-wrap: anywhere;
}
.b09-cat-subtitle {
	margin: 0.75rem 0 0;
	font-size: 0.8125rem;
	font-weight: 600;
	letter-spacing: 0.12em;
	text-transform: uppercase;
	/* accent-strong: accent on the pink cover was 4.31:1 (3.75 on the glow). */
	color: var(--wp--preset--color--accent-strong, #c2004c);
}
.b09-cat-rule {
	display: block;
	width: 56px;
	height: 3px;
	margin: 1.1rem 0;
	border-radius: 3px;
	background: var(--wp--preset--color--accent);
}
.b09-cat-meta {
	margin: 0;
	font-size: var(--wp--preset--font-size--small);
	color: var(--wp--preset--color--slate);
}
/* "77 prodotti" never splits; on a phone date and count go on two lines
   instead of "… · 77 / prodotti" (B4-09). */
.b09-cat-meta > span:not(.b09-cat-meta-sep) {
	white-space: nowrap;
}
@media (max-width: 480px) {
	.b09-cat-meta > .b09-cat-meta-sep {
		display: none; /* same weight as the span rule below, or it wins */
	}
	.b09-cat-meta > span {
		display: block;
	}
}
.b09-cat-cover-media img {
	display: block;
	width: auto;
	max-width: 100%;
	height: auto;
	max-height: 440px;
	margin: 0 auto;
	border-radius: 14px;
	box-shadow: 0 18px 44px rgba(80, 104, 112, 0.18);
}

/* --- Action bar (screen only) ------------------------------------------- */
.b09-cat-actions {
	display: flex;
	flex-wrap: wrap;
	justify-content: center;
	align-items: center;
	gap: 0.75rem;
	margin: 1.5rem 0 0;
}
.b09-cat-btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 0.55rem;
	box-sizing: border-box;
	width: 100%;
	min-height: 50px;
	margin: 0;
	padding: 0.75rem 1.4rem;
	border: 0;
	border-radius: 999px;
	font-family: inherit;
	font-size: 1rem;
	font-weight: 600;
	line-height: 1.2;
	text-decoration: none;
	cursor: pointer;
	transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.b09-cat-btn svg {
	flex: none;
	width: 20px;
	height: 20px;
}
.b09-cat-btn.is-print {
	background: var(--wp--preset--color--accent);
	color: var(--wp--preset--color--base);
}
.b09-cat-btn.is-print:disabled {
	opacity: 0.7;
	cursor: progress;
}
.b09-cat-btn.is-wa {
	background: #25d366;
	color: var(--wp--preset--color--contrast, #1b1b1b); /* 8.68:1; white was 1.98:1 */
}
.b09-cat-btn.is-shop {
	background: var(--wp--preset--color--base);
	color: var(--wp--preset--color--accent);
	box-shadow: inset 0 0 0 2px var(--wp--preset--color--accent);
}
.b09-cat-btn[hidden],
.b09-cat-help[hidden] {
	display: none;
}
.b09-cat-help {
	flex-basis: 100%;
	margin: 0;
	font-size: 0.8125rem;
	text-align: center;
	color: var(--wp--preset--color--slate);
}
@media (hover: hover) {
	.b09-cat-btn:hover {
		transform: translateY(-2px);
		box-shadow: 0 10px 24px rgba(80, 104, 112, 0.18);
	}
	.b09-cat-btn.is-shop:hover {
		box-shadow: inset 0 0 0 2px var(--wp--preset--color--accent), 0 10px 24px rgba(80, 104, 112, 0.18);
	}
	.b09-cat-btn.is-print:hover {
		color: #fff;
	}
	.b09-cat-btn.is-wa:hover {
		color: var(--wp--preset--color--contrast, #1b1b1b);
	}
}

/* --- Intro and sections index ------------------------------------------- */
.b09-cat-intro {
	max-width: 720px;
	margin: 2rem auto 0;
	font-size: var(--wp--preset--font-size--medium);
	text-align: center;
	color: var(--wp--preset--color--slate);
}
.b09-cat-intro > :first-child {
	margin-top: 0;
}
.b09-cat-intro > :last-child {
	margin-bottom: 0;
}
.b09-cat-toc {
	display: flex;
	flex-wrap: wrap;
	justify-content: center;
	gap: 0.5rem;
	margin: 1.75rem 0 0;
}
.b09-cat-toc a {
	display: inline-flex;
	align-items: center;
	gap: 0.4rem;
	padding: 0.45rem 0.95rem;
	border-radius: 999px;
	background: var(--wp--preset--color--neutral);
	color: var(--wp--preset--color--contrast);
	font-size: var(--wp--preset--font-size--small);
	font-weight: 600;
	text-decoration: none;
}
.b09-cat-toc a span {
	font-weight: 400;
	color: var(--wp--preset--color--slate);
}

/* --- Sections and product cards ----------------------------------------- */
.b09-cat-group {
	margin-top: 2.5rem;
	scroll-margin-top: 96px; /* the sticky header */
}
.b09-cat-group-head {
	display: flex;
	flex-wrap: wrap;
	align-items: baseline;
	gap: 0.25rem 0.75rem;
	margin: 0 0 1rem;
	padding-bottom: 0.6rem;
	border-bottom: 2px solid var(--wp--preset--color--accent-soft);
}
.b09-cat-group-parent {
	flex-basis: 100%;
	margin: 0;
	font-size: 0.75rem;
	font-weight: 600;
	letter-spacing: 0.12em;
	text-transform: uppercase;
	color: var(--wp--preset--color--accent);
}
.b09-cat-group-title {
	margin: 0;
	font-size: var(--wp--preset--font-size--large);
}
.b09-cat-group-count {
	margin: 0;
	font-size: var(--wp--preset--font-size--small);
	color: var(--wp--preset--color--slate);
}
.b09-catalog-grid {
	display: grid;
	grid-template-columns: repeat(2, minmax(0, 1fr));
	gap: 0.75rem;
	margin: 0;
	padding: 0;
	list-style: none;
}
.b09-cat-item {
	position: relative;
	display: flex;
	flex-direction: column;
	margin: 0;
	overflow: hidden;
	border: 1px solid #eee;
	border-radius: 16px;
	background: var(--wp--preset--color--base);
	transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}
.b09-cat-media {
	aspect-ratio: 4 / 3;
	overflow: hidden;
	border-bottom: 1px solid #f3f3f3;
	background: var(--wp--preset--color--base);
}
.b09-cat-img {
	display: block;
	width: 100%;
	height: 100%;
	object-fit: contain;
}
/* The brand placeholder is a square: shown whole and a little smaller than
   the frame, so a catalogue still waiting for its photos reads as a grid of
   products, not as a wall of pink. */
.b09-cat-img.is-placeholder {
	box-sizing: border-box;
	padding: 6%;
	object-fit: contain;
}
.b09-cat-body {
	display: flex;
	flex-direction: column;
	gap: 0.3rem;
	padding: 0.75rem 0.8rem 0.9rem;
}
.b09-cat-sku {
	margin: 0;
	font-size: 0.75rem;
	font-weight: 700;
	letter-spacing: 0.03em;
	color: var(--wp--preset--color--accent);
	overflow-wrap: anywhere;
}
.b09-cat-sku-label {
	font-weight: 600;
	color: var(--wp--preset--color--slate);
}
.b09-catalog-name {
	margin: 0;
	font-family: var(--wp--preset--font-family--body);
	font-size: 0.875rem;
	font-weight: 600;
	line-height: 1.3;
	overflow-wrap: anywhere;
}
.b09-catalog-name a {
	color: var(--wp--preset--color--contrast);
	text-decoration: none;
}
/* The whole card opens the product page. */
.b09-catalog-name a::after {
	content: "";
	position: absolute;
	inset: 0;
}
.b09-catalog-name a:focus-visible {
	outline: none;
}
/* Same keyboard ring as the rest of the site; :focus-within also lit up on
   mouse clicks. */
.b09-cat-item:has(.b09-catalog-name a:focus-visible) {
	outline: 3px solid var(--wp--preset--color--contrast, #1b1b1b);
	outline-offset: 3px;
}
.b09-cat-desc {
	display: -webkit-box;
	margin: 0;
	overflow: hidden;
	font-size: 0.8125rem;
	line-height: 1.45;
	color: var(--wp--preset--color--slate);
	-webkit-line-clamp: 4;
	-webkit-box-orient: vertical;
}
.b09-cat-empty,
.b09-cat-index-empty {
	margin: 2.5rem 0;
	text-align: center;
	color: var(--wp--preset--color--slate);
}
@media (hover: hover) {
	.b09-cat-item:hover {
		transform: translateY(-3px);
		border-color: transparent;
		box-shadow: 0 14px 32px rgba(80, 104, 112, 0.14);
	}
}

@media (min-width: 640px) {
	.b09-catalog-grid {
		grid-template-columns: repeat(3, minmax(0, 1fr));
		gap: 1rem;
	}
	.b09-cat-btn {
		width: auto;
	}
}

@media (min-width: 782px) {
	.b09-cat-cover {
		padding: 3.5rem 3rem;
	}
	.b09-cat-cover.has-image {
		grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
		text-align: left;
	}
	.b09-cat-cover.has-image .b09-cat-cover-text {
		align-items: flex-start;
	}
}

@media (min-width: 1024px) {
	.b09-catalog-grid {
		grid-template-columns: repeat(4, minmax(0, 1fr));
		gap: 1.25rem;
	}
	.b09-catalog-name {
		font-size: 0.9375rem;
	}
}

/* --- Index /cataloghi/: the shop cards plus a "Sfoglia" pill ------------ */
.b09-cat-index {
	margin-top: 1rem;
}
.b09-cat-card-go {
	align-self: flex-start;
	margin-top: 0.4rem;
	padding: 0.25rem 0.8rem;
	border-radius: 999px;
	background: var(--wp--preset--color--accent);
	color: var(--wp--preset--color--base);
	font-size: 0.8125rem;
	font-weight: 600;
	line-height: 1.4;
}
/* Phone: the shop card's arrow is the one invitation, like in the shop; the
   "Sfoglia" pill takes over from 782px, where the arrow is hidden (B4-17). */
@media (max-width: 781px) {
	.b09-cat-card-go {
		display: none;
	}
}
.b09-cat-index .b09-shop-card-media img {
	object-fit: contain;
	background: var(--wp--preset--color--accent-soft);
}

/* --- Closing of a catalogue: shop, share and the way back (B4-11) ------- */
.b09-cat-end {
	display: flex;
	flex-wrap: wrap;
	justify-content: center;
	align-items: center;
	gap: 0.75rem;
	margin: var(--wp--preset--spacing--70) 0 0;
	padding-top: var(--wp--preset--spacing--50);
	border-top: 2px solid var(--wp--preset--color--accent-soft);
}
.b09-cat-back {
	flex-basis: 100%;
	display: inline-block;
	padding-block: 0.85rem; /* 44px hit area */
	text-align: center;
	font-weight: 600;
	text-decoration: none;
	color: var(--wp--preset--color--accent);
}

/* =========================================================================
 * Print and "Salva come PDF" — A4, light, no decoration
 * =========================================================================
 * Page 1: the cover alone. Then a 3-column grid of cards that never break
 * across two pages, section titles that never stay alone at the bottom of a
 * page. Site header/footer, action bar, WhatsApp button and admin bar out.
 */
@media print {
	@page {
		size: A4;
		margin: 14mm 12mm 16mm;

		@bottom-left {
			font-family: "Figtree", sans-serif;
			font-size: 8pt;
			color: #506870;
		}
		@bottom-right {
			content: counter(page) " / " counter(pages);
			font-family: "Figtree", sans-serif;
			font-size: 8pt;
			color: #506870;
		}
	}
	@page :first {
		@bottom-left {
			content: none;
		}
		@bottom-right {
			content: none;
		}
	}

	html,
	body {
		background: #fff !important;
	}
	html {
		margin-top: 0 !important; /* admin bar offset */
	}
	* {
		-webkit-print-color-adjust: exact;
		print-color-adjust: exact;
	}

	#wpadminbar,
	.wp-site-blocks > header,
	.wp-site-blocks > footer,
	header.wp-block-template-part,
	footer.wp-block-template-part,
	.b09-whatsapp-fab,
	.b09-cat-actions,
	.b09-cat-end,
	.b09-cat-toc,
	.b09-cat-main .wp-block-spacer {
		display: none !important;
	}
	.wp-site-blocks,
	.b09-cat-main {
		margin: 0 !important;
		padding: 0 !important;
	}
	.b09-cat {
		width: 100% !important;
		max-width: none !important;
		margin: 0 !important;
		font-size: 9pt;
	}

	/* Cover: the whole first page. */
	.b09-cat-cover {
		display: flex;
		flex-direction: column;
		justify-content: center;
		align-items: center;
		gap: 10mm;
		box-sizing: border-box;
		height: 258mm;
		padding: 18mm 14mm;
		border-radius: 6mm;
		text-align: center;
		break-after: page;
		page-break-after: always;
		break-inside: avoid;
	}
	.b09-cat-cover.has-image .b09-cat-cover-text {
		align-items: center;
	}
	.b09-cat-logo {
		width: 62mm;
		max-width: none;
		margin-bottom: 12mm;
	}
	.b09-cat-title {
		font-size: 34pt;
	}
	.b09-cat-subtitle {
		margin-top: 4mm;
		font-size: 10pt;
	}
	.b09-cat-rule {
		margin: 7mm 0;
	}
	.b09-cat-meta {
		font-size: 11pt;
	}
	.b09-cat-cover-media img {
		max-height: 120mm;
		box-shadow: none;
	}

	.b09-cat-intro {
		max-width: none;
		margin: 0 0 6mm;
		font-size: 10pt;
		text-align: left;
	}
	.b09-cat-group {
		margin-top: 7mm;
	}
	.b09-cat-intro + .b09-cat-group,
	.b09-cat-cover + .b09-cat-actions + .b09-cat-group,
	.b09-cat-cover + .b09-cat-group {
		margin-top: 0;
	}
	.b09-cat-group-head {
		margin-bottom: 4mm;
		padding-bottom: 1.5mm;
		break-after: avoid;
		page-break-after: avoid;
		break-inside: avoid;
	}
	.b09-cat-group-title {
		font-size: 15pt;
	}
	.b09-cat-group-count,
	.b09-cat-group-parent {
		font-size: 8pt;
	}

	.b09-catalog-grid {
		grid-template-columns: repeat(3, minmax(0, 1fr));
		gap: 4mm;
	}
	.b09-cat-item {
		border: 0.3mm solid #e2e2e2;
		border-radius: 3mm;
		box-shadow: none !important;
		transform: none !important;
		break-inside: avoid;
		page-break-inside: avoid;
	}
	.b09-cat-media {
		aspect-ratio: auto;
		height: 32mm;
	}
	.b09-cat-img {
		height: 32mm;
		max-height: 32mm;
	}
	.b09-cat-body {
		gap: 1mm;
		padding: 2.5mm 3mm 3mm;
	}
	.b09-cat-sku {
		font-size: 7.5pt;
	}
	.b09-catalog-name {
		font-size: 8.5pt;
	}
	.b09-cat-desc {
		display: block;
		overflow: visible;
		font-size: 7.5pt;
		-webkit-line-clamp: unset;
	}
}
