/**
 * AS Frequently Bought Together - Frontend Styles
 *
 * Bewusst schlank gehalten und ohne harte Farbwerte: Farben werden, wo
 * verfuegbar, von Blocksy/WooCommerce CSS-Variablen uebernommen. Der
 * Warenkorb-Button nutzt die vorhandene WooCommerce ".button"-Klasse, damit
 * das Theme-Button-Styling automatisch greift.
 */

/**
 * Blocksy rendert Produktgalerie, unseren Block und ".entry-summary" als
 * gleichrangige Geschwister in ".product-entry-wrapper". Die Theme-Regeln
 * dazu stammen aus gallery-common.scss und sind dort unter
 * ".ct-default-gallery, .ct-stacked-gallery" verschachtelt - die
 * kompilierten Selektoren (".ct-default-gallery .product-entry-wrapper" etc.)
 * haben dadurch ZWEI Klassen (Spezifitaet 0,2,0), waehrend unsere
 * Ein-Klassen-Selektoren (0,1,0) im Spezifitaets-Vergleich automatisch
 * verlieren und wirkungslos bleiben. Deshalb hier gezielt "!important" nur
 * auf den drei tatsaechlich konkurrierenden Eigenschaften (display, width,
 * margin-inline-start) - alle anderen Grid-Eigenschaften sind neu und
 * brauchen das nicht. Keine Theme-Datei wird veraendert.
 */

.woocommerce-product-gallery {
	--header-sticky-height-animated: none !important;
}

/*
 * Mobil (unterhalb der Grid-Breite weiter unten) rendert Blocksy
 * ".product-entry-wrapper" nicht als Flex-/Grid-Container, sondern als
 * normalen Block - die drei Geschwister stapeln sich dort einfach in
 * Dokumentreihenfolge (Galerie, unser Block, Summary). Damit der Set-Block
 * dort stattdessen NACH der Zusammenfassung erscheint, machen wir den
 * Wrapper hier zu einem simplen Flex-Stack mit "order" - oberhalb der
 * Grid-Breite hat "grid-area" (siehe Media Query unten) Vorrang vor "order",
 * die Werte hier stören das Grid-Layout also nicht.
 */
.product-entry-wrapper {
	display: flex;
	flex-direction: column;
}

.product-entry-wrapper > .woocommerce-product-gallery {
	order: 1;
}

.product-entry-wrapper > .summary.entry-summary {
	order: 2;
}

.product-entry-wrapper > .as-fbt {
	order: 3;
}

@media (min-width: 789px) {
	.product-entry-wrapper {
		display: grid !important;
		grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
		grid-template-areas:
			"gallery summary"
			"fbt summary";
		column-gap: 40px;
		align-items: start;
	}

	.product-entry-wrapper > .woocommerce-product-gallery {
		grid-area: gallery;
		width: auto !important;
	}

	.product-entry-wrapper > .as-fbt {
		grid-area: fbt;
		width: auto;
	}

	.product-entry-wrapper > .summary.entry-summary {
		grid-area: summary;
		width: auto !important;
		margin-inline-start: 0 !important;
	}
}

.as-fbt {
	margin: 2em 0;
	padding: 1.25em;
	border: 1px solid var(--theme-border-color, #e2e2e2);
	border-radius: var(--theme-card-border-radius, 6px);
	background: var(--theme-block-background-color, transparent);
}

.as-fbt__title {
	margin: 0 0 0.25em;
	font-size: 1.15em;
	color: var(--heading-color, inherit);
}

.as-fbt__subtitle {
	margin: 0 0 1em;
	color: var(--paragraph-color, inherit);
	opacity: 0.8;
}

.as-fbt__items {
	display: flex;
	flex-wrap: wrap;
	gap: 1em;
	align-items: stretch;
}

.as-fbt__item {
	flex: 1 1 180px;
	min-width: 150px;
	max-width: 220px;
}

.as-fbt__card {
	display: flex;
	flex-direction: column;
	height: 100%;
	background: #fff;
	border-radius: var(--theme-card-border-radius, 8px);
	overflow: hidden;
}

.as-fbt__card-image {
	position: relative;
	background-color: #f5f5f5;
	aspect-ratio: 1 / 1;
	display: flex;
	align-items: center;
	justify-content: center;
}

/* Checkbox oben rechts über dem Kartenbild (nicht neben dem Titel) - der
   Titel ist per label[for] mit dieser Checkbox verknüpft, siehe
   render_item_card() in class-as-fbt-frontend.php. */
.as-fbt__card-image input[type="checkbox"] {
	position: absolute;
	top: 0.6em;
	right: 0.6em;
	z-index: 2;
	margin: 0;
	width: 20px;
	height: 20px;
}

.as-fbt__card-image img {
	width: 100%;
	height: 100%;
	object-fit: contain;
}

.as-fbt__plus {
	display: flex;
	align-items: center;
	justify-content: center;
	flex: 0 0 auto;
	font-size: 1.5em;
	font-weight: 700;
	line-height: 1;
	color: var(--paragraph-color, inherit);
	opacity: 0.45;
}

.as-fbt__card-details {
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 0.35em;
	padding: 1em;
	font-size: 0.9em;
	text-align: center;
}

.as-fbt__card-title {
	font-weight: 600;
}

.as-fbt__card-title--main {
	display: block;
}

/* Nur wenn der Titel als label[for] mit der Checkbox verknüpft ist
   (auswählbare Set-Produkte) - nicht bei <span>/<a>-Varianten. */
label.as-fbt__card-title {
	cursor: pointer;
}

.as-fbt__card-price {
	font-weight: 500;
}

.as-fbt__card-price .as-price-tax-note {
	display: none;
}

.as-fbt__card-stock--out {
	font-size: 0.85em;
}

.as-fbt__variation-hint {
	margin: 0;
	font-size: 0.8em;
	font-style: italic;
	opacity: 0.75;
}

.as-fbt__actions {
	margin-top: 1.25em;
	display: flex;
	flex-direction: column;
	align-items: flex-start;
	gap: 0.5em;
}

.as-fbt__notice {
	margin: 0;
	font-size: 0.9em;
}

.as-fbt__total {
	margin: 0;
	font-size: 1em;
}

.as-fbt__total-amount {
	font-weight: 700;
}

.as-fbt__submit[disabled] {
	opacity: 0.5;
	cursor: not-allowed;
}

.as-fbt__message {
	font-size: 0.9em;
}

.as-fbt__message--success {
	color: var(--theme-palette-color-1, #2c5f4e);
}

.as-fbt__message--error {
	color: #b32d2e;
}

.as-fbt__message a {
	margin-left: 0.5em;
	text-decoration: underline;
}

/* Desktop: kompakter, nebeneinander */
@media (min-width: 782px) {
	.as-fbt__items {
		flex-wrap: nowrap;
		overflow-x: auto;
	}
}

/* Mobil: sauber untereinander */
@media (max-width: 599px) {
	.as-fbt__items {
		flex-direction: column;
		gap: 0.5em;
	}

	.as-fbt__item {
	    flex: unset;
		max-width: 100%;
	}

	.as-fbt__card {
		flex-direction: row;
		align-items: center;
	}

	.as-fbt__card-image {
		flex: 0 0 120px;
	}

	.as-fbt__card-details {
		align-items: baseline;
	    text-align: left;
	}

}
