@keyframes flickerAnimation {
    0% {
        opacity: 1;
    }

    50% {
        opacity: 0.5;
    }

    100% {
        opacity: 1;
    }
}

@-o-keyframes flickerAnimation {
    0% {
        opacity: 1;
    }

    50% {
        opacity: 0.5;
    }

    100% {
        opacity: 1;
    }
}

@-moz-keyframes flickerAnimation {
    0% {
        opacity: 1;
    }

    50% {
        opacity: 0.5;
    }

    100% {
        opacity: 1;
    }
}

@-webkit-keyframes flickerAnimation {
    0% {
        opacity: 1;
    }

    50% {
        opacity: 0.5;
    }

    100% {
        opacity: 1;
    }
}
        
.gallery-container {
    position: relative;
    width: 100%;
}

.thumbnails {
    display: block;
    width: 100%;
    max-width: 100%;
}

.thumbnails .thumbnails-inner .preloader {
    grid-column: -1/1;
    grid-row: span 4;
    display: block;
    width: 100%;
    height: 100%;
    min-height: 100vh;
}

.thumbnails .thumbnails-inner .preloader .thumbnails-inner {
    width: 100%;
    height: 100%;
}

.thumbnails .thumbnails-inner .preloader .thumbnails-inner {
    -webkit-animation: flickerAnimation 1.5s infinite;
    -moz-animation: flickerAnimation 1.5s infinite;
    -o-animation: flickerAnimation 1.5s infinite;
    animation: flickerAnimation 1.5s infinite;
}

.thumbnails .thumbnails-inner .preloader .thumbnails-inner a {
    display: block;
    width: 100%;
    min-height: 100%;
    aspect-ratio: 1/1;
    background-color: #3433332b;
    pointer-events: none;
}

.thumbnails .thumbnails-inner {
    width: 100%;
    max-width: 100%;
    display: grid;
    /* Výchozí 3 sloupce pro menší monitory a tablety */
    grid-template-columns: repeat(3, 1fr);
    grid-gap: 0.35rem;
}

.thumbnails .thumbnails-inner a {
    position: relative;
    display: grid;
    grid-template-columns: 1fr;
    grid-template-rows: 1fr;
}

.thumbnails .thumbnails-inner a img {
    grid-column: 1/2;
    grid-row: 1/2;
    z-index: 1;
    width: 100%;
    max-width: initial;
    height: auto;
    aspect-ratio: 1/1;
    object-fit: cover;
    object-position: center center;
    cursor: pointer;
}

.scene-type-label {
    position: absolute;
    top: 10px;
    right: 10px;
    z-index: 3; /* Musí být nad obrázkem (z-index: 1) i nad gradientem (z-index: 2) */
    background-color: rgba(200, 160, 110, 0.9);
    color: white;
    padding: 4px 8px;
    font-size: 12px;
    font-weight: 600;
    border-radius: 4px;
    text-transform: uppercase;
    line-height: 1.2;
}

.scene-type-label.ready-to-use {
    background-color: #28a745;
    color: white;
}

.scene-type-label.inspiration {
    background-color: #ffc107;
    color: #333;
}
        
