/* =========================================================
   BoscoCR — Unified "Nuestro Trabajo" Gallery
   Ordered masonry + filters + shared-element expand lightbox
   Vanilla CSS/JS, no dependencies.
   ========================================================= */

#work-gallery {
    padding: 30px 0 70px;
    background: #f7f7f7;
}

/* ---------------- Filters ---------------- */

.bosco-filters {
    max-width: 1400px;
    margin: 0 auto 30px;
    padding: 0 16px;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.bosco-filter {
    -webkit-appearance: none;
    appearance: none;
    font: inherit;
    font-size: 12px;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: #555;
    background: #fff;
    border: 1px solid #dcdcdc;
    border-radius: 999px;
    padding: 8px 16px;
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}

.bosco-filter:hover {
    border-color: #ffc153;
    color: #222;
}

.bosco-filter.is-active {
    background: #ffc153;
    border-color: #ffc153;
    color: #222;
    font-weight: 700;
}

.bosco-filter:focus-visible,
.bosco-gallery-item:focus-visible {
    outline: 2px solid #222;
    outline-offset: 3px;
}

.bosco-filter-sep {
    display: inline-block;
    width: 1px;
    height: 20px;
    background: #d5d5d5;
    margin: 0 4px;
}

.bosco-empty {
    text-align: center;
    color: #888;
    padding: 40px 16px 0;
    margin: 0;
}

/* ---------------- Ordered masonry ---------------- */

.bosco-gallery {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 16px;
    display: flex;
    align-items: flex-start;
    gap: 16px;
}

.bosco-col {
    flex: 1 1 0;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.bosco-gallery-item {
    display: block;
    width: 100%;
    padding: 0;
    border: 0;
    margin: 0;
    background: #e9e9e9;
    border-radius: 6px;
    overflow: hidden;
    cursor: zoom-in;
    position: relative;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.06);
    -webkit-appearance: none;
    appearance: none;
}

.bosco-gallery-item img {
    display: block;
    width: 100%;
    height: auto;
    transform: scale(1);
    transition: transform 0.5s cubic-bezier(.2, .8, .2, 1);
}

.bosco-gallery-item:hover img {
    transform: scale(1.045);
}

.bosco-gallery-item.is-open-source img {
    /* source thumbnail hides while its shared-element clone animates */
    visibility: hidden;
}

@media (max-width: 768px) {
    .bosco-gallery { gap: 10px; padding: 0 10px; }
    .bosco-col { gap: 10px; }
    .bosco-filters { justify-content: flex-start; flex-wrap: nowrap; overflow-x: auto; -webkit-overflow-scrolling: touch; padding-bottom: 6px; }
    .bosco-filter { font-size: 11px; padding: 7px 13px; }
}

/* ---------------- Lightbox ---------------- */

.bosco-lightbox-backdrop {
    position: fixed;
    inset: 0;
    z-index: 9998;
    background: rgba(12, 12, 12, 0.72);
    -webkit-backdrop-filter: blur(18px) saturate(140%);
    backdrop-filter: blur(18px) saturate(140%);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.4s ease;
}

.bosco-lightbox-backdrop.is-active {
    opacity: 1;
    pointer-events: auto;
}

.bosco-lightbox-img {
    position: fixed;
    z-index: 9999;
    top: 0;
    left: 0;
    object-fit: cover;
    border-radius: 6px;
    box-shadow: 0 25px 70px rgba(0, 0, 0, 0.55);
    transition: top 0.5s cubic-bezier(.2, .8, .2, 1),
                left 0.5s cubic-bezier(.2, .8, .2, 1),
                width 0.5s cubic-bezier(.2, .8, .2, 1),
                height 0.5s cubic-bezier(.2, .8, .2, 1),
                opacity 0.25s ease;
    will-change: top, left, width, height;
    cursor: grab;
    display: none;
}

.bosco-lightbox-img.is-dragging {
    transition: none;
    cursor: grabbing;
}

/* navigating between images cross-fades in place instead of flying
   back to a thumbnail that may be far outside the viewport */
.bosco-lightbox-img.is-swapping {
    transition: opacity 0.18s ease;
}

.bosco-lightbox-img.is-expanded {
    object-fit: contain;
    background: #111;
}

.bosco-lightbox-close,
.bosco-lightbox-nav {
    position: fixed;
    z-index: 10000;
    background: rgba(20, 20, 20, 0.45);
    color: #fff;
    border: none;
    width: 46px;
    height: 46px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease, background 0.2s ease;
}

.bosco-lightbox-close:hover,
.bosco-lightbox-nav:hover {
    background: rgba(20, 20, 20, 0.8);
}

.bosco-lightbox-close.is-active,
.bosco-lightbox-nav.is-active {
    opacity: 1;
    pointer-events: auto;
}

.bosco-lightbox-close { top: 24px; right: 24px; }
.bosco-lightbox-nav.prev { left: 24px; top: 50%; margin-top: -23px; }
.bosco-lightbox-nav.next { right: 24px; top: 50%; margin-top: -23px; }

.bosco-lightbox-counter {
    position: fixed;
    z-index: 10000;
    bottom: 26px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(20, 20, 20, 0.55);
    color: #fff;
    font-size: 13px;
    letter-spacing: 0.06em;
    padding: 7px 15px;
    border-radius: 999px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.bosco-lightbox-counter.is-active { opacity: 1; }

/* lock page scroll behind the lightbox */
body.bosco-lock {
    overflow: hidden;
}

@media (max-width: 600px) {
    .bosco-lightbox-nav { display: none; }
    .bosco-lightbox-close { top: 14px; right: 14px; }
    .bosco-lightbox-counter { bottom: 16px; }
}

@media (prefers-reduced-motion: reduce) {
    .bosco-lightbox-img,
    .bosco-gallery-item img {
        transition: none;
    }
}
