/* =========================================================
   SM Photo Gallery – sm-gallery.css  v1.0.0
   Hero grid + Booking.com-style masonry lightbox
   ========================================================= */

/* ── RESET / SCOPE ── */
.sm-photo-grid *,
.sm-lightbox * {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

/* =========================================================
   HERO GRID
   ========================================================= */
.sm-photo-grid {
    position: relative;
    display: grid;
    grid-template-columns: 2fr 1fr;
    grid-template-rows: 480px;
    gap: 4px;
    border-radius: 14px;
    overflow: hidden;
    margin-bottom: 32px;
    background: #eee;
}

/* ── Hero cell (left 2/3) ── */
.sm-photo-grid__hero {
    position: relative;
    overflow: hidden;
    cursor: pointer;
}

.sm-photo-grid__hero img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform 0.4s cubic-bezier(.4,0,.2,1);
}

/* ── Sidebar (right 1/3) ── */
.sm-photo-grid__sidebar {
    display: grid;
    grid-template-rows: repeat(3, 1fr);
    gap: 4px;
}

/* ── Each thumb ── */
.sm-photo-grid__thumb {
    position: relative;
    overflow: hidden;
    cursor: pointer;
}

.sm-photo-grid__thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform 0.4s cubic-bezier(.4,0,.2,1);
}

/* ── Hover shimmer shared ── */
.sm-photo-grid__cell-hover {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0);
    transition: background 0.3s ease;
    pointer-events: none;
}

.sm-photo-grid__cell:hover .sm-photo-grid__cell-hover {
    background: rgba(0,0,0,0.10);
}

.sm-photo-grid__cell:hover img {
    transform: scale(1.04);
}

/* ── "+N" badge on last thumb ── */
.sm-photo-grid__badge {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0.52);
    backdrop-filter: blur(1px);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: #fff;
    pointer-events: none;
    transition: background 0.3s;
}

.sm-photo-grid__thumb--more:hover .sm-photo-grid__badge {
    background: rgba(0,0,0,0.62);
}

.sm-photo-grid__badge-num {
    font-size: 2.2rem;
    font-weight: 700;
    line-height: 1;
    letter-spacing: -1px;
}

.sm-photo-grid__badge-lbl {
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    opacity: 0.88;
    margin-top: 5px;
}

/* ── "View all" floating button ── */
.sm-photo-grid__btn-all {
    position: absolute;
    bottom: 16px;
    right: 16px;
    background: #fff;
    border: 1.5px solid rgba(0,0,0,0.18);
    border-radius: 9px;
    padding: 9px 16px;
    font-size: 0.83rem;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 7px;
    box-shadow: 0 2px 12px rgba(0,0,0,0.14);
    transition: background 0.18s, box-shadow 0.18s, transform 0.15s;
    z-index: 10;
    color: #1a1a1a;
    line-height: 1;
    letter-spacing: -.01em;
}

.sm-photo-grid__btn-all:hover {
    background: #f7f7f7;
    box-shadow: 0 4px 20px rgba(0,0,0,0.22);
    transform: translateY(-1px);
}

.sm-photo-grid__btn-all:active {
    transform: translateY(0);
}

/* =========================================================
   LIGHTBOX OVERLAY
   ========================================================= */
body.sm-lb-open {
    overflow: hidden !important;
}

.sm-lightbox {
    position: fixed;
    inset: 0;
    z-index: 999999;
    background: #fff;
    display: flex;
    flex-direction: column;
    animation: smLbFadeIn 0.22s ease both;
}

@keyframes smLbFadeIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}

/* ── GRID VIEW container ── */
.sm-lb-grid-view {
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow-x: hidden;
    overflow-y: auto;   /* the whole panel scrolls, header stays sticky */
    -webkit-overflow-scrolling: touch;
}

/* ── Header shared ── */
.sm-lb-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 24px;
    border-bottom: 1px solid #ebebeb;
    flex-shrink: 0;
    background: #fff;
    /* Sticky so it stays visible while grid scrolls down */
    position: sticky;
    top: 0;
    z-index: 10;
}

.sm-lb-header__title {
    font-size: 1.05rem;
    font-weight: 700;
    color: #1a1a1a;
    display: flex;
    align-items: center;
}

.sm-lb-header__count {
    font-weight: 400;
    font-size: 0.85rem;
    color: #888;
    margin-left: 10px;
}

/* ── Close button ── */
.sm-lb-close {
    background: none;
    border: none;
    cursor: pointer;
    padding: 8px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #1a1a1a;
    transition: background 0.18s;
    line-height: 0;
    flex-shrink: 0;
}

.sm-lb-close:hover {
    background: #f0f0f0;
}

/* ── Masonry scrollable area ── */
.sm-lb-masonry {
    /* No flex / height limit – content expands downward naturally */
    padding: 20px 24px 60px;
    max-width: 1400px;
    margin: 0 auto;
    width: 100%;

    /* 4-column CSS masonry – photos keep natural height, fill columns top→down */
    columns: 3;
    column-gap: 10px;
}

/* ── Individual masonry card ── */
.sm-lb-masonry__item {
    break-inside: avoid;
    margin-bottom: 10px;
    border-radius: 4px;
    overflow: hidden;
    cursor: pointer;
    position: relative;
    display: block;
    transition: transform 0.18s ease, box-shadow 0.18s ease;
    background: #e8e8e8;
}

.sm-lb-masonry__item:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(0,0,0,0.14);
    z-index: 1;
}

.sm-lb-masonry__item:hover .sm-lb-masonry__overlay {
    opacity: 1;
}

