/* Own Gallery – version 1.5
   Only affects the image column and the gallery lightbox.
   The existing layout widths of .DtArtSuperLeft and .DtArtSuperRight
   are deliberately NOT overwritten.
*/

:is(.DtArtSuperLeft, .LeftPart).own-gallery {
    display: flex;
    float: left;
    align-items: flex-start;
    gap: 10px;
    min-width: 0;
    box-sizing: border-box;
}

:is(.DtArtSuperLeft, .LeftPart).own-gallery > .DtArtLeft {
    float: none;
    flex: 0 0 95px;
    width: 95px;
    min-width: 0;
    max-height: min(80vh, 850px) !important;
    overflow-x: hidden;
    display: flex;
    flex-direction: column;
    overflow-y: hidden !important;
}

:is(.DtArtSuperLeft, .LeftPart).own-gallery #WPic {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    scrollbar-width: none;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

:is(.DtArtSuperLeft, .LeftPart).own-gallery #WPic .ImageWeitere {
    flex: 0 0 auto;
    float: none !important;
    display: block;
    width: 100%;
    margin: 0;
    cursor: pointer;
}

:is(.DtArtSuperLeft, .LeftPart).own-gallery #WPic .ImageWeitere .own-gallery-thumb {
    appearance: none;
    border: 0;
    background: transparent;
    padding: 0;
    margin: 0;
    cursor: pointer;
    display: block;
    width: 100%;
    line-height: 0;
    outline-offset: 2px;
}

:is(.DtArtSuperLeft, .LeftPart).own-gallery #WPic .ImageWeitere img {
    width: 100%;
    height: auto;
    aspect-ratio: auto;
    display: block;
    padding: 0;
    margin: 0;
    border: none !important;
}

:is(.DtArtSuperLeft, .LeftPart).own-gallery #WPic .ImageWeitere.own-gallery-active img {
    outline: 2px solid #222;
    outline-offset: -2px;
}

:is(.DtArtSuperLeft, .LeftPart).own-gallery > .DtArtMiddle {
    float: none;
    flex: 1 1 0;
    width: 0;
    min-width: 0;
    max-width: 100%;
}

:is(.DtArtSuperLeft, .LeftPart).own-gallery #PicContainer,
:is(.DtArtSuperLeft, .LeftPart).own-gallery #Detailbild {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:is(.DtArtSuperLeft, .LeftPart).own-gallery .own-gallery-stage {
    position: relative;
    width: 100%;
    aspect-ratio: 3 / 4;
    max-height: 850px;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    overflow: hidden;
    background: #fff;
    cursor: zoom-in;
    touch-action: pan-y;
    user-select: none;
}

:is(.DtArtSuperLeft, .LeftPart).own-gallery .own-gallery-main-image {
    display: block;
    position: static;
    transform: none;
    width: auto;
    height: auto;
    max-width: 100% !important;
    max-height: 100% !important;
    object-fit: contain;
    pointer-events: none;
    -webkit-user-drag: none;
}

:is(.DtArtSuperLeft, .LeftPart).own-gallery .own-gallery-progress {
    display: none;
    justify-content: center;
    align-items: center;
    gap: 6px;
    padding: 16px 8px 18px;
}

:is(.DtArtSuperLeft, .LeftPart).own-gallery .own-gallery-progress button {
    appearance: none;
    display: block;
    flex: 0 1 26px;
    width: 26px;
    height: 2px;
    min-width: 8px;
    padding: 0;
    border: 0;
    border-radius: 0;
    background: #ccc;
    cursor: pointer;
}

:is(.DtArtSuperLeft, .LeftPart).own-gallery .own-gallery-progress button.active {
    background: #111;
}

.own-gallery-lightbox {
    position: fixed;
    inset: 0;
    /* Shop header uses 2147483645; keep the complete zoom above it. */
    z-index: 2147483647;
    display: none;
    flex-direction: column;
    background: #fff;
}

.own-gallery-lightbox.open {
    display: flex;
    animation: own-gallery-lightbox-appear 220ms ease-out both;
}

.own-gallery-lightbox.open .own-gallery-lightbox-content {
    animation: own-gallery-content-appear 280ms cubic-bezier(.2, .7, .2, 1) both;
}

