/* ==========================================================================
   CoupleMinutes Flyout Cart
   --------------------------------------------------------------------------
   HIER STEHT DIE GANZE GESTALTUNG, nicht nur die Zustaende.

   Im Vorbild paarzeit-flyout-cart enthaelt diese Datei ausschliesslich
   Zustands- und Animations-CSS; Layout und Farben kommen dort aus
   Tailwind-Klassen im Markup, die ein Build im wp-content-Root
   mitkompiliert. Diesen Build gibt es hier nicht - und selbst mit ihm
   waeren es die falschen Tokens: das Theme rechnet mit --cm-*.

   ALLE WERTE KOMMEN AUS assets/css/tokens.css DES THEMES. Das Flyout
   laedt sie nicht selbst; es erbt sie von :root. Faellt das Theme
   einmal weg, greifen die Rueckfallwerte in jedem var() - sie stehen
   deshalb ueberall dort, wo ohne sie eine unlesbare Flaeche entstuende
   (Schrift auf gleichfarbigem Grund), und nur dort.
   ========================================================================== */

/* --- Schleier ------------------------------------------------------------ */

.cmfc-schleier {
	position: fixed;
	inset: 0;
	z-index: 99998;
	background: rgba(37, 50, 58, 0.35);
	opacity: 0;
	pointer-events: none;
	transition: opacity 0.3s;
}

.cmfc-schleier.is-offen {
	opacity: 1;
	pointer-events: auto;
}

/* --- Die Lade ------------------------------------------------------------ */

.cmfc-flyout {
	position: fixed;
	top: 0;
	right: 0;
	z-index: 99999;
	display: flex;
	flex-direction: column;
	width: 420px;
	max-width: 90vw;

	/* dvh statt vh: auf dem Telefon zieht sich die Adressleiste beim
	   Scrollen zusammen, und mit vh raegte die Lade dann unten aus dem
	   Bild - der Knopf zur Kasse waere nicht erreichbar. */
	height: 100dvh;

	background: var(--cm-color-surface, #FFFFFF);
	color: var(--cm-color-ink, #25323A);
	font: var(--cm-text-body);
	box-shadow: -8px 0 30px rgba(0, 0, 0, 0.12);
	transform: translateX(100%);
	transition: transform 0.45s cubic-bezier(0.22, 1, 0.36, 1);
}

.cmfc-flyout.is-offen {
	transform: translateX(0);
}

/* Scroll-Sperre. Sie gehoert auf <html> und NICHT auf <body>: dort machte
   overflow:hidden den Body zu einem eigenen Scroll-Behaelter - die Seite
   scrollte weiter, und jedes position:sticky darin verlor seinen
   Bezugsrahmen. Die Begruendung steht ausfuehrlich in cart.js. */
html.cmfc-scroll-sperre {
	overflow: hidden;
	padding-right: var(--cmfc-scrollbalken, 0px);
}

.cmfc-flyout,
#cmfc-flyout .cmfc-positionen {
	overscroll-behavior: contain;
}

/* --- Kopf ---------------------------------------------------------------- */

#cmfc-flyout .cmfc-kopf {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 16px;
	flex: none;
	padding: 20px 24px 14px;
	border-bottom: 1px solid var(--cm-color-tint-blush, #FCEBE7);
}

#cmfc-flyout .cmfc-kopf__titel {
	margin: 0;
	font: var(--cm-text-h5);
	color: var(--cm-color-ink, #25323A);
}

#cmfc-flyout .cmfc-kopf__zahl {
	color: var(--cm-color-ink-muted, #546763);
}

/* ---------------------------------------------------------------------
   KNOPF-ZURUECKSETZUNG

   Das Theme gestaltet JEDEN <button> als dunkle Pille (basis.css, die
   Auswahlliste dort nennt button ohne Klasse). Ohne diese Regel waeren
   Schliessen-Kreuz, Mengenknoepfe und Muelleimer drei fette schwarze
   Kapseln. Der ID-Selektor gewinnt die Spezifitaet - deshalb #cmfc-flyout
   davor und kein !important.
   --------------------------------------------------------------------- */
#cmfc-flyout button {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	padding: 0;
	border: 0;
	border-radius: 0;
	background: none;
	color: inherit;
	font: inherit;
	cursor: pointer;
	transition: background-color 0.2s, color 0.2s;
}

