.byond_portfolio_3d {
    --gap: 32px;
    --radius: 20px;
    --main: #3e4e59;
    --accent: #f25652;
    --accent70: #f58885;
    --bg: #fff;
    --text: #1f2937;
    --muted: #6b7280;
    --card-width: 720px;
    position: relative;
    padding: 10px 0;
    /* Break out of Gutenberg content-size constraint to use wide-size */
    max-width: var(--wp--style--global--wide-size, 1340px);
    margin-inline: auto;
}

.byond_portfolio_3d .track {
    display: flex;
    align-items: flex-start;
    gap: var(--gap);
    padding: 40px calc((var(--wp--style--global--wide-size, 1340px) - var(--card-width)) / 2) 60px;
    overflow-x: auto;
    overflow-y: hidden;
    scroll-snap-type: x mandatory;
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    -ms-overflow-style: none;
    /* Firefox-spezifische Scroll-Restaurierung deaktivieren */
    overscroll-behavior-x: none;
}
.byond_portfolio_3d .track::-webkit-scrollbar { display: none; }

.byond_portfolio_3d .slide_card {
    flex: 0 0 var(--card-width);
    scroll-snap-align: center;
    background: var(--bg);
    border-radius: var(--radius);
    box-shadow: 0 6px 24px rgba(0,0,0,.12);
    transition: transform 0.5s ease-out, opacity 0.5s ease-out, box-shadow 0.5s ease-out;
    transform: scale(0.75);
    opacity: 0.3;
}

.byond_portfolio_3d .slide_card.active {
    transform: scale(1);
    opacity: 1;
    box-shadow: 0 12px 40px rgba(0,0,0,.20);
    z-index: 10;
}

.byond_portfolio_3d .card_inner {
    display: grid;
    grid-template-columns: 1.2fr 1fr;
    height: 450px;
}

.byond_portfolio_3d .col_text {
    padding: 36px;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    overflow-y: auto;
}

.byond_portfolio_3d .title {
    font-size: 28px;
    font-weight: 700;
    line-height: 1.2;
    margin: 0 0 16px;
    color: var(--text);
}

.byond_portfolio_3d .meta_row {
    display: grid;
    grid-template-columns: 100px 1fr;
    gap: 8px 16px;
    margin-bottom: 20px;
    font-size: 14px;
}

.byond_portfolio_3d .meta_label {
    color: var(--muted);
    font-weight: 600;
    text-transform: uppercase;
    font-size: 11px;
    letter-spacing: 0.5px;
}

.byond_portfolio_3d .meta_value {
    color: var(--text);
}

.byond_portfolio_3d .desc {
    font-size: 18px;
    line-height: 1.7;
    color: var(--text);
    margin: 0 0 24px;
    overflow-y: auto;
    max-height: 300px;
    padding-right: 8px;
}

.byond_portfolio_3d .desc::-webkit-scrollbar {
    width: 4px;
}

.byond_portfolio_3d .desc::-webkit-scrollbar-track {
    background: transparent;
}

.byond_portfolio_3d .desc::-webkit-scrollbar-thumb {
    background: var(--accent);
    border-radius: 2px;
}

.byond_portfolio_3d .desc::-webkit-scrollbar-thumb:hover {
    background: #d64842;
}

/* Firefox scrollbar */
.byond_portfolio_3d .desc {
    scrollbar-width: thin;
    scrollbar-color: var(--muted) transparent;
}

.byond_portfolio_3d .cta_link a {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 24px;
    border-radius: 12px;
    background: var(--accent);
    color: #fff;
    text-decoration: none;
    font-weight: 600;
    font-size: 14px;
    transition: all 0.2s;
}

.byond_portfolio_3d .cta_link a:hover {
    background: #d64842;
    transform: translateY(-2px);
}

.byond_portfolio_3d .col_media {
    position: relative;
    background: var(--main);
    border-radius: 0 var(--radius) var(--radius) 0;
    overflow: hidden;
}

.byond_portfolio_3d .media_wrapper {
    position: relative;
    width: 100%;
    height: 100%;
    cursor: pointer;
}

.byond_portfolio_3d .media_slider {
    position: relative;
    width: 100%;
    height: 100%;
    min-height: 400px;
}

