/* Rezerwujemy miejsce na przyklejony nagłówek po przejściu do kotwicy. */
#foto_gallery,
#photo-gallery-title {
    scroll-margin-top: calc(64px + var(--wp-admin--admin-bar--height, 0px));
}

.ro-gallery-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 24px 4%;
}

#foto_gallery .ro-gallery-grid {
    padding-inline: 2%;
}

@media (max-width: 600px) {
    .ro-gallery-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        row-gap: 16px;
    }
}

.ro-gallery-card {
    display: block;
    min-width: 0;
    font-size: 14px;
    font-weight: bold;
}

#foto_gallery .ro-gallery-card,
#foto_gallery .ro-gallery-empty {
    color: #fff;
}

.ro-gallery-frame {
    position: relative;
    display: block;
    aspect-ratio: 250 / 141;
    background: #333;
}

.ro-gallery-frame .ro-gallery-photo {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.ro-gallery-frame .ro-gallery-photo[hidden],
.ro-gallery-missing[hidden],
.ro-gallery-large[hidden] {
    display: none;
}

.ro-gallery-missing {
    display: grid;
    min-height: 5rem;
    height: 100%;
    place-items: center;
    padding: 8px;
    box-sizing: border-box;
    font-size: 14px;
    text-align: center;
    color: #fff;
}

.ro-gallery-card-title {
    display: block;
    padding-top: 5px;
    overflow-wrap: anywhere;
    font-weight: 500;
}

.ro-gallery-card:focus-visible,
.ro-gallery-pagination a:focus-visible {
    outline: 2px solid currentColor;
    outline-offset: 4px;
}

.ro-gallery-pagination {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 12px;
    margin-top: 24px;
}

.ro-gallery-detail {
    margin-block: 30px 50px;
    padding-inline: 12px;
    box-sizing: border-box;
}

.ro-gallery-back {
    display: inline-block;
    margin-bottom: 16px;
}

#ro-gallery-dialog {
    width: min(960px, calc(100vw - 24px));
    max-height: calc(100dvh - 24px);
    box-sizing: border-box;
    padding: 12px;
    border: 0;
    color: #fff;
    background: #1b1b1b;
}

#ro-gallery-dialog:not([open]) {
    display: none;
}

#ro-gallery-dialog::backdrop {
    background: rgb(0 0 0 / .85);
}

.ro-gallery-dialog-header,
.ro-gallery-dialog-controls {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.ro-gallery-dialog-header p {
    margin: 0;
    font-weight: bold;
}

#ro-gallery-dialog figure {
    margin: 12px 0;
    text-align: center;
}

.ro-gallery-large {
    display: block;
    width: 100%;
    height: auto;
    max-height: min(62vh, 650px);
    object-fit: contain;
}

#ro-gallery-dialog figcaption:not(:empty) {
    margin-top: 8px;
}

#ro-gallery-dialog button {
    padding: 7px 10px;
    font: inherit;
    cursor: pointer;
}

#ro-gallery-dialog button[aria-disabled="true"] {
    opacity: .55;
    cursor: default;
}

/* Obracająca się ikona pojawia się na środku klikniętego zdjęcia. */
.ro-gallery-card.is-gallery-loading .ro-gallery-frame::before,
.ro-gallery-card.is-gallery-loading .ro-gallery-frame::after {
    content: '';
    position: absolute;
    inset: 0;
    margin: auto;
    border-radius: 50%;
    pointer-events: none;
}

.ro-gallery-card.is-gallery-loading .ro-gallery-frame::before {
    width: 3rem;
    height: 3rem;
    background: rgba(0, 0, 0, 0.8);
}

.ro-gallery-card.is-gallery-loading .ro-gallery-frame::after {
    width: 1.75rem;
    height: 1.75rem;
    box-sizing: border-box;
    border: 3px solid rgba(255, 255, 255, 0.4);
    border-top-color: #fff;
    animation: ro-gallery-spin 700ms linear infinite;
}

@keyframes ro-gallery-spin {
    to {
        transform: rotate(1turn);
    }
}

.ro-gallery-loading-status {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
}

