/* =============================================================================
   Product Hero — Figma "dati-principali-prodotto" 2018:49712 (399:301 "Prodotto v2").
   Token-only. 3 colonne uguali dentro .wrap (1340 utili, gap 20px).
   ============================================================================= */

.cmt-product-hero-block *,
.cmt-product-hero-block *::before,
.cmt-product-hero-block *::after {
	box-sizing: border-box;
}

.cmt-ph__row {
	display: flex;
	align-items: flex-start;
	gap: 20px;
	flex-wrap: wrap;
}

.cmt-ph__col {
	flex: 1 1 380px;
	min-width: 0;
}

/* ── WP core genera `.has-<slug>-font-size` per ogni fontSize di theme.json,
   ma kebab-izza gli slug con cifre (h1 → h-1): alias qui col nome "umano"
   usato dal render.php (stessa correzione di collection-grid/accordion-tabs). */
.cmt-ph-desc__title.has-display-font-size { font-size: var(--wp--preset--font-size--display); }
.cmt-ph-desc__title.has-h1-font-size      { font-size: var(--wp--preset--font-size--h-1); }
.cmt-ph-desc__title.has-h2-font-size      { font-size: var(--wp--preset--font-size--h-2); line-height: 1.2; }
.cmt-ph-desc__title.has-h3-font-size      { font-size: var(--wp--preset--font-size--h-3); line-height: 1.2; }
.cmt-ph-desc__title.has-body-l-font-size  { font-size: var(--wp--preset--font-size--body-l); line-height: 1.3; }
.cmt-ph-desc__title.has-body-m-font-size  { font-size: var(--wp--preset--font-size--body-m); line-height: 1.3; }
.cmt-ph-desc__title.has-caption-font-size { font-size: var(--wp--preset--font-size--caption); line-height: 1.3; }

/* =============================================================================
   COLONNA 1 — Gallery
   Miniature in una colonna riservata, separate dall'immagine principale.
   ============================================================================= */
.cmt-ph-gallery {
	display: grid;
	grid-template-columns: minmax(56px, 14%) minmax(0, 1fr);
	align-items: start;
	column-gap: 14px;
	width: 100%;
}

.cmt-ph-gallery__main {
	grid-column: 2;
	grid-row: 1;
	width: 100%;
	aspect-ratio: 416 / 524;
	border-radius: 2px;
	overflow: hidden;
	background: var(--wp--preset--color--bianco);
}

.cmt-ph-gallery__zoom-trigger {
	display: block;
	width: 100%;
	height: 100%;
	border: 0;
	padding: 0;
	background: transparent;
	cursor: zoom-in;
}

.cmt-ph-gallery__zoom-trigger:focus-visible,
.cmt-ph-gallery__zoom-close:focus-visible {
	outline: 3px solid var(--wp--preset--color--arancione);
	outline-offset: 3px;
}

.cmt-ph-gallery__main-img {
	display: block;
	width: 100%;
	height: 100%;
	object-fit: contain;
}

.cmt-ph-gallery__main-img--placeholder {
	background: var(--wp--preset--color--grigio-box);
}

@media (prefers-reduced-motion: no-preference) {
	.cmt-ph-gallery img.cmt-ph-gallery__main-img {
		animation: cmt-ph-image-enter 360ms ease-out;
	}
}

@keyframes cmt-ph-image-enter {
	from {
		opacity: 0.78;
		transform: translateY(6px);
	}
}

.cmt-ph-gallery__thumbs {
	grid-column: 1;
	grid-row: 1;
	position: static;
	width: 100%;
	display: flex;
	flex-direction: column;
	gap: 15px;
	max-height: 524px;
	overflow-y: auto;
	overflow-x: hidden;
	padding: 3px;
	margin: 0;
	list-style: none;
}

.cmt-ph-gallery__thumb {
	position: relative;
	display: block;
	width: 100%;
	aspect-ratio: 1;
	border: 0.5px solid var(--wp--preset--color--nero);
	border-radius: 2px;
	overflow: hidden;
	padding: 0;
	background: var(--wp--preset--color--bianco);
	cursor: pointer;
}