.byond_portfolio_3d .media_slide {
    position: absolute;
    top: 0;
    left: 0;
    width: calc(100% - 40px);
    height: calc(100% - 40px);
    opacity: 0;
    transition: opacity 0.8s ease-in-out;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.byond_portfolio_3d .media_slide.is_active {
    opacity: 1;
    z-index: 1;
}

.byond_portfolio_3d .media_slide img,
.byond_portfolio_3d .media_slide video {
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
    object-fit: contain;
    border-radius: 8px;
}

.byond_portfolio_3d .slider_dots {
    position: absolute;
    bottom: 16px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 8px;
    z-index: 10;
    background: rgba(255,255,255,0.9);
    padding: 8px 16px;
    border-radius: 20px;
    backdrop-filter: blur(8px);
    max-width: 240px;
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.byond_portfolio_3d .slider_dots::-webkit-scrollbar {
    display: none;
}

.byond_portfolio_3d .slider_dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #d1d5db;
    cursor: pointer;
    transition: all 0.3s;
    border: none;
    padding: 0;
}

.byond_portfolio_3d .slider_dot:hover {
    background: #9ca3af;
    transform: scale(1.2);
}

.byond_portfolio_3d .slider_dot.is_active {
    background: var(--accent);
    width: 24px;
    border-radius: 4px;
}

.byond_portfolio_3d .nav_dots {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 12px;
    position: relative;
    z-index: 20;
    min-height: 32px;
}

.byond_portfolio_3d .nav_dot {
    width: 12px;
    height: 12px;
    min-width: 12px;
    min-height: 12px;
    border-radius: 50%;
    background: #d1d5db;
    cursor: pointer;
    transition: all 0.3s;
    border: none;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0;
    font-weight: 600;
    color: #fff;
    flex-shrink: 0;
}

.byond_portfolio_3d .nav_dot:hover {
    background: #9ca3af;
    transform: scale(1.3);
}

.byond_portfolio_3d .nav_dot.is_active {
    background: var(--accent);
    width: 32px;
    height: 32px;
    min-width: 32px;
    min-height: 32px;
    border-radius: 50%;
    font-size: 14px;
}

/* Navigation Arrows */
.byond_portfolio_3d .nav_arrows {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 20px;
    margin-top: 12px;
    min-height: 32px;
}

.byond_portfolio_3d .nav_arrow {
    width: 32px;
    height: 32px;
    min-width: 32px;
    min-height: 32px;
    border-radius: 50%;
    background: var(--bg);
    border: 2px solid var(--accent);
    color: var(--accent);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: bold;
    transition: all 0.3s;
    user-select: none;
    flex-shrink: 0;
    align-self: center;
}

.byond_portfolio_3d .nav_arrow:hover {
    background: var(--accent);
    color: white;
    transform: scale(1.1);
}

.byond_portfolio_3d .nav_arrow:active {
    transform: scale(0.95);
}

.byond_lightbox {
    display: none;
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    background: rgba(0,0,0,.85) !important;
    z-index: 10000 !important;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.3s;
    padding: 20px;
    box-sizing: border-box !important;
}

.byond_lightbox.is_open {
    display: flex !important;
    opacity: 1 !important;
}

.byond_lightbox_content {
    max-width: 95vw;
    max-height: 95vh;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

.byond_lightbox_content img,
.byond_lightbox_content video {
    max-width: 90vw;
    max-height: 85vh;
    width: auto;
    height: auto;
    border-radius: 8px;
}

/* Desktop: Größere maximale Breite */
@media (min-width: 1200px) {
    .byond_lightbox_content img,
    .byond_lightbox_content video {
        max-width: 1200px;
        max-height: 90vh;
    }
}

/* Before/After Slider Styles */
.before-after-container {
    position: relative;
    max-width: 90vw;
    max-height: 85vh;
    overflow: hidden;
    display: inline-block;
    border-radius: 8px;
}

.before-after-container img {
    display: block;
    max-width: 90vw;
    max-height: 85vh;
    width: auto;
    height: auto;
}

/* Desktop: Größere maximale Breite */
@media (min-width: 1200px) {
    .before-after-container {
        max-width: 1200px;
        max-height: 90vh;
    }

    .before-after-container img {
        max-width: 1200px;
        max-height: 90vh;
    }
}

.before-after-container .after-image {
    position: absolute;
    top: 0;
    left: 0;
    width: 50%;
    height: 100%;
    overflow: hidden;
}

.before-after-container .after-image img {
    position: absolute;
    top: 0;
    left: 0;
    max-width: none;
}

.before-after-slider {
    position: absolute;
    top: 0;
    bottom: 0;
    left: 50%;
    width: 4px;
    background: white;
    cursor: ew-resize;
    z-index: 10;
    transform: translateX(-50%);
    box-shadow: 0 0 0 1px rgba(0,0,0,0.2);
}

.before-after-slider::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 50px;
    height: 50px;
    background: white;
    border: 4px solid var(--accent);
    border-radius: 50%;
    box-shadow: 0 4px 12px rgba(0,0,0,0.4);
    z-index: 1;
}

.before-after-slider::after {
    content: '←→';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: var(--accent);
    font-size: 20px;
    font-weight: bold;
    z-index: 2;
    text-shadow:
            1px 1px 0 white,
            -1px -1px 0 white,
            1px -1px 0 white,
            -1px 1px 0 white,
            0 0 8px rgba(255,255,255,0.8);
    line-height: 0;
    letter-spacing: -2px;
}

.before-after-label {
    position: absolute;
    top: 20px;
    padding: 8px 16px;
    background: rgba(0,0,0,0.7);
    color: white;
    font-size: 14px;
    font-weight: 600;
    border-radius: 4px;
    pointer-events: none;
    z-index: 5;
}

.before-after-label.before-label {
    left: 20px;
}

.before-after-label.after-label {
    right: 20px;
}

.byond_lightbox_close {
    position: fixed;
    top: 20px;
    right: 20px;
    background: rgba(255,255,255,0.9);
    border: none;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    z-index: 10002;
    line-height: 1;
}

.byond_lightbox_close:hover {
    background: #fff;
    transform: scale(1.1);
}

/* Lightbox Navigation Arrows */
.byond_lightbox_nav {
    position: fixed;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(255,255,255,0.9);
    border: none;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    z-index: 10002;
    color: #333;
    font-weight: bold;
}

.byond_lightbox_nav:hover {
    background: #fff;
    transform: translateY(-50%) scale(1.1);
}

.byond_lightbox_nav.prev {
    left: 20px;
}

.byond_lightbox_nav.next {
    right: 20px;
}

.byond_lightbox_nav.hidden {
    display: none;
}

/* Lightbox Counter */
.byond_lightbox_counter {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(255,255,255,0.9);
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 14px;
    font-weight: 600;
    color: #333;
    z-index: 10002;
}

/* ========================================
   MOBILE STYLES - Komplett neues Layout
   ======================================== */

@media (max-width: 1199px) {
    .byond_portfolio_3d {
        padding: 20px 0;
    }

    /* WordPress Container auf volle Breite wenn Portfolio drin ist */
    .wp-block-group.has-global-padding.is-layout-constrained:has(.byond_portfolio_3d) {
        max-width: 100vw !important;
    }

    /* Track: Kein horizontales Scrolling mehr, normale vertikale Anordnung */
    .byond_portfolio_3d .track {
        display: block;
        padding: 0 16px;
        overflow: visible;
        scroll-snap-type: none;
        gap: 0;
        background: transparent;
    }

    /* Cards: Weißer Block mit Schatten für klare Abgrenzung */
    .byond_portfolio_3d .slide_card {
        flex: none;
        width: 100%;
        max-width: 800px;
        margin: 0 auto 32px;
        transform: none !important;
        opacity: 1 !important;
        box-shadow: 0 4px 12px rgba(0,0,0,.1);
        border-radius: 16px;
        background: var(--bg);
        scroll-snap-align: none;
        overflow: hidden;
        box-sizing: border-box;
    }

    .byond_portfolio_3d .slide_card.active {
        transform: none !important;
        box-shadow: 0 4px 12px rgba(0,0,0,.1);
    }

    /* Card Inner: Bild oben, Text unten */
    .byond_portfolio_3d .card_inner {
        display: flex;
        flex-direction: column;
        height: auto;
    }

    /* Media Column: Volle Breite, oben */
    .byond_portfolio_3d .col_media {
        order: -1;
        width: 100%;
        min-height: 350px;
        max-height: 500px;
        border-radius: 16px 16px 0 0;
        margin: 0;
    }

    /* Text Column: Normale Breite, unten */
    .byond_portfolio_3d .col_text {
        padding: 20px 24px 24px;
        width: 100%;
        box-sizing: border-box;
        overflow: hidden;
    }

    .byond_portfolio_3d .title {
        font-size: 24px;
        margin-bottom: 16px;
        word-wrap: break-word;
        overflow-wrap: break-word;
    }

    .byond_portfolio_3d .title img {
        max-width: 100% !important;
        height: auto !important;
        width: 100% !important;
    }

    .byond_portfolio_3d .meta_row {
        font-size: 11px;
        grid-template-columns: auto;
        gap: 0;
        margin-bottom: 12px;
    }

    .byond_portfolio_3d .meta_label {
        display: block;
        margin-bottom: 0;
    }

    .byond_portfolio_3d .desc {
        font-size: 16px;
        line-height: 1.6;
        max-height: none;
        overflow-y: visible;
        margin-bottom: 20px;
        padding-right: 0;
        word-wrap: break-word;
        overflow-wrap: break-word;
    }

    .byond_portfolio_3d .cta_link a {
        margin-top: 4px;
    }

    /* Media Wrapper & Slider */
    .byond_portfolio_3d .media_wrapper {
        position: relative;
        width: 100%;
        height: 100%;
    }

    .byond_portfolio_3d .media_slider {
        min-height: 350px;
        max-height: 500px;
        height: 100%;
    }

    .byond_portfolio_3d .media_slide {
        padding: 0;
        width: 100%;
        height: 100%;
        overflow: hidden;
    }

    /* Portrait slides benötigen keine Zentrierung */
    .byond_portfolio_3d .media_slide.portrait-image {
        padding: 0;
    }

    .byond_portfolio_3d .media_slide img,
    .byond_portfolio_3d .media_slide video {
        max-width: 100%;
        max-height: 100%;
        width: auto;
        height: auto;
        object-fit: contain;
        border-radius: 0;
    }

    /* Nur Hochformat-Bilder (Portrait) als cover mit top focus */
    .byond_portfolio_3d .media_slide.portrait-image img {
        width: 100% !important;
        height: 100% !important;
        max-width: 100% !important;
        max-height: 100% !important;
        object-fit: cover !important;
        object-position: top center !important;
    }

    /* Slider Dots bleiben sichtbar innerhalb der Medien */
    .byond_portfolio_3d .slider_dots {
        bottom: 12px;
        padding: 6px 12px;
        max-width: calc(100% - 40px);
        left: 50%;
        transform: translateX(-50%);
    }

    .byond_portfolio_3d .slider_dot {
        width: 6px;
        height: 6px;
    }

    .byond_portfolio_3d .slider_dot.is_active {
        width: 20px;
    }

    /* Navigation: Komplett ausblenden */
    .byond_portfolio_3d .nav_arrows,
    .byond_portfolio_3d .nav_dots,
    .byond_portfolio_3d .nav_arrow,
    .byond_portfolio_3d .nav_dot {
        display: none !important;
    }

    /* Lightbox angepasst für Mobile */
    body .byond_lightbox {
        padding: 20px !important;
        width: 100% !important;
        left: 0 !important;
        right: 0 !important;
        overflow: hidden !important;
        box-sizing: border-box !important;
    }

    body .byond_lightbox.is_open {
        display: flex !important;
    }

    body .byond_lightbox_content {
        max-width: 100% !important;
        width: 100% !important;
        max-height: 85vh !important;
        margin: 0 auto !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        box-sizing: border-box !important;
    }

    body .byond_lightbox_content > img {
        max-width: 100% !important;
        max-height: 75vh !important;
        width: auto !important;
        height: auto !important;
        object-fit: contain !important;
    }

    body .byond_lightbox_content video,
    body .byond_lightbox_content iframe {
        max-width: 100% !important;
        max-height: 75vh !important;
        width: auto !important;
    }

    /* Before/After Container für Mobile - minimale Anpassung */
    body .byond_lightbox_content .before-after-container {
        max-width: 90vw !important;
        max-height: 70vh !important;
    }

    body .byond_lightbox_content .before-after-container img {
        max-width: 90vw !important;
        max-height: 70vh !important;
    }

    .byond_lightbox_close {
        top: 10px;
        right: 10px;
        width: 40px;
        height: 40px;
        font-size: 24px;
    }

    .byond_lightbox_nav {
        width: 44px;
        height: 44px;
        font-size: 20px;
    }

    .byond_lightbox_nav.prev {
        left: 10px;
    }

    .byond_lightbox_nav.next {
        right: 10px;
    }

    .byond_lightbox_counter {
        bottom: 20px;
        font-size: 13px;
    }

    /* Before/After Slider Mobile Anpassungen */
    .before-after-slider::before {
        width: 40px;
        height: 40px;
    }

    .before-after-slider::after {
        font-size: 16px;
    }

    .before-after-label {
        font-size: 12px;
        padding: 6px 12px;
        top: 10px;
    }

    .before-after-label.before-label {
        left: 10px;
    }

    .before-after-label.after-label {
        right: 10px;
    }
}