/* Reset e base */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: "Inter", sans-serif;
  background-color: #f9fbfc;
  color: #222;
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

main {
  flex: 1;
  max-width: 1200px;
  margin: 2rem auto 4rem;
  padding: 0 1rem;
  width: 100%;
}

h1 {
  margin-bottom: 1.5rem;
  color: #005b99;
  font-weight: 700;
  text-align: center;
  letter-spacing: 1px;
}

/* Grid da galeria */
.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 24px;
}

/* Card da imagem */
.gallery-item {
  position: relative;
  overflow: hidden;
  border-radius: 16px;
  background: #fff;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.08);
  cursor: pointer;
  transition: transform 0.35s ease, box-shadow 0.35s ease;
}

.gallery-item:hover {
  transform: translateY(-6px) scale(1.03);
  box-shadow: 0 12px 36px rgba(0, 91, 153, 0.25);
  z-index: 10;
}

/* Imagem responsiva */
.gallery-item img {
  width: 100%;
  height: 200px;
  object-fit: cover;
  display: block;
  border-radius: 16px;
  transition: transform 0.5s ease;
}

.gallery-item:hover img {
  transform: scale(1.08) rotate(0.5deg);
}

/* Overlay suave */
.gallery-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(
    180deg,
    rgba(0, 91, 153, 0.0) 30%,
    rgba(0, 91, 153, 0.85) 100%
  );
  opacity: 0;
  transition: opacity 0.35s ease;
  border-radius: 16px;
}

.gallery-item:hover .gallery-overlay {
  opacity: 1;
}

/* Legenda sobre imagem */
.gallery-caption {
  position: absolute;
  bottom: 1rem;
  left: 1rem;
  right: 1rem;
  color: #fff;
  font-weight: 600;
  font-size: 1.05rem;
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 0.35s ease, transform 0.35s ease;
  text-shadow: 0 2px 6px rgba(0,0,0,0.3);
}

.gallery-item:hover .gallery-caption {
  opacity: 1;
  transform: translateY(0);
}

/* Modal */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.9);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.4s ease;
  z-index: 9999;
}

.modal.open {
  opacity: 1;
  pointer-events: all;
}

.modal-content {
  position: relative;
  max-width: 90%;
  max-height: 90%;
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 0 40px rgba(0, 91, 153, 0.6);
  animation: zoomIn 0.45s ease;
}

@keyframes zoomIn {
  from { transform: scale(0.85); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

.modal-content img {
  width: 100%;
  height: auto;
  display: block;
  border-radius: 16px;
}

/* Botão fechar */
.modal-close {
  position: absolute;
  top: 14px;
  right: 14px;
  background: #005b99;
  border: none;
  color: #fff;
  font-size: 1.8rem;
  cursor: pointer;
  padding: 0.3rem 0.8rem;
  border-radius: 8px;
  transition: background 0.3s ease, transform 0.2s ease;
}

.modal-close:hover {
  background: #003f66;
  transform: scale(1.1);
}

/* === RESPONSIVIDADE === */

/* Até 600px */
@media (max-width: 600px) {
  .gallery-item img { height: 140px; }
  .modal-content { max-width: 95%; max-height: 85%; }
  .modal-close { font-size: 1.4rem; top: 10px; right: 10px; }
}

/* Até 540px — força 2 colunas */
@media (max-width: 540px) {
  main { padding: 0 0.5rem; }

  .gallery-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 12px;
  }

  .gallery-item { grid-column: auto !important; }
  .gallery-item img { height: 120px; }
}

/* Até 480px (mantém 2 colunas) */
@media (max-width: 480px) {
  h1 { font-size: 1.6rem; }

  .gallery-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 12px;
  }

  .gallery-item { grid-column: auto !important; }
  .gallery-caption { font-size: 0.9rem; padding: 0.6rem 0.8rem; }
  .modal-content { max-width: 96%; max-height: 80%; }
  .modal-close { font-size: 1.2rem; padding: 0.2rem 0.5rem; }
}

/* Até 360px (2 colunas + gaps menores) */
@media (max-width: 360px) {
  h1 { font-size: 1.4rem; }

  .gallery-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 8px;
  }

  .gallery-item { grid-column: auto !important; }
  .gallery-item img { height: 100px; }
  .gallery-caption { font-size: 0.8rem; padding: 0.5rem 0.6rem; }
  .modal-content { max-width: 98%; max-height: 75%; }
  .modal-close { font-size: 1rem; top: 8px; right: 8px; }
}