/* ==========================================================
 * gallery.css — galeria de obras (portfólio), seção "Obras reais"
 * da home, foto da página rural e mapa sob demanda.
 * Carregado fora do caminho crítico (preload + media="print").
 * Usa os tokens de tokens.css. Mobile-first, breakpoints 768/1024.
 * ========================================================== */

/* ---------- elementos comuns ---------- */
.g-eyebrow {
  display: inline-block;
  margin-bottom: 12px;
  color: var(--gold);
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 3px;
  text-transform: uppercase;
}

.g-title {
  font-size: clamp(1.8rem, 3.5vw, 2.5rem);
  line-height: 1.2;
  margin-bottom: 16px;
}

.g-lead {
  max-width: 62ch;
  line-height: 1.7;
}

/* ---------- galeria do portfólio (fundo escuro) ---------- */
.gallery-section {
  padding-block: var(--section-py-mob);
}

.gallery-section--dark {
  background: var(--bg-dark);
  color: var(--text-light);
}

.gallery-section--dark .g-title {
  color: var(--text-light);
}

.gallery-section--dark .g-lead {
  color: var(--text-muted-light);
}

.gallery-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 28px 0 24px;
}

.gallery-filter {
  min-height: 44px;
  padding: 10px 18px;
  border: 1px solid var(--bg-border-dark);
  border-radius: 999px;
  background: transparent;
  color: var(--text-light);
  font-family: var(--font-corpo);
  font-size: 0.92rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}

.gallery-filter:hover {
  border-color: var(--gold);
}

.gallery-filter[aria-pressed="true"] {
  background: var(--gold);
  border-color: var(--gold);
  color: var(--bg-dark);
}

.gallery-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.gallery-item[hidden] {
  display: none;
}

.gallery-link {
  position: relative;
  display: block;
  aspect-ratio: 4 / 5;
  overflow: hidden;
  border: 1px solid var(--bg-border-dark);
  border-radius: var(--radius-img);
  background: var(--bg-card-dark);
}

.gallery-link img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.35s ease;
}

.gallery-link:hover img,
.gallery-link:focus-visible img {
  transform: scale(1.04);
}

/* ---------- lightbox (<dialog>) ---------- */
.lightbox {
  margin: auto; /* o reset global zera a margem automática do <dialog> */
  width: min(92vw, 880px);
  max-height: 94vh;
  padding: 0;
  border: 1px solid var(--bg-border-dark);
  border-radius: var(--radius-card);
  background: var(--bg-dark);
  color: var(--text-light);
  overflow: hidden;
}

.lightbox::backdrop {
  background: rgba(10, 10, 10, 0.82);
}

.lightbox__fig {
  margin: 0;
  display: grid;
  justify-items: center;
}

.lightbox__img {
  display: block;
  width: auto;
  max-width: 100%;
  max-height: 78vh;
  object-fit: contain;
}

.lightbox__cap {
  padding: 14px 64px 16px;
  color: var(--text-muted-light);
  font-size: 0.9rem;
  line-height: 1.5;
  text-align: center;
}

.lightbox__close,
.lightbox__nav {
  position: absolute;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 50%;
  background: rgba(42, 42, 41, 0.85);
  color: var(--text-light);
  font-size: 1.6rem;
  line-height: 1;
  cursor: pointer;
}

.lightbox__close {
  top: 10px;
  right: 10px;
}

.lightbox__nav {
  top: 50%;
  transform: translateY(-50%);
}

.lightbox__prev {
  left: 10px;
}

.lightbox__next {
  right: 10px;
}

.lightbox__close:hover,
.lightbox__nav:hover {
  background: var(--gold);
  color: var(--bg-dark);
}

/* ---------- imagem nos cards "Atendemos todos os perfis" (home) ---------- */
.home-clients .home-card {
  overflow: hidden;
}

.home-card__media {
  margin: -32px -32px 24px;
  aspect-ratio: 4 / 3;
  overflow: hidden;
  background: var(--bg-border);
}

.home-card__media img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.35s ease;
}

.home-card:hover .home-card__media img {
  transform: scale(1.04);
}

/* ---------- imagem nos cards de serviço (página /servicos/) ---------- */
.services-grid .card {
  overflow: hidden;
}

