/* ===========================

   MOZAIKA NÁHLEDŮ V ČLÁNKU

   =========================== */



.smart-gallery-wrapper {

    width: 100%;

    /* Kompenzuje sticky header při návratu z detailu via #anchor */

    scroll-margin-top: 80px;

}



.smart-gallery-grid {

    display: grid;

    grid-auto-rows: 110px;

    gap: 5px;

}



/* 1–9 sloupců – výchozí je 3 */

.smart-gallery-cols-1 .smart-gallery-grid { grid-template-columns: repeat(1, 1fr); }

.smart-gallery-cols-2 .smart-gallery-grid { grid-template-columns: repeat(2, 1fr); }

.smart-gallery-cols-3 .smart-gallery-grid { grid-template-columns: repeat(3, 1fr); }

.smart-gallery-cols-4 .smart-gallery-grid { grid-template-columns: repeat(4, 1fr); }

.smart-gallery-cols-5 .smart-gallery-grid { grid-template-columns: repeat(5, 1fr); }

.smart-gallery-cols-6 .smart-gallery-grid { grid-template-columns: repeat(6, 1fr); }

.smart-gallery-cols-7 .smart-gallery-grid { grid-template-columns: repeat(7, 1fr); }

.smart-gallery-cols-8 .smart-gallery-grid { grid-template-columns: repeat(8, 1fr); }

.smart-gallery-cols-9 .smart-gallery-grid { grid-template-columns: repeat(9, 1fr); }



/* Dlaždice – inline style grid-column: span X přijde z PHP pro dorovnání posledního řádku */

.smart-gallery-thumb {

    position: relative;

    overflow: hidden;

    border-radius: 5px;

    cursor: pointer;

    display: block;

    /* Placeholder barva dokud se nenahrají thumbnaile */

    background: #e8e8e8;

}



.smart-gallery-thumb img {

    width: 100%;

    height: 100%;

    object-fit: cover;

    display: block;

    transition: transform 0.22s ease;

}



.smart-gallery-thumb:hover img,

.smart-gallery-thumb:focus-visible img {

    transform: scale(1.04);

}



/* Tmavnutí při hoveru */

.smart-gallery-thumb::after {

    content: '';

    position: absolute;

    inset: 0;

    background: rgba(0, 0, 0, 0);

    transition: background 0.22s ease;

    pointer-events: none;

    border-radius: 5px;

}



.smart-gallery-thumb:hover::after {

    background: rgba(0, 0, 0, 0.12);

}



/* Přístupný focus */

.smart-gallery-thumb:focus-visible {

    outline: 3px solid #0073aa;

    outline-offset: 2px;

}



/* Popisek pod gridem */

.smart-gallery-wrapper .smart-gallery-total-label {

    margin: 5px 0 0 !important;

    font-size: 12px !important;

    line-height: 1.4 !important;

    color: #aaa !important;

    text-align: right !important;

    font-weight: normal !important;

    padding: 0 !important;

    border: none !important;

    background: none !important;

}



.smart-gallery-total-icon {

    margin-right: 3px;

    opacity: 0.7;

}



/* Chybové hlášky */

.smart-gallery-error,

.smart-gallery-placeholder {

    color: #888;

    font-size: 13px;

    font-style: italic;

}



/* Responzivita: zmenšit výšku řádků na menších obrazovkách */

@media (max-width: 900px) {

    .smart-gallery-grid { grid-auto-rows: 96px; }

}

@media (max-width: 600px) {

    .smart-gallery-grid { grid-auto-rows: 80px; }

    /* Na velmi malých mobilech max 2 sloupce bez ohledu na nastavení */

    .smart-gallery-cols-4 .smart-gallery-grid,

    .smart-gallery-cols-5 .smart-gallery-grid,

    .smart-gallery-cols-6 .smart-gallery-grid,

    .smart-gallery-cols-7 .smart-gallery-grid,

    .smart-gallery-cols-8 .smart-gallery-grid,

    .smart-gallery-cols-9 .smart-gallery-grid { grid-template-columns: repeat(2, 1fr); }

}



/* ===========================

   STRÁNKA S JEDNOU FOTKOU

   =========================== */



.smart-gallery-page-wrapper {

    max-width: 1000px;

    margin: 20px auto;

    padding: 0 10px;

    box-sizing: border-box;

}



/* Kotva pro scrollování na začátek galerie */

.smart-gallery-anchor {

    height: 0;

    overflow: hidden;

}



