/* ==========================================================================
   Frentes — agricultura, pecuária, equoterapia e imobiliário
   --------------------------------------------------------------------------
   Página comum (sem JS ou com movimento reduzido): cada frente é uma tela
   com a sua foto, o texto embaixo e tudo à vista.

   Com o filme (.is-film no .filme em volta):
     - a foto sai: o fundo é o filme, que passa por baixo;
     - cada frente vira um trecho de scroll com o painel preso na tela;
     - as frentes se sobrepõem em (1 + --passagem) telas: por esse trecho, os
       dois painéis estão presos ao mesmo tempo e um texto sai enquanto o
       outro entra. A primeira frente se sobrepõe ao fim do hero do mesmo jeito.
   Com o módulo das frentes (.is-scrubbed), cada linha recebe --in e --out
   (0 a 1) e o painel recebe --presenca. Sem ele, o painel fica inteiro.
   ========================================================================== */

.servicos {
    --fs-frente: clamp(2.75rem, 1rem + 7.4vw, 5.5rem);

    position: relative;
    background: var(--green-night);
    color: var(--white);
}

/* --- Página comum: uma tela por frente ------------------------------------ */
.frente {
    position: relative;
    display: grid;
    min-height: min(var(--screen), 60rem);
    overflow: hidden;
    isolation: isolate;
}

.frente__foto,
.frente__foto img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
}

.frente__foto {
    z-index: -2;
}

.frente__foto img {
    object-fit: cover;
}

/* Mesmo véu da tela do filme: a frente parece igual com e sem movimento. */
.frente::before {
    content: "";
    position: absolute;
    inset: 0;
    z-index: -1;
    background: linear-gradient(0deg, rgba(var(--green-night-rgb), 0.92) 0%, rgba(var(--green-night-rgb), 0.55) 45%, rgba(var(--green-night-rgb), 0.1) 80%);
}

.frente__painel {
    position: relative;
    display: grid;
    grid-template-rows: auto 1fr;
    padding-top: calc(var(--header-h) + env(safe-area-inset-top) + 0.75rem);
    padding-bottom: clamp(3rem, 9vh, 6rem);
    isolation: isolate;
}

/* --- Legendas do topo ------------------------------------------------------ */
.frente__moldura {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1.5rem;
    padding-bottom: 0.875rem;
    color: var(--white-2);
    text-shadow: 0 1px 14px rgba(var(--green-night-rgb), 0.45);
}

/* A linha fina fica dentro da largura útil, como no hero. */
.frente__moldura::after {
    content: "";
    position: absolute;
    right: var(--gutter);
    bottom: 0;
    left: var(--gutter);
    height: 1px;
    background: var(--hairline-light);
}

.frente__moldura {
    position: relative;
}

.frente__secao {
    color: var(--leaf);
}

/* No celular, o lugar sai: a etiqueta e o título já dizem o que é. */
.frente__lugar {
    display: none;
}

/* --- Conteúdo ------------------------------------------------------------- */
.frente__conteudo {
    display: grid;
    align-content: end;
    justify-items: start;
    padding-top: 2rem;
}

.frente__etiqueta {
    color: var(--white);
}

.frente__etiqueta::before {
    color: var(--leaf);
}

.frente__indice {
    margin-left: 0.375rem;
    color: var(--white-3);
}

.frente__titulo {
    max-width: 16ch;
    margin-top: 1rem;
    font-size: var(--fs-frente);
    font-weight: var(--fw-bold);
    line-height: 0.94;
    letter-spacing: -0.045em;
    color: var(--white);
    text-wrap: balance;
}

/* A linha de baixo: texto, número de prova e botão. */
.frente__linha {
    display: grid;
    justify-items: start;
    width: 100%;
    margin-top: clamp(1.5rem, 4.5vh, 2.75rem);
}

.frente__descricao {
    max-width: 34rem;
    font-size: var(--fs-lead);
    color: var(--white-2);
    text-wrap: pretty;
}

.frente__descricao p + p {
    margin-top: 0.6em;
}

.frente__racas {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    max-width: 36rem;
    margin-top: 1.25rem;
}

.frente__racas li {
    padding: 0.3125rem 0.875rem;
    border-radius: var(--radius-pill);
    background: var(--glass);
    box-shadow: inset 0 0 0 1px var(--hairline-light);
    font-size: var(--fs-label);
    font-weight: var(--fw-bold);
    color: var(--white);
    white-space: nowrap;
}

/* Número de prova: no celular, numa linha só, antes do botão. */
.frente__prova {
    margin-top: 1.5rem;
}

.frente__prova-item {
    display: flex;
    flex-direction: row-reverse;
    justify-content: flex-end;
    align-items: baseline;
    gap: 0.75rem;
}

.frente__prova-valor {
    font-size: clamp(2rem, 1.4rem + 2.6vw, 2.75rem);
    font-weight: var(--fw-bold);
    line-height: 0.9;
    letter-spacing: -0.045em;
    font-variant-numeric: tabular-nums;
    color: var(--white);
}

