/* ================================================================
   Photo gallery block (Galerija)
   .pg-grid      — mosaic of photos (every 6th starts with a large one)
   .pg-lightbox  — full screen viewer with arrows, swipe and thumbnails
   Section head reuses .pub-section / .pub-section__head
   from publications-block.css
   ================================================================ */

.pg-block * {
    box-sizing: border-box;
}

/* bar above the grid */

.pg-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin: 0 0 20px;
}

.pg-bar__count {
    margin: 0;
    font-size: 13px;
    font-weight: 500;
    letter-spacing: .1em;
    text-transform: uppercase;
    color: var(--pub-bordo-soft);
}

.pg-bar__btn {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 11px 20px;
    border: 1px solid var(--pub-line);
    border-radius: 999px;
    background-color: #fff;
    font-family: 'Roboto', sans-serif;
    font-size: 15px;
    font-weight: 500;
    color: var(--pub-bordo);
    cursor: pointer;
    transition: border-color .2s ease, background-color .2s ease;
}

.pg-bar__btn:hover {
    border-color: var(--pub-bordo);
    background-color: var(--pub-card);
}

.pg-bar__btn svg {
    width: 20px;
    height: 20px;
}

/* mosaic */

.pg-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    grid-auto-rows: 250px;
    grid-auto-flow: dense;
    gap: 18px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.pg-item:nth-child(6n + 1) {
    grid-column: span 2;
    grid-row: span 2;
}

.pg-tile {
    position: relative;
    display: block;
    width: 100%;
    height: 100%;
    padding: 0;
    overflow: hidden;
    border: 0;
    border-radius: 20px;
    background-color: var(--pub-card);
    box-shadow: var(--pub-shadow-s);
    font-family: 'Roboto', sans-serif;
    text-align: left;
    cursor: zoom-in;
    isolation: isolate;
}

.pg-tile__img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform .6s cubic-bezier(.2, .7, .2, 1);
}

.pg-tile::after {
    content: '';
    position: absolute;
    inset: 0;
    z-index: 1;
    background: linear-gradient(180deg, rgba(40, 8, 18, 0) 38%, rgba(40, 8, 18, .55) 68%, rgba(40, 8, 18, .88) 100%);
    transition: opacity .3s ease;
}

.pg-tile__zoom {
    position: absolute;
    top: 16px;
    right: 16px;
    z-index: 2;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background-color: rgba(255, 255, 255, .92);
    color: var(--pub-bordo);
    opacity: 0;
    transform: scale(.8);
    transition: opacity .25s ease, transform .25s ease;
}

.pg-tile__zoom svg {
    width: 20px;
    height: 20px;
}

.pg-tile__caption {
    text-shadow: 0 1px 8px rgba(0, 0, 0, .35);
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 2;
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 20px 22px;
    color: #fff;
}

.pg-tile__num {
    font-size: 12px;
    font-weight: 500;
    letter-spacing: .14em;
    color: rgba(255, 255, 255, .75);
}

.pg-tile__caption b {
    font-size: 19px;
    font-weight: 700;
    line-height: 1.25;
}

.pg-tile__text {
    max-height: 0;
    overflow: hidden;
    font-size: 14px;
    line-height: 1.45;
    color: rgba(255, 255, 255, .85);
    opacity: 0;
    transition: max-height .35s ease, opacity .35s ease;
}

.pg-item:nth-child(6n + 1) .pg-tile__caption {
    padding: 28px 30px;
}

.pg-item:nth-child(6n + 1) .pg-tile__caption b {
    font-size: 26px;
}

.pg-item:nth-child(6n + 1) .pg-tile__text {
    max-height: 60px;
    opacity: 1;
}

.pg-tile:hover .pg-tile__img,
.pg-tile:focus-visible .pg-tile__img {
    transform: scale(1.05);
}

.pg-tile:hover .pg-tile__zoom,
.pg-tile:focus-visible .pg-tile__zoom {
    opacity: 1;
    transform: none;
}

.pg-tile:hover .pg-tile__text,
.pg-tile:focus-visible .pg-tile__text {
    max-height: 60px;
    opacity: 1;
}

.pg-tile:focus-visible {
    outline: 3px solid var(--pub-red);
    outline-offset: 3px;
}

/* lightbox */

.pg-lightbox {
    width: 100vw;
    max-width: 100vw;
    height: 100vh;
    height: 100dvh;
    max-height: 100dvh;
    margin: 0;
    padding: 18px 24px 16px;
    border: 0;
    background-color: rgba(24, 8, 14, .96);
    color: #fff;
    font-family: 'Roboto', sans-serif;
}

.pg-lightbox[open] {
    display: flex;
    flex-direction: column;
    gap: 14px;
    animation: pg-in .3s ease;
}

.pg-lightbox::backdrop {
    background-color: rgba(24, 8, 14, .6);
}

@keyframes pg-in {
    0% { opacity: 0; }
    100% { opacity: 1; }
}

.pg-lightbox__top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.pg-lightbox__count {
    margin: 0;
    font-size: 14px;
    letter-spacing: .08em;
    color: rgba(255, 255, 255, .7);
}

.pg-lightbox__count b {
    color: #fff;
}

