/* Hero: fundo próprio (corredor de trasteros, assets/ill/hero-bg*.svg) + ilustração da porta de enrolar.
   A coreografia vive no <style> do SVG inline (classes .ha-*): entrada ~3.5s (LED, destrave, porta sobe com
   antecipação+elástico, luz cresce, caixas assentam, chave brilha) e depois um ciclo contínuo de 28s: 3 caixas em carrinhos
   saem e entram à vez, a porta baixa e volta a subir, luz e pó sempre vivos.
   Aqui: layout, texto (legível desde t=0), fundo, parallax por camadas, pausa fora do ecrã e movimento reduzido.
   Só transform e opacity. */

.hero {
    --e-in: cubic-bezier(.16, 1, .3, 1);
}

/* Home cinema: the original SVG owns layout and is always the first paint. */
.home-cinema [data-home-hero] { position: relative; isolation: isolate; }
.home-cinema [data-home-hero] .ha,
.home-cinema [data-home-hero] .ha * { animation: none !important; }
.home-cinema .ha-par-in,
.home-cinema .ha-par-dust-f,
.home-cinema .ha-par-dust-m,
.home-cinema .ha-par-dust-n { transform: none; }
.home-cinema .home-hero-canvas {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    pointer-events: none;
    opacity: 0;
    transition: opacity .55s cubic-bezier(.22, 1, .36, 1);
}
/* Only linear gradients: dark left for the copy, fade into the next section at the bottom. */
.home-cinema.is-home-ready::after {
    content: "";
    position: absolute;
    inset: 0;
    z-index: -1;
    pointer-events: none;
    background:
        linear-gradient(180deg, transparent calc(100% - 120px), var(--night)),
        linear-gradient(90deg, rgb(16 13 9 / .96) 0%, rgb(16 13 9 / .82) 26%, transparent 56%);
}
/* Video door-light: so entra quando o 3D nao roda (home-hero.js). Ate tocar, o poster da home segue visivel; o scrim
   .fx-video--bg::after (fx.css) escurece a esquerda, onde esta o texto. Reduced-motion/saveData: o video nem e criado. */
.home-cinema .home-video { background: transparent; }
.home-cinema .hero-bg img { transition: opacity .55s ease; animation: none; }
.home-cinema.is-home-ready .hero-bg img { opacity: 0; }
@media (max-width: 768px) {
    .home-cinema.is-home-ready::after {
        background: linear-gradient(180deg, rgb(16 13 9 / .12) 0%, rgb(16 13 9 / .22) 70%, var(--night) 100%);
    }
}
.home-cinema.is-home-ready .home-hero-canvas { opacity: 1; }
/* Mascara LINEAR no proprio canvas (sem circulo): a cena esmaece para o fundo escuro onde fica o texto
   (esquerda) e na base, onde o hero encontra a proxima secao. */