/* The component toggles the native hidden state when a variant filters its gallery. */
.cmt-ph-gallery__thumb[hidden] {
	display: none !important;
}

.cmt-ph-varianti__group[hidden] {
	display: none !important;
}

.cmt-ph-varianti[hidden] {
	display: none !important;
}

.cmt-ph-gallery__thumb-img {
	display: block;
	width: 100%;
	height: 100%;
	object-fit: cover;
}

.cmt-ph-gallery__thumb--active {
	outline: 2px solid var(--wp--preset--color--arancione);
	outline-offset: 1px;
}

.cmt-ph-gallery__zoom-dialog {
	box-sizing: border-box;
	position: fixed;
	inset: 0;
	width: min(94vw, 1200px);
	height: min(94vh, 1000px);
	max-width: none;
	max-height: none;
	margin: auto;
	padding: 56px 24px 24px;
	border: 0;
	border-radius: 4px;
	overflow: hidden;
	background: var(--wp--preset--color--bianco);
	color: var(--wp--preset--color--nero);
}

.cmt-ph-gallery__zoom-dialog:not([open]) {
	display: none;
}

.cmt-ph-gallery__zoom-dialog[open] {
	display: grid;
	grid-template-rows: auto minmax(0, 1fr);
}

.cmt-ph-gallery__zoom-dialog--original-size {
	display: block !important;
	overflow: auto;
}

.cmt-ph-gallery__zoom-dialog:focus-visible {
	outline: 3px solid var(--wp--preset--color--arancione);
	outline-offset: 3px;
}

.cmt-ph-gallery__zoom-dialog::backdrop {
	background: rgb(0 0 0 / 82%);
}

.cmt-ph-gallery__zoom-toolbar {
	position: sticky;
	top: 0;
	z-index: 2;
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 12px;
	width: 100%;
	background: var(--wp--preset--color--bianco);
}

.cmt-ph-gallery__zoom-size-toggle,
.cmt-ph-gallery__zoom-close {
	min-height: 44px;
	border: 1px solid currentColor;
	border-radius: 2px;
	background: var(--wp--preset--color--bianco);
	color: currentColor;
	cursor: pointer;
}

.cmt-ph-gallery__zoom-size-toggle {
	min-width: 44px;
	padding: 8px 12px;
	font: inherit;
}

.cmt-ph-gallery__zoom-close {
	width: 44px;
	flex: 0 0 44px;
	padding: 0;
	font-size: 32px;
	line-height: 1;
}

/* Outrank WooCommerce's .woocommerce img { height: auto; } inside the dialog. */
.cmt-ph-gallery__zoom-dialog .cmt-ph-gallery__zoom-image {
	display: block;
	width: 100%;
	height: 100%;
	min-width: 0;
	min-height: 0;
	max-width: 100%;
	max-height: 100%;
	object-fit: contain;
}

.cmt-ph-gallery__zoom-dialog--original-size .cmt-ph-gallery__zoom-image {
	width: auto;
	height: auto;
	max-width: none;
	max-height: none;
	object-fit: initial;
}

/* =============================================================================
   COLONNA 2 — Titolo, descrizione, varianti
   ============================================================================= */
.cmt-ph-desc {
	display: flex;
	flex-direction: column;
}

.cmt-ph-desc__title {
	margin: 0 0 31px;
	font-family: Poppins, sans-serif;
	font-weight: 500;
	line-height: 1.06;
	color: var(--wp--preset--color--nero);
}

.cmt-ph-desc__text-wrap {
	display: flex;
	flex-direction: column;
	align-items: flex-end;
	gap: 8px;
}

.cmt-ph-desc__text {
	margin: 0;
	width: 100%;
	font-family: Poppins, sans-serif;
	font-weight: 300;
	font-size: 18px;
	line-height: 22px;
	color: var(--wp--preset--color--nero);
	hyphens: auto;
	overflow-wrap: anywhere;
	display: -webkit-box;
	-webkit-line-clamp: 5;
	-webkit-box-orient: vertical;
	overflow: hidden;
}