.sm-lb-masonry__item img {
    width: 100%;
    height: auto;
    display: block;
    vertical-align: top;
}

/* zoom icon overlay */
.sm-lb-masonry__overlay {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0.30);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.2s ease;
}

/* =========================================================
   SINGLE PHOTO VIEW
   ========================================================= */
.sm-lb-single-view {
    display: flex;
    flex-direction: column;
    height: 100vh;
    background: #111;
}

.sm-lb-single-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 20px;
    background: rgba(0,0,0,0.75);
    backdrop-filter: blur(8px);
    flex-shrink: 0;
    gap: 12px;
}

/* Back to grid */
.sm-lb-back {
    background: none;
    border: none;
    color: rgba(255,255,255,0.88);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 3px;
    font-size: 0.88rem;
    font-weight: 500;
    padding: 6px 12px 6px 8px;
    border-radius: 7px;
    transition: background 0.18s, color 0.18s;
    line-height: 1;
    white-space: nowrap;
}

.sm-lb-back:hover {
    background: rgba(255,255,255,0.12);
    color: #fff;
}

/* Counter "3 / 12" */
.sm-lb-single-counter {
    color: rgba(255,255,255,0.70);
    font-size: 0.88rem;
    letter-spacing: 0.03em;
    flex-shrink: 0;
}

.sm-lb-close--single {
    color: rgba(255,255,255,0.88);
}

.sm-lb-close--single:hover {
    background: rgba(255,255,255,0.12);
    color: #fff;
}

/* ── Stage (image + arrows) ── */
.sm-lb-single-stage {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
    user-select: none;
}

/* ── Image frame ── */
.sm-lb-single-frame {
    max-width: calc(100vw - 140px);
    max-height: calc(100vh - 70px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px 0;
}

.sm-lb-single-img {
    display: block;
    max-width: 100%;
    max-height: calc(100vh - 110px);
    object-fit: contain;
    border-radius: 3px;
    transition: opacity 0.2s ease;
}

/* ── Prev / Next arrows ── */
.sm-lb-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(255,255,255,0.14);
    border: 1px solid rgba(255,255,255,0.18);
    color: #fff;
    width: 54px;
    height: 54px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s, transform 0.2s;
    z-index: 10;
    backdrop-filter: blur(6px);
    line-height: 0;
    flex-shrink: 0;
}

.sm-lb-nav:hover {
    background: rgba(255,255,255,0.28);
    transform: translateY(-50%) scale(1.05);
}

.sm-lb-nav:active {
    transform: translateY(-50%) scale(0.97);
}

.sm-lb-nav--prev { left: 18px; }
.sm-lb-nav--next { right: 18px; }

.sm-lb-nav:disabled,
.sm-lb-nav.is-hidden {
    opacity: 0;
    pointer-events: none;
}

/* =========================================================
   RESPONSIVE
   ========================================================= */

/* ── Large tablet – 3 columns ── */
@media (max-width: 1100px) {
    .sm-lb-masonry {
        columns: 3;
        column-gap: 8px;
    }
}

/* ── Tablet – 2 columns ── */
@media (max-width: 900px) {
    .sm-photo-grid {
        grid-template-rows: 360px;
        border-radius: 10px;
    }

    .sm-photo-grid__badge-num {
        font-size: 1.7rem;
    }

    .sm-lb-masonry {
        columns: 2;
        padding: 14px 16px 48px;
        column-gap: 7px;
    }

    .sm-lb-single-frame {
        max-width: calc(100vw - 100px);
    }
}

/* ── Mobile ── */
@media (max-width: 640px) {
    .sm-photo-grid {
        grid-template-columns: 1fr;
        grid-template-rows: auto;
        border-radius: 8px;
        gap: 3px;
    }

    .sm-photo-grid__hero {
        height: 260px;
    }

    .sm-photo-grid__sidebar {
        grid-template-rows: none;
        grid-template-columns: repeat(3, 1fr);
        height: 105px;
    }

    .sm-photo-grid__badge-num {
        font-size: 1.5rem;
    }

    .sm-photo-grid__badge-lbl {
        display: none;
    }

    .sm-photo-grid__btn-all {
        bottom: 10px;
        right: 10px;
        font-size: 0.77rem;
        padding: 7px 11px;
    }

    /* Lightbox grid – single column on very small screens */
    .sm-lb-masonry {
        columns: 2;
        padding: 10px 10px 24px;
        column-gap: 6px;
    }

    .sm-lb-masonry__item {
        margin-bottom: 6px;
    }

    .sm-lb-header {
        padding: 12px 16px;
    }

    .sm-lb-header__title {
        font-size: 0.95rem;
    }

    /* Single view on mobile */
    .sm-lb-single-frame {
        max-width: 100vw;
        padding: 10px 0;
    }

    .sm-lb-single-img {
        max-height: calc(100vh - 100px);
        border-radius: 0;
    }

    .sm-lb-nav {
        width: 42px;
        height: 42px;
    }

    .sm-lb-nav--prev { left: 8px; }
    .sm-lb-nav--next { right: 8px; }

    .sm-lb-single-header {
        padding: 8px 12px;
    }
}

@media (max-width: 400px) {
    .sm-lb-masonry {
        columns: 1;
    }
}

/* ── Keyboard focus rings ── */
.sm-photo-grid__cell:focus-visible {
    outline: 3px solid #2563eb;
    outline-offset: -3px;
}

.sm-lb-nav:focus-visible,
.sm-lb-close:focus-visible,
.sm-lb-back:focus-visible {
    outline: 2px solid #2563eb;
    outline-offset: 2px;
}
