* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Montserrat', sans-serif;
}

/* ===== Runway de scroll (pin) ===== */
.hero-scroll {
  position: relative;
  height: 300vh;
}

.hero-pinned {
  position: sticky;
  top: 0;
  height: 100vh;
  overflow: hidden;
  display: flex;
  align-items: flex-end;
  padding-bottom: 20vh;
}

.hero-video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Cobre o vídeo com a imagem estática enquanto este faz, em segundo plano,
   a primeira reprodução completa (ver js/hero-scroll.js) — assim o
   utilizador só vê o vídeo "acordar" quando o scroll o pedir, nunca a
   animar sozinho ao abrir a página. Troca instantânea (sem transition):
   um crossfade, mesmo entre o poster e o 1º frame do próprio vídeo, dava
   um "flash" visível (JPG vs. frame descodificado nunca são pixel a pixel
   idênticos), o que parecia uma transição indesejada logo ao abrir a página. */
.hero-video-poster {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.hero-video-poster.is-hidden {
  opacity: 0;
  pointer-events: none;
}

/* Imagem estática do último frame do vídeo, usada só em mobile (ver
   @media (max-width: 768px) mais abaixo) em vez do scroll-scrub — depois de
   muitas tentativas de corrigir o vídeo controlado por scroll em iOS/Android
   (ver histórico extenso em js/hero-scroll.js), a decisão foi não tentar
   mais: mostra-se logo o resultado final, sem efeito nenhum. Escondida por
   omissão (desktop continua com o vídeo). */
.hero-mobile-final {
  display: none;
}

.hero-mobile-final__img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.hero-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(16, 16, 16, 0.6) 0%, rgba(16, 16, 16, 0.35) 55%, rgba(16, 16, 16, 0.55) 100%);
}

/* ===== Conteúdo ===== */
.hero-content {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 1360px;
  margin: 0 auto;
  padding: 0 32px;
  text-align: left;
  color: var(--cinza1);
  /* Escondido durante o scroll da hero, para dar destaque só ao vídeo; só
     aparece nos últimos instantes do scroll (ver body.hero-scrolled, aplicada
     em js/hero-scroll.js), junto com o menu e a barra de pesquisa. */
  opacity: 0;
  transform: translateY(16px);
  pointer-events: none;
  transition: opacity 0.5s ease, transform 0.5s ease;
}

body.hero-scrolled .hero-content {
  opacity: 1;
  transform: none;
  pointer-events: auto;
}

.hero-title {
  max-width: 640px;
  font-weight: 700;
  line-height: 1.05;
  margin-bottom: 20px;
}

.hero-accent {
  color: var(--primaria5);
}

.hero-subtitle {
  max-width: 520px;
  color: var(--suporte2);
  margin-bottom: 32px;
  line-height: 1.5;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-start;
  gap: 14px;
}

/* ===== Variante centrada (usada na hero de Imóveis) ===== */
.hero-pinned--center {
  align-items: center;
  justify-content: center;
  padding-bottom: 0;
}

.hero-content--center {
  text-align: center;
}

.hero-content--center .hero-title,
.hero-content--center .hero-subtitle {
  margin-left: auto;
  margin-right: auto;
}

.hero-content--center .hero-actions {
  justify-content: center;
}

.hero-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 13px 26px;
  border-radius: 999px;
  text-decoration: none;
  border: 1.5px solid transparent;
  transition: background-color 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}

.hero-btn--outline {
  border-color: var(--cinza1);
  color: var(--cinza1);
  background: transparent;
}

.hero-btn--outline:hover {
  background: rgba(255, 255, 255, 0.12);
}

.hero-btn--filled {
  background: var(--primaria5);
  color: var(--cinza1);
}

.hero-btn--filled:hover {
  background: var(--primaria6);
}

.hero-btn--light {
  background: var(--cinza1);
  color: var(--cinza11);
}

.hero-btn--light:hover {
  background: var(--suporte2);
}