.cmt-ph-desc__text--expanded {
	display: block;
	-webkit-line-clamp: unset;
	overflow: visible;
}

.cmt-ph-desc__toggle {
	display: inline;
	appearance: none;
	background: none;
	border: none;
	padding: 0;
	cursor: pointer;
	font-family: Poppins, sans-serif;
	font-weight: 600;
	font-size: 18px;
	color: #9c431a;
	text-decoration: underline;
	text-underline-offset: 0.18em;
}

.cmt-ph-desc__toggle::after {
	content: "";
	display: inline-block;
	width: 0.37em;
	height: 0.37em;
	margin: 0 0.15em 0.2em 0.5em;
	border: solid currentColor;
	border-width: 0 2px 2px 0;
	transform: rotate(45deg);
}

.cmt-ph-desc__toggle[aria-expanded="true"]::after {
	transform: rotate(225deg);
}

.cmt-ph-desc__toggle:hover {
	text-decoration-thickness: 2px;
}

.cmt-ph-desc__toggle:focus-visible {
	outline: 2px solid currentColor;
	outline-offset: 4px;
}

.cmt-ph-varianti {
	display: flex;
	flex-direction: column;
	gap: 24px;
	margin-top: 79px;
}

.cmt-ph-desc:not(:has(.cmt-ph-desc__text-wrap)) .cmt-ph-varianti {
	margin-top: 48px;
}

.cmt-ph-varianti__label {
	margin: 0 0 26px;
	font-family: Poppins, sans-serif;
	font-weight: 400;
	font-size: 16px;
	line-height: 18px;
	color: var(--wp--preset--color--nero);
	text-transform: uppercase;
}

.cmt-ph-varianti__options {
	display: flex;
	flex-wrap: wrap;
	gap: 6px;
}

.cmt-ph-varianti__opt {
	appearance: none;
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	width: auto;
	min-width: 49px;
	max-width: 100%;
	min-height: 49px;
	height: auto;
	padding: 8px;
	border: none;
	border-radius: 2px;
	background: var(--wp--preset--color--grigio-box);
	color: var(--wp--preset--color--nero);
	font-family: Poppins, sans-serif;
	font-size: 16px;
	line-height: 18px;
	text-align: center;
	white-space: normal;
	overflow-wrap: anywhere;
	transition: background 0.15s ease, color 0.15s ease;
}

.cmt-ph-varianti__opt:hover {
	background: color-mix(in srgb, var(--wp--preset--color--grigio-box) 70%, var(--wp--preset--color--arancione));
}

.cmt-ph-varianti__opt--active {
	background: var(--wp--preset--color--arancione);
	color: var(--wp--preset--color--bianco);
}

/* Specificità maggiorata: lo stato attivo deve restare arancione pieno anche
   con il mouse sopra (altrimenti :hover sopra vince e lo swatch appare slavato). */
.cmt-ph-varianti__opt.cmt-ph-varianti__opt--active,
.cmt-ph-varianti__opt.cmt-ph-varianti__opt--active:hover {
	background: var(--wp--preset--color--arancione);
	color: var(--wp--preset--color--bianco);
}

/* =============================================================================
   COLONNA 3 — Loghi, SKU, CTA, tabella specifiche
   ============================================================================= */
.cmt-ph-data {
	display: flex;
	flex-direction: column;
	gap: 34px;
}

.cmt-ph-data__top {
	display: flex;
	flex-direction: column;
	gap: 24px;
}

.cmt-ph-data__logos {
	display: flex;
	align-items: center;
	flex-wrap: wrap;
	gap: 20px 41px;
}

.cmt-ph-data__rating {
	display: flex;
	gap: 2px;
	flex-basis: 100%;
}

.cmt-ph-star {
	font-size: 20px;
	line-height: 1;
	color: var(--wp--preset--color--grigio-box);
}

