/* ─── Grid ─────────────────────────────────────── */
.sst-gallery {
    display: grid;
    gap: var(--gallery-gap, 12px);
    grid-template-columns: repeat(var(--gallery-cols, 3), 1fr);
}

.sst-gallery.cols-1 { --gallery-cols: 1; }
.sst-gallery.cols-2 { --gallery-cols: 2; }
.sst-gallery.cols-3 { --gallery-cols: 3; }
.sst-gallery.cols-4 { --gallery-cols: 4; }
.sst-gallery.cols-5 { --gallery-cols: 5; }
.sst-gallery.cols-6 { --gallery-cols: 6; }

@media (max-width: 768px) {
    .sst-gallery.cols-4,
    .sst-gallery.cols-5,
    .sst-gallery.cols-6 { --gallery-cols: 3; }
}
@media (max-width: 540px) {
    .sst-gallery { --gallery-cols: 2; }
}

/* ─── Item ─────────────────────────────────────── */
.sst-item {
    margin: 0;
    position: relative;
    overflow: hidden;
    border-radius: var(--gallery-radius, 6px);
    background: #111;
    aspect-ratio: 1;
}

.sst-item__link {
    display: block;
    width: 100%;
    height: 100%;
}

.sst-item__img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform .35s ease, opacity .35s ease;
}

.sst-item:hover .sst-item__img {
    transform: scale(1.04);
    opacity: .88;
}

.sst-item__overlay {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity .25s ease;
    background: rgba(0,0,0,.25);
    color: #fff;
    font-size: 28px;
    pointer-events: none;
}

.sst-item:hover .sst-item__overlay {
    opacity: 1;
}

.sst-item__caption {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 8px 12px;
    background: rgba(0,0,0,.55);
    color: #fff;
    font-size: 13px;
    line-height: 1.4;
}

.sst-item__credit {
    position: absolute;
    bottom: 6px;
    right: 8px;
    font-style: normal;
    font-size: 10px;
    color: rgba(255,255,255,.7);
    text-shadow: 0 1px 2px rgba(0,0,0,.6);
    pointer-events: none;
    z-index: 2;
}

/* ─── Lightbox ─────────────────────────────────── */
#sst-lightbox {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 99999;
    background: rgba(0,0,0,.92);
    align-items: center;
    justify-content: center;
}

#sst-lightbox.open {
    display: flex;
}

#sst-lightbox img {
    max-width: 96vw;
    max-height: calc(100vh - 100px);
    width: auto;
    height: auto;
    object-fit: contain;
    border-radius: 4px;
    box-shadow: 0 8px 40px rgba(0,0,0,.5);
}

.sst-lb-close {
    position: fixed;
    top: 16px;
    right: 20px;
    color: #fff;
    font-size: 32px;
    cursor: pointer;
    line-height: 1;
    background: none;
    border: none;
    padding: 0;
    opacity: .8;
    transition: opacity .2s;
}
.sst-lb-close:hover { opacity: 1; }

.sst-lb-arrow {
    position: fixed;
    top: 50%;
    transform: translateY(-50%);
    color: #fff;
    font-size: 36px;
    cursor: pointer;
    background: none;
    border: none;
    padding: 0 16px;
    opacity: .7;
    transition: opacity .2s;
}
.sst-lb-arrow:hover { opacity: 1; }
.sst-lb-prev { left: 0; }
.sst-lb-next { right: 0; }

.sst-lb-counter {
    position: fixed;
    bottom: 16px;
    left: 50%;
    transform: translateX(-50%);
    color: rgba(255,255,255,.6);
    font-size: 13px;
}

.sst-lb-fav,
.sst-lb-dl {
    position: fixed;
    bottom: 14px;
    background: none;
    border: 1px solid rgba(255,255,255,.35);
    border-radius: 20px;
    color: #fff;
    font-size: 13px;
    cursor: pointer;
    padding: 6px 14px;
    opacity: .75;
    transition: opacity .2s, border-color .2s, color .2s;
    text-decoration: none;
    line-height: 1.4;
}
.sst-lb-fav { right: 16px; }
.sst-lb-dl  { left: 16px; }
.sst-lb-fav:hover,
.sst-lb-dl:hover { opacity: 1; border-color: rgba(255,255,255,.7); }
.sst-lb-fav.active {
    color: #e8453c;
    border-color: #e8453c;
    opacity: 1;
}

/* ─── Cover image ───────────────────────────────── */
.sst-gallery-cover {
    margin-bottom: var(--gallery-gap, 12px);
    border-radius: var(--gallery-radius, 6px);
    overflow: hidden;
}
.sst-gallery-cover img {
    width: 100%;
    max-height: 560px;
    object-fit: contain;
    display: block;
    background: #f5f5f5;
}

/* ─── Related link ──────────────────────────────── */
.sst-gallery-related {
    margin-top: 16px;
    text-align: right;
}
.sst-gallery-related__link {
    font-size: 14px;
    font-weight: 500;
    color: var(--gallery-accent, #111);
    text-decoration: none;
}
.sst-gallery-related__link:hover {
    text-decoration: underline;
}

/* ─── Pagination ────────────────────────────────── */
.sst-pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    margin-top: 16px;
}
.sst-page-btn {
    background: none;
    border: 1px solid #ddd;
    border-radius: 4px;
    padding: 6px 14px;
    font-size: 16px;
    cursor: pointer;
    transition: background .2s, border-color .2s;
}
.sst-page-btn:hover:not(:disabled) {
    background: #f5f5f5;
    border-color: #999;
}
.sst-page-btn:disabled {
    opacity: .35;
    cursor: default;
}
.sst-page-info {
    font-size: 13px;
    color: #666;
    min-width: 48px;
    text-align: center;
}

