/*
 Produktseite: Bild | Titel, Auswahl, Gewährleistung | Kaufbox
 Die Hüllen .hy-pd-info und .hy-pd-buy setzt inc/hy-produktseite.php.
 Alle Regeln des neuen Aufbaus hängen an .hy-pd (Klasse am Hauptartikel) - die
 ähnlichen Produkte liegen im selben Container und bleiben unberührt.
*/

/* --- Auswahl: verknüpfte Varianten und Spiegelfelder (gilt in beiden Aufbauten) --- */

.hy-pd-auswahl {
	margin: 0 0 1rem;
	max-width: 26rem;
}

.hy-pd-auswahl-label {
	display: block;
	margin-bottom: .25rem;
	font-weight: 600;
}

.hy-varianten-wahl {
	position: relative;
}

.hy-varianten-knopf {
	overflow: hidden;
	text-align: left;
	text-overflow: ellipsis;
	white-space: nowrap;
	cursor: pointer;
}

.hy-varianten-liste {
	width: 100%;
	max-height: 22rem;
	overflow-y: auto;
}

.hy-varianten-liste .dropdown-item {
	display: flex;
	align-items: center;
	gap: .6rem;
	white-space: normal;
}

.hy-varianten-liste img {
	flex: none;
	width: 32px;
	height: 32px;
	object-fit: contain;
	background: #fff;
}

/* Spiegelfelder der WooCommerce-Varianten (aufklappbare Listen wie die verknüpften
   Varianten): erst sichtbar, wenn das Skript sie gefüllt hat. Bis dahin (und wenn das
   Skript ausfällt) bleibt die Auswahl in der Kaufbox stehen. */
.hy-pd-spiegel {
	display: none;
}

html.hy-varsel-on .hy-pd-spiegel {
	display: block;
}

html.hy-varsel-on .hy-pd-buy form.variations_form table.variations,
html.hy-varsel-on .hy-pd-buy form.variations_form .reset_variations {
	display: none;
}

/* Verfügbarkeit wie früher an den Varianten-Buttons (Customizer-CSS: 4 px grün/rot oben):
   oben am geschlossenen Feld für den gewählten Wert, links an jedem Eintrag der Liste.
   Grün = bestellbar (auch Nachbestellung), rot = nicht vorrätig. */
.hy-pd-spiegel .hy-varianten-knopf.hy-bestand-da {
	border-top: 4px solid green;
}

.hy-pd-spiegel .hy-varianten-knopf.hy-bestand-aus {
	border-top: 4px solid red;
}

.hy-pd-spiegel .hy-varianten-liste .dropdown-item {
	border-left: 4px solid transparent;
}

.hy-pd-spiegel .hy-varianten-liste .dropdown-item.hy-bestand-da {
	border-left-color: green;
}

.hy-pd-spiegel .hy-varianten-liste .dropdown-item.hy-bestand-aus {
	border-left-color: red;
}

/* --- Spalten --- */

.hy-pd .summary {
	display: flex;
	flex-direction: column;
}

/* Gestapelt (unter 1200 px) löst sich die Mittelspalte auf, damit die Kaufbox direkt
   nach Titel und Auswahl kommt und nicht erst hinter Artikeldaten und Kurzbeschreibung. */
.hy-pd .hy-pd-info {
	display: contents;
}

.hy-pd .hy-pd-info > * {
	order: 8;
}

.hy-pd .hy-pd-info > .product_title {
	order: 1;
}

.hy-pd .hy-pd-info > .hy-pd-kategorie,
.hy-pd .hy-pd-info > .woocommerce-product-rating {
	order: 2;
}

.hy-pd .hy-pd-info > .hy-pd-auswahl {
	order: 3;
}

.hy-pd .hy-pd-buy {
	order: 4;
}

.hy-pd .hy-pd-info > .product_meta {
	order: 5;
}

.hy-pd .hy-pd-info > .hy-pd-gewaehrleistung {
	order: 6;
}

.hy-pd .hy-pd-info > .woocommerce-product-details__short-description {
	order: 7;
}

/* Das Customizer-CSS versteckt lose <span> direkt in .summary; mit den Hüllen greift
   die Regel dort nicht mehr, deshalb hier dasselbe noch einmal. */
.hy-pd .hy-pd-info > span,
.hy-pd .hy-pd-buy > span {
	display: none;
}

@media (min-width: 1200px) {
	/* WooCommerce setzt seine 48 % mit #content im Selektor */
	.woocommerce #content div.product.hy-pd div.images {
		width: 38%;
	}

	.woocommerce #content div.product.hy-pd div.summary {
		display: grid;
		grid-template-columns: minmax(0, 1fr) 300px;
		column-gap: 1.75rem;
		align-items: start;
		width: 59%;
	}

	.hy-pd .hy-pd-info {
		display: block;
	}
}

