/* ==========================================================================
   Galeria

   Duas formas, mesmo HTML:
   · base (sem JS, com movimento reduzido ou em tela baixa demais): a fita rola de lado,
     com encaixe em cada foto, e todas as fotos já aparecem;
   · .is-live: palco preso à tela. A rolagem da página empurra a fita para a esquerda
     (--gallery-x), e cada foto se revela em blocos ao entrar. O desenho está aqui; o
     gallery.js só informa posições e troca classes.

   A moldura é o hexágono da marca esticado: as pontas ficam nos lados, como no hero.
   ========================================================================== */

.gallery {
    --shot-h: clamp(13rem, 44vw, 26rem);
    --chamfer: calc(var(--shot-h) * 0.11);
    --shot-gap: clamp(1rem, 2.2vw, 2rem);

    position: relative;
    overflow-x: clip;
    color: var(--ink);
    background: var(--paper);
}

/* --- Título --------------------------------------------------------------- */
.gallery__head {
    display: grid;
    justify-items: start;
    gap: 1.25rem;
    padding: clamp(5rem, 14vw, 8rem) var(--gutter) clamp(2rem, 5vw, 3rem);
}

.gallery__title {
    font-size: var(--fs-section);
    font-weight: var(--fw-title);
    line-height: var(--lh-tight);
    letter-spacing: var(--tracking-title);
}

.gallery__line {
    display: block;
    text-wrap: balance;
}

.gallery__line--soft {
    color: var(--ink-3);
}

/* O hexágono da marca no lugar de uma palavra, como nos outros títulos. */
.gallery__hex {
    display: inline-block;
    width: 0.94em;
    height: 0.8em;
    margin-inline: 0.06em;
    vertical-align: -0.1em;
    background: var(--navy);
    clip-path: polygon(20% 0, 80% 0, 100% 50%, 80% 100%, 20% 100%, 0 50%);
}

/* --- Fita ----------------------------------------------------------------- */
.gallery__window {
    overflow-x: auto;
    overscroll-behavior-x: contain;
    scroll-snap-type: x mandatory;
    scroll-padding-inline: var(--gutter);
    scrollbar-width: thin;
    scrollbar-color: var(--hairline) transparent;
}

.gallery__strip {
    display: flex;
    gap: var(--shot-gap);
    width: max-content;
    padding: 0 var(--gutter) clamp(4rem, 10vw, 6rem);
}

.shot {
    flex: none;
    scroll-snap-align: start;
}

.shot__figure {
    position: relative;
    width: max-content;
}

.shot__frame,
.shot__edge {
    clip-path: polygon(
        var(--chamfer) 0,
        calc(100% - var(--chamfer)) 0,
        100% 50%,
        calc(100% - var(--chamfer)) 100%,
        var(--chamfer) 100%,
        0 50%
    );
}

.shot__frame {
    position: relative;
    height: var(--shot-h);
    overflow: hidden;
    background: var(--paper-2);
}

/* A mesma forma atrás da foto, deslocada: sobra só o filete laranja da marca. Aparece
   na foto em destaque. */
.shot__edge {
    position: absolute;
    top: 0;
    right: 0;
    left: 0;
    height: var(--shot-h);
    background: var(--orange);
    opacity: 0;
    transition: translate var(--t-slow) var(--ease), opacity var(--t-base) var(--ease);
}

.shot.is-active .shot__edge {
    opacity: 1;
    translate: calc(var(--chamfer) * -0.22) 0;
}

.shot__image {
    display: block;
    width: auto;
    max-width: 84vw;
    height: 100%;
    object-fit: cover;
}

.shot__blocks {
    position: absolute;
    inset: 0;
    display: none;
    width: 100%;
    height: 100%;
}

.shot__caption {
    display: flex;
    align-items: baseline;
    gap: 0.625rem;
    max-width: 84vw;
    margin-top: 0.875rem;
    padding-left: calc(var(--chamfer) * 0.5);
    font-size: var(--fs-small);
    white-space: nowrap;
}

