/**
 * @package     Joomla.Plugin
 * @subpackage  Content.ocbgallery
 *
 * @copyright   (C) 2026 Sistema OCB
 * @license     GNU General Public License version 2 or later; see LICENSE.txt
 *
 * Lightbox compartilhado pelos layouts Classic e Carousel.
 *
 * E um asset separado, carregado apenas quando o layout renderizado tem o
 * lightbox ligado. O Slider nunca o carrega. Todas as classes usam o prefixo
 * proprio .ocb-lightbox, sem tocar em nenhuma classe de layout.
 */

/* O <dialog> so aparece quando tem o atributo open. Declarar display: flex
   sem essa condicao sobrescreve a regra do navegador
   `dialog:not([open]) { display: none }` e o lightbox fica na tela depois de
   fechado. */
.ocb-lightbox:not([open]) {
    display: none;
}

.ocb-lightbox[open] {
    position: fixed;
    inset: 0;
    z-index: 1100;
    display: flex;
    align-items: center;
    justify-content: center;
    max-width: 100vw;
    max-height: 100vh;
    width: 100vw;
    height: 100vh;
    padding: clamp(0.5rem, 3vw, 2.5rem);
    border: 0;
    background-color: rgb(17 17 17 / 92%);
    color: #fff;
}

.ocb-lightbox::backdrop {
    background-color: rgb(17 17 17 / 92%);
}

.ocb-lightbox .ocb-lightbox__figure {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    align-items: center;
    max-width: 100%;
    max-height: 100%;
    margin: 0;
}

.ocb-lightbox .ocb-lightbox__image {
    max-width: 100%;
    max-height: calc(100vh - 8rem);
    width: auto;
    height: auto;
    object-fit: contain;
}

.ocb-lightbox .ocb-lightbox__caption {
    max-width: 60ch;
    text-align: center;
    font-size: 0.875rem;
    line-height: 1.4;
}

.ocb-lightbox .ocb-lightbox__counter {
    display: block;
    opacity: 0.75;
    font-variant-numeric: tabular-nums;
}

/* A classe e repetida de proposito: eleva a especificidade e vence as regras
   de <button> dos templates, sem recorrer a regras marcadas como importantes. */
.ocb-lightbox .ocb-lightbox__button.ocb-lightbox__button {
    position: absolute;
    z-index: 2;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 3rem;
    height: 3rem;
    min-width: 0;
    min-height: 0;
    max-width: none;
    padding: 0;
    margin: 0;
    border: 1px solid rgb(255 255 255 / 30%);
    border-radius: 50%;
    background: rgb(255 255 255 / 14%);
    backdrop-filter: blur(6px);
    box-shadow: 0 2px 10px rgb(0 0 0 / 35%);
    color: #fff;
    text-indent: 0;
    text-transform: none;
    visibility: visible;
    opacity: 1;
    pointer-events: auto;
    cursor: pointer;
    transition: background-color 150ms ease, transform 150ms ease;
}

.ocb-lightbox .ocb-lightbox__button.ocb-lightbox__button:hover {
    background: rgb(255 255 255 / 30%);
    transform: scale(1.06);
}

.ocb-lightbox .ocb-lightbox__button.ocb-lightbox__button:focus-visible {
    outline: 2px solid #fff;
    outline-offset: 3px;
}

.ocb-lightbox .ocb-lightbox__button svg {
    display: block;
    width: 24px;
    height: 24px;
}

.ocb-lightbox .ocb-lightbox__button--close {
    top: 1.25rem;
    right: 1.25rem;
}

.ocb-lightbox .ocb-lightbox__button--prev {
    top: 50%;
    left: 1.25rem;
    transform: translateY(-50%);
}

.ocb-lightbox .ocb-lightbox__button--next {
    top: 50%;
    right: 1.25rem;
    transform: translateY(-50%);
}

.ocb-lightbox .ocb-lightbox__button--prev:hover,
.ocb-lightbox .ocb-lightbox__button--next:hover {
    transform: translateY(-50%) scale(1.06);
}

.ocb-lightbox .ocb-lightbox__button[hidden] {
    display: none;
}

@media (prefers-reduced-motion: reduce) {
    .ocb-lightbox .ocb-lightbox__button.ocb-lightbox__button {
        transition: none;
    }

    .ocb-lightbox .ocb-lightbox__button.ocb-lightbox__button:hover {
        transform: none;
    }

    .ocb-lightbox .ocb-lightbox__button--prev:hover,
    .ocb-lightbox .ocb-lightbox__button--next:hover {
        transform: translateY(-50%);
    }
}

/* Impede a rolagem do fundo enquanto o lightbox esta aberto. */
.ocb-lightbox-open {
    overflow: hidden;
}

@media print {
    .ocb-lightbox {
        display: none;
    }
}
