/* Container geral */
.gallery-3d-swiper {
  --slide-w: clamp(280px, 72vw, 1080px);
  --ratio: 16/9;
  position: relative;
}

/* Swiper core size */
#gallery3d {
  padding: 24px 54px; /* espaço p/ setas */
}

/* Cada slide tem largura fixa (para slidesPerView:'auto') */
#gallery3d .swiper-slide {
  width: var(--slide-w);
  display: flex;
  justify-content: center;
}

/* Cartão (imagem + legenda) */
.card-3d {
  position: relative;
  aspect-ratio: var(--ratio);
  border-radius: 16px;
  overflow: hidden;
  box-shadow: var(--shadow);
  background: var(--card);
}

.card-3d > img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: var(--card-2);
  backface-visibility: hidden;
  transform: translateZ(0);
}

.card-3d > figcaption {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  padding: 10px 14px;
  font: 500 14px/1.2 system-ui, -apple-system, "Segoe UI", Roboto, Arial;
  color: var(--brand-2);
  user-select: none;
  text-align: center;
}

/* Navegação */
.nav3d {
  position: absolute;
  top: 50%;
  translate: 0 -50%;
  z-index: 5;
  width: 44px; height: 44px;
  border: 0; border-radius: 999px;
  background: color-mix(in srgb, var(--fg) 12%, transparent);
  color: var(--fg);
  font-size: 26px;
  display: grid; place-items: center;
  cursor: pointer;
  backdrop-filter: blur(6px);
  transition: background .2s ease, transform .15s ease;
}
.nav3d:hover { background: color-mix(in srgb, var(--fg) 20%, transparent); }
.nav3d:active { transform: scale(.96); }
.nav3d.prev { left: 8px; }
.nav3d.next { right: 8px; }

/* Paginação */
.dots3d { margin-top: 10px; }
.dots3d .swiper-pagination-bullet {
  background: var(--muted);
  opacity: .7;
}
.dots3d .swiper-pagination-bullet-active {
  background: var(--brand-1);
  opacity: 1;
  width: 22px;
  border-radius: 999px;
}

/* Acessibilidade "screen reader only" */
.sr-only {
  position: absolute!important;
  width:1px; height:1px;
  padding:0; margin:-1px;
  overflow:hidden; clip:rect(0,0,0,0);
  white-space:nowrap; border:0;
}

/* Preferência de menos movimento: desliga 3D e usa slide comum */
@media (prefers-reduced-motion: reduce) {
  #gallery3d { padding: 0 0 14px; }
}

/* Modal */
.img-modal {
  display: none; 
  position: fixed;
  z-index: 9999;
  padding: 20px;
  left: 0; top: 0;
  width: 100%; height: 100%;
  background: rgba(0,0,0,.9);
  text-align: center;
  align-content: center;
}

.img-modal-content {
  max-width: 90%;
  max-height: 80%;
  margin-top: 4%;
  border-radius: 8px;
  justify-self: anchor-center;
}

.img-modal-close {
  position: absolute;
  top: 20px; right: 30px;
  color: #fff;
  font-size: 40px;
  font-weight: bold;
  cursor: pointer;
}

#imgModalCaption {
  margin-top: 10px;
  color: #ccc;
  font-size: 16px;
}

/* --- Patches Safari/WebKit para o coverflow --- */
.gallery-3d-swiper {
  perspective: 1000px;
  -webkit-perspective: 1000px; /* Safari */
}

/* Deixa o 3D "sair" do container sem ser cortado no Safari */
#gallery3d { overflow: visible; }

/* Garante que o wrapper mantenha o contexto 3D */
#gallery3d .swiper-wrapper {
  transform-style: preserve-3d;
  -webkit-transform-style: preserve-3d;
  display: flex; /* evita sobrescrita acidental */
}

/* Evita flicker/z-fighting nos elementos transformados */
#gallery3d,
#gallery3d .swiper,
#gallery3d .swiper-wrapper,
#gallery3d .swiper-slide,
.card-3d,
.card-3d > img {
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  transform: translateZ(0);
  will-change: transform;
}

/* Fallback para navegadores que não suportam 'translate' individual */
.nav3d { transform: translateY(-50%); } /* mantém seu 'translate: 0 -50%;' como está */
