/* =============================================================================
   mod_photogallery — Frontend styles
   BEM naming: .pg-block__element--modifier
   Requires: Bootstrap 5 (bundled with Joomla 5/6)
   ============================================================================= */

/* ── Shared tile ─────────────────────────────────────────────────────────── */
.pg-tile {
    position: relative;
    overflow: hidden;
    border-radius: .375rem;
    background: #1a1a1a;
    cursor: zoom-in;
}

.pg-tile__img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform .3s ease, opacity .3s ease;
}

.pg-tile:hover .pg-tile__img {
    transform: scale(1.04);
    opacity: .9;
}

.pg-tile__caption {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: .4rem .6rem;
    background: linear-gradient(transparent, rgba(0,0,0,.65));
    color: #fff;
    font-size: .8125rem;
    line-height: 1.3;
    pointer-events: none;
}

/* ── Masonry mode ────────────────────────────────────────────────────────── */
.pg-masonry {
    columns: var(--pg-cols, 3);
    column-gap: .5rem;
}

.pg-masonry__item {
    break-inside: avoid;
    margin-bottom: .5rem;
    border-radius: .375rem;
    overflow: hidden;
    position: relative;
    cursor: zoom-in;
}

.pg-masonry__img {
    width: 100%;
    height: auto;
    display: block;
    transition: transform .3s ease, opacity .3s ease;
}

.pg-masonry__item:hover .pg-masonry__img {
    transform: scale(1.03);
    opacity: .92;
}

.pg-masonry__item .pg-tile__caption {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: .4rem .6rem;
    background: linear-gradient(transparent, rgba(0,0,0,.65));
    color: #fff;
    font-size: .8125rem;
    line-height: 1.3;
    pointer-events: none;
}

@media (max-width: 575.98px) {
    .pg-masonry { columns: 1 !important; }
}

@media (min-width: 576px) and (max-width: 767.98px) {
    .pg-masonry { columns: min(2, var(--pg-cols, 3)) !important; }
}

/* ── Carousel mode ───────────────────────────────────────────────────────── */
.pg-carousel {
    border-radius: .375rem;
    overflow: hidden;
}

.pg-carousel__img {
    height: 100%;
    object-fit: cover;
    cursor: pointer;
}

.pg-carousel__caption p {
    font-size: .875rem;
    margin-bottom: 0;
    text-shadow: 0 1px 3px rgba(0,0,0,.8);
}

/* ── Spotlight mode ──────────────────────────────────────────────────────── */
.pg-spotlight {
    display: flex;
    flex-direction: column;
    gap: .5rem;
}

.pg-spotlight__hero {
    position: relative;
    overflow: hidden;
    border-radius: .375rem;
    background: #1a1a1a;
    cursor: zoom-in;
    max-height: 480px;
}

.pg-spotlight__hero-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    max-height: 480px;
    transition: transform .3s ease;
}

.pg-spotlight__hero:hover .pg-spotlight__hero-img {
    transform: scale(1.025);
}

.pg-spotlight__strip {
    display: flex;
    flex-wrap: nowrap;
    gap: .375rem;
    overflow-x: auto;
    scroll-behavior: smooth;
    scrollbar-width: thin;
    scrollbar-color: #adb5bd transparent;
    padding-bottom: .25rem;
}

.pg-spotlight__strip::-webkit-scrollbar { height: 4px; }
.pg-spotlight__strip::-webkit-scrollbar-track { background: transparent; }
.pg-spotlight__strip::-webkit-scrollbar-thumb { background: #adb5bd; border-radius: 2px; }

.pg-spotlight__thumb {
    flex: 0 0 auto;
    width: 80px;
    height: 60px;
    border-radius: .25rem;
    overflow: hidden;
    cursor: zoom-in;
    opacity: .75;
    transition: opacity .2s ease, transform .2s ease;
}

.pg-spotlight__thumb:hover {
    opacity: 1;
    transform: scale(1.05);
}

.pg-spotlight__thumb-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

/* ── Lightbox ────────────────────────────────────────────────────────────── */
.pg-lightbox {
    position: fixed;
    inset: 0;
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
}

.pg-lightbox[hidden] {
    display: none !important;
}

.pg-lightbox__backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, .88);
    cursor: pointer;
}

.pg-lightbox__stage {
    position: relative;
    z-index: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    padding: 3rem 4.5rem;
    box-sizing: border-box;
}

.pg-lightbox__figure {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: .625rem;
    max-width: 100%;
    max-height: 100%;
    margin: 0;
}

.pg-lightbox__img {
    display: block;
    max-width: 100%;
    max-height: calc(100vh - 8rem);
    object-fit: contain;
    border-radius: .25rem;
    box-shadow: 0 8px 40px rgba(0, 0, 0, .6);
    user-select: none;
}

.pg-lightbox__caption {
    color: rgba(255, 255, 255, .85);
    font-size: .875rem;
    text-align: center;
    max-width: 60ch;
    line-height: 1.4;
    min-height: 1.2em;
}

/* ── Lightbox buttons ────────────────────────────────────────────────────── */
.pg-lightbox__btn {
    position: absolute;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    border: 2px solid rgba(255,255,255,.3);
    border-radius: 50%;
    background: rgba(0, 0, 0, .45);
    color: #fff;
    cursor: pointer;
    transition: background .15s, border-color .15s, transform .15s;
    z-index: 2;
    line-height: 1;
}

.pg-lightbox__btn:hover {
    background: rgba(0, 0, 0, .75);
    border-color: rgba(255,255,255,.7);
    transform: scale(1.08);
}

.pg-lightbox__btn:focus-visible {
    outline: 2px solid #0d6efd;
    outline-offset: 2px;
}

.pg-lightbox__btn--close {
    top: 1rem;
    right: 1rem;
    width: 2.5rem;
    height: 2.5rem;
    font-size: 1.1rem;
}

.pg-lightbox__btn--prev,
.pg-lightbox__btn--next {
    top: 50%;
    transform: translateY(-50%);
    width: 3rem;
    height: 3rem;
    font-size: 1.75rem;
}

.pg-lightbox__btn--prev:hover,
.pg-lightbox__btn--next:hover {
    transform: translateY(-50%) scale(1.08);
}

.pg-lightbox__btn--prev { left: .75rem; }
.pg-lightbox__btn--next { right: .75rem; }

.pg-lightbox--single .pg-lightbox__btn--prev,
.pg-lightbox--single .pg-lightbox__btn--next {
    display: none;
}

/* ── Lightbox animation ──────────────────────────────────────────────────── */
.pg-lightbox:not([hidden]) {
    animation: pgLbFadeIn .18s ease;
}

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

/* ── Reduce motion ───────────────────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
    .pg-tile__img,
    .pg-masonry__img,
    .pg-spotlight__hero-img,
    .pg-spotlight__thumb,
    .pg-lightbox__btn {
        transition: none;
    }

    .pg-lightbox:not([hidden]) {
        animation: none;
    }
}
