/* --------------------------------------------------------------------------
   SOMAJA Hero Produktgalerie
   Scope: Nur Galerie im Artikel-Hero-Block
   Voraussetzung im HTML:
   class="wp-block-woocommerce-product-image-gallery somaja-hero-product-gallery"
   -------------------------------------------------------------------------- */

.somaja-hero-product-gallery {
    --somaja-gallery-height: 100%;
    --somaja-thumb-size: 64px;
    --somaja-thumb-column: 88px;

    width: 100%;
    max-width: 100%;
    min-width: 0;
}

.somaja-hero-product-gallery,
.somaja-hero-product-gallery .woocommerce-product-gallery {
    height: 100%;
}

/* Native WooCommerce Galerie im Hero */
.somaja-hero-product-gallery .woocommerce-product-gallery {
    position: relative;
    display: grid;
    grid-template-columns: var(--somaja-thumb-column) minmax(0, 1fr);
    grid-template-areas: "thumbs main";
    gap: 0.875rem;
    width: 100%;
    max-width: 100%;
    margin: 0;
}

/* Hauptbildbereich rechts */
.somaja-hero-product-gallery .flex-viewport,
.somaja-hero-product-gallery .woocommerce-product-gallery__wrapper {
    grid-area: main;
    margin: 0;
    border-radius: 1.1rem;
    background: transparent;
    overflow: hidden;
    min-width: 0;
    height: var(--somaja-gallery-height) !important;
}

/* WooCommerce Slider-Wrapper */
.somaja-hero-product-gallery .woocommerce-product-gallery__wrapper {
    padding: 0;
    transition: all cubic-bezier(.795, -.035, 0, 1) .5s;
}

/* Einzelne Galerie-Slides */
.somaja-hero-product-gallery .woocommerce-product-gallery__image {
    background: transparent;
}

/* Bildfläche */
.somaja-hero-product-gallery .woocommerce-product-gallery__image {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: var(--somaja-gallery-height);
}

.somaja-hero-product-gallery .woocommerce-product-gallery__image > a {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: var(--somaja-gallery-height);
    padding: 1rem;
    box-sizing: border-box;
}

/* Hauptbild: Höhe nutzen, nicht verzerren */
.somaja-hero-product-gallery .woocommerce-product-gallery__image > a > img {
    display: block;
    width: auto;
    height: auto;
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    object-position: center;
    box-shadow: none;
}

/* WooCommerce Zoom-Bild */
.somaja-hero-product-gallery .woocommerce-product-gallery__wrapper .zoomImg {
    background: #ffffff;
    opacity: 0;
}

/* Lightbox / Zoom Trigger oben rechts */
.somaja-hero-product-gallery .woocommerce-product-gallery__trigger {
    position: absolute;
    top: 0.75rem;
    right: 0.75rem;
    z-index: 20;
    width: 2.25rem;
    height: 2.25rem;
    border-radius: 9999px;
    background: rgba(255, 255, 255, 0.9);
    box-sizing: content-box;
    text-indent: -9999px;
    overflow: hidden;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.28);
}

/* Lupen-Kreis */
.somaja-hero-product-gallery .woocommerce-product-gallery__trigger::before {
    content: "";
    position: absolute;
    top: 0.62rem;
    left: 0.62rem;
    display: block;
    width: 0.62rem;
    height: 0.62rem;
    border: 2px solid #020617;
    border-radius: 9999px;
    box-sizing: content-box;
}

/* Lupen-Griff */
.somaja-hero-product-gallery .woocommerce-product-gallery__trigger::after {
    content: "";
    position: absolute;
    top: 1.25rem;
    left: 1.38rem;
    display: block;
    width: 2px;
    height: 0.55rem;
    border-radius: 9999px;
    background: #020617;
    transform: rotate(-45deg);
    box-sizing: content-box;
}