/* --- Mittelspalte --- */

.woocommerce #content div.product.hy-pd .product_title {
	margin-bottom: .35rem;
	font-size: 1.6rem;
	line-height: 1.25;
}

.hy-pd .hy-pd-kategorie {
	margin-bottom: .75rem;
	font-size: .9rem;
}

.hy-pd .hy-pd-kategorie a {
	text-decoration: none;
}

.hy-pd .hy-pd-info .product_meta {
	margin-bottom: 1rem;
	font-size: .9rem;
}

/* Die Kategorien stehen schon unter dem Titel */
.hy-pd .hy-pd-info .product_meta .posted_in {
	display: none;
}

.hy-pd .hy-pd-gewaehrleistung {
	margin: 0 0 1rem;
	font-size: .9rem;
}

/* --- Kaufbox --- */

.hy-pd .hy-pd-buy {
	display: flex;
	flex-direction: column;
	margin: 0 0 1.25rem;
	padding: 1rem 1.1rem;
	border: 1px solid var(--bs-gray-300);
	background: var(--bs-gray-100);
}

.hy-pd .hy-pd-buy > * {
	order: 3;
}

.hy-pd .hy-pd-buy > .hy-pd-lager {
	order: 1;
	margin: 0 0 .15rem;
	font-weight: 600;
}

/* Lieferzeit (hy_pd_lieferzeit, ersetzt die Germanized-Zeile); Farbe aus style.css */
.hy-pd .hy-pd-buy > .hy-lieferzeit {
	order: 2;
	margin: 0 0 .6rem;
	font-weight: 600;
}

.hy-pd .hy-lager-da {
	color: green;
}

.hy-pd .hy-lager-nachbestellung {
	color: orange;
}

.hy-pd .hy-lager-aus {
	color: red;
}

/* Das Customizer-CSS zwingt .wc-gzd-additional-info auf display:block - leere
   Platzhalter von Germanized nähmen in der Spalte sonst Platz weg. */
.hy-pd .hy-pd-buy .wc-gzd-additional-info:empty,
.hy-pd .hy-pd-buy .wc-gzd-additional-info-placeholder,
.hy-pd .hy-pd-buy .wc-gzd-additional-info[aria-hidden="true"] {
	display: none !important;
}

.woocommerce div.product.hy-pd .hy-pd-buy p.price {
	margin: 0 0 .15rem;
	line-height: 1.15;
}

.woocommerce div.product.hy-pd .hy-pd-buy p.price:not(.price-unit) .woocommerce-Price-amount.amount {
	font-size: 2rem;
}

.woocommerce div.product.hy-pd .hy-pd-buy p.price:not(.price-unit) del .woocommerce-Price-amount.amount {
	font-size: 1rem;
	font-weight: 400;
}

.hy-pd .hy-pd-buy .legal-price-info p {
	margin: 0 0 .6rem;
	font-size: .85rem;
}

.woocommerce div.product.hy-pd .hy-pd-buy form.cart {
	display: flex;
	flex-direction: column;
	gap: .6rem;
	margin: .4rem 0 0;
}

.woocommerce div.product.hy-pd .hy-pd-buy form.cart::before,
.woocommerce div.product.hy-pd .hy-pd-buy form.cart::after {
	display: none;
}

.hy-pd .hy-pd-buy .woocommerce-variation-add-to-cart {
	display: flex;
	flex-direction: column;
	gap: .6rem;
}

.hy-pd .hy-pd-buy .woocommerce-variation.single_variation {
	margin-bottom: .6rem;
}

/* B2BKing legt die Staffeltabelle einer Variante in diesen Bereich; das Theme blendet
   ihn aus. Der Bestandstext darin bleibt über das Customizer-CSS versteckt. */
.hy-pd .hy-pd-buy .woocommerce-variation-availability {
	display: block;
}

/* Mengenregler */
.woocommerce div.product.hy-pd .hy-pd-buy form.cart div.quantity {
	float: none;
	width: 100%;
	margin: 0;
}

.hy-pd .hy-pd-buy .hy-menge {
	display: flex;
	align-items: stretch;
	border: 1px solid var(--bs-gray-400);
	background: #fff;
}

.hy-pd .hy-pd-buy .hy-menge input.qty {
	flex: 1 1 auto;
	width: auto;
	min-width: 0;
	margin: 0 !important;
	border: 0;
	border-radius: 0;
	box-shadow: none;
	text-align: center;
	-moz-appearance: textfield;
	appearance: textfield;
}

/* Das Feld selbst hat keinen Rahmen mehr, der Fokus zeigt sich am ganzen Regler */
.hy-pd .hy-pd-buy .hy-menge:focus-within {
	border-color: var(--bs-primary);
	box-shadow: 0 0 0 .2rem rgba(var(--bs-primary-rgb), .25);
}

