/* Galeria de imagens — grade de miniaturas + lightbox. Usa os tokens do
   peti-editorial.css (--creme, --verde, --terracota, --hairline, etc.). */

.gal-intro-sec {
    padding-bottom: clamp(1.5rem, 3vw, 2.5rem);
}

/* Mosaico dinâmico: grade de 4 colunas com tiles de destaque (grandes e
   panorâmicos) quebrando o ritmo. grid-auto-flow: dense preenche os buracos. */
.gal-grid {
    list-style: none;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    grid-auto-rows: clamp(140px, 14.5vw, 210px);
    grid-auto-flow: dense;
    gap: clamp(0.5rem, 1vw, 0.85rem);
    padding: 0 0 clamp(3.5rem, 8vw, 6.5rem);
}

.gal-cell { grid-row: span 1; }
.gal-cell--big  { grid-column: span 2; grid-row: span 2; }
.gal-cell--wide { grid-column: span 2; }

.gal-item {
    display: block;
    width: 100%;
    height: 100%;
    margin: 0;
    padding: 0;
    border: 1px solid var(--hairline);
    border-radius: 6px;
    background: #e8ece3;
    overflow: hidden;
    cursor: zoom-in;
    line-height: 0;
    position: relative;
}

.gal-item img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.7s cubic-bezier(0.2, 0.7, 0.2, 1);
}

/* Overlay no hover/foco: escurece as bordas e mostra uma lupa central. */
.gal-item::after {
    content: "";
    position: absolute;
    inset: 0;
    background:
        url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='46' height='46' viewBox='0 0 24 24' fill='none' stroke='%23f7f3ea' stroke-width='2' stroke-linecap='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cline x1='16.5' y1='16.5' x2='21' y2='21'/%3E%3C/svg%3E") no-repeat center,
        radial-gradient(circle at center, rgba(11, 61, 47, 0) 45%, rgba(11, 61, 47, 0.45) 100%);
    opacity: 0;
    transition: opacity 0.35s ease;
    pointer-events: none;
}

.gal-item:hover img,
.gal-item:focus-visible img {
    transform: scale(1.08);
}
.gal-item:hover::after,
.gal-item:focus-visible::after {
    opacity: 1;
}

.gal-item:focus-visible {
    outline: 2px solid var(--terracota);
    outline-offset: 2px;
}

/* Entrada: fade-up conforme cada tile entra na viewport (via IntersectionObserver).
   O estado "escondido" só vale com JS ativo (html.js) — sem JS os tiles aparecem
   normalmente, sem depender do observer para revelá-los. */
.gal-reveal {
    transition: opacity 0.6s ease, transform 0.6s ease;
}
.js .gal-reveal {
    opacity: 0;
    transform: translateY(20px);
}
.js .gal-reveal.is-visible {
    opacity: 1;
    transform: none;
}

@media (prefers-reduced-motion: reduce) {
    .js .gal-reveal { opacity: 1; transform: none; transition: none; }
    .gal-item img, .gal-item::after { transition: none; }
}

/* Responsivo: 3 colunas no tablet, 2 no celular (mantendo os destaques). */
@media (max-width: 900px) {
    .gal-grid { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 560px) {
    .gal-grid {
        grid-template-columns: repeat(2, 1fr);
        grid-auto-rows: 42vw;
    }
    .gal-cell--big { grid-column: span 2; grid-row: span 2; }
    .gal-cell--wide { grid-column: span 2; grid-row: span 1; }
}

/* ---------- Lightbox ---------- */
.gal-lightbox {
    position: fixed;
    inset: 0;
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(9, 26, 18, 0.94);
    padding: clamp(0.5rem, 3vw, 2.5rem);
    animation: gal-fade 0.2s ease;
}
.gal-lightbox[hidden] { display: none; }

@keyframes gal-fade { from { opacity: 0; } to { opacity: 1; } }

.gal-lb-fig {
    margin: 0;
    max-width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.gal-lb-fig img {
    max-width: 100%;
    max-height: 86vh;
    object-fit: contain;
    border-radius: 4px;
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.55);
}

.gal-lb-btn {
    position: absolute;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(247, 243, 234, 0.12);
    color: #fff;
    border: 0;
    border-radius: 999px;
    cursor: pointer;
    transition: background 0.2s ease;
    -webkit-tap-highlight-color: transparent;
}
.gal-lb-btn:hover { background: rgba(247, 243, 234, 0.26); }

.gal-lb-close {
    top: clamp(0.6rem, 2vw, 1.4rem);
    right: clamp(0.6rem, 2vw, 1.4rem);
    width: 44px;
    height: 44px;
    font-size: 1.8rem;
    line-height: 1;
}

.gal-lb-prev,
.gal-lb-next {
    top: 50%;
    transform: translateY(-50%);
    width: 52px;
    height: 52px;
    font-size: 2.2rem;
    line-height: 1;
}
.gal-lb-prev { left: clamp(0.4rem, 2vw, 1.6rem); }
.gal-lb-next { right: clamp(0.4rem, 2vw, 1.6rem); }

.gal-lb-count {
    position: absolute;
    bottom: clamp(0.6rem, 2vw, 1.4rem);
    left: 50%;
    transform: translateX(-50%);
    color: rgba(247, 243, 234, 0.85);
    font-family: var(--caps);
    font-size: 0.72rem;
    letter-spacing: 0.14em;
}

@media (max-width: 560px) {
    .gal-lb-prev, .gal-lb-next { width: 44px; height: 44px; font-size: 1.8rem; }
}
