/* =========================================================
   CHOTEK – Galerie i Tabele
   ========================================================= */

/* ---------- GALERIE ---------- */

/* Gutenberg */
.wp-block-gallery,
.blocks-gallery-grid,
.gallery {
    --chotek-gallery-gap: 12px;
}

/* Gutenberg – standardowe elementy */
.wp-block-gallery .wp-block-image,
.wp-block-gallery figure.wp-block-image,
.blocks-gallery-grid .blocks-gallery-item,
.gallery .gallery-item {
    overflow: hidden;
}

/* Miniatury zawsze mają równy, kwadratowy format.
   Pełne zdjęcie w lightboxie NIE jest przycinane. */
.wp-block-gallery .wp-block-image > a,
.wp-block-gallery .wp-block-image > img,
.wp-block-gallery figure.wp-block-image > a,
.wp-block-gallery figure.wp-block-image > img,
.blocks-gallery-grid .blocks-gallery-item a,
.blocks-gallery-grid .blocks-gallery-item img,
.gallery .gallery-icon a,
.gallery .gallery-icon img {
    display: block;
    width: 100%;
}

/* Sam obraz miniatury */
.wp-block-gallery .wp-block-image img,
.blocks-gallery-grid .blocks-gallery-item img,
.gallery .gallery-icon img {
    width: 100% !important;
    height: auto !important;
    aspect-ratio: 1 / 1;
    object-fit: cover !important;
    object-position: center center;
    cursor: zoom-in;
}

/* Gutenberg czasem dodaje własne wysokości do figure */
.wp-block-gallery.has-nested-images figure.wp-block-image {
    aspect-ratio: 1 / 1;
    overflow: hidden;
}

.wp-block-gallery.has-nested-images figure.wp-block-image img {
    width: 100% !important;
    height: 100% !important;
    object-fit: cover !important;
}

/* Podpis pod zdjęciem */
.wp-block-gallery figcaption,
.gallery-caption {
    box-sizing: border-box;
}

/* ---------- LIGHTBOX ---------- */

.chotek-lightbox {
    position: fixed;
    inset: 0;
    z-index: 999999;
    display: none;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, .92);
    padding: 24px;
}

.chotek-lightbox.is-open {
    display: flex;
}

.chotek-lightbox__stage {
    position: relative;
    width: min(96vw, 1600px);
    height: min(92vh, 1100px);
    display: flex;
    align-items: center;
    justify-content: center;
}

.chotek-lightbox__image {
    display: block;
    max-width: 100%;
    max-height: 92vh;
    width: auto;
    height: auto;
    object-fit: contain;
    box-shadow: 0 8px 40px rgba(0,0,0,.35);
    user-select: none;
}

.chotek-lightbox__close,
.chotek-lightbox__prev,
.chotek-lightbox__next {
    position: fixed;
    z-index: 2;
    border: 0;
    background: rgba(0,0,0,.48);
    color: #fff;
    cursor: pointer;
    line-height: 1;
    transition: background .2s ease, transform .2s ease;
}

.chotek-lightbox__close:hover,
.chotek-lightbox__prev:hover,
.chotek-lightbox__next:hover {
    background: rgba(0,0,0,.75);
}

.chotek-lightbox__close {
    top: 18px;
    right: 18px;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    font-size: 34px;
}

.chotek-lightbox__prev,
.chotek-lightbox__next {
    top: 50%;
    transform: translateY(-50%);
    width: 54px;
    height: 72px;
    font-size: 42px;
    border-radius: 8px;
}

.chotek-lightbox__prev {
    left: 18px;
}

.chotek-lightbox__next {
    right: 18px;
}

.chotek-lightbox__counter {
    position: fixed;
    left: 50%;
    bottom: 18px;
    transform: translateX(-50%);
    color: #fff;
    background: rgba(0,0,0,.5);
    padding: 6px 10px;
    border-radius: 999px;
    font-size: 13px;
}

.chotek-lightbox__caption {
    position: fixed;
    left: 50%;
    bottom: 54px;
    transform: translateX(-50%);
    max-width: min(90vw, 1000px);
    color: #fff;
    text-align: center;
    font-size: 14px;
    line-height: 1.4;
}

/* ---------- TABELE ---------- */

.chotek-table-wrap {
    position: relative;
    width: 100%;
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin: 0 0 1.5em;
}