.smart-gallery-page-main {

    position: relative;

    display: flex;

    justify-content: center;

    align-items: center;

    overflow: hidden;

    margin-bottom: 8px;

    height: 70vh;

    max-height: 70vh;

}



.smart-gallery-page-main-inner {

    position: relative;

    display: flex;

    justify-content: center;

    align-items: center;

    max-height: 100%;

}



.smart-gallery-page-main-img {

    max-width: 100%;

    max-height: 100%;

    height: auto;

    border-radius: 4px;

    cursor: zoom-in;

    display: block;

    /* Plynulý fade při přepínání fotek */

    transition: opacity 0.18s ease;

}



.smart-gallery-page-main-inner.is-loading .smart-gallery-page-main-img {

    opacity: 0.25;

}



/* LOADING SPINNER (detail) */

.smart-gallery-page-main-inner.is-loading::before {

    content: '';

    position: absolute;

    inset: 0;

    background: rgba(0, 0, 0, 0.18);

    border-radius: 4px;

    z-index: 4;

}



.smart-gallery-page-main-inner.is-loading::after {

    content: '';

    position: absolute;

    left: 50%;

    top: 50%;

    width: 38px;

    height: 38px;

    margin-left: -19px;

    margin-top: -19px;

    border-radius: 50%;

    border: 3px solid rgba(255, 255, 255, 0.35);

    border-top-color: rgba(255, 255, 255, 0.95);

    animation: smartGallerySpin 0.8s linear infinite;

    z-index: 5;

}



@keyframes smartGallerySpin {

    to { transform: rotate(360deg); }

}



/* Šipky (navigace) */

.smart-gallery-page-arrow {

    position: absolute;

    top: 50%;

    transform: translateY(-50%);

    text-decoration: none;

    background: rgba(0, 0, 0, 0.4);

    color: #fff;

    font-size: 26px;

    width: 44px;

    height: 44px;

    border-radius: 50%;

    cursor: pointer;

    display: flex;

    justify-content: center;

    align-items: center;

    z-index: 2;

    transition: background 0.18s ease, transform 0.18s ease;

    /* Zabraňuje nechtěnému označení textu při kliknutí */

    user-select: none;

}



.smart-gallery-page-prev { left: 8px; }

.smart-gallery-page-next { right: 8px; }



.smart-gallery-page-arrow:hover {

    background: rgba(0, 0, 0, 0.65);

}



.smart-gallery-page-arrow:focus-visible {

    outline: 3px solid #fff;

    outline-offset: 2px;

    background: rgba(0, 0, 0, 0.65);

}



/* META ŘÁDEK: vlevo odkaz zpět, vpravo stáhnout + index */

.smart-gallery-page-meta {

    display: flex;

    justify-content: space-between;

    align-items: center;

    gap: 12px;

    margin-top: 6px;

    margin-bottom: 8px;

    flex-wrap: wrap;

}



.smart-gallery-page-back {

    font-size: 14px;

}



.smart-gallery-page-back a {

    text-decoration: none;

    color: #0073aa;

}



.smart-gallery-page-back a:hover {

    text-decoration: underline;

}



/* Pravá strana: stáhnout + index */

.smart-gallery-page-actions {

    display: flex;

    align-items: center;

    gap: 14px;

    flex-shrink: 0;

}



/* Klávesová nápověda */

.smart-gallery-kbd-hint {

    display: flex;

    align-items: center;

    gap: 6px;

    font-size: 12px;

    color: #aaa;

    margin-top: 4px;

    user-select: none;

}



.smart-gallery-kbd-hint kbd {

    display: inline-block;

    padding: 1px 5px;

    font-size: 11px;

    font-family: inherit;

    background: #f2f2f2;

    border: 1px solid #ccc;

    border-bottom-width: 2px;

    border-radius: 3px;

    line-height: 1.5;

    color: #555;

}



.smart-gallery-page-index {

    font-size: 13px;

    color: #666;

    white-space: nowrap;

}





/* ===========================

   SPODNÍ NÁHLEDY (scrollovatelné)

   =========================== */



.smart-gallery-page-bottom-thumbs {

    /* Mřížka – všechny náhledy viditelné najednou, žádný horizontální scroll */

    display: grid;

    grid-template-columns: repeat(auto-fill, minmax(72px, 1fr));

    gap: 5px;

    margin-top: 8px;

}



.smart-gallery-page-bottom-thumb {

    display: block;

}