.thumbnails .thumbnails-inner a > .thumbnail-descriptions {
    grid-column: 1/2;
    grid-row: 1/2;
    z-index: 2;
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    padding: 20px;
    /* UPRAVENO: Gradient je menší a pouze dole */
    background-image: linear-gradient(0deg, #343333 0%, #3433332b 25%, rgba(0,0,0,0) 40%);
    background-size: 100% 200%;
    background-position: 0% 100%; /* Začíná schovaný dole */
    background-repeat: no-repeat;
    display: flex;
    flex-direction: column;
    /* UPRAVENO: Obsah je zarovnaný dolů */
    justify-content: flex-end;
    align-items: center;
    transition: all 0.3s ease-in-out;

    opacity: 0; /* Ve výchozím stavu je popisek i s gradientem neviditelný */
    transition: opacity 0.3s ease-in-out;
}

.thumbnails .thumbnails-inner a:hover > .thumbnail-descriptions {
    opacity: 1; /* Při najetí myší se popisek i s gradientem plynule objeví */
}

.thumbnails .thumbnails-inner a:hover > .thumbnail-descriptions {
    background-image: linear-gradient(0deg, #343333 0%, rgba(0, 0, 0, 0) 40%);
    background-position: 0% 100%; /* Zůstane dole a jen se zjeví */
}

.thumbnails .thumbnails-inner a .thumbnail-descriptions,
.thumbnails .thumbnails-inner a .thumbnail-descriptions h4 {
        color: transparent;
        transition: all 0.5s ease-in-out;
}

.thumbnails .thumbnails-inner a:hover>.thumbnail-descriptions,
.thumbnails .thumbnails-inner a:hover>.thumbnail-descriptions h4 {
        color: white;
}

.thumbnails .thumbnails-inner a .thumbnail-descriptions span.name {
        font-weight: 600;
}

.thumbnails .thumbnails-inner a.active img {
        box-shadow: 0px 0px 8px #000000b8;
}

/* Přidá přes každý náhled neviditelnou vrstvu,
   která zabrání přímé interakci s obrázkem (jako je uložení nebo přetažení). */
.thumbnails .thumbnails-inner a::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 4; /* Ujistíme se, že je nad obrázkem */
    background: transparent;
}

.gallery-container .pagination {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    -webkit-box-pack: unset;
    -ms-flex-pack: unset;
    position: relative;
    margin: 8px auto;
    padding: 0;
    width: 100%;
}

.gallery-container .pagination a {
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 5px 8px 0;
    width: 3rem;
    height: 3rem;
    border: 2px solid #343333;
    border-radius: 50px;
    padding: .3em 1em;
    font-weight: 400;
    font-size: 1rem;
    line-height: 1.1em !important;
    text-align: center;
    transition: color 300ms ease 0ms, background-color 300ms ease 0ms;
    cursor: pointer;
}

.gallery-container .pagination a.active,
.gallery-container .pagination a:hover {
    background-color: #343333;
    border: 2px solid #343333;
    border-radius: 50px;
    color: #fff !important;
    transition: color 300ms ease 0ms, background-color 300ms ease 0ms;
}

.mfp-bottom-bar {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.mfp-bottom-bar .mfp-title {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    justify-content: start;
    width: 100%;
    padding-right: 0;
}

.mfp-bottom-bar .mfp-title span {
    display: block;
    font-size: 0.9rem;
    font-weight: 400;
    white-space: nowrap;
}

.mfp-bottom-bar .mfp-title span::after {
    content: '|';
    margin: 0 0.5rem;
}

.mfp-bottom-bar .mfp-title span:last-of-type:after {
    content: '';
}

.mfp-bottom-bar .mfp-counter {
    position: relative;
    inset: unset;
    white-space: nowrap;
}

@media all and (max-width: 768px) {
    .thumbnails .thumbnails-inner {
        grid-template-columns: repeat(2, 1fr);
    }

    .thumbnails .thumbnails-inner a img {
        aspect-ratio: 1/1;
        object-fit: cover;
    }
}

@media all and (max-width: 480px) {
    .thumbnails .thumbnails-inner {
        grid-template-columns: repeat(1, 1fr);
    }
}

/* Media query pro větší monitory */
@media all and (min-width: 1600px) {
    .thumbnails .thumbnails-inner {
        /* 4 sloupce */
        grid-template-columns: repeat(4, 1fr);
    }
}

@media all and (min-width: 2000px) {
    .thumbnails .thumbnails-inner {
        /* 5 sloupců */
        grid-template-columns: repeat(5, 1fr);
    }
}

/* --- Styly pro Scene Loader --- */
#scene-loader {
    display: none; /* Ve výchozím stavu je skrytý */
    position: fixed; /* Překryje celou obrazovku */
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(255, 255, 255, 0.9);
    z-index: 9999;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

#scene-loader p {
    font-size: 1.2em;
    font-weight: 600;
    color: #333;
}

.loader-spinner {
    border: 5px solid #f3f3f3;
    border-top: 5px solid #343333;
    border-radius: 50%;
    width: 50px;
    height: 50px;
    animation: spin 1s linear infinite;
    margin-bottom: 20px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/*** POPISKY PRO FILTRY A ŘAZENÍ V KNIHOVNĚ SCÉN ***/

/* Společný styl pro všechny nové popisky */
.filter-group-label {
    display: block;
    font-weight: 600;
    color: #333;
    text-transform: uppercase;
    font-size: 0.9em;
    letter-spacing: 1px;
    padding: .5rem;
}

.filter-group-label:not(:first-child) {
    margin-top: 1rem;
}

/* Úprava layoutu pro sekci s řazením */
.scene-sorting-section {
    display: flex;
    flex-direction: column;
    align-items: flex-start; /* Zarovnání popisku a selectu doleva */
    text-align: left;
}

/* Zajištění, aby popisek a select box měly konzistentní šířku */
#scene_sort {
    width: 100%;
}

.filter-menu-toggle .active-filter-text,
.scene-sorting-section .filter-group-label {
    display: none;
}

/* Oprava proklikávání mobilního menu v knihovně scén (verze 2) */

/* Pokud má BODY třídu 'mobile-filter-is-open'... */
body.mobile-filter-is-open #galerie .thumbnails-inner a::after {
    /* ...tak naši ochrannou vrstvu na dlaždicích uděláme dočasně "neklikatelnou". */
    pointer-events: none;
}

