/* Ppd Listing Variants v0.2 — Kachel-Erweiterung
 * Spezifität durch Container-Klassen-Wrap angehoben (Theme-Button-Styles würden
 * sonst overriden). Kein !important. */

.ppd-lv-container {
    margin-top: 8px;
}

.ppd-lv-container .ppd-lv-group {
    margin-bottom: 8px;
}

.ppd-lv-container .ppd-lv-group-label {
    font-size: 11px;
    color: #6b7885;
    margin-bottom: 4px;
    text-transform: uppercase;
    letter-spacing: 0.02em;
    line-height: 1.35;
    min-height: 1.35em;   /* verhindert Kachel-Springen beim Hover-Label-Wechsel */
    /* Ausrichtung per Config (labelAlign): --ppd-lv-label-align wird inline
     * auf .ppd-lv-container gesetzt. Default: left (heutiger Zustand). */
    text-align: var(--ppd-lv-label-align, left);
}
.ppd-lv-container .ppd-lv-group-label__text {
    display: block;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
}

.ppd-lv-container .ppd-lv-swatch-row {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: center;
    /* Ausrichtung per Config (swatchRowAlign): --ppd-lv-row-align wird inline
     * auf .ppd-lv-container gesetzt (flex-start/center/flex-end). Default:
     * flex-start (heutiger Zustand). */
    justify-content: var(--ppd-lv-row-align, flex-start);
}

/* Swatch = <a>. Reset für Anchor-Defaults (Underline, Farbe) und Theme-Button-Regeln.
 * Spezifität 0,2,0 statt 0,1,0, damit Theme-Anchor-Styles verlieren. */
.ppd-lv-container .ppd-lv-swatch {
    background: none;
    padding: 2px;
    border: 2px solid transparent;
    border-radius: 6px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
    line-height: 1;
    color: inherit;
    text-decoration: none;
    box-shadow: none;
    position: relative;

    /* Feste Kantenlänge für color- und image-Swatches */
    width: 44px;
    height: 44px;
    flex: 0 0 auto;

    touch-action: manipulation;
    transition: border-color 120ms, box-shadow 120ms, transform 100ms;
}
.ppd-lv-container a.ppd-lv-swatch:hover,
.ppd-lv-container a.ppd-lv-swatch:focus {
    text-decoration: none;
    color: inherit;
}

/* NAME-Variante: Chip statt Quadrat */
/* Text-Swatches: displayType = 'text' oder 'select'. Beide bekommen
 * min-width statt fixed width (Textlänge variiert), max-width 220px als
 * Zeilenumbruch-Schutz. Höhe unter 576px fest 32px, ab 576px per Variable. */
.ppd-lv-container .ppd-lv-swatch--text,
.ppd-lv-container .ppd-lv-swatch--select {
    width: auto;
    min-width: 44px;
    max-width: 220px;
    height: 32px;
    padding: 0 10px;
    background: #fff;
    border: 2px solid rgba(0, 0, 0, 0.2);
    font-size: 12px;
    color: #333;
}

.ppd-lv-container .ppd-lv-swatch__color {
    display: block;
    width: 100%;
    height: 100%;
    border-radius: 4px;
    border: 1px solid rgba(0, 0, 0, 0.2);
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.3);
}

.ppd-lv-container .ppd-lv-swatch__image {
    display: block;
    width: 100%;
    height: 100%;
    border-radius: 4px;
    object-fit: cover;
    border: 1px solid rgba(0, 0, 0, 0.15);
}

.ppd-lv-container .ppd-lv-swatch__text {
    display: inline-block;
    line-height: 1.1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
}

/* Hover-Rand als visuelles Feedback beim Zeigen. */
.ppd-lv-container .ppd-lv-swatch:hover {
    border-color: #9aa0a6;
    border-width: 1px;
}

/* Aktive Auswahl (Mehrgruppen-Fall — 1-Gruppen-Fall setzt kein aria-current). */
.ppd-lv-container .ppd-lv-swatch[aria-current="true"] {
    border-color: #2a55a0;
    box-shadow: 0 0 0 1px #2a55a0;
}

/* aria-disabled=true: nicht klickbar, keine Hover-Border */
.ppd-lv-container .ppd-lv-swatch[aria-disabled="true"] {
    cursor: not-allowed;
    pointer-events: auto; /* Hover soll trotzdem visuell reagieren? Nein — reines Anzeigen. */
}
.ppd-lv-container .ppd-lv-swatch[aria-disabled="true"]:hover {
    border-color: transparent;
}

