/* ==========================================================================
   Motomarine v3 · Gallery
   .cs-gallery = photo grid of .cs-gallery__item links (square cells, --wide
   spans two, --uniform 4/3 cells) with a hover overlay,
   zoom icon and caption. Every item opens #galleryLightbox (modal.css,
   main.js [data-gallery]). The carousel reuses .cs-carousel. .cs-gallery-stack =
   big photo + thumbnail strip (main.js [data-gallery-stack]).
   ========================================================================== */

.cs-gallery {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    grid-auto-flow: dense;
    gap: 16px;
}
.cs-gallery__item {
    position: relative;
    display: block;
    overflow: hidden;
    aspect-ratio: 1 / 1;
    border-radius: 4px;
    background: var(--light-bg);
    cursor: zoom-in;
}
.cs-gallery__item--wide {
    grid-column: span 2;
    aspect-ratio: auto;
}
.cs-gallery__item img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform .6s ease;
}
.cs-gallery__item:hover img {
    transform: scale(1.04);
}
.cs-gallery__item::after {
    content: '';
    position: absolute;
    inset: 0;
    z-index: 1;
    background: linear-gradient(to top, rgba(15, 23, 43, .7), rgba(15, 23, 43, .2));
    opacity: 0;
    transition: var(--transition);
}
.cs-gallery__zoom {
    position: absolute;
    top: 50%;
    left: 50%;
    z-index: 2;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    border-radius: 4px;
    background: var(--white);
    color: var(--heading);
    font-size: 16px;
    opacity: 0;
    transform: translate(-50%, -50%) scale(.9);
    transition: var(--transition);
}
.cs-gallery__cap {
    position: absolute;
    left: 16px;
    right: 16px;
    bottom: 14px;
    z-index: 2;
    font-family: var(--font-heading);
    font-size: 14px;
    font-weight: 600;
    line-height: 1.3;
    color: var(--white);
    opacity: 0;
    transform: translateY(6px);
    transition: var(--transition);
}
.cs-gallery__item:hover::after,
.cs-gallery__item:hover .cs-gallery__zoom,
.cs-gallery__item:hover .cs-gallery__cap {
    opacity: 1;
}
.cs-gallery__item:hover .cs-gallery__zoom {
    transform: translate(-50%, -50%) scale(1);
}
.cs-gallery__item:hover .cs-gallery__cap {
    transform: none;
}

/* --- Uniform grid: 4/3 cells --- */
.cs-gallery--uniform .cs-gallery__item {
    aspect-ratio: 4 / 3;
}

/* --- Carousel of photos --- */
.cs-carousel .cs-gallery__item {
    aspect-ratio: 4 / 3;
}

/* --- Copy with photo stack: one big photo, a strip of thumbnails under it --- */
.cs-gallery-stack__copy .cs-btn-row {
    margin-top: 28px;
}
.cs-gallery-stack__main {
    position: relative;
    display: block;
    overflow: hidden;
    border-radius: 4px;
    background: var(--light-bg);
    cursor: zoom-in;
}
.cs-gallery-stack__main img {
    display: block;
    width: 100%;
    height: auto;
    aspect-ratio: 5 / 4;
    object-fit: cover;
}
.cs-gallery-stack__main::after {
    content: '';
    position: absolute;
    inset: 0;
    z-index: 1;
    background: rgba(15, 23, 43, .3);
    opacity: 0;
    transition: var(--transition);
}
.cs-gallery-stack__main:hover::after,
.cs-gallery-stack__main:hover .cs-gallery__zoom {
    opacity: 1;
}
.cs-gallery-stack__main:hover .cs-gallery__zoom {
    transform: translate(-50%, -50%) scale(1);
}
/* Thumb strip scrolls sideways (scroll snap, no scrollbar), five per view */
.cs-gallery-stack__thumbs {
    display: flex;
    gap: 10px;
    margin-top: 10px;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
}
.cs-gallery-stack__thumbs::-webkit-scrollbar {
    display: none;
}
.cs-gallery-stack__thumb {
    position: relative;
    flex: 0 0 calc((100% - 40px) / 5);
    scroll-snap-align: start;
    padding: 0;
    border: 2px solid transparent;
    border-radius: 4px;
    background: var(--light-bg);
    overflow: hidden;
    cursor: pointer;
    transition: var(--transition);
}
.cs-gallery-stack__thumb img {
    display: block;
    width: 100%;
    height: auto;
    aspect-ratio: 1 / 1;
    object-fit: cover;
    opacity: .7;
    transition: var(--transition);
}
.cs-gallery-stack__thumb:hover img,
.cs-gallery-stack__thumb.is-current img {
    opacity: 1;
}
.cs-gallery-stack__thumb.is-current {
    border-color: var(--primary);
}
/* Arrows over the main photo */
.cs-gallery-stack__arrow {
    position: absolute;
    top: 50%;
    z-index: 2;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    padding: 0;
    border: 0;
    border-radius: 4px;
    background: rgba(255, 255, 255, .9);
    color: var(--heading);
    font-size: 16px;
    cursor: pointer;
    transform: translateY(-50%);
    transition: var(--transition);
}
.cs-gallery-stack__arrow--prev {
    left: 16px;
}
.cs-gallery-stack__arrow--next {
    right: 16px;
}
.cs-gallery-stack__arrow:hover {
    background: var(--primary);
    color: var(--white);
}

