/* -------------------------------------
   Geral
------------------------------------- */
:root {
    .gallery{
        --z-index: 99999;
        --transition-hover: all 0.3s ease;
    
        /* modal */
        --modal-top-spacing: 40px;
        --modal-side-spacing: 72px;
        --modal-inner-width: calc(100% - (2 * var(--modal-side-spacing)));
        --modal-inner-height: calc(100% - (2 * var(--modal-top-spacing)));
        --modal-switcher-right: 24px;
    
        /* thumbnails */
        --thumb-width-highlight: 194px;
        --thumb-width-default: 145px;
        --thumb-width-grid: 270px;
    
        --content-height: 156px;
    }
  }

section.gallery {
    position: relative;
    margin: 24px 0;

    /* Reset */
    & ul {
        list-style: none;
        display: flex;
        margin: 0;
        padding: 0;
        & li {
            margin-bottom: 0;
            &:before {
                display: none;
            }
        }
    }

    & [type=radio], [type=checkbox] {
        display: none;
    }

    /* Barra de scroll */
    & ::-webkit-scrollbar {
        width: 4px;
    }

    & ::-webkit-scrollbar-thumb {
        background-color: var(--clr-cnn);
        border-radius: 4px;
    }

    /* Mudando a cor do fundo da scrollbar */
    & ::-webkit-scrollbar-track {
        border-radius: 4px;
        background-color: var(--clr-cnn-grey-1);
    }

    /* Anúncios */
    & .gallery__ad {
        position: absolute;
        top: 0;
        left: 0;
        padding: 0;
        margin: 0;
        z-index: 2;
        width: 100%;
        height: 100%;
        display: none;

        & > * {
            pointer-events: all;
        }
    }

    /* Modal */
    .gallery__modal {
        content: '';
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        width: 100lvw;
        height: 100lvh;
        transition: background-color 0.5s ease;
        z-index: var(--z-index);
        background-color: rgba(40 40 40 / 0.9);
    }

    /* Imagens com efeito blur */
    .gallery__main-wrapper {
        position: relative;
        width: 100%;
        aspect-ratio: 16/9;
        
        .gallery__img-blur {
            overflow: hidden;
            width: 100%;
            height: 100%;
            position: absolute;
        }
        
        .gallery__img-blur__bg {
            width: 100%;
            height: 100%;
            background-color: #0C0C0C;
            position: absolute;
            top: 0;
            left: 0;
            z-index: -1;
        }
        
        .gallery__img {
            object-fit: contain;
            width: 100%;
            height: 100%;
        }

        .gallery__img__label {
            position: absolute;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            display: none;
        }
    }
    
    /* Contador */
    .gallery__counter {
        background-color: var(--clr-cnn);
        padding: 6px;
        color: #fff;
        font-weight: 500;
        width: fit-content;
        font-size: 14px;
        line-height: 14px;
        pointer-events: none;
        height: 25px;
        z-index: 1;
        visibility: hidden;
    }

    /* Conteúdo */
    .gallery__description-wrapper {
        width: 100%;
        pointer-events: none;
    
        p {
            color: #fff;
            margin: 0;
            font-size: 14px;
            line-height: 20px;
        }
        
        a {
            color: #fff;
            text-decoration: underline;

            &:hover {
                opacity: .8;
            }
        }

        .gallery__description {
            width: 100%;
            font-weight: 500;
            position: relative;
            padding-right: 16px;
            max-height: 80px;
            overflow-y: auto;
            pointer-events: all;
        }

        .gallery__credit {
            font-weight: 400;
            margin-top: 16px;
            font-size: 12px;
        }

    }

     /* Setas de navegação */
     .gallery__navigation {
        position: absolute;
        top: 0;
        z-index: 1;
        width: 100%;
        height: 100%;
        pointer-events: none;

        .gallery__button {
            pointer-events: all;
            position: absolute;
            top: 50%;
            translate: 0 -50%;
        }
    }
    
    /* Thumbnails */
    .gallery__thumb-label {
        cursor: pointer;
        position: relative;
    }
    
    /* Div que contém os elementos de troca do modo de exibição  */
    .gallery__switcher {
        display: flex;
        gap: 16px;
        flex-direction: column;
    }
}