#cmfc-flyout .cmfc-schliessen {
	width: 40px;
	height: 40px;
	margin-right: -8px;
	border-radius: 50%;
	color: var(--cm-color-ink-muted, #546763);
}

#cmfc-flyout .cmfc-schliessen:hover {
	background: var(--cm-color-tint-blush, #FCEBE7);
	color: var(--cm-color-ink, #25323A);
}

/* --- Versandstreifen ----------------------------------------------------- */

#cmfc-flyout .cmfc-versand {
	flex: none;
	padding: 10px 24px;
	background: var(--cm-color-tint-peach, #FFE3C8);
}

#cmfc-flyout .cmfc-versand__haupt {
	margin: 0;
	font: var(--cm-text-small-bold);
}

#cmfc-flyout .cmfc-versand__zusatz {
	margin: 2px 0 0;
	font: var(--cm-text-caption);
	line-height: 1.4;
}

/* --- Positionen ---------------------------------------------------------- */

#cmfc-flyout .cmfc-positionen {
	flex: 1 1 auto;
	overflow-y: auto;
	padding: 0 24px;
}

#cmfc-flyout .cmfc-position {
	position: relative;
	display: flex;
	gap: 16px;
	padding: 20px 0;
	border-bottom: 1px solid var(--cm-color-tint-blush, #FCEBE7);
}

/* Waehrend eine Mengenaenderung laeuft: gedaempft und gesperrt, damit
   nicht gegen den Server angeklickt wird. */
#cmfc-flyout .cmfc-position--wartet {
	opacity: 0.5;
	pointer-events: none;
}

#cmfc-flyout .cmfc-position__bild {
	flex: none;
	display: flex;
	align-items: center;
	justify-content: center;
	width: 74px;
	aspect-ratio: 4 / 5;
	overflow: hidden;
	border-radius: 8px;
	background: var(--cm-color-tint-blush, #FCEBE7);
}

#cmfc-flyout .cmfc-position__bild img {
	width: 100%;
	height: 100%;
	object-fit: cover;
}

#cmfc-flyout .cmfc-position__text {
	display: flex;
	flex-direction: column;
	flex: 1 1 auto;
	min-width: 0;
}

#cmfc-flyout .cmfc-position__name {
	/* Platz fuer den Muelleimer, der oben rechts darueber liegt. */
	margin: 0 36px 0 0;
	font: var(--cm-text-body-bold);
}

#cmfc-flyout .cmfc-position__hinweis {
	margin: 6px 0 0;
	padding: 6px 10px;
	border-left: 2px solid var(--cm-color-signal, #F79E4B);
	background: var(--cm-color-tint-blush, #FCEBE7);
	font: var(--cm-text-caption);
	line-height: 1.5;
}

#cmfc-flyout .cmfc-position__fuss {
	display: flex;
	align-items: flex-end;
	justify-content: space-between;
	gap: 12px;
	margin-top: auto;
	padding-top: 12px;
}

#cmfc-flyout .cmfc-position__preis {
	font: var(--cm-text-body-bold);
	white-space: nowrap;
}

/* --- Mengensteller ------------------------------------------------------- */

#cmfc-flyout .cmfc-menge {
	display: flex;
	align-items: center;
	border: 1px solid var(--cm-color-ink, #25323A);
	border-radius: 6px;
}

#cmfc-flyout .cmfc-menge button {
	width: 36px;
	height: 36px;
	font-size: 18px;
	line-height: 1;
}

#cmfc-flyout .cmfc-menge button:hover {
	background: var(--cm-color-tint-blush, #FCEBE7);
}

#cmfc-flyout .cmfc-menge span {
	min-width: 28px;
	font: var(--cm-text-small-bold);
	text-align: center;
	user-select: none;
}

/* --- Entfernen ----------------------------------------------------------- */

/* 40px Ziel statt der 18px des Zeichens - auf dem Telefon ist alles
   darunter nicht sicher zu treffen. */
#cmfc-flyout .cmfc-entfernen {
	position: absolute;
	top: 14px;
	right: -8px;
	width: 40px;
	height: 40px;
	border-radius: 50%;
	color: var(--cm-color-ink-muted, #546763);
}

#cmfc-flyout .cmfc-entfernen:hover {
	background: var(--cm-color-tint-blush, #FCEBE7);
	color: var(--cm-color-ink, #25323A);
}

#cmfc-flyout .cmfc-entfernen:active {
	transform: scale(0.9);
}