.bg-dark .cs-gallery__item,
.bg-dark .cs-gallery-stack__main,
.bg-dark .cs-gallery-stack__thumb {
    background: rgba(255, 255, 255, .06);
}

/* --- Responsive --- */
@media (max-width: 991px) {
    .cs-gallery {
        grid-template-columns: repeat(3, 1fr);
    }
}
@media (max-width: 575px) {
    .cs-gallery {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }
    .cs-gallery-stack__thumbs {
        gap: 6px;
        margin-top: 6px;
    }
    .cs-gallery-stack__thumb {
        flex-basis: calc((100% - 18px) / 4);
    }
    .cs-gallery-stack__arrow {
        width: 34px;
        height: 34px;
    }
    .cs-gallery__cap {
        left: 10px;
        right: 10px;
        bottom: 10px;
        font-size: 12px;
    }
}


/* ==========================================================================
   v5 · Modern gallery layouts
   .cs-gallery--bento              Wide grid: bento of one big photo, four
                                   small ones and a wide one (repeats every 6)
   .cs-gallery--modern             Uniform grid: captions always on
   .cs-gallery-carousel--modern    Photo carousel: captions always on
   .cs-gallery-stack--modern       Photo stack: round arrows, ringed thumbs
   Captions sit on a soft bottom shade; the round zoom chip only shows on
   hover because every photo is a link to the lightbox.
   ========================================================================== */
.cs-gallery--bento {
    grid-template-columns: repeat(5, minmax(0, 1fr));
    grid-auto-rows: 210px;
}
.cs-gallery--bento .cs-gallery__item,
.cs-gallery--bento .cs-gallery__item--wide {
    grid-column: auto;
    grid-row: auto;
    aspect-ratio: auto;
}
.cs-gallery--bento .cs-gallery__item:nth-child(6n+1) {
    grid-column: span 2;
    grid-row: span 2;
}
.cs-gallery--bento .cs-gallery__item:nth-child(6n) {
    grid-column: span 2;
}

/* --- Shared: shade, caption and zoom chip --- */
.cs-gallery--bento .cs-gallery__item::after,
.cs-gallery--modern .cs-gallery__item::after,
.cs-gallery-carousel--modern .cs-gallery__item::after {
    background: linear-gradient(to top, rgba(15, 23, 43, .78), rgba(15, 23, 43, 0) 55%);
    opacity: 1;
}
.cs-gallery--bento .cs-gallery__cap,
.cs-gallery--modern .cs-gallery__cap,
.cs-gallery-carousel--modern .cs-gallery__cap {
    display: flex;
    align-items: center;
    gap: 10px;
    left: 20px;
    right: 20px;
    bottom: 18px;
    opacity: 1;
    transform: none;
}
.cs-gallery--bento .cs-gallery__cap::before,
.cs-gallery--modern .cs-gallery__cap::before,
.cs-gallery-carousel--modern .cs-gallery__cap::before {
    content: '';
    flex: 0 0 auto;
    width: 16px;
    height: 2px;
    background: var(--primary);
}
.cs-gallery--bento .cs-gallery__item:nth-child(6n+1) .cs-gallery__cap {
    left: 28px;
    bottom: 26px;
    font-size: 20px;
}
.cs-gallery--bento .cs-gallery__zoom,
.cs-gallery--modern .cs-gallery__zoom,
.cs-gallery-carousel--modern .cs-gallery__zoom {
    top: 14px;
    right: 14px;
    left: auto;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    font-size: 14px;
    color: var(--white);
    background: var(--primary);
    box-shadow: 0 0 0 5px rgba(255, 255, 255, .25);
    transform: scale(.8);
}
.cs-gallery--bento .cs-gallery__item:hover .cs-gallery__zoom,
.cs-gallery--modern .cs-gallery__item:hover .cs-gallery__zoom,
.cs-gallery-carousel--modern .cs-gallery__item:hover .cs-gallery__zoom {
    transform: scale(1);
}
.cs-gallery--bento .cs-gallery__item:hover img,
.cs-gallery--modern .cs-gallery__item:hover img,
.cs-gallery-carousel--modern .cs-gallery__item:hover img {
    transform: scale(1.06);
}

/* --- Photo carousel: pill dots --- */
.cs-gallery-carousel--modern .cs-carousel__dots button,
.cs-gallery-carousel--modern .cs-dots button {
    transition: width .3s ease, background .3s ease;
}
.cs-gallery-carousel--modern .cs-carousel__dots button.is-active,
.cs-gallery-carousel--modern .cs-dots button.is-active {
    width: 24px;
    border-radius: 40px;
}