.smart-gallery-page-bottom-thumb img {

    display: block;

    width: 100%;

    aspect-ratio: 4 / 3;

    object-fit: cover;

    cursor: pointer;

    border-radius: 3px;

    opacity: 0.65;

    transition: opacity 0.2s ease, box-shadow 0.2s ease, transform 0.18s ease;

}



.smart-gallery-page-bottom-thumb img:hover {

    opacity: 1;

    transform: scale(1.05);

}



.smart-gallery-page-bottom-thumb.is-active img {

    opacity: 1;

    box-shadow: 0 0 0 2px #0073aa;

}



.smart-gallery-page-bottom-thumb:focus-visible {

    outline: 3px solid #0073aa;

    outline-offset: 2px;

    border-radius: 3px;

}



/* ===========================

   INFO PANEL PŘES FOTKU

   =========================== */



.smart-gallery-info-toggle {

    position: absolute;

    left: 10px;

    bottom: 10px;

    width: 30px;

    height: 30px;

    border-radius: 50%;

    border: none;

    background: rgba(0, 0, 0, 0.65);

    color: #fff;

    font-size: 16px;

    font-style: italic;

    font-family: Georgia, serif;

    cursor: pointer;

    display: flex;

    align-items: center;

    justify-content: center;

    padding: 0;

    z-index: 3;

    transition: background 0.18s ease;

}



.smart-gallery-info-toggle:hover {

    background: rgba(0, 0, 0, 0.85);

}



.smart-gallery-info-toggle:focus-visible {

    outline: 2px solid #fff;

    outline-offset: 2px;

}



.smart-gallery-info-panel {

    position: absolute;

    left: 10px;

    bottom: 48px; /* nad toggle tlačítkem */

    max-width: 65%;

    background: rgba(0, 0, 0, 0.82);

    color: #fff;

    padding: 10px 14px;

    border-radius: 6px;

    font-size: 13px;

    line-height: 1.5;

    transform: translateY(8px);

    opacity: 0;

    pointer-events: none;

    transition: transform 0.22s ease, opacity 0.22s ease;

    z-index: 3;

}



.smart-gallery-info-panel.is-open {

    transform: translateY(0);

    opacity: 1;

    pointer-events: auto;

}



.smart-gallery-info-title {

    font-weight: 600;

    margin-bottom: 4px;

}



.smart-gallery-info-text {

    font-weight: 400;

}



/* ===========================

   LIGHTBOX

   =========================== */



.smart-gallery-lightbox {

    position: fixed;

    inset: 0;

    display: none;

    z-index: 9999;

}



.smart-gallery-lightbox[data-active="true"] {

    display: block;

}



.smart-gallery-lightbox-backdrop {

    position: absolute;

    inset: 0;

    background: rgba(0, 0, 0, 0.85);

    cursor: zoom-out;

}



.smart-gallery-lightbox-inner {

    position: fixed;

    inset: 0;

    margin: 0;

    padding: 20px;

    display: flex;

    justify-content: center;

    align-items: center;

    z-index: 1;

}



.smart-gallery-lightbox-frame {

    position: relative;

    /* Explicitní rozměry = obrázek se má čeho chytit pro max-width/max-height.

       padding: 20px z -inner se odečte → obrázek nikdy nepřesáhne viewport. */

    max-width:  calc(100vw - 40px);

    max-height: calc(100vh - 40px);

    width: fit-content;

    height: fit-content;

    display: flex;

    justify-content: center;

    align-items: center;

}



.smart-gallery-lightbox-img {

    display: block;

    /* Obrázek se vejde do framu – zachová poměr stran, nepřeteče */

    max-width:  calc(100vw - 40px);

    max-height: calc(100vh - 40px);

    width: auto;

    height: auto;

    object-fit: contain;

    border-radius: 4px;

    cursor: zoom-out;

}



/* LOADING SPINNER (lightbox) */

.smart-gallery-lightbox-frame.is-loading::before {

    content: '';

    position: absolute;

    inset: 0;

    background: rgba(0, 0, 0, 0.22);

    border-radius: 4px;

    z-index: 4;

}



.smart-gallery-lightbox-frame.is-loading::after {

    content: '';

    position: absolute;

    left: 50%;

    top: 50%;

    width: 44px;

    height: 44px;

    margin-left: -22px;

    margin-top: -22px;

    border-radius: 50%;

    border: 3px solid rgba(255, 255, 255, 0.35);

    border-top-color: rgba(255, 255, 255, 0.95);

    animation: smartGallerySpin 0.8s linear infinite;

    z-index: 5;

}