/* Fokus */
.ppd-lv-container .ppd-lv-swatch:focus-visible {
    outline: 3px solid #f39c12;
    outline-offset: 2px;
}

/* Nicht kombinierbar */
.ppd-lv-container .ppd-lv-swatch[data-ppd-state="not-combinable"] {
    opacity: 0.55;
}

/* Nicht verfügbar: rot durchgestrichen + gedimmt */
.ppd-lv-container .ppd-lv-swatch[data-ppd-state="unavailable"] {
    opacity: 0.4;
    cursor: not-allowed;
}
.ppd-lv-container .ppd-lv-swatch[data-ppd-state="unavailable"]::before {
    content: '';
    position: absolute;
    left: 4px;
    right: 4px;
    top: 50%;
    height: 2px;
    background: rgba(200, 30, 30, 0.85);
    transform: rotate(-25deg);
    pointer-events: none;
    z-index: 2;
}

/* +N Toggle — flex-order stellt sicher, dass er beim Aufklappen ans Ende rutscht */
.ppd-lv-container .ppd-lv-more {
    background: none;
    border: 1px dashed rgba(0, 0, 0, 0.35);
    padding: 0 8px;
    height: 44px;
    min-width: 32px;
    font-size: 12px;
    border-radius: 6px;
    cursor: pointer;
    color: #52667a;
    box-sizing: border-box;
    order: 100;   /* höher als jede Swatch-order */
    flex: 0 0 auto;
}
.ppd-lv-container .ppd-lv-more:focus-visible {
    outline: 3px solid #f39c12;
    outline-offset: 2px;
}

.ppd-lv-variants-from {
    font-size: 0.85em;
    color: #6c757d;
    margin: 2px 0 6px;
    line-height: 1.2;
}
/* Variante c: Platz IMMER reservieren, damit alle PPD-Kacheln unter sich
 * bündig sind — auch die, deren Initial-Variante zufällig das Minimum ist
 * und die Zeile deshalb via [hidden] unsichtbar ist. visibility:hidden
 * statt display:none behält den Layout-Fluss inkl. echter Höhe (auch bei
 * langen Beträgen wie "Varianten ab 12.345,67 €", die schmaler Kacheln
 * theoretisch umbrechen könnten — min-height wäre rigide, visibility:hidden
 * skaliert korrekt mit dem gerenderten Inhalt). */
/* [hidden] wird vom Theme in all.css mit display:none !important gesetzt —
 * hier brauchen wir das Gegengewicht, damit das Element layoutet wird und
 * Platz reserviert (nur unsichtbar bleibt). */
.ppd-lv-variants-from[hidden] { display: block !important; visibility: hidden; }

/* ────────────────────────────────────────────────────────────────────────
 * Kachel-Layout-Fixes für PPD-Kacheln (B2/Runde 3):
 *   1. Preis + Delivery an den UNTEREN Kachelrand geankert (margin-top:auto)
 *   2. Alle Kacheln einer Zeile gleich hoch (height:100% + flex-column)
 *   3. padding-bottom reserviert Platz für das Theme-Details-Overlay,
 *      damit es NICHT über dem Preis liegt (Overlay bleibt Theme-Sache).
 *
 * :has()-Selektor scoped auf Kacheln mit .ppd-lv-container — andere
 * Listing-Kacheln bleiben unangetastet. In Browsern ohne :has()-Support
 * greifen die Regeln nicht (graceful degradation zum aktuellen Verhalten).
 * ────────────────────────────────────────────────────────────────────── */
.card.product-box:has(.ppd-lv-container) {
    height: 100%;
    display: flex;
    flex-direction: column;
}
.card.product-box:has(.ppd-lv-container) .card-body {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    /* Bodenpolster analog zum Theme-Standard (20 px) — mehr würde den
     * Preisblock relativ zu den Nachbarkacheln nach oben schieben
     * (jedes zusätzliche Padding = zusätzlicher priceTop-Versatz).
     * Overlap zum .product-action-Overlay ist damit vergleichbar mit
     * den Nachbarn (≈ 9 px im Theme-Standard). */
    padding-bottom: 20px;
}
.card.product-box:has(.ppd-lv-container) .product-info {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
}
/* Der PPD-Container (Swatches) nimmt den flexiblen Raum zwischen
 * Header und Preisblock — dadurch bleibt der Preisblock unten fest. */