/* --- Photo stack: round glass arrows, ringed thumbs, corner dots --- */
.cs-gallery-stack--modern {
    position: relative;
}
.cs-gallery-stack--modern .cs-gallery-stack__arrow {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: rgba(255, 255, 255, .85);
    -webkit-backdrop-filter: blur(6px);
    backdrop-filter: blur(6px);
}
.cs-gallery-stack--modern .cs-gallery-stack__main .cs-gallery__zoom {
    top: 16px;
    right: 16px;
    left: auto;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    color: var(--white);
    background: var(--primary);
    box-shadow: 0 0 0 5px rgba(255, 255, 255, .25);
    transform: scale(.8);
}
.cs-gallery-stack--modern .cs-gallery-stack__main:hover .cs-gallery__zoom {
    transform: scale(1);
}
.cs-gallery-stack--modern .cs-gallery-stack__main::after {
    background: linear-gradient(to top, rgba(15, 23, 43, .35), rgba(15, 23, 43, 0) 40%);
}
.cs-gallery-stack--modern .cs-gallery-stack__thumbs {
    gap: 12px;
    margin-top: 12px;
    padding: 4px;
}
.cs-gallery-stack--modern .cs-gallery-stack__thumb {
    flex-basis: calc((100% - 48px) / 5);
    border: 0;
}
.cs-gallery-stack--modern .cs-gallery-stack__thumb.is-current {
    box-shadow: 0 0 0 2px var(--white), 0 0 0 4px var(--primary);
}
.bg-dark .cs-gallery-stack--modern .cs-gallery-stack__thumb.is-current {
    box-shadow: 0 0 0 2px var(--heading), 0 0 0 4px var(--primary);
}
.bg-lighter .cs-gallery-stack--modern .cs-gallery-stack__thumb.is-current {
    box-shadow: 0 0 0 2px var(--bg-light), 0 0 0 4px var(--primary);
}

/* --- Modern gallery: responsive --- */
@media (max-width: 991px) {
    .cs-gallery--bento {
        grid-template-columns: repeat(4, minmax(0, 1fr));
        grid-auto-rows: 180px;
    }
    .cs-gallery--bento .cs-gallery__item:nth-child(6n) {
        grid-column: span 4;
    }
}
@media (max-width: 575px) {
    .cs-gallery--bento {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        grid-auto-rows: 150px;
    }
    .cs-gallery--bento .cs-gallery__item:nth-child(6n) {
        grid-column: span 2;
    }
    .cs-gallery--bento .cs-gallery__item:nth-child(6n+1) .cs-gallery__cap {
        left: 16px;
        bottom: 16px;
        font-size: 16px;
    }
    .cs-gallery--bento .cs-gallery__cap,
    .cs-gallery--modern .cs-gallery__cap,
    .cs-gallery-carousel--modern .cs-gallery__cap {
        left: 12px;
        right: 12px;
        bottom: 12px;
        gap: 8px;
    }
    .cs-gallery--bento .cs-gallery__cap::before,
    .cs-gallery--modern .cs-gallery__cap::before,
    .cs-gallery-carousel--modern .cs-gallery__cap::before {
        width: 10px;
    }
    .cs-gallery--bento .cs-gallery__zoom,
    .cs-gallery--modern .cs-gallery__zoom,
    .cs-gallery-carousel--modern .cs-gallery__zoom {
        top: 10px;
        right: 10px;
        width: 32px;
        height: 32px;
        font-size: 12px;
    }
    .cs-gallery-stack--modern .cs-gallery-stack__thumbs {
        gap: 8px;
        margin-top: 8px;
    }
    .cs-gallery-stack--modern .cs-gallery-stack__thumb {
        flex-basis: calc((100% - 32px) / 4);
    }
}

/* Grids without captions: no resting shade, a light wash on hover only */
.cs-gallery--bento .cs-gallery__item::after,
.cs-gallery--modern .cs-gallery__item::after {
    background: rgba(15, 23, 43, .25);
    opacity: 0;
}
.cs-gallery--bento .cs-gallery__item:hover::after,
.cs-gallery--modern .cs-gallery__item:hover::after {
    opacity: 1;
}

/* Photo stack: the active ring sits inside the thumb so the scrolling
   strip never clips it */
.cs-gallery-stack--modern .cs-gallery-stack__thumbs {
    padding: 0;
}
.cs-gallery-stack--modern .cs-gallery-stack__thumb.is-current,
.bg-dark .cs-gallery-stack--modern .cs-gallery-stack__thumb.is-current,
.bg-lighter .cs-gallery-stack--modern .cs-gallery-stack__thumb.is-current {
    box-shadow: none;
}
.cs-gallery-stack--modern .cs-gallery-stack__thumb::after {
    content: '';
    position: absolute;
    inset: 0;
    border: 2px solid transparent;
    box-shadow: inset 0 0 0 2px transparent;
    pointer-events: none;
    transition: border-color .2s ease;
}
.cs-gallery-stack--modern .cs-gallery-stack__thumb.is-current::after {
    border-color: var(--primary);
    box-shadow: inset 0 0 0 2px var(--white);
}
