/* =============================================
   WP Media Manager – Frontend Gallery CSS
   ============================================= */

/* ── Gallery grid ── */
.wpmm-gallery {
    display: grid;
    gap: 12px;
    margin: 1.5em 0;
}

.wpmm-gallery.wpmm-cols-1 { grid-template-columns: 1fr; }
.wpmm-gallery.wpmm-cols-2 { grid-template-columns: repeat(2, 1fr); }
.wpmm-gallery.wpmm-cols-3 { grid-template-columns: repeat(3, 1fr); }
.wpmm-gallery.wpmm-cols-4 { grid-template-columns: repeat(4, 1fr); }
.wpmm-gallery.wpmm-cols-5 { grid-template-columns: repeat(5, 1fr); }
.wpmm-gallery.wpmm-cols-6 { grid-template-columns: repeat(6, 1fr); }

@media (max-width: 768px) {
    .wpmm-gallery.wpmm-cols-3,
    .wpmm-gallery.wpmm-cols-4,
    .wpmm-gallery.wpmm-cols-5,
    .wpmm-gallery.wpmm-cols-6 {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 480px) {
    .wpmm-gallery { grid-template-columns: 1fr !important; }
}

/* ── Gallery item ──
   Technika: padding-top na wrapperu vytvoří čtvercový box,
   img je absolutně pozicovaný a vyplní ho celý.
   Funguje v Chrome, Edge, Safari, Firefox bez výjimky.
── */
.wpmm-gallery-item {
    margin: 0;
    position: relative;
    overflow: hidden;
    border-radius: 4px;
    background: #f0f0f0;
    /* padding-top trik: výška = šířka = čtverec */
    padding-top: 75%; /* 4:3, změňte na 100% pro čtverec */
    height: 0;
}

.wpmm-gallery-item a,
.wpmm-gallery-item > .wpmm-gallery-img {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    height: 100%;
    display: block;
}

.wpmm-gallery-img {
    /* !important přebije theme styly i WP inline width/height */
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    width: 100% !important;
    height: 100% !important;
    object-fit: cover !important;
    object-position: center !important;
    display: block !important;
    margin: 0 !important;
    max-width: none !important;
    max-height: none !important;
    transition: transform .3s ease, filter .3s ease;
}

.wpmm-gallery-item:hover .wpmm-gallery-img {
    transform: scale(1.04);
    filter: brightness(1.05);
}

/* ── Captions ── */
.wpmm-gallery-title,
.wpmm-gallery-caption {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(transparent, rgba(0,0,0,.65));
    color: #fff;
    font-size: 13px;
    padding: 24px 10px 8px;
    margin: 0;
    text-align: center;
    opacity: 0;
    transform: translateY(6px);
    transition: opacity .25s, transform .25s;
}

.wpmm-gallery-item:hover .wpmm-gallery-title,
.wpmm-gallery-item:hover .wpmm-gallery-caption {
    opacity: 1;
    transform: none;
}

/* ── Pagination ── */
.wpmm-gallery-pagination {
    text-align: center;
    margin: 20px 0;
}

.wpmm-load-more {
    padding: 10px 28px;
    font-size: 14px;
    cursor: pointer;
    border-radius: 4px;
}

/* ── Empty state ── */
.wpmm-gallery-empty {
    color: #777;
    font-style: italic;
    text-align: center;
    padding: 2em;
}

/* ── Lightbox ── */
#wpmm-lightbox {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 999999;
}

#wpmm-lightbox.wpmm-lb-open {
    display: flex;
    align-items: center;
    justify-content: center;
}

.wpmm-lb-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, .92);
    cursor: zoom-out;
}

.wpmm-lb-inner {
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    max-width: 90vw;
    max-height: 90vh;
    animation: wpmm-lb-in .2s ease;
}

@keyframes wpmm-lb-in {
    from { opacity: 0; transform: scale(.95); }
    to   { opacity: 1; transform: none; }
}

.wpmm-lb-img-wrap {
    display: flex;
    align-items: center;
    justify-content: center;
    max-width: 90vw;
    max-height: 80vh;
}

.wpmm-lb-img {
    max-width: 100%;
    max-height: 80vh;
    object-fit: contain;
    border-radius: 3px;
    box-shadow: 0 8px 40px rgba(0,0,0,.6);
    transition: opacity .2s;
}

.wpmm-lb-img.wpmm-lb-loading {
    opacity: .3;
}

.wpmm-lb-caption {
    color: #ccc;
    font-size: 14px;
    margin-top: 10px;
    text-align: center;
    max-width: 600px;
}

/* Buttons */
.wpmm-lb-close,
.wpmm-lb-prev,
.wpmm-lb-next {
    background: rgba(255,255,255,.12);
    border: none;
    color: #fff;
    cursor: pointer;
    transition: background .2s;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    line-height: 1;
}

.wpmm-lb-close:hover,
.wpmm-lb-prev:hover,
.wpmm-lb-next:hover {
    background: rgba(255,255,255,.25);
}

.wpmm-lb-close {
    position: absolute;
    top: -44px;
    right: 0;
    width: 36px;
    height: 36px;
}

.wpmm-lb-prev,
.wpmm-lb-next {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 48px;
    height: 48px;
    font-size: 32px;
}

.wpmm-lb-prev { left: -60px; }
.wpmm-lb-next { right: -60px; }

@media (max-width: 600px) {
    .wpmm-lb-prev { left: 8px; }
    .wpmm-lb-next { right: 8px; }
    .wpmm-lb-close { top: 8px; right: 8px; position: fixed; }
}