.scene-library-section {
    @media screen and (min-width: 425px) {
        .reference-filter-form {
            display: flex !important;
            flex-direction: row;
            flex-wrap: nowrap;
            gap: 1.5rem;
        }

        .reference-filter-form .col {
            flex: 1;
        }
    }

    @media screen and (min-width: 768px) {
        .reference-filter-form .col ul {
            display: flex;
        }

        .filter-menu-toggle .active-filter-text,
        .scene-sorting-section .filter-group-label {
            display: block;
        }

        .reference-filter-section {
            display: flex;
            align-items: center;
        }

        .filter-sorts .filter-menu-toggle {
            flex-direction: row-reverse;
            gap: .5rem;
        }

        .filter-sorts .filter-menu-toggle span  {    
            font-weight: 600;
            color: #333;
            text-transform: uppercase;
            font-size: 0.9em;
            letter-spacing: 1px;
        }

        .filter-sorts .scene-sorting-section {
            flex-direction: row;
            flex-wrap: nowrap;
            max-width: fit-content;
            gap: .5rem;
        }

        .filter-sorts .scene-sorting-section .filter-group-label {
            white-space: nowrap;
        }
    }

    @media screen and (min-width: 981px) {
        .reference-filter-section {
            padding-top: 0 !important;
        }

        .scene-sorting-section {
            padding-top: 0;
        }

        .reference-filter-form {
            flex-direction: column;
            gap: 0;
        }

        .filter-sorts {
            padding-bottom: 1rem;
        }

        .filter-sorts .scene-sorting-section {
            flex-direction: column;
            gap: 0;
            max-width: 165px;
        }

        .reference-filter-form ul {
            justify-content: flex-start;
        }

        .reference-filter-form li {
            flex: 0;
        }

        .reference-filter-form li a {
            max-width: 150px;
        }

        .filter-group-label {
            padding-left: 0;
        }
    }

    @media screen and (min-width: 1440px) {
        .reference-filter-form {
            flex-direction: row;
        }

        .filters-scene-type {
            flex-basis: 80%;
        }

        .filters-tag {
            flex-grow: 0 !important;
            flex-basis: 31% !important;
        }
    }

    /*** VLASTNÍ VZHLED PRO SELECT BOX (ŘAZENÍ) ***/

    /* 1. Kontejner, který drží select a naši novou šipku */
    .custom-select-wrapper {
        position: relative;
        display: inline-block;
        width: 100%;
    }

    /* 2. Naše nová, vlastní šipka (vytvořená jako pseudo-element) */
    .custom-select-wrapper::after {
        content: ''; /* Musí být prázdný */
        position: absolute;
        top: 50%;
        right: 15px; /* Odsazení od pravého kraje */
        transform: translateY(-50%);
        width: 12px;
        height: 8px;
        background-color: #333; /* Barva šipky */

        /* Tvar trojúhelníku pomocí clip-path */
        clip-path: polygon(0 0, 100% 0, 50% 100%);

        pointer-events: none; /* Důležité, aby šlo kliknout na select pod šipkou */
        transition: transform 0.2s ease;
    }

    /* 3. Samotný <select> element, kterému skryjeme výchozí vzhled */
    #scene_sort {
        -webkit-appearance: none; /* Skryje výchozí vzhled pro Webkit (Chrome, Safari) */
        -moz-appearance: none;    /* Skryje výchozí vzhled pro Firefox */
        appearance: none;         /* Standardní vlastnost */

        /* Odstranění specifických šipek pro starší prohlížeče */
        &::-ms-expand {
            display: none;
        }

        /* Teď už bude padding fungovat, jak má! */
        /* Větší padding vpravo, aby text nepodlézal pod naši novou šipku */
        padding-right: 40px !important; 
    }
}