/* Galerie-Shortcode [Galerie-slug] – einheitliche Karten + Lightbox */
.cmsp-gallery-module {
    margin: 2rem 0;
}

.cmsp-gallery-title {
    font-size: 1.75rem;
    margin: 0 0 1.25rem;
    text-align: center;
    font-weight: 700;
}

.cmsp-gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 16px;
}

.cmsp-gallery-item {
    display: block;
    width: 100%;
    padding: 0;
    border: 0;
    background: transparent;
    cursor: pointer;
    text-align: left;
}

.cmsp-gallery-item:focus-visible {
    outline: none;
}

.cmsp-gallery-item:focus-visible .cmsp-gallery-item__card {
    outline: 3px solid rgba(150, 188, 77, 0.85);
    outline-offset: 2px;
}

.cmsp-gallery-item__card {
    height: 100%;
    background: #fff;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    transition: transform 0.25s ease, box-shadow 0.25s ease;
}

.cmsp-gallery-item:hover .cmsp-gallery-item__card {
    transform: translateY(-3px);
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.16);
}

.cmsp-gallery-item__media {
    position: relative;
    aspect-ratio: 4 / 3;
    overflow: hidden;
    background: #f3f4f6;
}

.cmsp-gallery-item__thumb {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
    transform-origin: center center;
    transition: transform 0.35s ease;
}

.cmsp-gallery-item:hover .cmsp-gallery-item__thumb.is-rot-0 {
    transform: scale(1.05);
}

.cmsp-gallery-item__thumb.is-rot-90 {
    transform: rotate(90deg) scale(1.34);
}

.cmsp-gallery-item__thumb.is-rot-180 {
    transform: rotate(180deg);
}

.cmsp-gallery-item__thumb.is-rot-270 {
    transform: rotate(270deg) scale(1.34);
}

.cmsp-gallery-item:hover .cmsp-gallery-item__thumb.is-rot-90 {
    transform: rotate(90deg) scale(1.42);
}

.cmsp-gallery-item:hover .cmsp-gallery-item__thumb.is-rot-180 {
    transform: rotate(180deg) scale(1.05);
}

.cmsp-gallery-item:hover .cmsp-gallery-item__thumb.is-rot-270 {
    transform: rotate(270deg) scale(1.42);
}

.cmsp-gallery-lightbox {
    position: fixed;
    inset: 0;
    z-index: 10050;
    display: none;
    flex-direction: column;
    align-items: stretch;
    justify-content: center;
    padding: 0;
    background: rgba(0, 0, 0, 0.94);
}

.cmsp-gallery-lightbox.is-open {
    display: flex;
}

.cmsp-gallery-lightbox__dialog {
    position: relative;
    flex: 1 1 auto;
    min-height: 0;
    max-width: min(1200px, 96vw);
    width: 100%;
    margin: 0 auto;
    padding: 56px 72px 12px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.cmsp-gallery-lightbox__image-wrap {
    display: flex;
    align-items: center;
    justify-content: center;
    max-width: 100%;
    max-height: calc(100vh - 220px);
}

.cmsp-gallery-lightbox__image {
    max-width: 100%;
    max-height: calc(100vh - 220px);
    width: auto;
    height: auto;
    object-fit: contain;
    border-radius: 8px;
    transform-origin: center center;
}

.cmsp-gallery-lightbox__image.is-rot-90 {
    transform: rotate(90deg);
}

.cmsp-gallery-lightbox__image.is-rot-180 {
    transform: rotate(180deg);
}

.cmsp-gallery-lightbox__image.is-rot-270 {
    transform: rotate(270deg);
}

.cmsp-gallery-lightbox__caption {
    margin: 0.75rem 0 0;
    color: #fff;
    font-size: 0.95rem;
    text-align: center;
}

.cmsp-gallery-lightbox__counter {
    margin-top: 0.5rem;
    color: #fff;
    font-size: 0.95rem;
    letter-spacing: 0.02em;
}

.cmsp-gallery-lightbox__close,
.cmsp-gallery-lightbox__nav {
    position: fixed;
    border: 0;
    background: rgba(0, 0, 0, 0.55);
    color: #fff;
    cursor: pointer;
    transition: background-color 0.2s ease, opacity 0.2s ease;
    z-index: 10051;
    padding: 0;
    margin: 0;
    box-sizing: border-box;
    font-family: Arial, Helvetica, sans-serif;
    -webkit-appearance: none;
    appearance: none;
}

.cmsp-gallery-lightbox__close:hover,
.cmsp-gallery-lightbox__close:focus-visible,
.cmsp-gallery-lightbox__nav:hover,
.cmsp-gallery-lightbox__nav:focus-visible {
    background: rgba(0, 0, 0, 0.78);
}

.cmsp-gallery-lightbox__close {
    top: 0;
    right: 0;
    width: 72px;
    height: 72px;
    font-size: 3rem;
    font-weight: 300;
    line-height: 72px;
    text-align: center;
    border-radius: 0;
    z-index: 10053;
}

.cmsp-gallery-lightbox__nav {
    top: 0;
    bottom: 0;
    transform: none;
    width: 56px;
    height: auto;
    font-size: 2.25rem;
    line-height: 1;
    border-radius: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.cmsp-gallery-lightbox__nav--prev {
    left: 0;
}

.cmsp-gallery-lightbox__nav--next {
    right: 0;
    top: 72px;
}

.cmsp-gallery-lightbox__thumbs {
    flex: 0 0 auto;
    display: flex;
    gap: 8px;
    align-items: center;
    justify-content: flex-start;
    overflow-x: auto;
    padding: 12px 16px 16px;
    background: rgba(0, 0, 0, 0.72);
    scrollbar-width: thin;
}

.cmsp-gallery-lightbox__thumb {
    flex: 0 0 auto;
    width: 72px;
    height: 54px;
    padding: 0;
    border: 2px solid transparent;
    border-radius: 4px;
    background: transparent;
    cursor: pointer;
    overflow: hidden;
    opacity: 0.65;
    transition: opacity 0.2s ease, border-color 0.2s ease;
}

.cmsp-gallery-lightbox__thumb img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
    pointer-events: none;
}

.cmsp-gallery-lightbox__thumb:hover,
.cmsp-gallery-lightbox__thumb:focus-visible {
    opacity: 0.9;
    outline: none;
}

.cmsp-gallery-lightbox__thumb.is-active {
    opacity: 1;
    border-color: #fff;
}

@media (max-width: 767.98px) {
    .cmsp-gallery-grid {
        grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
        gap: 12px;
    }

    .cmsp-gallery-lightbox__dialog {
        padding: 52px 48px 8px;
    }

    .cmsp-gallery-lightbox__nav {
        width: 44px;
    }

    .cmsp-gallery-lightbox__nav--next {
        top: 64px;
    }

    .cmsp-gallery-lightbox__close {
        width: 64px;
        height: 64px;
        font-size: 2.75rem;
        line-height: 64px;
    }

    .cmsp-gallery-lightbox__thumb {
        width: 60px;
        height: 45px;
    }
}

@media (max-width: 575.98px) {
    .cmsp-gallery-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}