.smart-gallery-lightbox-frame.is-loading .smart-gallery-lightbox-img {

    opacity: 0.5;

}



/* Zavřít tlačítko */

.smart-gallery-lightbox-close {

    position: absolute;

    top: 8px;

    right: 8px;

    border: 2px solid rgba(255, 255, 255, 0.5);

    background: rgba(0, 0, 0, 0.7);

    color: #fff;

    font-size: 20px;

    width: 36px;

    height: 36px;

    border-radius: 50%;

    cursor: pointer;

    z-index: 7;

    display: flex;

    align-items: center;

    justify-content: center;

    transition: background 0.18s ease, border-color 0.18s ease;

}



.smart-gallery-lightbox-close::before {

    content: '×';

    font-size: 24px;

    line-height: 1;

}



.smart-gallery-lightbox-close:hover {

    background: rgba(0, 0, 0, 0.9);

    border-color: #fff;

}



.smart-gallery-lightbox-close:focus-visible {

    outline: 3px solid #fff;

    outline-offset: 2px;

}



/* Šipky v lightboxu */

.smart-gallery-lightbox-arrow {

    position: fixed;

    top: 50%;

    transform: translateY(-50%);

    width: 46px;

    height: 46px;

    border-radius: 50%;

    border: 2px solid rgba(255, 255, 255, 0.3);

    background: rgba(0, 0, 0, 0.55);

    color: #fff;

    font-size: 22px;

    cursor: pointer;

    display: flex;

    align-items: center;

    justify-content: center;

    z-index: 7;

    transition: background 0.18s ease, border-color 0.18s ease;

}



.smart-gallery-lightbox-prev { left: 12px; }

.smart-gallery-lightbox-next { right: 12px; }



.smart-gallery-lightbox-arrow:hover {

    background: rgba(0, 0, 0, 0.82);

    border-color: rgba(255, 255, 255, 0.7);

}



.smart-gallery-lightbox-arrow:focus-visible {

    outline: 3px solid #fff;

    outline-offset: 3px;

}



/* ===========================

   RESPONZIVITA

   =========================== */



@media (max-width: 768px) {

    .smart-gallery-page-wrapper {

        margin: 12px auto;

        padding: 0 6px;

    }



    /* Na mobilech klávesová nápověda nedává smysl */

    .smart-gallery-kbd-hint {

        display: none;

    }



    .smart-gallery-page-main {

        height: 60vw;

        max-height: 60vw;

    }



    .smart-gallery-info-panel {

        max-width: 85%;

    }



    .smart-gallery-page-meta {

        flex-direction: column;

        align-items: flex-start;

        gap: 6px;

    }



    .smart-gallery-page-actions {

        width: 100%;

        justify-content: space-between;

    }



    .smart-gallery-lightbox-arrow {

        width: 36px;

        height: 36px;

        font-size: 18px;

    }



    .smart-gallery-lightbox-prev { left: 4px; }

    .smart-gallery-lightbox-next { right: 4px; }

}



@media (max-width: 480px) {

    .smart-gallery-page-main {

        height: 70vw;

        max-height: 70vw;

    }



    .smart-gallery-page-bottom-thumb {

        flex: 0 0 64px;

    }



    .smart-gallery-page-bottom-thumb img {

        width: 64px;

        height: 50px;

    }



    .smart-gallery-page-arrow {

        width: 36px;

        height: 36px;

        font-size: 20px;

    }

}


/* ===================================================================
   INLINE LIGHTBOX – galerie v článku (sg-article-lightbox)
   =================================================================== */

.sg-article-lightbox {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 99999;
    align-items: center;
    justify-content: center;
}
.sg-article-lightbox.sg-al-open {
    display: flex;
}

.sg-al-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, .92);
}

.sg-al-img-wrap {
    position: relative;
    z-index: 1;
    max-width: 92vw;
    max-height: 90vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

.sg-al-img {
    max-width: 92vw;
    max-height: 88vh;
    object-fit: contain;
    border-radius: 3px;
    transition: opacity .2s ease;
    display: block;
}

/* LOADING SPINNER – článkový lightbox */
.sg-al-img-wrap.is-loading::before {
    content: '';
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.22);
    border-radius: 4px;
    z-index: 4;
}
.sg-al-img-wrap.is-loading::after {
    content: '';
    position: absolute;
    left: 50%;
    top: 50%;
    width: 44px;
    height: 44px;
    margin-left: -22px;
    margin-top: -22px;
    border-radius: 50%;
    border: 3px solid rgba(255, 255, 255, 0.35);
    border-top-color: rgba(255, 255, 255, 0.95);
    animation: smartGallerySpin 0.8s linear infinite;
    z-index: 5;
}