.cmt-ph-star--on {
	color: var(--wp--preset--color--arancione);
}

.cmt-ph-data__linea-logo {
	display: block;
	max-width: 183px;
	max-height: 66px;
	width: auto;
	height: auto;
	object-fit: contain;
}

.cmt-ph-data__linea-label {
	font-family: Poppins, sans-serif;
	font-weight: 600;
	font-size: 16px;
	color: var(--wp--preset--color--nero);
	text-transform: uppercase;
}

/* Marchi e stelle dei soli tag ERP esplicitamente confermati, sopra lo SKU. */
.cmt-ph-data__feature-icons {
	display: flex;
	flex-direction: column;
	align-items: flex-start;
	gap: 8px;
}

.cmt-ph-data__feature-icons[hidden] {
	display: none;
}

.cmt-ph-data__feature-stars,
.cmt-ph-data__feature-brands {
	display: flex;
	align-items: center;
	flex-wrap: wrap;
	gap: 8px 14px;
}

/* La linea e la giga categoria occupano righe distinte sopra il codice. */
.cmt-ph-data__feature-brands {
	flex-direction: column;
	align-items: flex-start;
}

.cmt-ph-data__feature-stars[hidden],
.cmt-ph-data__feature-brands[hidden] {
	display: none;
}

.cmt-ph-data__feature-icon {
	display: block;
}

.cmt-ph-data__feature-icon .cmt-ph-data__tag-icon-img {
	max-width: 183px;
	max-height: 44px;
}

.cmt-ph-data__feature-icon--big .cmt-ph-data__tag-icon-img {
	max-height: 66px;
}

.cmt-ph-data__feature-rating {
	display: inline-flex;
	align-items: center;
}

.cmt-ph-data__feature-rating .cmt-ph-data__tag-icon-img {
	max-width: 183px;
	max-height: 36px;
	width: auto;
	height: auto;
	object-fit: contain;
	/* Recolor the white client artwork to CMT orange; CSS color filters preserve PNG alpha. */
	filter: invert(67.19%) sepia(69.41%) saturate(1440.85%) hue-rotate(352.47deg) brightness(137.99%) contrast(72.59%);
}

/* Le altre icone ERP restano sotto lo SKU, con proporzioni automatiche. */
.cmt-ph-data__tag-icons {
	display: flex;
	align-items: center;
	flex-wrap: wrap;
	gap: 9px 14px;
	margin-top: -14px;
}

.cmt-ph-data__tag-icons[hidden] {
	display: none;
}

.cmt-ph-data__tag-icon {
	display: grid;
	place-items: center;
	width: max-content;
	max-width: 100px;
	height: 40px;
	border-radius: 2px;
	overflow: visible;
}

.cmt-ph-data__tag-icon--big {
	width: 86px;
	height: 44px;
}

.cmt-ph-data__tag-icon-img {
	display: block;
	max-width: 100%;
	max-height: 100%;
	width: auto;
	height: auto;
	object-fit: contain;
}

.cmt-ph-data__tag-icon:not(.cmt-ph-data__tag-icon--big) .cmt-ph-data__tag-icon-img {
	width: auto;
	height: 40px;
	max-width: 100px;
	max-height: 40px;
	object-fit: contain;
}

@media (hover: hover) and (prefers-reduced-motion: no-preference) {
	.cmt-ph-data__tag-icon-img {
		transition: transform 0.2s ease;
	}

	.cmt-ph-data__tag-icon:hover .cmt-ph-data__tag-icon-img {
		transform: scale(1.12);
	}
}

.cmt-ph-data__tag-icon--big .cmt-ph-data__tag-icon-img {
	width: auto;
	height: auto;
	max-width: 86px;
	max-height: 34px;
	object-fit: contain;
}

.cmt-ph-data__badges {
	display: grid;
	grid-template-columns: repeat(3, 29px);
	grid-auto-rows: 29px;
	gap: 9px 14px;
}