/* Thumbnail-Leiste links: bei vielen Bildern scrollbar */
.somaja-hero-product-gallery .flex-control-thumbs {
    grid-area: thumbs;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    align-self: stretch;
    justify-self: start;
    width: var(--somaja-thumb-column);
    height: var(--somaja-gallery-height);
    max-height: var(--somaja-gallery-height);
    margin: 0;
    padding: 0 1rem 0 0;
    overflow-y: auto;
    overflow-x: hidden;
    scrollbar-width: thin;
    scrollbar-color: rgba(103, 232, 249, 0.55) rgba(255, 255, 255, 0.08);
}

/* Scrollbar für Chrome, Edge, Safari */
.somaja-hero-product-gallery .flex-control-thumbs::-webkit-scrollbar {
    width: 6px;
}

.somaja-hero-product-gallery .flex-control-thumbs::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.08);
    border-radius: 9999px;
}

.somaja-hero-product-gallery .flex-control-thumbs::-webkit-scrollbar-thumb {
    background: rgba(103, 232, 249, 0.55);
    border-radius: 9999px;
}

.somaja-hero-product-gallery .flex-control-thumbs::-webkit-scrollbar-thumb:hover {
    background: rgba(103, 232, 249, 0.8);
}

/* Einzelnes Thumbnail */
.somaja-hero-product-gallery .flex-control-thumbs li {
    list-style: none;
    width: var(--somaja-thumb-size);
    height: var(--somaja-thumb-size);
    margin: 0;
    padding: 0;
    flex: 0 0 auto;
}

/* Thumbnail-Bilder */
.somaja-hero-product-gallery .flex-control-thumbs li img {
    display: block;
    width: var(--somaja-thumb-size);
    height: var(--somaja-thumb-size);
    cursor: pointer;
    border-radius: 0.75rem;
    object-fit: contain;
    object-position: center;
    background: rgba(255, 255, 255, 0.04);
    opacity: 0.5;
    transition: opacity 0.2s ease, transform 0.2s ease;
}

/* Aktives / Hover Thumbnail */
.somaja-hero-product-gallery .flex-control-thumbs li img.flex-active,
.somaja-hero-product-gallery .flex-control-thumbs li img:hover {
    opacity: 1;
    transform: scale(1.03);
}

/* Tablet */
@media (max-width: 900px) {
    .somaja-hero-product-gallery {
        --somaja-gallery-height: 100%;
        --somaja-thumb-size: 56px;
        --somaja-thumb-column: 64px;
    }

    .somaja-hero-product-gallery .woocommerce-product-gallery {
        gap: 0.75rem;
    }
}