/* Desktop: tabela wykorzystuje pełną szerokość dostępnego obszaru. */
.chotek-table-wrap > table {
    margin-bottom: 0 !important;
    width: 100% !important;
    min-width: 100% !important;
    max-width: 100% !important;
    table-layout: auto !important;
}

/* Pływające sterowanie tabelą */
.chotek-table-controls {
    display: none;
    position: relative;
    z-index: 60;
    width: 100%;
    height: 54px;
    margin: 0 0 8px;
    pointer-events: none;
}

.chotek-table-controls.is-floating .chotek-table-controls__inner {
    position: fixed;
    top: var(--chotek-table-scroll-top, 12px);
    left: var(--chotek-table-controls-left, 12px);
    width: var(--chotek-table-controls-width, auto);
    z-index: 9999;
}

.chotek-table-controls.is-needed {
    display: flex;
    justify-content: center;
}

.chotek-table-controls:not(.is-floating) .chotek-table-controls__inner {
    position: relative;
}

.chotek-table-controls__inner {
    display: flex;
    align-items: center;
    gap: 8px;
    max-width: 100%;
    padding: 6px;
    border-radius: 999px;
    background: rgba(255,255,255,.97);
    box-shadow: 0 4px 18px rgba(0,0,0,.14);
    border: 1px solid rgba(0,0,0,.08);
    pointer-events: auto;
}

.chotek-table-controls button {
    appearance: none;
    border: 0;
    border-radius: 999px;
    background: #111;
    color: #fff;
    min-height: 42px;
    padding: 9px 14px;
    font-size: 12px;
    line-height: 1;
    font-weight: 700;
    letter-spacing: .02em;
    cursor: pointer;
    white-space: nowrap;
}

.chotek-table-controls button:hover {
    opacity: .88;
}

.chotek-table-controls button:disabled {
    opacity: .28;
    cursor: default;
}

.chotek-table-controls__position {
    min-width: 72px;
    text-align: center;
    font-size: 11px;
    font-weight: 700;
    color: #555;
    white-space: nowrap;
}

@media (max-width: 520px) {
    .chotek-table-controls__inner {
        width: 100%;
        justify-content: space-between;
        border-radius: 12px;
    }

    .chotek-table-controls button {
        padding: 9px 10px;
        font-size: 11px;
    }

    .chotek-table-controls__position {
        min-width: 46px;
        font-size: 10px;
    }
}

/* Żeby linki i tekst w tabelach nie rozwalały layoutu */
.chotek-table-wrap td,
.chotek-table-wrap th {
    overflow-wrap: anywhere;
}

/* ---------- MOBILE ---------- */

@media (max-width: 1024px) {

    .chotek-table-wrap {
        width: 100%;
        max-width: 100%;
        overflow-x: auto;
    }

    .chotek-table-wrap > table {
        width: 1000px !important;
        min-width: 1000px !important;
        max-width: none !important;
    }

    .wp-block-gallery,
    .wp-block-gallery.has-nested-images,
    .blocks-gallery-grid,
    .gallery {
        gap: 8px !important;
    }

    .chotek-lightbox {
        padding: 10px;
    }

    .chotek-lightbox__stage {
        width: 100vw;
        height: 100vh;
    }

    .chotek-lightbox__image {
        max-width: calc(100vw - 20px);
        max-height: calc(100vh - 90px);
    }

    .chotek-lightbox__prev,
    .chotek-lightbox__next {
        width: 44px;
        height: 58px;
        font-size: 34px;
    }

    .chotek-lightbox__prev {
        left: 6px;
    }

    .chotek-lightbox__next {
        right: 6px;
    }

    .chotek-lightbox__close {
        top: 8px;
        right: 8px;
    }

}

body.chotek-lightbox-open {
    overflow: hidden !important;
}




/* ---------- ZDJĘCIE WYRÓŻNIAJĄCE POD TREŚCIĄ WPISU ---------- */

.single-post .chotek-featured-below-content {
    display: block;
    margin: 32px 0 24px;
    width: 100%;
}

.single-post .chotek-featured-below-content__img {
    display: block;
    width: 100%;
    height: auto;
    object-fit: contain;
}

.single-post .chotek-featured-below-content__caption {
    margin-top: 8px;
    font-size: 13px;
    line-height: 1.5;
    opacity: .75;
}