.home-cinema .home-hero-canvas {
    -webkit-mask-image:
        linear-gradient(90deg, rgb(0 0 0 / .1) 0%, rgb(0 0 0 / .2) 22%, rgb(0 0 0 / .62) 42%, #000 60%),
        linear-gradient(180deg, #000 0, #000 calc(100% - 150px), transparent 100%);
    -webkit-mask-composite: source-in;
    mask-image:
        linear-gradient(90deg, rgb(0 0 0 / .1) 0%, rgb(0 0 0 / .2) 22%, rgb(0 0 0 / .62) 42%, #000 60%),
        linear-gradient(180deg, #000 0, #000 calc(100% - 150px), transparent 100%);
    mask-composite: intersect;
}
@media (max-width: 768px) {
    .home-cinema .home-hero-canvas {
        -webkit-mask-image: linear-gradient(180deg, #000 0%, #000 80%, transparent 100%);
        mask-image: linear-gradient(180deg, #000 0%, #000 80%, transparent 100%);
        -webkit-mask-composite: source-over;
        mask-composite: add;
    }
}
/* Com a cena 3D no ar a ilustracao SVG (1a pintura) sai de cena: sem isto ficava a porta SVG por cima do canvas
   (duas portas/dois teclados) e a abertura 3D por baixo aparecia como "fantasma" atras do texto. */
.home-cinema [data-home-hero] > .ha { transition: opacity .55s cubic-bezier(.22, 1, .36, 1); }
.home-cinema.is-home-ready [data-home-hero] > .ha { opacity: 0; }
.home-cinema:not(.is-home-ready) [data-home-hero] > .ha { opacity: 1; }
/* Keep the LCP copy/poster out of page-motion's generic entry reveals. */
.home-cinema .hero-text :is(h1, p, .btn, .cta-link),
.home-cinema .hero-illustration {
    opacity: 1 !important;
    transform: none !important;
    translate: none !important;
}
/* K2: CTA primário magnético (js/fx-site.js → magnetic, só ponteiro fino). Única exceção ao translate:none acima;
   mantém as transições do .btn (page-motion.css) e soma a do translate. */
@media (prefers-reduced-motion: no-preference) {
    .home-cinema .hero-text .btn.fx-magnetic {
        translate: var(--fx-mx, 0) var(--fx-my, 0) !important;
        transition: transform var(--motion-base) var(--motion-out), opacity var(--motion-fast) var(--motion-smooth), translate .45s var(--motion-out);
    }
}
.home-cinema .hero-text {
    opacity: var(--home-copy-opacity, 1);
    transform: translate3d(0, var(--home-copy-y, 0px), 0);
}
.home-cinema .hero-text:focus-within { opacity: 1; transform: none; }
/* Lead legivel sobre o poster (pior pixel atras do texto: pilar amarelo #cfc667).
   Antes #b3aa9b sem scrim = 1.30:1; agora #f2ede4 sobre night .72 (#454123) = 8.86:1 (scripts/contrast.js). */
.home-cinema .hero-text > p {
    color: var(--on-night);
    font-weight: 450;
}
.home-cinema .hero-text .cta-link { gap: .5rem; }
.home-cinema .hero-text .cta-link > .arrow { flex: none; }
/* Desktop: scrim so atras do bloco de texto (o mobile ja tem o seu em page-motion.css).
   Nucleo .72 cobre todo o texto; as bordas esmaecem nos 48px de folga, sem caixa visivel nem escurecer a cena. */
@media (min-width: 769px) {
    .home-cinema .hero-text {
        position: relative;
        isolation: isolate;
    }
    .home-cinema .hero-text::before {
        content: "";
        position: absolute;
        z-index: -1;
        inset: -3rem -3.5rem;
        pointer-events: none;
        background: rgb(16 13 9 / .72);
        -webkit-mask-image:
            linear-gradient(90deg, transparent 0, #000 3.5rem, #000 calc(100% - 3.5rem), transparent 100%),
            linear-gradient(180deg, transparent 0, #000 3rem, #000 calc(100% - 3rem), transparent 100%);
        -webkit-mask-composite: source-in;
        mask-image:
            linear-gradient(90deg, transparent 0, #000 3.5rem, #000 calc(100% - 3.5rem), transparent 100%),
            linear-gradient(180deg, transparent 0, #000 3rem, #000 calc(100% - 3rem), transparent 100%);
        mask-composite: intersect;
    }
}
@media (prefers-reduced-motion: reduce) {
    .home-cinema .home-hero-canvas { display: none; }
    .home-cinema.is-home-ready [data-home-hero] > .ha { opacity: 1; transition: none; }
    .home-cinema .hero-text { opacity: 1; transform: none; }
}

/* ---------- Fundo: um único foco (halo fixo atrás da cena) ---------- */
.hero-bg {
    position: absolute;
    z-index: -2;
    inset: 0;
    overflow: hidden;
    pointer-events: none;
}

/* <picture>: abaixo de 768px usa hero-bg-m.svg (sem luminárias por trás do texto). */
.hero-bg picture {
    display: block;
    height: 100%;
}

.hero-bg img {
    display: block;
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
    transform: none;
    animation: none;
}

/* Fundo funde-se com a secção seguinte (gradiente estático, sem máscara). */
.hero-bg::after {
    position: absolute;
    inset: auto 0 0;
    height: 120px;
    background: linear-gradient(180deg, transparent, var(--night));
    content: "";
}

@keyframes hero-bg-in {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* Um só foco de luz: o do fundo (bg-end, atrás da cena). O brilho do ponteiro e o feixe vertical saem. */
.hero::before,
.hero::after {
    content: none;
}

/* ---------- Ilustração (texto 6 colunas + cena 6 colunas, na mesma linha) ---------- */
.hero .hero-text {
    grid-column: 1 / span 6;
}

.hero .hero-illustration {
    grid-column: 7 / span 6;
    width: min(100%, 540px);
    transform: translate3d(var(--par-x, 0), var(--par-y, 0), 0);
}

.hero .hero-illustration::after {
    content: none;
}

/* Sem drop-shadow no SVG animado (re-filtrava a cada frame); a sombra está desenhada na arte. */
.hero .hero-illustration svg {
    filter: none;
    overflow: visible;
}

.hero-defs {
    position: absolute;
    width: 0;
    height: 0;
    overflow: hidden;
}

/* ---------- Texto: legível desde t=0; só lead e CTA sobem 8px (0.1s/0.2s). Sem parallax no texto. ---------- */
.hero h1 .h1-line {
    display: block;
}

/* Título da home («Trasteros en Paiporta, / cerca de Valencia») é mais longo que o antigo: duas linhas, sem o limite de 11ch. */
@media (min-width: 1025px) {
    .hero.home-cinema h1 {
        max-width: none;
        font-size: clamp(2.75rem, 3.9vw, 4rem);
    }
}

.hero-text > p {
    animation: rise-in .6s var(--e-in) .1s backwards;
}

.hero .cta-buttons {
    animation: rise-in .6s var(--e-in) .2s backwards;
}

@keyframes rise-in {
    from { opacity: .001; transform: translate3d(0, 8px, 0); }
    to { opacity: 1; transform: none; }
}

/* ---------- Fora do ecrã: cena em pausa (o ciclo continua de onde parou ao voltar) ---------- */
.hero.is-offscreen .hero-scene,
.hero.is-offscreen .hero-scene * {
    animation-play-state: paused !important;
}

/* ---------- Mobile: texto e CTA primeiro; cena inteira no 1.º ecrã a 390x844 ---------- */
/* A navegação é fixa e transparente por cima do hero: o hero reserva a altura dela
   (section.hero para vencer .hero de mobile.css, que carrega depois). */
section.hero {
    padding-top: calc(var(--nav-height) + clamp(3rem, 7vw, 5rem));
}

/* Mobile em retrato: a cena vai para cima, grande e recortada nas laterais da parede (a porta ocupa
   quase a largura toda); título + CTA logo a seguir, tudo no 1.º ecrã a 390x844.
   section.hero / section.hero .container vencem .hero / .hero .container de mobile.css (carrega depois). */
@media (max-width: 768px) {
    section.hero {
        padding-top: calc(var(--nav-height) + .5rem);
    }

    section.hero .container {
        gap: .75rem;
    }

    .hero .hero-text {
        grid-column: 1;
    }

    .hero .hero-illustration {
        order: -1;
        grid-column: 1;
        width: 100%;
        max-width: 440px;
        margin: 0;
        overflow: hidden;
    }

    .hero .hero-illustration svg {
        width: 114%;
        max-width: none;
        margin-left: -7%;
    }

    /* Carrinhos só dentro da unidade: surgem ao fundo e desvanecem na soleira (y<392), sem fios no chão junto
       ao título. Mesmas durações/atrasos do SVG; só trocam as keyframes (opacidade na camada X, profundidade na Y). */
    .hero .ha-tx-a { animation-name: ha-tx-a-m; }
    .hero .ha-tx-b { animation-name: ha-tx-b-m; }
    .hero .ha-tx-c { animation-name: ha-tx-c-m; }
    .hero .ha-ty-a { animation-name: ha-ty-a-m; }
    .hero .ha-ty-b { animation-name: ha-ty-b-m; }
    .hero .ha-ty-c { animation-name: ha-ty-c-m; }
}

@keyframes ha-tx-a-m {
    0% { opacity: 0; }
    1.79% { opacity: 0; animation-timing-function: cubic-bezier(.4, 0, .2, 1); }
    5.71% { opacity: 1; }
    8% { opacity: 1; animation-timing-function: cubic-bezier(.4, 0, .6, 1); }
    12% { opacity: 0; }
    100% { opacity: 0; }
}

@keyframes ha-ty-a-m {
    0% { transform: translateY(342px) scale(.6); }
    1.79% { transform: translateY(342px) scale(.6); animation-timing-function: cubic-bezier(.35, 0, .2, 1); }
    11.79% { transform: translateY(388px) scale(.93); }
    100% { transform: translateY(388px) scale(.93); }
}

@keyframes ha-tx-b-m {
    0% { opacity: 0; }
    32.14% { opacity: 0; animation-timing-function: cubic-bezier(.4, 0, .4, 1); }
    37.14% { opacity: 1; }
    51.43% { opacity: 1; animation-timing-function: cubic-bezier(.4, 0, .6, 1); }
    55.71% { opacity: 0; }
    100% { opacity: 0; }
}

@keyframes ha-ty-b-m {
    0% { transform: translateY(388px) scale(.93); }
    42.86% { transform: translateY(388px) scale(.93); animation-timing-function: cubic-bezier(.4, 0, .25, 1); }
    55% { transform: translateY(342px) scale(.6); }
    100% { transform: translateY(342px) scale(.6); }
}

@keyframes ha-tx-c-m {
    0% { opacity: 0; }
    60.71% { opacity: 0; animation-timing-function: cubic-bezier(.4, 0, .4, 1); }
    65% { opacity: 1; }
    68.57% { opacity: 1; animation-timing-function: cubic-bezier(.4, 0, .6, 1); }
    72.5% { opacity: 0; }
    100% { opacity: 0; }
}

@keyframes ha-ty-c-m {
    0% { transform: translateY(342px) scale(.6); }
    60.71% { transform: translateY(342px) scale(.6); animation-timing-function: cubic-bezier(.35, 0, .2, 1); }
    71.43% { transform: translateY(388px) scale(.93); }
    100% { transform: translateY(388px) scale(.93); }
}

@media (max-width: 768px) {
    .hero-bg img { inset: 0; width: 100%; height: 100%; max-width: none; object-position: center; transform: none; }

    .hero-bg::after {
        inset: 0;
        height: auto;
        background: linear-gradient(180deg,
            transparent 0,
            transparent calc(var(--door-b, 380px) + 24px),
            var(--night) calc(var(--text-y, 430px) - 8px));
    }

}

/* ---------- Movimento reduzido: estado final estático ---------- */
@media (prefers-reduced-motion: reduce) {
    .hero-bg img,
    .hero-text > p,
    .hero .cta-buttons {
        animation: none !important;
    }

    .hero-bg img,
    .hero .hero-illustration {
        transform: none;
    }
}

/* Hero fixo: imagem estatica manda. Ilustracao SVG antiga da porta (figure.hero-illustration) escondida. */
.home-cinema .hero-illustration{visibility:hidden!important}