.card__media {
  margin: -24px -24px 20px; /* o .card tem padding de 24px */
  aspect-ratio: 4 / 3;
  overflow: hidden;
  background: var(--bg-border);
}

.card__media img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.35s ease;
}

.services-grid .card:hover .card__media img {
  transform: scale(1.04);
}

/* ---------- página Sobre: respiro entre título e texto ---------- */
.about-page .container > h2,
.about-page .about-grid h2 {
  margin-bottom: 16px;
}

.about-page .container > p + p,
.about-page .about-grid p + p {
  margin-top: 12px;
}

/* ---------- seção "Obras reais" da home ---------- */
.home-obras {
  background: var(--bg-card-light);
  color: var(--text-dark);
  border-top: 1px solid var(--bg-border);
}

.home-obras .g-lead {
  color: var(--text-muted-dark);
}

.home-obras .gallery-grid {
  margin-top: 40px;
  gap: 12px;
}

.home-obras .gallery-link {
  border-color: var(--bg-border);
  background: var(--bg-border);
}

/* mobile e tablet mostram 6 fotos (fecham linhas de 2 e 3); desktop mostra as 8 */
.home-obras .gallery-item:nth-child(n + 7) {
  display: none;
}

.home-obras__cta {
  margin-top: 36px;
  text-align: center;
}

/* botões em fundo claro: contorno dourado e texto escuro (contraste adequado).
 * O CSS embutido da home redefine .c-btn com border:0, então reforçamos aqui. */
.home-obras .btn-outline,
.home-map .btn-outline,
.contact-where .btn-outline {
  border: 2px solid var(--gold);
  background: transparent;
  color: var(--text-dark);
}

.home-obras .btn-outline:hover,
.home-map .btn-outline:hover,
.contact-where .btn-outline:hover {
  background: var(--gold);
  color: var(--bg-dark);
}

/* ---------- página de Contato ---------- */
.contact-channels {
  display: grid;
  gap: 16px;
  margin-top: 24px;
}

.contact-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
  padding: 24px;
  border: 1px solid var(--bg-border);
  border-radius: var(--radius-card);
  background: var(--bg-card-light);
  box-shadow: 0 2px 20px rgba(42, 42, 41, 0.08);
}

.contact-card__label {
  color: var(--gold-soft);
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 2px;
  text-transform: uppercase;
}

.contact-card__number {
  font-family: var(--font-titulo);
  font-size: 1.5rem;
  font-weight: 700;
}

.contact-card__text {
  margin-bottom: 8px;
  color: var(--text-muted-dark);
  line-height: 1.6;
}

.contact-card .c-btn {
  margin-top: auto;
}

.contact-card__list {
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
  line-height: 1.5;
  overflow-wrap: anywhere;
}

.contact-card__list a {
  color: var(--text-dark);
  font-weight: 600;
  text-decoration: underline;
  text-decoration-color: var(--gold);
  text-underline-offset: 3px;
}

.contact-main {
  display: grid;
  gap: 24px;
  margin-top: 40px;
}

.form-card__title {
  margin-bottom: 8px;
  font-size: clamp(1.4rem, 2.5vw, 1.8rem);
  line-height: 1.2;
}

.form-card__lead {
  margin-bottom: 16px;
  color: var(--text-muted-dark);
  line-height: 1.6;
}

.form-status {
  margin-top: 14px;
  color: var(--text-dark);
  line-height: 1.5;
}

.form-status:empty {
  display: none;
}

.form-status a {
  font-weight: 700;
  text-decoration: underline;
  text-decoration-color: var(--gold);
  text-underline-offset: 3px;
}

.contact-where .map-embed {
  min-height: 300px;
}

@media (min-width: 1024px) {
  /* alinha o título com o do formulário, que tem 24px de padding no cartão */
  .contact-where {
    padding-top: 24px;
  }
}

/* ---------- bloco "Atendimento direto" (foto + texto + números) ---------- */
.direct {
  display: grid;
  gap: 28px;
  align-items: center;
}

.direct__photo img {
  display: block;
  width: min(100%, 240px);
  height: auto; /* sem isto o height="1024" do HTML vale no celular e a foto fica gigante */
  margin-inline: auto; /* centralizada quando empilhada no celular */
  aspect-ratio: 4 / 5;
  object-fit: cover;
  object-position: center 30%;
  border-radius: var(--radius-card);
}