.cmt-ph-data__badge {
	width: 29px;
	height: 29px;
	border-radius: 2px;
	overflow: hidden;
}

.cmt-ph-data__badge-img {
	display: block;
	width: 100%;
	height: 100%;
	object-fit: cover;
}

.cmt-ph-data__sku {
	display: inline-flex;
	align-items: center;
	align-self: flex-start;
	height: 30px;
	padding: 0 18px;
	border-radius: 2px;
	background: var(--wp--preset--color--arancione);
	color: var(--wp--preset--color--bianco);
	font-family: Poppins, sans-serif;
	font-weight: 500;
	font-size: 14px;
	white-space: nowrap;
}

.cmt-ph-data__california-warning {
	width: 147px;
	max-width: 100%;
}

.cmt-ph-data__california-warning img {
	display: block;
	width: 100%;
	height: auto;
}

.cmt-ph-varianti__opt:disabled {
	background: var(--wp--preset--color--grigio-box);
	color: #777;
	opacity: 0.65;
	cursor: not-allowed;
	text-decoration: line-through;
	text-decoration-thickness: 1px;
}

.cmt-ph-varianti__opt:disabled:hover {
	background: var(--wp--preset--color--grigio-box);
}

.cmt-ph-data__specs-title {
	margin: 0 0 15px;
	font-family: Poppins, sans-serif;
	font-weight: 400;
	font-size: 16px;
	color: var(--wp--preset--color--nero);
}

/* Compatibilità con i controlli colore del wrapper Gutenberg. Restano esclusi
   swatch, badge e CTA, i cui colori descrivono uno stato funzionale. */
.cmt-product-hero-block.has-text-color :where(
	.cmt-ph-desc__title,
	.cmt-ph-desc__text,
	.cmt-ph-varianti__label,
	.cmt-ph-data__linea-label,
	.cmt-ph-data__specs-title
) {
	color: inherit;
}

.cmt-product-hero-block.has-link-color :where(.cmt-ph-desc__toggle) {
	color: var(--wp--style--color--link, inherit);
}

.cmt-ph-data__ctas {
	display: flex;
	flex-wrap: wrap;
	gap: 16px;
}

/* ── prefers-reduced-motion ───────────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
	.cmt-ph-varianti__opt {
		transition: none;
	}
}

/* =============================================================================
   RESPONSIVE
   ============================================================================= */

/* Tablet: colonne su 2 file (gallery+desc affiancate, dati sotto a piena larghezza) */
@media (max-width: 1024px) {
	.cmt-ph__col {
		flex-basis: 45%;
	}
	.cmt-ph-data {
		flex-basis: 100%;
	}
}

/* Mobile: tutto impilato, gallery con thumbs in riga sotto l'immagine */
@media (max-width: 781px) {
	.cmt-ph__row {
		flex-direction: column;
	}
	.cmt-ph__col {
		flex-basis: auto;
		width: 100%;
	}

	.cmt-ph-gallery {
		display: flex;
		flex-direction: column;
		gap: 0;
	}

	.cmt-ph-gallery__main {
		order: 1;
		aspect-ratio: 1;
	}

	.cmt-ph-gallery__thumbs {
		order: 2;
		width: 100%;
		flex-direction: row;
		margin-top: 15px;
		max-height: none;
		overflow-x: auto;
		overflow-y: hidden;
		padding: 0 0 3px;
	}

	.cmt-ph-gallery__thumb {
		flex: 0 0 clamp(72px, 24vw, 120px);
	}

	.cmt-ph-gallery__zoom-dialog {
		width: 96vw;
		height: 92vh;
		padding: 54px 12px 12px;
	}

	.cmt-ph-varianti {
		margin-top: 40px;
	}

	.cmt-ph-data__badges {
		grid-template-columns: repeat(6, 29px);
	}
}

@media (max-width: 480px) {
	.cmt-ph-desc__title {
		font-size: 26px !important;
	}
	.cmt-ph-data__badges {
		grid-template-columns: repeat(4, 29px);
	}
}