.frente__prova-rotulo {
    max-width: 14rem;
    color: var(--white-3);
}

.frente__cta {
    margin-top: 1.75rem;
}

/* ==========================================================================
   Com o filme (.is-film)
   ========================================================================== */

.is-film .servicos {
    margin-top: calc(var(--screen) * (-1 - var(--passagem)));
    background: transparent;
}

.is-film .frente {
    --altura: 3;

    display: block;
    height: calc(var(--screen) * var(--altura));
    min-height: 0;
    overflow: visible;
    isolation: auto;

    /* O menu leva ao ponto em que o texto da frente já entrou inteiro
       (sections/servicos.js: a última linha termina 0,75 tela depois do topo). */
    scroll-margin-top: calc(var(--screen) * -0.8 - var(--header-h));
}

/* A pecuária atravessa o Nelore e os cavalos: mais filme, mais scroll. */
.is-film .frente--pecuaria {
    --altura: 3.6;
}

.is-film .frente + .frente,
.is-film .servicos__desfecho {
    margin-top: calc(var(--screen) * (-1 - var(--passagem)));
}

.is-film .frente__foto,
.is-film .frente::before {
    display: none;
}

.is-film .frente__painel {
    position: sticky;
    top: 0;
    height: var(--screen);
    pointer-events: none;
}

.is-film .frente__cta {
    pointer-events: auto;
}

/* Véu suave atrás do texto, que entra e sai com ele. Dois painéis trocando
   ao mesmo tempo somam véus iguais: a luz do filme quase não muda. */
.is-film .frente__painel::before {
    content: "";
    position: absolute;
    inset: 0;
    z-index: -1;
    background: linear-gradient(0deg, rgba(var(--green-night-rgb), 0.5) 0%, rgba(var(--green-night-rgb), 0.3) 40%, rgba(var(--green-night-rgb), 0) 70%);
    opacity: var(--presenca, 1);
}

/* O fim do filme: o drone termina de subir até o horizonte, sem texto, e abre
   a história da família. O véu sai entre 0,3 e 0,9 tela (sections/servicos.js),
   e a última tela é a da história subindo por cima do horizonte
   (sections/historia.css). */
.servicos__desfecho {
    display: none;
}

.is-film .servicos__desfecho {
    display: block;
    height: calc(var(--screen) * 2.8);
}

/* --- Texto que entra e sai com o scroll (.is-scrubbed) ---------------------- */
.is-scrubbed .frente__painel {
    visibility: var(--painel-visibilidade, hidden);
}

.is-scrubbed [data-frente-item] {
    opacity: calc(var(--in, 0) * (1 - var(--out, 0)));
    transform: translate3d(0, calc((1 - var(--in, 0)) * 2rem - var(--out, 0) * 1.5rem), 0);
}

/* ==========================================================================
   Telas baixas (celular deitado): só o essencial cabe.
   ========================================================================== */
@media (max-height: 560px) and (orientation: landscape) {
    .frente__moldura,
    .frente__descricao p + p,
    .frente__racas {
        display: none;
    }

    .frente__titulo {
        font-size: min(var(--fs-frente), 11vh);
    }

    .frente__painel {
        padding-bottom: 1.5rem;
    }

    .frente__linha,
    .frente__prova,
    .frente__cta {
        margin-top: 0.75rem;
    }
}

/* ==========================================================================
   Tablet: o lugar volta para a legenda da direita
   ========================================================================== */
@media (min-width: 768px) {
    .frente__lugar {
        display: inline-flex;
    }
}

/* ==========================================================================
   Desktop: título grande em cima; embaixo, depois de uma linha fina, o texto
   à esquerda, o número de prova no meio e o botão na ponta direita.
   ========================================================================== */
@media (min-width: 1024px) {
    .servicos {
        --fs-frente: min(6.8vw, 15vh);
    }

    .frente__titulo {
        max-width: 18ch;
    }

    .frente__linha {
        grid-template-columns: minmax(0, 36rem) minmax(0, 1fr) auto;
        align-items: end;
        column-gap: clamp(2rem, 4vw, 4rem);
        padding-top: 1.5rem;
        border-top: 1px solid var(--hairline-light);
    }

    .frente__descricao {
        font-size: var(--fs-body);
    }

    .frente__prova {
        justify-self: end;
        margin-top: 0;
    }

    .frente__prova-item {
        flex-direction: column-reverse;
        align-items: flex-start;
        gap: 0.75rem;
    }

    .frente__prova-valor {
        font-size: var(--fs-stat);
    }

    .frente__prova-rotulo {
        max-width: 15rem;
    }

    .frente__cta {
        justify-self: end;
        margin-top: 0;
    }

    .frente__painel {
        padding-bottom: clamp(3rem, 9vh, 6rem);
    }

    .is-film .frente__painel::before {
        background: linear-gradient(0deg, rgba(var(--green-night-rgb), 0.55) 0%, rgba(var(--green-night-rgb), 0.25) 45%, rgba(var(--green-night-rgb), 0) 70%);
    }
}