.direct .g-title {
  color: var(--text-light);
}

.direct .g-lead {
  color: var(--text-muted-light);
}

.direct__brands {
  margin-top: 16px;
  color: var(--text-muted-light);
  font-size: 0.9rem;
}

.direct-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin: 28px 0 0;
  padding: 0;
  list-style: none;
}

.direct-stats li {
  padding: 16px 10px;
  border: 1px solid var(--bg-border-dark);
  border-radius: var(--radius-img);
  background: var(--bg-card-dark);
  text-align: center;
}

.direct-stats strong {
  display: block;
  color: var(--gold);
  font-family: var(--font-titulo);
  font-size: clamp(1.4rem, 4vw, 2rem);
}

.direct-stats span {
  color: var(--text-muted-light);
  font-size: 0.85rem;
}

/* ---------- foto da página rural ---------- */
.rural-photo {
  max-width: 820px;
  margin: 0 auto;
}

.rural-photo img {
  display: block;
  width: 100%;
  height: auto;
  border-radius: var(--radius-card);
}

.rural-photo figcaption {
  margin-top: 12px;
  color: var(--text-muted-dark);
  font-size: 0.92rem;
  text-align: center;
}

/* ---------- mapa sob demanda (home) ---------- */
.home-map {
  background: var(--bg-light);
  color: var(--text-dark);
}

.home-map__grid {
  display: grid;
  gap: 32px;
  margin-top: 40px;
}

.home-map__list {
  display: grid;
  gap: 18px;
  margin: 0;
}

.home-map__list dt {
  color: var(--gold-soft);
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 2px;
  text-transform: uppercase;
}

.home-map__list dd {
  margin: 4px 0 0;
  line-height: 1.6;
}

.home-map__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 24px;
}

.map-embed {
  position: relative;
  min-height: 340px;
  overflow: hidden;
  border: 1px solid var(--bg-border);
  border-radius: var(--radius-card);
  background: var(--bg-dark);
}

.map-embed iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
}

.map-facade {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 24px;
  border: 0;
  background:
    linear-gradient(rgba(220, 165, 74, 0.07) 1px, transparent 1px) 0 0 / 36px 36px,
    linear-gradient(90deg, rgba(220, 165, 74, 0.07) 1px, transparent 1px) 0 0 / 36px 36px,
    var(--bg-dark);
  color: var(--text-light);
  font-family: var(--font-corpo);
  text-align: center;
  cursor: pointer;
}

.map-facade svg {
  width: 44px;
  height: 44px;
  color: var(--gold);
}

.map-facade__cta {
  display: inline-block;
  padding: 12px 22px;
  border-radius: var(--radius-btn);
  background: var(--gold);
  color: var(--bg-dark);
  font-weight: 700;
}

.map-facade:hover .map-facade__cta,
.map-facade:focus-visible .map-facade__cta {
  background: var(--gold-hover);
}

.map-facade__note {
  max-width: 34ch;
  color: var(--text-muted-light);
  font-size: 0.8rem;
  line-height: 1.5;
}

/* ---------- breakpoints ---------- */
@media (min-width: 768px) {
  .contact-channels {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .direct {
    grid-template-columns: minmax(0, 3fr) minmax(0, 7fr);
    gap: 40px;
  }

  .direct__photo img {
    width: 100%;
    max-width: 300px;
    margin-inline: 0; /* no computador, fica à esquerda, ao lado do texto */
  }

  .gallery-section {
    padding-block: var(--section-py);
  }

  .gallery-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 16px;
  }

  .home-obras .gallery-grid {
    gap: 16px;
  }

  .map-embed {
    min-height: 420px;
  }
}

@media (min-width: 1024px) {
  .contact-main {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    align-items: start;
  }

  .gallery-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .home-obras .gallery-item:nth-child(n + 7) {
    display: block;
  }

  .home-map__grid {
    grid-template-columns: minmax(0, 5fr) minmax(0, 7fr);
    align-items: stretch;
    gap: 48px;
  }

  .map-embed {
    min-height: 460px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .gallery-link img,
  .gallery-filter {
    transition: none;
  }

  .gallery-link:hover img,
  .gallery-link:focus-visible img,
  .home-card:hover .home-card__media img,
  .services-grid .card:hover .card__media img {
    transform: none;
  }
}