.card.product-box:has(.ppd-lv-container) .product-variant-characteristics {
    flex: 1 1 auto;
}
/* Preisblock ans untere Ende des Info-Bereichs drücken — jetzt am
 * .product-price-info (Direct-Child des flex-column .product-info),
 * damit margin-top:auto überhaupt greift. Der .product-price-wrapper
 * war zuvor NICHT Direct-Child und wurde daher nicht verortet. */
.card.product-box:has(.ppd-lv-container) .product-price-info {
    margin-top: auto;
}

/* "Varianten ab …" nur einmal: Core rendert .product-cheapest-price bei
 * aufgefaecherten Variantenkacheln zusaetzlich zur Plugin-Zeile
 * .ppd-lv-variants-from. Plugin-Zeile bleibt (wird beim Swatch-Wechsel
 * gepflegt), Core-Block wird in Plugin-Kacheln abgeschaltet. CSS-Weg statt
 * Template-Overload, weil der Core-Block im separaten Template
 * price-unit.html.twig definiert ist — ein CSS-Reset haelt keine Theme-
 * Vererbung durcheinander und ueberlebt Theme-Updates. :has() ist vom
 * Browser-Profil des Sales Channels getragen (Fix F1 vom 2026-11-23). */
.card.product-box:has(.ppd-lv-container) .product-cheapest-price {
    display: none;
}

/* Konfigurierbare Swatch-Größen ab 576px. Unter 576px bleibt es bei den
 * touch-freundlichen 44px Basiswerten (WCAG 2.5.5) — die --ppd-lv-swatch-size
 * greift dort bewusst NICHT, damit Klein auf dem Handy keine unfassbaren
 * Swatches erzeugt. Text-Hoehe skaliert unabhängig (28/32/38 statt 36/44/52),
 * weil Text-Swatches auch heute schon kleiner als 44px sind — die
 * Trefferflaeche wird ueber min-width + Padding gehalten. */
@media (min-width: 576px) {
    .ppd-lv-container .ppd-lv-swatch {
        width:  var(--ppd-lv-swatch-size, 44px);
        height: var(--ppd-lv-swatch-size, 44px);
    }
    .ppd-lv-container .ppd-lv-swatch--text,
    .ppd-lv-container .ppd-lv-swatch--select {
        min-width: var(--ppd-lv-swatch-size, 44px);
        height:    var(--ppd-lv-swatch-text-height, 32px);
    }
}

/* L3-Fix 2026-11-25: Namen-Zeile in PPD-Variantenkacheln nicht springen lassen.
 * Theme TcinnThemeWareLights setzt an .product-name eine line-clamp + fixe
 * height (2.75rem oder 66px je nach Kontext). Falls in der Variantenkachel-
 * Kaskade ein Override height:auto / min-height:0 greift (box-minimal-Varianten),
 * sorgt diese Regel fuer eine Mindesthoehe von 3 Textzeilen (Maximum aus
 * variantNames-Statistik: 82 Zeichen -> ca. 3 Zeilen bei line-height 1.375rem).
 * - Keine eigene line-clamp: Theme regelt die Kuerzung schon.
 * - Scoped auf [data-ppd-is-variant-tile="true"]: Standard-Kacheln bleiben
 *   unangetastet.
 * :has() ist vom Browser-Profil des Sales Channels getragen (gleiche Pattern-
 * Nutzung bereits ab Z.218 fuer .card.product-box:has(.ppd-lv-container)). */
.card.product-box:has(.ppd-lv-container[data-ppd-is-variant-tile="true"]) .product-name {
    min-height: calc(1.375rem * 3);
}

/* ppd-lv Platzhalter 2026-11-25: [hidden] soll wirken, auch wenn das Theme
 * display:flex/block auf .product-image-placeholder-artige Container setzt.
 * [hidden] ist Browser-Default display:none, aber Theme-Rules koennen das
 * ueberschreiben. Hier mit !important fuer Robustheit. */
.ppd-lv-placeholder[hidden],
.ppd-lv-img-fallback[hidden] {
    display: none !important;
}