/* --- Leer und Laden ------------------------------------------------------ */

#cmfc-flyout .cmfc-leer,
#cmfc-flyout .cmfc-laden {
	margin: 48px 0 0;
	color: var(--cm-color-ink-muted, #546763);
	text-align: center;
}

#cmfc-flyout .cmfc-weiter {
	display: block;
	margin-top: 12px;
	color: var(--cm-color-ink, #25323A);
	font: var(--cm-text-small);
	text-align: center;
}

#cmfc-flyout .cmfc-position--geist {
	opacity: 0.6;
}

/* --- Fuss ---------------------------------------------------------------- */

#cmfc-flyout .cmfc-fuss {
	flex: none;
	padding: 18px 24px calc(16px + env(safe-area-inset-bottom));
	border-top: 1px solid var(--cm-color-tint-blush, #FCEBE7);
	box-shadow: 0 -5px 20px rgba(0, 0, 0, 0.04);
}

#cmfc-flyout .cmfc-summe,
#cmfc-flyout .cmfc-ersparnis {
	display: flex;
	align-items: baseline;
	justify-content: space-between;
	gap: 12px;
}

#cmfc-flyout .cmfc-summe {
	margin-bottom: 14px;
}

#cmfc-flyout .cmfc-summe__wort {
	font: var(--cm-text-body);
}

#cmfc-flyout .cmfc-summe__wert {
	font: var(--cm-text-h5);
	font-family: var(--cm-font-body);
	font-weight: var(--cm-weight-bold);
}

#cmfc-flyout .cmfc-summe__wert.is-wartet {
	opacity: 0.5;
}

#cmfc-flyout .cmfc-summe__vorher {
	margin-right: 6px;
	color: var(--cm-color-ink-muted, #546763);
	font: var(--cm-text-small);
}

#cmfc-flyout .cmfc-ersparnis {
	margin-bottom: 8px;
	padding-bottom: 8px;
	border-bottom: 1px dashed var(--cm-color-tint-blush, #FCEBE7);
	color: var(--cm-color-product-heartfelt, #E9795E);
	font: var(--cm-text-small);
}

#cmfc-flyout .cmfc-ersparnis__wert {
	font: var(--cm-text-small-bold);
}

#cmfc-flyout .cmfc-summe.is-ersparnis .cmfc-summe__wert {
	color: var(--cm-color-product-heartfelt, #E9795E);
}

/* Der Knopf zur Kasse erbt .button vom Theme und braucht hier nur die
   volle Breite. */
#cmfc-flyout .cmfc-kasse {
	display: block;
	width: 100%;
	padding-inline: 20px;
}

#cmfc-flyout .cmfc-lieferhinweis {
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 6px;
	margin: 10px 0 0;
	color: var(--cm-color-ink-muted, #546763);
	font: var(--cm-text-caption);
	line-height: 1.4;
}

#cmfc-flyout .cmfc-lieferhinweis svg {
	flex: none;
	color: var(--cm-color-product-lighthearted, #74958E);
}

/* --- Kreisel ------------------------------------------------------------- */

.cmfc-kreisel {
	display: inline-block;
	width: 18px;
	height: 18px;
	border: 2px solid var(--cm-color-tint-blush, #FCEBE7);
	border-top-color: var(--cm-color-ink-muted, #546763);
	border-radius: 50%;
	animation: cmfc-drehen 0.9s linear infinite;
}

@keyframes cmfc-drehen {
	100% { transform: rotate(360deg); }
}

/* Der Kaufknopf, solange sein Aufruf laeuft. */
.single_add_to_cart_button.is-wartet {
	opacity: 0.7;
	pointer-events: none;
}

/* --- Scrollbalken im Positionsbereich ------------------------------------ */

#cmfc-flyout .cmfc-positionen::-webkit-scrollbar {
	width: 6px;
}

#cmfc-flyout .cmfc-positionen::-webkit-scrollbar-track {
	background: transparent;
}

#cmfc-flyout .cmfc-positionen::-webkit-scrollbar-thumb {
	border-radius: 10px;
	background: var(--cm-color-tint-blush, #FCEBE7);
}

/* --- Wer keine Bewegung will, bekommt keine ------------------------------ */

@media (prefers-reduced-motion: reduce) {

	.cmfc-flyout,
	.cmfc-schleier {
		transition: none;
	}

	.cmfc-kreisel {
		animation-duration: 3s;
	}
}
