/*
 * Galeria automática de imagens no conteúdo das notícias/páginas.
 * Gerada por i3_agrupar_galeria_automatica_conteudo() (nucleo/funcoes/helpers.php) quando o
 * conteúdo tem 3+ imagens inseridas em sequência, sem texto entre elas.
 *
 * A rolagem horizontal com scroll-snap funciona mesmo sem JavaScript (arrasto/swipe nativo);
 * publico/assets/js/i3-content-gallery.js apenas melhora a experiência (setas, miniaturas,
 * teclado e contador sincronizados).
 */
.i3-content-gallery {
    --i3-gallery-primary: var(--theme-primary, var(--color-primary, var(--primary, #137fec)));
    --i3-gallery-accent: var(--theme-secondary, var(--color-secondary, var(--i3-gallery-primary)));
    --i3-gallery-bg: #0f172a;
    position: relative;
    width: 100%;
    margin: 1.5rem 0;
}

.i3-content-gallery__viewport {
    display: flex;
    overflow-x: auto;
    overflow-y: hidden;
    scroll-snap-type: x mandatory;
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
    border-radius: 1rem;
    background: var(--i3-gallery-bg);
    scrollbar-width: none;
    outline: none;
}

.i3-content-gallery__viewport::-webkit-scrollbar {
    display: none;
}

.i3-content-gallery__viewport:focus-visible {
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--i3-gallery-primary) 45%, transparent);
}

.i3-content-gallery__track {
    display: flex;
    width: 100%;
}

.i3-content-gallery__slide {
    position: relative;
    flex: 0 0 100%;
    scroll-snap-align: start;
    scroll-snap-stop: always;
    margin: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 220px;
    max-height: 68vh;
    background: var(--i3-gallery-bg);
}

.i3-content-gallery__slide img {
    display: block;
    width: 100%;
    height: 100%;
    max-height: 68vh;
    object-fit: contain;
}

.i3-content-gallery__slide figcaption {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    padding: 0.6rem 0.9rem;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.72), rgba(0, 0, 0, 0));
    color: #f8fafc;
    font-size: 0.82rem;
    line-height: 1.35;
    text-align: left;
}

.i3-content-gallery__nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 40px;
    height: 40px;
    border: 0;
    border-radius: 999px;
    background: rgba(15, 23, 42, 0.55);
    cursor: pointer;
    transition: background 0.18s ease, transform 0.18s ease;
    z-index: 2;
}

.i3-content-gallery__nav:hover {
    background: rgba(15, 23, 42, 0.78);
}

.i3-content-gallery__nav:focus-visible {
    outline: 3px solid color-mix(in srgb, var(--i3-gallery-primary) 45%, transparent);
    outline-offset: 2px;
}

.i3-content-gallery__nav::before {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    width: 10px;
    height: 10px;
    border-top: 2px solid #ffffff;
    border-right: 2px solid #ffffff;
}

.i3-content-gallery__nav--prev {
    left: 0.6rem;
}

.i3-content-gallery__nav--prev::before {
    transform: translate(-30%, -50%) rotate(-135deg);
}

.i3-content-gallery__nav--next {
    right: 0.6rem;
}

.i3-content-gallery__nav--next::before {
    transform: translate(-70%, -50%) rotate(45deg);
}

.i3-content-gallery__nav[disabled] {
    opacity: 0.35;
    cursor: default;
    pointer-events: none;
}

.i3-content-gallery__counter {
    position: absolute;
    top: 0.6rem;
    right: 0.6rem;
    padding: 0.15rem 0.6rem;
    border-radius: 999px;
    background: rgba(15, 23, 42, 0.6);
    color: #f8fafc;
    font-size: 0.75rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    z-index: 2;
    pointer-events: none;
}

.i3-content-gallery__thumbs {
    display: flex;
    gap: 0.4rem;
    margin-top: 0.5rem;
    padding-bottom: 0.15rem;
    overflow-x: auto;
    scrollbar-width: none;
}

.i3-content-gallery__thumbs::-webkit-scrollbar {
    display: none;
}

.i3-content-gallery__thumb {
    flex: 0 0 auto;
    width: 56px;
    height: 56px;
    padding: 0;
    border: 2px solid transparent;
    border-radius: 0.6rem;
    overflow: hidden;
    background: none;
    cursor: pointer;
    opacity: 0.6;
    transition: opacity 0.18s ease, border-color 0.18s ease;
}

.i3-content-gallery__thumb img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.i3-content-gallery__thumb:hover {
    opacity: 0.9;
}

.i3-content-gallery__thumb:focus-visible {
    outline: 3px solid color-mix(in srgb, var(--i3-gallery-primary) 45%, transparent);
    outline-offset: 2px;
}

.i3-content-gallery__thumb.is-active {
    opacity: 1;
    border-color: var(--i3-gallery-primary);
}

body.theme-portalguaira .i3-content-gallery {
    --i3-gallery-primary: var(--pg-primary, var(--theme-primary, #333333));
    --i3-gallery-accent: var(--pg-accent, var(--theme-secondary, #ff7f00));
}

body.theme-portallindeiros .i3-content-gallery {
    --i3-gallery-primary: var(--cor-primaria, var(--theme-primary, #137fec));
}

body.theme-modelo_default_v1 .i3-content-gallery,
body.theme-portalpiata .i3-content-gallery,
body.theme-modelo_default_v2 .i3-content-gallery {
    --i3-gallery-primary: var(--theme-primary, #137fec);
    --i3-gallery-accent: var(--theme-secondary, #ff7f00);
}

body.theme-oestenoticias .i3-content-gallery {
    --i3-gallery-primary: var(--oeste-primary, var(--theme-primary, #0f766e));
}

@media (max-width: 520px) {
    .i3-content-gallery__nav {
        width: 34px;
        height: 34px;
    }

    .i3-content-gallery__thumb {
        width: 46px;
        height: 46px;
    }

    .i3-content-gallery__slide {
        min-height: 180px;
    }
}