/* Mobile: Thumbnails unter das Bild */
@media (max-width: 640px) {
    .somaja-hero-product-gallery {
        --somaja-gallery-height: 260px;
        --somaja-thumb-size: 3.5rem; /* Etwas größer für bessere Bedienbarkeit */
    }

    .somaja-hero-product-gallery,
    .somaja-hero-product-gallery .woocommerce-product-gallery {
        height: auto;
        overflow: visible; /* Wichtig, damit Schatten/Skalierung nicht abgeschnitten werden */
    }

    .somaja-hero-product-gallery .woocommerce-product-gallery {
        display: flex; /* Wechsel von Grid auf Flex für einfacheres Mobile-Handling */
        flex-direction: column;
        gap: 0.75rem;
    }

    .somaja-hero-product-gallery .flex-viewport {
        width: 100%;
        height: var(--somaja-gallery-height) !important;
        order: 1;
    }

    /* Mobile: horizontale Thumbnail-Leiste optimiert */
	.somaja-hero-product-gallery .flex-control-thumbs {
		order: 2;
		display: flex !important;
		flex-direction: row !important;
		align-items: flex-start !important; /* Liste oben anpinnen */
		flex-wrap: nowrap !important;
		gap: 0.625rem;
		width: calc(100% + 1rem);
		margin: 0 -0.5rem !important;
		padding: 0.25rem 0.5rem 0.25rem 0.5rem !important; /* Kompaktes Padding */
		height: max-content !important; 
		overflow-x: auto;
		overflow-y: hidden;
		-webkit-overflow-scrolling: touch;
		scrollbar-width: thin;
		scrollbar-color: rgba(103, 232, 249, 0.65) rgba(255, 255, 255, 0.1);
	}

	/* WooCommerce <li> Reset - Zwingt die Boxen in die richtige Größe */
	.somaja-hero-product-gallery .flex-control-thumbs li {
		display: flex !important;
		align-items: flex-start !important; /* Element oben anpinnen */
		justify-content: center !important;
		width: 60px !important; /* Hier kannst du auf bis zu 100px gehen */
		height: 60px !important; 
		flex: 0 0 60px !important; 
		margin: 0 !important;
		padding: 0 !important;
		border: none !important;
	}

	/* WooCommerce <img> Reset - Verhindert das "Abrutschen" */
	.somaja-hero-product-gallery .flex-control-thumbs li img {
		display: block !important;
		width: 100% !important;
		height: 100% !important;
		object-fit: contain !important;
		object-position: top !important; /* Zieht das Bild INNERHALB der Box nach ganz oben */
		margin: 0 !important;
		padding: 0 !important;
		transform: translateY(0) !important; /* Hebelt WooCommerce-JS-Verschiebungen aus */
	}

    .somaja-hero-product-gallery .flex-control-thumbs::-webkit-scrollbar {
        height: 6px;
    }

    .somaja-hero-product-gallery .flex-control-thumbs::-webkit-scrollbar-track {
        background: rgba(255, 255, 255, 0.1);
        border-radius: 9999px;
    }

    .somaja-hero-product-gallery .flex-control-thumbs::-webkit-scrollbar-thumb {
        background: rgba(103, 232, 249, 0.65);
        border-radius: 9999px;
    }

    .somaja-hero-product-gallery .flex-control-thumbs::-webkit-scrollbar-thumb:hover {
        background: rgba(103, 232, 249, 0.9);
    }



    .somaja-hero-product-gallery .flex-control-thumbs li img.flex-active,
    .somaja-hero-product-gallery .flex-control-thumbs li img:hover {
        transform: none;
    }
}

/* --------------------------------------------------------------------------
   SOMAJA Hero Produktgalerie Firefox/LibreWolf Bildposition
   Scope: Nur sichtbares Hauptbild, Zoom bleibt aktiv
   -------------------------------------------------------------------------- */

/* Standard: keine Verschiebung in Chrome, Edge, Safari */
.somaja-hero-product-gallery {
    --somaja-hero-main-image-shift-x: 0px;
}

/* Nur Firefox/LibreWolf */
@supports (-moz-appearance: none) {
    /* Mobile bis 640px */
    .somaja-hero-product-gallery {
        --somaja-hero-main-image-shift-x: -10px;
    }

    /* Tablet / mittlere Breiten */
    @media (min-width: 641px) and (max-width: 1023px) {
        .somaja-hero-product-gallery {
            --somaja-hero-main-image-shift-x: -24px;
        }
    }

    /* Desktop */
    @media (min-width: 1024px) {
        .somaja-hero-product-gallery {
            --somaja-hero-main-image-shift-x: -50px;
        }
    }
}

/*
 * Sichtbares Hauptbild positionieren.
 * zoomImg wird bewusst ausgeschlossen, damit WooCommerce-Zoom nicht zerstört wird.
 */
.somaja-hero-product-gallery .woocommerce-product-gallery__image > a > img:not(.zoomImg) {
    width: auto !important;
    height: auto !important;
    max-width: 100% !important;
    max-height: 100% !important;
    object-fit: contain !important;
    object-position: center center !important;
    transform: translateX(var(--somaja-hero-main-image-shift-x));
    transition: transform 0.2s ease;
}