/* ─── Download / selection mode ─────────────────── */
.sst-gallery[data-download="1"] .sst-item {
    cursor: pointer;
}
.sst-item__select {
    position: absolute;
    top: 8px;
    left: 8px;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    border: 2px solid #fff;
    background: rgba(0,0,0,.35);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity .2s;
    pointer-events: none;
    z-index: 3;
}
.sst-gallery[data-download="1"] .sst-item:hover .sst-item__select,
.sst-item.selected .sst-item__select {
    opacity: 1;
}
.sst-item.selected .sst-item__select {
    background: #e8453c;
    border-color: #e8453c;
}
.sst-item.selected .sst-item__select::after {
    content: '';
    width: 10px;
    height: 6px;
    border-left: 2px solid #fff;
    border-bottom: 2px solid #fff;
    transform: rotate(-45deg) translateY(-1px);
    display: block;
}
.sst-item.selected .sst-item__img {
    opacity: .8;
}

/* ─── Download bar ──────────────────────────────── */
.sst-download-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 12px;
    padding: 10px 14px;
    background: #f5f5f5;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 13px;
}
.sst-dl-count {
    flex: 1;
    color: #444;
}
.sst-dl-btn {
    background: #0a0a0a;
    color: #fff;
    border: none;
    border-radius: 4px;
    padding: 6px 14px;
    font-size: 13px;
    cursor: pointer;
    transition: background .2s;
}
.sst-dl-btn:hover { background: #333; }
.sst-dl-btn:disabled { opacity: .5; cursor: default; }
.sst-dl-clear {
    background: none;
    border: 1px solid #ccc;
    border-radius: 4px;
    padding: 6px 10px;
    font-size: 13px;
    cursor: pointer;
}
.sst-dl-clear:hover { border-color: #999; }

/* ─── Multi-gallery bento grid ──────────────────── */
.sst-gallery-bento {
    display: grid;
    grid-template-columns: 2fr 1fr 1fr;
    grid-auto-rows: minmax(180px, 1fr);
    gap: 10px;
}

/* Featured card spans both rows on the left */
.sst-bento-card--featured {
    grid-row: 1 / 3;
}

/* Thumbnail cards maintain aspect ratio but respect the row min-height */
.sst-bento-card:not(.sst-bento-card--featured) {
    aspect-ratio: 4 / 3;
    min-height: 180px;
}

.sst-bento-card {
    position: relative;
    overflow: hidden;
    border-radius: 6px;
    background: #111;
    display: block;
    text-decoration: none;
    /* min-height prevents collapse when there is no image */
    min-height: 80px;
}

.sst-bento-card__img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform .4s ease, opacity .35s ease;
}

.sst-bento-card:hover .sst-bento-card__img {
    transform: scale(1.04);
    opacity: .88;
}

.sst-bento-card__overlay {
    position: absolute;
    inset: 0;
    background: linear-gradient(to top, rgba(0,0,0,.62) 0%, transparent 55%);
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    padding: 16px;
    transition: background .25s ease;
    z-index: 2;
}

.sst-bento-card:hover .sst-bento-card__overlay {
    background: linear-gradient(to top, rgba(0,0,0,.72) 0%, rgba(0,0,0,.15) 100%);
}

.sst-bento-card__title {
    color: #fff;
    font-size: 15px;
    font-weight: 600;
    line-height: 1.3;
    display: block;
}

.sst-bento-card--featured .sst-bento-card__title {
    font-size: 20px;
}

.sst-bento-card__count {
    color: rgba(255,255,255,.7);
    font-size: 12px;
    margin-top: 4px;
    display: block;
}

/* ── Shuffle: mini collage inside a bento card ── */
.sst-bento-card__collage {
    position: absolute;
    inset: 0;
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-template-rows: 1fr 1fr;
    gap: 6px;
    padding: 6px;
    background: #fff; /* white shows through gap + padding = thick white borders */
    z-index: 1;
}

.sst-bento-card__collage-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: opacity .3s ease;
}

.sst-bento-card:hover .sst-bento-card__collage-img {
    opacity: .88;
}

/* Tablet: featured full-width on top, thumbnails in a row below */
@media (max-width: 680px) {
    .sst-gallery-bento {
        grid-template-columns: 1fr 1fr;
        grid-auto-rows: minmax(140px, 1fr);
    }
    .sst-bento-card--featured {
        grid-column: 1 / 3;
        grid-row: 1 / 2;
        aspect-ratio: 16 / 7;
        min-height: 200px;
    }
    .sst-bento-card:not(.sst-bento-card--featured) {
        aspect-ratio: 1;
        min-height: 140px;
    }
}

/* Mobile: single column */
@media (max-width: 400px) {
    .sst-gallery-bento {
        grid-template-columns: 1fr;
    }
    .sst-bento-card--featured,
    .sst-bento-card:not(.sst-bento-card--featured) {
        grid-column: auto;
        grid-row: auto;
        aspect-ratio: 4 / 3;
    }
}

/* ─── Gallery info ──────────────────────────────── */
.sst-gallery-info {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: baseline;
    margin-bottom: var(--gallery-gap, 12px);
    font-size: 14px;
    color: #555;
}
.sst-gallery-info__date {
    font-weight: 500;
    color: #333;
}
.sst-gallery-info__photographer {
    color: #555;
}
.sst-gallery-info__details {
    width: 100%;
    margin: 0;
    font-size: 13px;
    color: #666;
    line-height: 1.5;
}