@keyframes own-gallery-lightbox-appear {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes own-gallery-content-appear {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}
.own-gallery-lightbox[hidden] { display: none !important; }

.own-gallery-lightbox-header {
    flex: 0 0 58px;
    display: flex;
    justify-content: flex-end;
    align-items: center;
    padding: 0 22px;
}

.own-gallery-lightbox button {
    appearance: none;
    background: transparent;
    border: none;
    color: #111;
    cursor: pointer;
    font: inherit;
}

.own-gallery-lightbox-close {
    font-size: 36px !important;
    line-height: 1;
    padding: 6px 10px;
}

.own-gallery-lightbox-body {
    flex: 1 1 auto;
    min-height: 0;
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
    touch-action: pan-y;
}

.own-gallery-lightbox-image {
    display: block;
    width: auto;
    height: auto;
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    -webkit-user-drag: none;
}

.own-gallery-lightbox-arrow {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    z-index: 1;
    font-size: 34px !important;
    padding: 12px !important;
}

.own-gallery-lightbox-prev { left: 8px; }
.own-gallery-lightbox-next { right: 8px; }

.own-gallery-lightbox-count {
    flex: 0 0 40px;
    text-align: center;
    font-size: 12px;
    color: #555;
}

@media (max-width: 767px) {
    :is(.DtArtSuperLeft, .LeftPart).own-gallery {
        float: none;
        display: block;
        width: 100%;
        max-width: 100%;
        margin: 0;
        padding: 0;
    }

    :is(.DtArtSuperLeft, .LeftPart).own-gallery > .DtArtLeft {
        display: none !important;
    }

    :is(.DtArtSuperLeft, .LeftPart).own-gallery > .DtArtMiddle {
        float: none;
        display: block;
        width: 100%;
        max-width: 100%;
    }

    :is(.DtArtSuperLeft, .LeftPart).own-gallery .own-gallery-stage {
        max-height: none;
        cursor: zoom-in;
    }

    :is(.DtArtSuperLeft, .LeftPart).own-gallery .own-gallery-progress {
        display: flex;
    }

    .own-gallery-lightbox-header { flex-basis: 48px; padding: 0 12px; }
    .own-gallery-lightbox-arrow { font-size: 28px !important; padding: 8px !important; }
}

/* Zoom navigation */
.own-gallery-lightbox-content {
    display: flex;
    flex: 1 1 auto;
    min-height: 0;
    min-width: 0;
}

.own-gallery-lightbox-content > .own-gallery-lightbox-body {
    min-width: 0;
}

.own-gallery-lightbox-rail {
    display: flex;
    flex-direction: column;
    flex: 0 0 88px;
    min-height: 0;
    padding: 4px 16px 4px 24px;
}

.own-gallery-lightbox-thumbnails {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    min-height: 0;
    gap: 10px;
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-width: none;
}

.own-gallery-lightbox-thumbnails button {
    display: block;
    flex: 0 0 auto;
    width: 100%;
    padding: 0;
    border: 0;
    box-sizing: border-box;
    line-height: 0;
}

.own-gallery-lightbox-thumbnails button.active img {
    outline: 1px solid #111;
    outline-offset: -1px;
}

.own-gallery-lightbox-thumbnails img {
    display: block;
    width: 100%;
    height: auto;
}

.own-gallery-lightbox-progress {
    display: flex;
    flex: 0 0 auto;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 12px 24px 0;
}

.own-gallery-lightbox-progress button {
    display: block;
    flex: 0 1 32px;
    width: 32px;
    height: 28px;
    min-width: 12px;
    padding: 0;
    border-radius: 0;
    background: linear-gradient(#ccc, #ccc) center / 100% 2px no-repeat;
}

.own-gallery-lightbox-progress button.active {
    background-image: linear-gradient(#111, #111);
}

.own-gallery-lightbox button:focus-visible {
    outline: 2px solid #111;
    outline-offset: 2px;
}

.own-gallery-lightbox .own-gallery-lightbox-close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    padding: 0;
    flex-shrink: 0;
}

@media (max-width: 767px) {
    .own-gallery-lightbox-rail { display: none; }
}

/* Enlarge only as far as the original image resolution permits. */
.own-gallery-lightbox-image {
    flex-shrink: 0;
    transform-origin: center;
    user-select: none;
}

.own-gallery-lightbox-image.zoom-transitioning {
    transition: transform 240ms cubic-bezier(.2, .7, .2, 1);
}

.own-gallery-lightbox-image.can-zoom { cursor: zoom-in; }
.own-gallery-lightbox-body.image-zoomed { touch-action: none; }
.own-gallery-lightbox-body.image-zoomed .own-gallery-lightbox-image { cursor: zoom-out; }
.own-gallery-lightbox-image:focus-visible { outline: 2px solid #111; outline-offset: -2px; }

/* Previous image fades away once its replacement is ready. */
:is(.DtArtSuperLeft, .LeftPart).own-gallery .own-gallery-fade-image,
.own-gallery-lightbox-fade-image {
    position: absolute;
    display: block;
    pointer-events: none;
}

/* Scroll controls overlay the list so both image columns start at the top. */
.own-gallery-thumb-rail { position: relative; }
:is(.DtArtSuperLeft, .LeftPart).own-gallery #WPic::-webkit-scrollbar,
.own-gallery-lightbox-thumbnails::-webkit-scrollbar {
    display: none;
}

.own-gallery-thumb-rail > .own-gallery-scroll-arrow {
    display: none;
    position: absolute;
    left: 0;
    z-index: 2;
    align-items: center;
    justify-content: center;
    appearance: none;
    width: 100%;
    height: 28px;
    min-height: 28px;
    box-sizing: border-box;
    padding: 0;
    margin: 0;
    border: 0;
    background: #fff;
    color: #111;
    font: 24px/1 Arial, sans-serif;
    cursor: pointer;
}

.own-gallery-thumb-rail > .own-gallery-scroll-up { top: 0; }
.own-gallery-thumb-rail > .own-gallery-scroll-down { bottom: 0; }
.own-gallery-lightbox-rail > .own-gallery-scroll-arrow { left: 24px; width: calc(100% - 40px); }
.own-gallery-thumb-rail.has-overflow > .own-gallery-scroll-arrow { display: flex; }
.own-gallery-thumb-rail > .own-gallery-scroll-arrow[hidden] { display: none !important; }
.own-gallery-thumb-rail > .own-gallery-scroll-arrow:focus-visible { outline: 2px solid #111; outline-offset: -2px; }

/* Continuous zoom controls stay in the header, clear of the product image. */
.own-gallery-zoom-controls {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-right: 16px;
    color: #111;
}

.own-gallery-zoom-controls[hidden] { display: none !important; }

.own-gallery-zoom-controls > button {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 36px;
    padding: 0;
    font-size: 22px;
}

.own-gallery-zoom-controls > button:disabled { opacity: 0.3; cursor: default; }

.own-gallery-zoom-range {
    width: 140px;
    min-width: 0;
    height: 28px;
    padding: 0;
    margin: 0;
    accent-color: #111;
    cursor: pointer;
}

.own-gallery-zoom-range:focus-visible { outline: 2px solid #111; outline-offset: 2px; }
.own-gallery-zoom-value { min-width: 44px; font-size: 12px; text-align: right; font-variant-numeric: tabular-nums; }

@media (max-width: 767px) {
    .own-gallery-zoom-controls { gap: 4px; margin-right: 8px; }
    .own-gallery-zoom-range { width: 95px; }
}

/* Delayed loading feedback keeps quick image changes free of flashing UI. */
.own-gallery-loader {
    position: absolute;
    top: 50%;
    left: 50%;
    z-index: 3;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    transform: translate(-50%, -50%);
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.9);
    box-shadow: 0 1px 8px rgba(0, 0, 0, 0.12);
    pointer-events: none;
}

.own-gallery-loader[hidden] { display: none !important; }

.own-gallery-loader::before {
    content: '';
    width: 20px;
    height: 20px;
    border: 2px solid #ccc;
    border-top-color: #111;
    border-radius: 50%;
    animation: own-gallery-loading 0.75s linear infinite;
}

.own-gallery-loader-text {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
}

@keyframes own-gallery-loading { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
    .own-gallery-loader::before { animation: none; }
    .own-gallery-lightbox.open,
    .own-gallery-lightbox.open .own-gallery-lightbox-content { animation: none; }
    .own-gallery-lightbox-image.zoom-transitioning { transition: none; }
}

/* Legacy product detail layout: thumbnails beside the main image. */
.detailartikel .LeftPart.own-gallery {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    min-width: 0;
    box-sizing: border-box;
}
.detailartikel .LeftPart.own-gallery > .own-gallery-legacy-rail {
    flex: 0 0 95px;
    order: -1;
    width: 95px;
    max-height: min(80vh, 850px);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.detailartikel .LeftPart.own-gallery > #PicContainer {
    flex: 1 1 0;
    width: 0;
    min-width: 0;
}
.detailartikel .LeftPart.own-gallery > .own-gallery-legacy-rail #WPic {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
}
@media (max-width: 767px) {
    .detailartikel .LeftPart.own-gallery {
        display: block;
        width: 100%;
    }
    .detailartikel .LeftPart.own-gallery > .own-gallery-legacy-rail {
        display: none;
    }
    .detailartikel .LeftPart.own-gallery > #PicContainer {
        display: block;
        width: 100%;
    }
}