/* Všechna tři tlačítka – explicitní !important na barvu a tvar,
   protože WordPress témata mají globální button styly které to přebíjejí */
.sg-article-lightbox .sg-al-close,
.sg-article-lightbox .sg-al-prev,
.sg-article-lightbox .sg-al-next {
    position: fixed;
    z-index: 99999;
    /* Barva s !important – přebije téma i admin CSS */
    background: rgba(20, 20, 20, .72) !important;
    background-color: rgba(20, 20, 20, .72) !important;
    border: 1px solid rgba(255,255,255,.12) !important;
    color: #fff !important;
    cursor: pointer;
    border-radius: 50%;
    /* Flexbox – spolehlivé centrování šipky/křížku bez ohledu na font */
    display: flex !important;
    align-items: center;
    justify-content: center;
    padding: 0;
    margin: 0;
    line-height: 1;
    font-family: sans-serif;
    transition: background .15s, transform .1s;
    box-shadow: 0 2px 8px rgba(0,0,0,.5);
    /* reset případných theme stylů */
    text-decoration: none;
    outline-offset: 2px;
}
.sg-article-lightbox .sg-al-close:hover,
.sg-article-lightbox .sg-al-prev:hover,
.sg-article-lightbox .sg-al-next:hover {
    background: rgba(255, 255, 255, .18) !important;
    background-color: rgba(255, 255, 255, .18) !important;
    border-color: rgba(255,255,255,.35) !important;
}

.sg-article-lightbox .sg-al-close {
    top: 16px;
    right: 16px;
    /* Pevný čtverec → border-radius: 50% = dokonalý kruh */
    width: 40px;
    height: 40px;
    font-size: 18px;
}

.sg-article-lightbox .sg-al-prev,
.sg-article-lightbox .sg-al-next {
    /* Šipky centrované na výšku obrázku, ne na viewport.
       img-wrap má max-height: 90vh, takže top 50% viewportu ≈ střed obrázku
       pro drtivou většinu případů. Přesnější řešení by vyžadovalo JS. */
    top: 50%;
    transform: translateY(-50%);
    width: 44px;
    height: 44px;
    font-size: 20px;
}
.sg-article-lightbox .sg-al-prev { left: 16px; }
.sg-article-lightbox .sg-al-next { right: 16px; }

.sg-article-lightbox .sg-al-counter {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 99999;
    color: rgba(255,255,255,.85);
    font-size: 13px;
    font-family: sans-serif;
    background: rgba(20,20,20,.6);
    padding: 4px 14px;
    border-radius: 20px;
    white-space: nowrap;
    pointer-events: none;
}

@media (max-width: 600px) {
    .sg-article-lightbox .sg-al-prev { left: 6px; }
    .sg-article-lightbox .sg-al-next { right: 6px; }
    .sg-article-lightbox .sg-al-prev,
    .sg-article-lightbox .sg-al-next { width: 38px; height: 38px; font-size: 17px; }
    .sg-article-lightbox .sg-al-close { width: 36px; height: 36px; font-size: 16px; }
}

/* Info panel – article lightbox */
.sg-article-lightbox .sg-al-info {
    position: fixed;
    bottom: 52px; /* nad counterem */
    left: 50%;
    transform: translateX(-50%);
    z-index: 99999;
    max-width: min(600px, 88vw);
    width: max-content;
    text-align: center;
    pointer-events: none;
}
.sg-article-lightbox .sg-al-info-title {
    color: #fff;
    font-size: 14px;
    font-weight: 600;
    font-family: sans-serif;
    line-height: 1.4;
    text-shadow: 0 1px 4px rgba(0,0,0,.8);
}
.sg-article-lightbox .sg-al-info-text {
    color: rgba(255,255,255,.75);
    font-size: 13px;
    font-family: sans-serif;
    line-height: 1.4;
    margin-top: 2px;
    text-shadow: 0 1px 3px rgba(0,0,0,.8);
}
@media (max-width: 600px) {
    .sg-article-lightbox .sg-al-info {
        bottom: 48px;
        max-width: 92vw;
    }
    .sg-article-lightbox .sg-al-info-title { font-size: 13px; }
    .sg-article-lightbox .sg-al-info-text  { font-size: 12px; }
}