/* ===== Texto da história (aparece a meio do scroll, sobre o vídeo) =====
   A opacidade e o transform são calculados frame a frame em js/hero-scroll.js,
   em função do progresso do scroll — tal como o próprio vídeo — por isso não
   há transitions aqui (fariam o texto "atrasar-se" em relação ao scroll). */
.hero-story {
  /* Escondido a pedido — a lógica de scroll em js/hero-scroll.js continua a
     correr (custo desprezável), mas o texto nunca chega a mostrar-se. */
  display: none;
}

.hero-story__container {
  width: 100%;
  max-width: 1360px;
  margin: 0 auto;
  padding: 0 32px;
}

.hero-story__text {
  display: inline-block;
  max-width: 640px;
  margin: 0;
  font-family: 'Montserrat', sans-serif;
  font-size: 46px;
  font-weight: 700;
  line-height: 1.3;
  color: var(--cinza1);
  text-shadow: 0 4px 28px rgba(0, 0, 0, 0.5);
  opacity: 0;
  transform-origin: left center;
  will-change: opacity, transform;
}

@media (max-width: 768px) {
  .hero-story__text {
    font-size: 30px;
  }
}

/* ===== Indicador de scroll ===== */
.hero-scroll-indicator {
  position: absolute;
  z-index: 1;
  left: 50%;
  bottom: 44px;
  display: flex;
  flex-direction: column;
  align-items: center;
  color: var(--primaria5);
  transform: translateX(-50%);
  opacity: 1;
  transition: opacity 0.4s ease, transform 0.4s ease;
}

/* Aplicada via JS (hero-scroll.js) assim que o utilizador começa a fazer scroll. */
.hero-scroll-indicator.is-hidden {
  opacity: 0;
  transform: translateX(-50%) translateY(12px);
}

.hero-scroll-indicator__chevron {
  width: 30px;
  height: 18px;
  margin-top: -8px;
  opacity: 0;
  filter: drop-shadow(0 0 8px rgba(204, 60, 43, 0.55));
  animation: hero-scroll-chevron 1.8s ease-in-out infinite;
}

.hero-scroll-indicator__chevron:first-child {
  margin-top: 0;
}

.hero-scroll-indicator__chevron:nth-child(1) { animation-delay: 0s; }
.hero-scroll-indicator__chevron:nth-child(2) { animation-delay: 0.25s; }
.hero-scroll-indicator__chevron:nth-child(3) { animation-delay: 0.5s; }

@keyframes hero-scroll-chevron {
  0% {
    opacity: 0;
    transform: translateY(-10px);
  }
  50% {
    opacity: 1;
  }
  100% {
    opacity: 0;
    transform: translateY(12px);
  }
}

@media (prefers-reduced-motion: reduce) {
  .hero-scroll-indicator__chevron {
    animation: none;
    opacity: 1;
  }
}

@media (max-width: 768px) {
  /* Sem scroll-scrub em mobile (ver js/hero-scroll.js e .hero-mobile-final
     acima) — a hero deixa de precisar do "runway" alto nem do pin, passa a
     ser uma secção normal com a imagem final como fundo estático. */
  .hero-scroll {
    height: auto;
  }

  .hero-pinned {
    position: relative;
    height: 100vh;
  }

  .hero-video,
  .hero-video-poster,
  .hero-scroll-indicator {
    display: none;
  }

  .hero-mobile-final {
    display: block;
  }

  /* Título/subtítulo/botões e o cabeçalho (ver css/header.css) ficam
     visíveis de imediato — sem vídeo a "chegar ao fim", não há scroll
     nenhum que dispare body.hero-scrolled. */
  .hero-content {
    opacity: 1;
    transform: none;
    pointer-events: auto;
  }

  .hero-title {
    font-size: 40px;
  }

  .hero-subtitle {
    font-size: 16px;
  }
}

@media (max-width: 480px) {
  .hero-title {
    font-size: 30px;
  }

  .hero-actions {
    flex-direction: column;
    width: 100%;
  }

  .hero-btn {
    width: 100%;
  }
}