/* -------------------------------------
   Botões
------------------------------------- */
.gallery__button {
    width: 32px;
    height: 32px;
    border-radius: 2px;
    cursor: pointer;
    text-indent: -999px;
    overflow: hidden;
    z-index: 1;
    cursor: pointer;
    display: block;
    color: transparent;
}

.gallery__button--default {
    background: url(/wp-content/plugins/shortcode-gallery/assets/img/ico-exit.svg) var(--clr-cnn) center center no-repeat;
}

.gallery__button--full {
    background: url(/wp-content/plugins/shortcode-gallery/assets/img/ico-full.svg) var(--clr-cnn) center center no-repeat;
}

.gallery__button--grid {
    background: url(/wp-content/plugins/shortcode-gallery/assets/img/ico-grid.svg) var(--clr-cnn) center center no-repeat;
}

.gallery__button--prev {
    background: url(/wp-content/plugins/shortcode-gallery/assets/img/ico-arrow.svg) var(--clr-cnn) center center no-repeat;
}

.gallery__button--next {
    background: url(/wp-content/plugins/shortcode-gallery/assets/img/ico-arrow.svg) var(--clr-cnn) center center no-repeat;
    transform: rotate(180deg);
}


/* -------------------------------------
   Controle de exibição do conteúdo
------------------------------------- */
/* Define o estilo inicial para itens de galeria */
.gallery__item {
    position: absolute;
    z-index: -9999;
    width: 100%;

    /* Animação de transição para conteúdo exibido*/
    .gallery__img,
    .gallery__description {
        opacity: 0;
        transition: opacity .5s ease;
    }
}

/* Exibe o conteúdo de cada item quando o radio estiver marcado */
.gallery__selector:checked {
    & + .gallery__item {
        position: relative;
        visibility: visible;
        z-index: 1;

        .gallery__img,
        .gallery__description {
            opacity: 1;
        }

        .gallery__counter {
            visibility: visible;
        }
    }
}