.pg-lightbox__close,
.pg-lightbox__nav {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    padding: 0;
    border: 1px solid rgba(255, 255, 255, .22);
    border-radius: 50%;
    background-color: rgba(255, 255, 255, .06);
    color: #fff;
    cursor: pointer;
    transition: background-color .2s ease, border-color .2s ease;
}

.pg-lightbox__close:hover,
.pg-lightbox__nav:hover {
    border-color: rgba(255, 255, 255, .6);
    background-color: rgba(255, 255, 255, .16);
}

.pg-lightbox__close:focus-visible,
.pg-lightbox__nav:focus-visible,
.pg-thumb:focus-visible {
    outline: 2px solid #fff;
    outline-offset: 2px;
}

.pg-lightbox__close:focus:not(:focus-visible) {
    outline: none;
}

.pg-lightbox__close svg,
.pg-lightbox__nav svg {
    width: 22px;
    height: 22px;
}

.pg-lightbox__stage {
    position: relative;
    display: flex;
    flex: 1 1 auto;
    align-items: center;
    justify-content: center;
    min-height: 0;
    margin: 0;
    padding: 0 72px;
    touch-action: pan-y;
}

.pg-lightbox__img {
    display: block;
    max-width: 100%;
    max-height: 100%;
    border-radius: 14px;
    object-fit: contain;
    box-shadow: 0 24px 60px rgba(0, 0, 0, .45);
    user-select: none;
    -webkit-user-drag: none;
}

.pg-lightbox__img.is-in {
    animation: pg-img .35s ease;
}

@keyframes pg-img {
    0% { opacity: 0; transform: scale(.97); }
    100% { opacity: 1; transform: none; }
}

.pg-lightbox__nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
}

.pg-lightbox__nav--prev {
    left: 0;
}

.pg-lightbox__nav--next {
    right: 0;
}

.pg-lightbox__info {
    max-width: 760px;
    margin: 0 auto;
    text-align: center;
}

.pg-lightbox__title {
    margin: 0 0 4px;
    font-size: 22px;
    font-weight: 700;
    line-height: 1.3;
}

.pg-lightbox__text {
    margin: 0;
    font-size: 15px;
    line-height: 1.5;
    color: rgba(255, 255, 255, .75);
}

.pg-lightbox__text:empty {
    display: none;
}

.pg-lightbox__thumbs {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin: 0;
    padding: 4px 0;
    overflow-x: auto;
    list-style: none;
    scrollbar-width: none;
}

.pg-lightbox__thumbs::-webkit-scrollbar {
    display: none;
}

.pg-thumb {
    display: block;
    flex: 0 0 auto;
    width: 78px;
    height: 54px;
    padding: 0;
    overflow: hidden;
    border: 2px solid transparent;
    border-radius: 10px;
    background: none;
    opacity: .5;
    cursor: pointer;
    transition: opacity .2s ease, border-color .2s ease;
}

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

.pg-thumb:hover {
    opacity: .85;
}

.pg-thumb.is-active {
    border-color: #fff;
    opacity: 1;
}

html.pg-lock {
    overflow: hidden;
}

/* ================= responsive ================= */

@media (max-width: 1024px) {
    .pg-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        grid-auto-rows: 220px;
        gap: 14px;
    }

    .pg-item:nth-child(6n) {
        grid-column: span 2;
    }
}

@media (max-width: 768px) {
    .pg-tile__text {
        max-height: 60px;
        opacity: 1;
    }

    .pg-tile__zoom {
        opacity: 1;
        transform: none;
        width: 36px;
        height: 36px;
    }

    .pg-lightbox {
        padding: 14px 12px 12px;
    }

    .pg-lightbox__stage {
        padding: 0;
    }

    .pg-lightbox__nav {
        top: auto;
        bottom: 10px;
        width: 42px;
        height: 42px;
        transform: none;
        background-color: rgba(24, 8, 14, .6);
    }

    .pg-lightbox__nav--prev {
        left: 10px;
    }

    .pg-lightbox__nav--next {
        right: 10px;
    }

    .pg-lightbox__title {
        font-size: 18px;
    }

    .pg-lightbox__text {
        font-size: 14px;
    }

    .pg-thumb {
        width: 60px;
        height: 42px;
    }
}

@media (max-width: 576px) {
    .pg-bar {
        flex-wrap: wrap;
    }

    .pg-grid {
        grid-template-columns: minmax(0, 1fr);
        grid-auto-rows: auto;
        gap: 12px;
    }

    .pg-item,
    .pg-item:nth-child(6n),
    .pg-item:nth-child(6n + 1) {
        grid-column: auto;
        grid-row: auto;
    }

    .pg-tile,
    .pg-item:nth-child(6n + 1) .pg-tile {
        min-height: 0;
        aspect-ratio: 4 / 3;
        border-radius: 16px;
    }

    .pg-tile__caption,
    .pg-item:nth-child(6n + 1) .pg-tile__caption {
        padding: 16px 18px;
    }

    .pg-tile__caption b,
    .pg-item:nth-child(6n + 1) .pg-tile__caption b {
        font-size: 18px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .pg-tile__img,
    .pg-lightbox[open],
    .pg-lightbox__img.is-in {
        transition: none;
        animation: none;
    }
}