.hy-pd .hy-pd-buy .hy-menge input.qty::-webkit-outer-spin-button,
.hy-pd .hy-pd-buy .hy-menge input.qty::-webkit-inner-spin-button {
	margin: 0;
	-webkit-appearance: none;
}

.hy-pd .hy-pd-buy .hy-menge-knopf {
	flex: 0 0 2.75rem;
	padding: 0;
	border: 0;
	background: transparent;
	color: var(--bs-primary);
	font-size: 1.35rem;
	line-height: 1;
	cursor: pointer;
}

.hy-pd .hy-pd-buy .hy-menge-knopf:hover {
	background: var(--bs-gray-200);
}

.hy-pd .hy-pd-buy .hy-menge-minus {
	border-right: 1px solid var(--bs-gray-400);
}

.hy-pd .hy-pd-buy .hy-menge-plus {
	border-left: 1px solid var(--bs-gray-400);
}

.woocommerce div.product.hy-pd .hy-pd-buy form.cart .single_add_to_cart_button {
	float: none;
	width: 100%;
	margin: 0;
	padding: .7rem 1rem;
	font-weight: 600;
}

/* Staffelpreise (B2BKing): bei einfachen Artikeln hängt die Tabelle hinter dem Knopf */
.hy-pd .hy-pd-buy form.cart > .b2bking_tiered_price_table {
	order: -1;
}

.hy-pd .hy-pd-buy .b2bking_tiered_price_table {
	width: 100%;
	margin: 0;
	border: 0;
	border-collapse: collapse;
	border-radius: 0;
	background: transparent;
	font-size: .9rem;
}

.hy-pd .hy-pd-buy .b2bking_tiered_price_table th {
	padding: .25rem .25rem .25rem 0;
	border: 0;
	border-bottom: 1px solid var(--bs-gray-400);
	font-size: .78rem;
	font-weight: 600;
}

.hy-pd .hy-pd-buy .b2bking_tiered_price_table td {
	padding: .3rem .25rem .3rem 0;
	border: 0;
	border-bottom: 1px solid var(--bs-gray-300);
}

.hy-pd .hy-pd-buy .b2bking_tiered_price_table th:last-child,
.hy-pd .hy-pd-buy .b2bking_tiered_price_table td:last-child {
	padding-right: 0;
	text-align: right;
}

/* Kontakt-Karte für Großbestellungen */
.hy-pd .hy-pd-buy > .card {
	margin-top: .9rem !important;
}

.hy-pd .hy-pd-buy > .card .card-body {
	padding: .6rem .75rem;
}

.hy-pd .hy-pd-buy > .card .card-text {
	font-size: .9rem !important;
}

/* --- Bild --- */

/* Quadratische Bildfläche: die senkrechte Leiste richtet sich nach der Bildhöhe und
   schrumpft bei Querformaten sonst auf wenige Pixel. */
.woocommerce div.product.hy-pd div.images .woocommerce-product-gallery__image img:not(.zoomImg) {
	aspect-ratio: 1 / 1;
	object-fit: contain;
}

@supports selector(:has(*)) {
	@media (min-width: 769px) {
		/* Der Abstand sitzt auf dem Galerie-Container: Flexslider misst in Firefox den
		   Container und nicht den sichtbaren Ausschnitt. */
		.woocommerce div.product.hy-pd div.images.woocommerce-product-gallery:has(.flex-control-thumbs) {
			padding-left: 84px;
		}

		.woocommerce div.product.hy-pd div.images.woocommerce-product-gallery .flex-control-thumbs {
			position: absolute;
			top: 0;
			bottom: 0;
			left: 0;
			display: flex;
			flex-direction: column;
			gap: 8px;
			width: 72px;
			overflow-x: hidden;
			overflow-y: auto;
			scrollbar-width: thin;
		}

		.woocommerce div.product.hy-pd div.images.woocommerce-product-gallery .flex-control-thumbs li {
			flex: none;
			float: none;
			clear: none;
			width: 100%;
		}

		.woocommerce div.product.hy-pd div.images.woocommerce-product-gallery .flex-control-thumbs li img {
			aspect-ratio: 1 / 1;
			object-fit: contain;
			border: 1px solid var(--bs-gray-300);
		}

		.woocommerce div.product.hy-pd div.images.woocommerce-product-gallery .flex-control-thumbs li img.flex-active {
			border-color: var(--bs-primary);
		}

		/* Das Angebots-Badge säße sonst auf dem ersten Vorschaubild */
		.woocommerce div.product.hy-pd:has(div.images .flex-control-thumbs) > .badge.sale {
			left: calc(84px + 1rem);
		}
	}
}