.shot__index {
    font-size: var(--fs-micro);
    color: var(--ink-3);
    transition: color var(--t-fast) var(--ease);
}

.shot__name {
    overflow: hidden;
    text-overflow: ellipsis;
    color: var(--ink);
}

.gallery__foot {
    display: none;
}

/* ==========================================================================
   Palco
   ========================================================================== */

.gallery.is-live .gallery__track {
    height: calc(var(--screen) + var(--gallery-distance, 0px));
}

.gallery.is-live .gallery__stage {
    position: sticky;
    top: 0;
    display: grid;
    grid-template-rows: auto minmax(0, 1fr) auto;
    height: var(--screen);
    padding-top: var(--header-h);
    overflow: hidden;
}

.gallery.is-live .gallery__head {
    padding: clamp(1rem, 5vh, 3.5rem) var(--gutter) clamp(1rem, 4vh, 2.5rem);
}

/* A altura que sobra entre o título e o rodapé do palco decide o tamanho das fotos. */
.gallery.is-live .gallery__window {
    container-type: size;
    display: flex;
    align-items: center;
    overflow: visible;
    scroll-snap-type: none;
}

.gallery.is-live .gallery__strip {
    --shot-h: min(100cqh - 2.75rem, 34rem);

    padding-bottom: 0;
    translate: var(--gallery-x, 0px) 0;
    will-change: translate;
}

.gallery.is-live .shot__name {
    color: var(--ink-3);
    transition: color var(--t-base) var(--ease);
}

.gallery.is-live .shot.is-active .shot__name {
    color: var(--ink);
}

.gallery.is-live .shot.is-active .shot__index {
    color: var(--orange);
}

/* A foto corre um pouco dentro da moldura, mais devagar que a fita. */
.gallery.is-live .shot__image {
    scale: 1.12;
    translate: var(--drift, 0%) 0;
    transition: scale 1.2s var(--ease-heavy);
}

/* Antes da passagem a moldura é azul liso; durante, os blocos do canvas assumem. */
.gallery.is-live .shot:not(.is-shown):not(.is-revealing) .shot__frame::after {
    content: "";
    position: absolute;
    inset: 0;
    background: var(--navy);
}

.gallery.is-live .shot:not(.is-shown) .shot__image {
    scale: 1.3;
}

.gallery.is-live .shot.is-revealing .shot__blocks {
    display: block;
}

.gallery.is-live .gallery__foot {
    display: flex;
    align-items: center;
    gap: 1.25rem;
    padding: clamp(1rem, 3vh, 2rem) var(--gutter) calc(var(--gutter) + env(safe-area-inset-bottom));
}

.gallery__code {
    display: flex;
    flex: none;
    align-items: center;
    gap: 0.4rem;
    font-size: var(--fs-micro);
    color: var(--ink);
}

.gallery__code-total {
    color: var(--ink-2);
}

.gallery__bar {
    position: relative;
    flex: 1;
    height: 2px;
    overflow: hidden;
    background: var(--hairline);
}

.gallery__fill {
    position: absolute;
    inset: 0;
    background: var(--orange);
    transform-origin: left;
    scale: var(--fill, 0) 1;
}

/* --- Entrada -------------------------------------------------------------- */
.gallery.is-live .gallery__head,
.gallery.is-live .gallery__foot {
    transition: opacity var(--t-slow) var(--ease), translate var(--t-slow) var(--ease);
}

.gallery.is-live:not(.is-in) .gallery__head,
.gallery.is-live:not(.is-in) .gallery__foot {
    opacity: 0;
    translate: 0 1.25rem;
}

/* ==========================================================================
   Telas maiores
   ========================================================================== */

@media (min-width: 768px) {
    .shot__image {
        max-width: 62vw;
    }

    .shot__caption {
        max-width: 62vw;
    }
}

@media (min-width: 1024px) {
    .shot__image,
    .shot__caption {
        max-width: 48vw;
    }
}