/* -------------------------------------
   Modo Default
------------------------------------- */
.gallery__layout--default:checked {
    /* Div que contém os elementos de troca do modo de exibição */
    & ~ .gallery__switcher {
        position: absolute;
        top: 16px;
        right: 16px;

        .gallery__button--default,
        .gallery__button--grid {
            display: none;
        }
    }

    /* Conteúdo principal */
    & ~ .gallery__larger {
        .gallery__counter {
            position: absolute;
            top: 16px;
            left: 16px;
            border-radius: 4px;
        }

        .gallery__item {
            width: 100%;
        }

        .gallery__img-blur {
            border-radius: 4px 4px 0 0;
        }

        .gallery__img__label--full {
            display: block;
        }

        .gallery__description-wrapper {
            position: absolute;
            bottom: 0;
            height: 225px;
            padding: 24px;
            display: flex;
            align-items: flex-end;
            background: linear-gradient(0deg, #000000 18.02%, rgba(0, 0, 0, 0) 86.22%);
        }

        /* Setas de navegação */
        .gallery__navigation {
            .gallery__button--prev {
                left: 16px;
            }

            .gallery__button--next {
                right: 16px;
            }
        }

        .gallery__selector--ad:checked + .gallery__item--ad {
            z-index: 2;

            .gallery__ad {
                display: flex;
                align-items: center;
                justify-content: center;
            }

            .gallery__navigation {
                z-index: 2;
            }
        }
    }

    /* Thumbnails */
    & ~ .gallery__thumbnails {
        .gallery__thumb-list {
            overflow: hidden;
            gap: 2px;
            margin-top: 2px;
        }

        .gallery__thumb {
            min-width: var(--thumb-width-default);
        }

        .gallery__thumb-label::before {
            content: '';
            display: block;
            border-bottom: 7px solid var(--clr-cnn);
            width: 100%;
            position: absolute;
            z-index: 1;
            bottom: 0;
            opacity: 0;
            transition: var(--transition-hover);
        }

        .gallery__thumb--active .gallery__thumb-label::before,
        .gallery__thumb-label:hover::before {
            opacity: 1;
        }
    }
}

/* Galeria destacada */
@media(min-width: 992px) {
    .gallery--highlight .gallery__layout--default:checked {
        & ~ .gallery__thumbnails .gallery__thumb {
            min-width: var(--thumb-width-highlight);
        }
    }
}


/* -------------------------------------
   Modo Fullscreen
------------------------------------- */
.gallery__layout--full:checked {
    /* Div que contém os elementos de troca do modo de exibição */
    & ~ .gallery__switcher {
        position: fixed;
        z-index: var(--z-index);
        top: var(--modal-top-spacing);
        right: var(--modal-switcher-right);

        .gallery__button--full {
            display: none;
        }
    }
    
    /* Modal */
    & ~ .gallery__modal {
        display: block;
    }
    
    /* Conteúdo principal */
    & ~ .gallery__larger {
        position: fixed;
        top: var(--modal-top-spacing);
        left: var(--modal-side-spacing);
        z-index: var(--z-index);
        width: var(--modal-inner-width);
        height: var(--modal-inner-height);
        pointer-events: none;

        .gallery__list {
            max-width: 100%;
            max-height: 100%;
            pointer-events: all;
        }

        .gallery__main-wrapper {
            height: calc(100vh - var(--content-height) - var(--modal-top-spacing));
        }

        .gallery__img-blur {
            border-radius: 4px;
        }

        .gallery__img__label--default {
            display: block;
        }
        
        /* Contador */
        .gallery__counter {
            position: absolute;
            top: 16px;
            left: 16px;
            border-radius: 4px;
        }
        
        /* Texto conteúdo */
        .gallery__description-wrapper {
            padding: 16px 0 24px 0;
            min-height: 156px;
        }
        
        /* Setas de navegação */
        .gallery__navigation {
            .gallery__button--prev {
                left: calc(-32px - 16px);
            }

            .gallery__button--next {
                right: calc(-32px - 16px);
            }
            
            .gallery__button--ad {
                display: none;
            }
        }
    }
    
    /* Thumbnails */
    & ~ .gallery__thumbnails {
        display: none;
    }
}    


/* -------------------------------------
   Modo Grid
------------------------------------- */
.gallery__layout--grid:checked {
    /* Div que contém os elementos de troca do modo de exibição */
    & ~ .gallery__switcher {
        position: fixed;
        z-index: var(--z-index);
        top: var(--modal-top-spacing);
        right: var(--modal-switcher-right);

        .gallery__button--default,
        .gallery__button--grid {
            display: none;
        }
    }

    /* Modal */
    & ~ .gallery__modal {
        display: block;
    }

    /* Conteúdo principal */
    & ~ .gallery__larger {
        display: none;
    }

    /* Thumbnails */
    & ~ .gallery__thumbnails {
        position: fixed;
        top: 0;
        left: var(--modal-side-spacing);
        z-index: var(--z-index);
        width: var(--modal-inner-width);
        height: 100%;
        display: flex;
        align-items: center;
        justify-content: center;
        overflow-y: auto;
        pointer-events: none;
        
        .gallery__thumb-list {
            display: grid;
            grid-gap: 32px 24px;
            grid-template-columns: repeat(3, auto);
            overflow-x: hidden;
            padding: 16px;
            max-height: 100%;
            pointer-events: all;
        }

        .gallery__thumb {
            width: var(--thumb-width-grid);
        }

        .gallery__img-blur {
            border-radius: 4px;
        }

        .gallery__thumb-label::before {
            content: '';
            display: block;
            border: 2px solid var(--clr-cnn);
            width: 100%;
            height: 100%;
            position: absolute;
            z-index: 1;
            top: 0;
            opacity: 0;
            transition: var(--transition-hover);
            border-radius: 4px;
        }

        .gallery__thumb-label:hover::before {
            opacity: 1;
        }
    }
}


/* -------------------------------------
   Mobile
------------------------------------- */
@media(max-width: 991px) {
    /* GERAL */
    section.gallery {        
        .gallery__layout:checked ~ .gallery__larger .gallery__img {
            border-radius: 0;
        }

        .gallery__switcher {
            gap: 32px;
        }

        .gallery__button {
            width: 24px;
            height: 24px;
        }

        .gallery__description-wrapper {
            .gallery__description {
                max-height: 64px;
                overflow-y: auto;
            }
        }
    }


    /* MODO DEFAULT */
    .gallery__layout--default:checked {
        & ~ .gallery__switcher {
            top: 16px;
            right: 16px;
        }

        & ~ .gallery__larger {
            .gallery__img-blur {
                border-radius: 0;
            }

            .gallery__description-wrapper {
                bottom: -56px; /* compensar este valor em gallery__thumbnails */
                height: 192px;
                padding-bottom: 16px;
                background: linear-gradient(0deg, #000000 38.26%, rgba(0, 0, 0, 0) 59.12%);
            }

            .gallery__ad {
                height: calc(100% + 142px); /* 100% + altura da thumbnail + altura da descrição */
            }
            
            .gallery__navigation {
                display: none;
            }
        }

        & ~ .gallery__thumbnails {
            width: 100%;
            margin-top: 57px ; /* compensar este valor em gallery__description-wrapper */
            
            .gallery__thumb-list {
                overflow-x: scroll;

                &::-webkit-scrollbar {
                    display: none;
                }
            }

            .gallery__thumb {
                min-width: 150px;
            }

            .gallery__thumb:not(.gallery__thumb--active) {
                .gallery__thumb-label:hover::before {
                    opacity: 0;
                }
            }
        } 
    }


    /* MODO FULL */
    .gallery__layout--full:checked {
        & ~ .gallery__switcher {
            top: 64px;
            right: 16px;
            width: 100%;
            flex-direction: column-reverse;
            gap: 40px;
            align-items: flex-end;
        }
        
        & ~ .gallery__larger {
            top: 112px;
            left: 0;
            width: 100vw;

            .gallery__main-wrapper {
                height: initial;
            }
            
            .gallery__img-blur {
                border-radius: 0;
            }

            .gallery__navigation {
                top: inherit;
                bottom: calc(-1 * var(--content-height) - 32px);
                height: 24px;
                display: flex;
                justify-content: center;
                gap: 24px;

                .gallery__button {
                    position: initial;
                }
            }

            .gallery__description-wrapper {
                padding: 16px 24px;
            }
        }
    }
    
    /* MODO GRID */
    .gallery__layout--grid:checked {
        & ~ .gallery__switcher {
            margin: 64px 24px 0 0;
            top: 0;
            right: 0;
        }

        & ~ .gallery__thumbnails  {
            width: 100%;
            left: 0;
            padding: 104px 24px 0 24px;

            .gallery__thumb-list {
                width: 100%;
                padding: 0;
                grid-template-columns: auto auto;
                padding-right: 16px;
            }

            .gallery__thumb {
                width: 100%;
            }
        }
    }

    /* Espaçamento ADS */
    .gallery__layout--default:checked {
        &~.gallery__larger {
            .gallery__selector--ad:checked + .gallery__item--ad {
                z-index: 2;
                margin-bottom: 86px;
            }
        }
    }
}


/* Mobile no modo paisagem */
@media(max-width: 991px) and (orientation: landscape) {
    section.gallery {
        /* MODO FULL */
        .gallery__layout--full:checked {
            & ~ .gallery__switcher {
                top: 16px;
                align-items: flex-end;
                gap: 16px;

                .gallery__button--default {
                    margin: 0;
                }
            }

            & ~ .gallery__larger {
                top: 0;
                height: 100%;
                max-height: 100%;

                .gallery__main-wrapper {
                    max-height: 100%;
                }

                .gallery__description-wrapper {
                    position: absolute;
                    bottom: 0;
                    padding: 112px 24px 40px 24px;
                    background: linear-gradient(0deg, #000000 13.95%, rgba(0, 0, 0, 0) 81.3%);
                }

                .gallery__navigation {
                    display: none;
                    top: 50%;
                    justify-content: space-between;

                    .gallery__button {
                        margin: 0 24px;
                    }
                }

                .gallery__selector:checked + .gallery__item .gallery__navigation {
                    display: flex;
                }
            }
            
        }
    }
}

.no__scroll {
    overflow: hidden;
    touch-action: pinch-zoom;
}