/* Zaznaczamy pierwsze pobieranie biblioteki i danych. */
.ro-gallery-grid[aria-busy="true"],
.ro-gallery-grid[aria-busy="true"] a {
    cursor: progress;
}

/* Gesty zdjęcia i przewijanie paska mają osobne obszary dotyku. */
.pswp.ro-gallery-lightbox {
    --pswp-bg: #000;
    touch-action: auto;
}

.ro-gallery-lightbox .pswp__scroll-wrap {
    touch-action: none;
}

.ro-gallery-lightbox img.pswp__img {
    object-fit: contain;
}

/* Po otwarciu galerii wskaźnik PhotoSwipe pozostaje w obszarze zdjęcia. */
.ro-gallery-lightbox .pswp__preloader {
    position: fixed;
    top: 50%;
    left: 50%;
    display: grid;
    place-items: center;
    width: 3rem;
    height: 3rem;
    margin: 0;
    border-radius: 50%;
    transform: translate(-50%, -50%);
    pointer-events: none;
}

.ro-gallery-lightbox .pswp__preloader--active {
    background: rgba(0, 0, 0, 0.8);
}

.ro-gallery-lightbox .pswp__preloader .pswp__icn {
    position: static;
    width: 2rem;
    height: 2rem;
}

@media (prefers-reduced-motion: reduce) {
    .ro-gallery-card.is-gallery-loading .ro-gallery-frame::after,
    .ro-gallery-lightbox .pswp__preloader .pswp__icn {
        animation: none;
    }
}

/* Boczne kolumny oddzielają wyśrodkowany tytuł od licznika i zamknięcia. */
.ro-gallery-lightbox .pswp__top-bar {
    height: auto;
    display: grid;
    grid-template-columns: minmax(4.5rem, 1fr) minmax(0, 6fr) minmax(4.5rem, 1fr);
    align-items: start;
}

.ro-gallery-lightbox .pswp__counter {
    grid-area: 1 / 1;
    justify-self: start;
}

.ro-gallery-lightbox .pswp__button--close {
    grid-area: 1 / 3;
    justify-self: end;
}

.ro-gallery-lightbox-title {
    grid-area: 1 / 2;
    min-width: 0;
    margin: 0;
    padding: 0.75rem 0.25rem;
    color: #fff;
    font-size: clamp(0.9375rem, 3vw, 1.125rem);
    font-weight: 600;
    line-height: 1.25;
    text-align: center;
    overflow-wrap: anywhere;
}

/* Podpis i miniatury są poza obszarem przesuwania zdjęcia. */
.ro-gallery-lightbox-footer {
    --thumb-width: 84px;
    position: absolute;
    right: 0;
    bottom: 0;
    left: 0;
    z-index: 10;
    color: #fff;
}

.ro-gallery-lightbox-caption {
    max-width: 60rem;
    margin: 0 auto;
    padding: 0.35rem 0.75rem;
    font-size: 0.875rem;
    line-height: 1.3;
    text-align: center;
    overflow-wrap: anywhere;
}

.ro-gallery-lightbox-caption:empty {
    display: none;
}

.ro-gallery-lightbox-thumbs {
    position: relative;
    display: flex;
    justify-content: safe center;
    gap: 0.375rem;
    padding: 0.5rem max(0.5rem, env(safe-area-inset-right)) max(0.5rem, env(safe-area-inset-bottom)) max(0.5rem, env(safe-area-inset-left));
    overflow-x: auto;
    overscroll-behavior-x: contain;
    touch-action: pan-x;
}

.ro-gallery-lightbox-thumbs button {
    flex: 0 0 var(--thumb-width);
    display: block;
    padding: 2px;
    border: 0;
    aspect-ratio: 7 / 5;
    background: #262626;
    cursor: pointer;
}

.ro-gallery-lightbox-thumbs button[aria-current],
.ro-gallery-lightbox-thumbs button:focus-visible {
    outline: 2px solid #fff;
    outline-offset: -2px;
}

.ro-gallery-lightbox-thumbs img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

@media (max-width: 600px) {
    .ro-gallery-lightbox-footer {
        --thumb-width: 60px;
    }
}
