/* Home carousel - stacked overlapping images */
.home-carousel {
    /* maior tamanho responsivo: mínimo 420px, ideal ~48vw, máximo 820px */
    width: clamp(420px, 48vw, 820px);
    max-width: 100%;
    height: min(60vh, 520px); /* usar viewport-based height para garantir visibilidade */
    position: relative;
    margin: 0 auto; /* centraliza o carrossel na coluna */
    padding: 0 24px; /* garante afastamento das laterais do site */
    transform: translateX(-40px); /* desloca levemente para a esquerda para balancear visualmente */
    transition: transform 0.28s ease;
    perspective: 800px;
}

.home-carousel .stack {
    position: relative;
    width: 100%;
    height: 100%;
}

/* Background slideshow inside the same carousel container */
.home-carousel .bg-slideshow {
    /* colocar no fluxo normal para que elementos seguintes (caption) fiquem abaixo */
    position: relative;
    width: 100%;
    height: 100%;
    overflow: hidden;
}

.home-carousel .bg-slideshow .slide {
    position: absolute;
    inset: 0 0 0 0;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    opacity: 0;
    /* start off-screen to the right so it can slide-in */
    transform: translateX(100%) scale(1.02);
    will-change: transform, opacity;
     /* nova animação: entra da direita, atravessa até a borda da sessão, pausa ~3s e sai rápido */
     /* cada slide ocupa 5s: 3.5s visível + ~1s saída
         -> animation-duration = 30s (5s por slide * 6 slides). */
    animation: slideSlide 12s infinite linear;
}

/* Se um slide precisar mostrar a imagem inteira sem crop, usar `data-fit="contain"` */
.home-carousel .bg-slideshow .slide[data-fit="contain"] {
    background-size: contain;
    background-position: center center;
    background-repeat: no-repeat;
    background-color: var(--dark-blue); /* evita bordas brancas quando houver letterbox */
}

.home-carousel .bg-slideshow .slide .slide-label {
    display: none; /* esconder nomes dos slides na seção home */
}

@media (max-width: 900px) {
    .home-carousel .bg-slideshow .slide {
        /* keep space for label on smaller screens if necessary */
    }
    .home-carousel .bg-slideshow .slide .slide-label {
        font-size: 1.8rem; /* mobile scale */
        padding: 6px 10px;
        bottom: 10px;
        -webkit-text-stroke: 0.2px rgba(0,0,0,0.6);
    }
}

.home-carousel .bg-slideshow .slide:nth-child(1) { animation-delay: 0s; }
.home-carousel .bg-slideshow .slide:nth-child(2) { animation-delay: 3s; }
.home-carousel .bg-slideshow .slide:nth-child(3) { animation-delay: 6s; }
.home-carousel .bg-slideshow .slide:nth-child(4) { animation-delay: 9s; }

@keyframes slideSlide {
        /* Ciclo total = 12s (4 slides * 3s por slide).
             Fluxo por slide (3s): entrada ~0.5s, visível 2s, saída ~0.5s.
             Percentuais relativos ao ciclo de 12s:
                 entrada completa: 0.5 / 12 = 4.1667%
                 visível até: 2.5 / 12 = 20.8333%
                 fim do slot: 3 / 12 = 25% */
        0%        { opacity: 0; transform: translateX(120vw) scale(1.02); }
        4.1667%   { opacity: 1; transform: translateX(0) scale(1.00); }
        20.8333%  { opacity: 1; transform: translateX(0) scale(1.00); }
        25%       { opacity: 0; transform: translateX(0) scale(0.99); }
        100%      { opacity: 0; transform: translateX(0) scale(0.99); }
}

.home-carousel .stack .item {
    position: absolute;
    top: 50%;
    left: 0;
    width: 72%;
    aspect-ratio: 1 / 1; /* força formato quadrado */
    height: auto;
    border-radius: 14px;
    overflow: hidden;
    box-shadow: 0 6px 18px rgba(0,0,0,0.12);
    transition: transform 0.45s cubic-bezier(.2,.8,.2,1), opacity 0.45s;
    cursor: pointer;
    background: #1b8fb5;
    transform: translateY(-50%); /* posiciona verticalmente centralizado - JS acrescenta translateX/scale */
}

.home-carousel .stack .item img {
    width: 100%;
    height: 100%;
    object-fit: contain; /* preserva a proporção real (quadrada) dentro do quadrado */
    display: block;
    background: #1b8fb5; /* evita áreas transparentes aparentes */
}

/* control offsets — JS will set inline transform, but a small fallback */
.home-carousel .controls {
    display: none; /* controles ocultos: autoplay ativado */
}

/* Ajustes para o container pai garantir 100% de altura disponível */
.hero-image {
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* quando em telas pequenas mantém bom tamanho */
@media (max-width: 900px) {
    .home-carousel {
        width: 100%;
        height: 48vh; /* quase metade da viewport para mobile */
        transform: none; /* reset no mobile para evitar overflow */
    }
    .home-carousel .stack .item {
        width: 88%;
        aspect-ratio: 1 / 1;
        left: 50%;
        transform: translate(-50%, -50%);
    }
}

/* Legenda do carrossel: sempre abaixo da imagem, com margem de 10px */
.home-carousel-caption {
    text-align: center;
    margin-top: 10px; /* requisito: distância de 10px da imagem */
    color: #ffffff; /* legenda em branco conforme pedido */
    font-size: 2rem; /* ajustado solicitado */
    line-height: 1.1;
    font-weight: 700; /* negrito */
    text-transform: uppercase; /* maiúsculas */
    pointer-events: none;
    opacity: 0; /* controlar visibilidade via classe .show */
    transition: opacity 600ms ease; /* transição suave de visibilidade */
    will-change: opacity;
}

.home-carousel-caption.show {
    opacity: 1;
}

@media (max-width: 600px) {
    .home-carousel-caption { font-size: 1.2rem; }
}

.home-carousel .controls button {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: var(--primary-color);
    color: white;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: var(--shadow-sm);
}

@media (max-width: 900px) {
    .hero-content {
        grid-template-columns: 1fr;
    }
    .home-carousel {
        width: 100%;
        height: 220px;
        transform: none; /* garantir comportamento previsível em telas pequenas */
    }
    .home-carousel .stack .item {
        left: 50%;
        transform: translate(-50%, -50%);
        width: 90%;
        aspect-ratio: 1 / 1;
        height: auto;
    }
}
