/* Produktseite (oscar/catalogue/detail.html, partials/gallery.html, partials/kaufleiste.html)

   Am Handy sollen Marke, Name und Preis im ersten Bildschirm stehen:
   kurzer Kopf, Titel und Preis über dem Bild, Bilder als Wischreihe mit
   begrenzter Höhe, unten eine feste Leiste „Größe wählen“ bzw. „In den Warenkorb“.
   Ab 992 px (Bootstrap lg) wie bisher: Bild links, Angaben rechts. */

/* --- Aufteilung -------------------------------------------------------- */

.ks-produkt {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas:
        "kopf"
        "bild"
        "rest";
}

.ks-produkt__kopf {
    grid-area: kopf;
}

.ks-produkt__bild {
    grid-area: bild;
    min-width: 0;
}

.ks-produkt__rest {
    grid-area: rest;
}

@media (min-width: 992px) {
    .ks-produkt {
        grid-template-columns: minmax(0, 7fr) minmax(0, 5fr);
        grid-template-rows: auto 1fr;
        grid-template-areas:
            "bild kopf"
            "bild rest";
        column-gap: 30px;
    }
}

/* --- Bilder ------------------------------------------------------------ */

.ks-bilder.shop-single-item-photos {
    padding-left: 0;
}

.ks-bilder__liste {
    margin: 0;
    padding: 0;
    list-style: none;
}

.ks-bilder__bild img {
    display: block;
    width: 100%;
    height: auto;
}

/* Breit: erstes Bild groß rechts, die übrigen als schmale Spalte links */
@media (min-width: 992px) {
    .ks-bilder__liste {
        display: grid;
        grid-template-columns: 90px minmax(0, 1fr);
        column-gap: 10px;
        align-items: start;
    }

    .ks-bilder__bild {
        grid-column: 1;
        margin-bottom: 10px;
    }

    .ks-bilder__bild:first-child {
        grid-column: 2;
        grid-row: 1 / span 40;
        margin-bottom: 0;
    }

    .ks-bilder__liste:has(> .ks-bilder__bild:only-child) {
        grid-template-columns: minmax(0, 1fr);
    }

    .ks-bilder__bild:only-child {
        grid-column: 1;
    }
}

/* Handy und Tablet: Wischreihe, das nächste Bild schaut am Rand hervor */
@media (max-width: 991.98px) {
    .ks-bilder.shop-single-item-photos {
        margin: 0 -15px 16px;
    }

    .ks-bilder__liste {
        display: flex;
        gap: 8px;
        padding: 0 15px;
        overflow-x: auto;
        scroll-snap-type: x mandatory;
        scroll-padding: 0 15px;
        scrollbar-width: none;
        -webkit-overflow-scrolling: touch;
    }

    .ks-bilder__liste::-webkit-scrollbar {
        display: none;
    }

    .ks-bilder__liste:focus-visible {
        outline: 2px solid currentColor;
        outline-offset: -2px;
    }

    .ks-bilder__bild {
        flex: 0 0 82%;
        scroll-snap-align: start;
    }

    .ks-bilder__bild:only-child {
        flex-basis: 100%;
    }

    .ks-bilder__bild img {
        height: min(48vh, 420px);
        object-fit: contain;
        background: #fff;
    }
}

/* --- Kopf am Handy ----------------------------------------------------- */

@media (max-width: 991.98px) {
    /* Grauer Seitenkopf nur mit einer Zeile Brotkrumen */
    .ks-produktkopf.module-page-title {
        padding: 10px 0 6px !important;
    }

    .ks-produktkopf .breadcrumb {
        flex-wrap: nowrap;
        overflow-x: auto;
        white-space: nowrap;
        margin-bottom: 0 !important;
        scrollbar-width: none;
        font-size: .8125rem;
    }

    .ks-produktkopf .breadcrumb::-webkit-scrollbar {
        display: none;
    }

    /* Der Titel steht gleich darunter mit Marke und Preis: die h1 bleibt für Screenreader */
    .ks-seitentitel {
        position: absolute !important;
        width: 1px;
        height: 1px;
        overflow: hidden;
        clip: rect(0 0 0 0);
        white-space: nowrap;
    }

    #main-container .module.p-t-30 {
        padding-top: 14px !important;
    }

    .ks-produkt__kopf .shop-single-item-title {
        font-size: 1.5rem;
        margin-bottom: 4px;
    }

    .ks-produkt__kopf .availability {
        margin-bottom: 12px;
    }
}

/* --- Feste Kaufleiste am Handy ----------------------------------------- */

.ks-kaufleiste {
    display: none;
}

@media (max-width: 991.98px) {
    .ks-kaufleiste:not([hidden]) {
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 1030;
        display: flex;
        align-items: center;
        gap: 12px;
        padding: 10px 15px calc(10px + env(safe-area-inset-bottom));
        background: #fff;
        border-top: 1px solid #e6e4df;
        box-shadow: 0 -4px 16px rgba(0, 0, 0, .08);
    }

    .ks-kaufleiste__preis {
        flex: 0 0 auto;
        font-weight: 600;
        font-size: 1.0625rem;
    }

    .ks-kaufleiste__knopf {
        flex: 1 1 auto;
        min-height: 48px;
        padding: 12px 16px;
        border-radius: 6px;
        background: var(--d-brand, #1b1d1c);
        border: 1px solid var(--d-brand, #1b1d1c);
        color: var(--d-on-brand, #fff);
        font-size: .9375rem;
        letter-spacing: 0;
        text-transform: none;
    }

    .ks-kaufleiste__knopf:hover,
    .ks-kaufleiste__knopf:focus-visible {
        background: var(--d-brand-hover, #303536);
        color: var(--d-on-brand, #fff);
    }

    /* Offenes Handy-Menü (site-header.js setzt mnav-open): Leiste weg, sie schaute sonst
       neben dem Menü durch */
    html.mnav-open .ks-kaufleiste {
        display: none !important;
    }

    /* Platz unter dem letzten Inhalt, damit die Leiste nichts verdeckt */
    html.ks-kaufleiste-offen body {
        padding-bottom: 72px;
    }

    /* Siegel von Trusted Shops und „Nach oben“ über die Leiste heben, sie lägen
       sonst auf dem Preis. Beim Siegel ist nicht der äußere Container fest
       positioniert, sondern ein inneres div um den Knopf: Ein translate am
       Container würde es aus dem Bild schieben. translate statt transform,
       damit es eigene transform-Werte des Siegels nicht überschreibt. */
    html.ks-kaufleiste-offen [id^="trustbadge-container"] :has(> [id^="minimized-trustbadge"]),
    html.ks-kaufleiste-offen .scroll-top {
        translate: 0 calc(-72px - env(safe-area-inset-bottom)) !important;
    }
}
