/* Reset básico */
* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Segoe UI', Arial, sans-serif;
  background: #f8f8fa;
  color: #222;
  min-height: 100vh;
}

main {
  max-width: 1200px;
  margin: 0 auto;
  padding: 24px;
}

h1 {
  text-align: center;
  margin-bottom: 24px;
  font-size: 2rem;
  color: #3a3a55;
}

/* Galería con CSS Grid */
.gallery {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 16px;
    max-width: 1200px;
    margin: 0 auto;
    padding: 16px;
  } 

.gallery-item {
  position: relative;
  cursor: pointer;
  border-radius: 8px;
  overflow: hidden;
  background: #fff;
  box-shadow: 0 2px 8px rgba(60,60,80,0.07);
  transition: box-shadow 0.2s;
}

.gallery-item:focus-within,
.gallery-item:hover {
  box-shadow: 0 4px 16px rgba(60,60,80,0.18);
}

.gallery-item img {
  width: 100%;
  height: 160px;
  object-fit: cover;
  display: block;
  transition: transform 0.2s;
}

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

.gallery-item figcaption {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  background: rgba(30,30,40,0.6);
  color: #fff;
  font-size: 0.95rem;
  padding: 6px 10px;
  text-align: left;
  pointer-events: none;
}

/* Lightbox */
.lightbox {
  display: none;
  position: fixed;
  z-index: 1000;
  inset: 0;
  background: rgba(20,20,30,0.92);
  justify-content: center;
  align-items: center;
  flex-direction: column;
  transition: opacity 0.25s;
}

.lightbox.open {
  display: flex;
  animation: fadeIn 0.3s;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.lightbox img {
  max-width: 90vw;
  max-height: 80vh;
  border-radius: 10px;
  box-shadow: 0 0 24px #000a;
  background: #fff;
  margin: 0 48px;
  transition: box-shadow 0.2s;
}

.lightbox .caption {
  color: #fff;
  margin-top: 12px;
  font-size: 1.1rem;
  text-align: center;
  min-height: 1.5em;
}

.lightbox .counter {
  color: #bbb;
  font-size: 0.95rem;
  margin-top: 4px;
  text-align: center;
}

.lightbox button {
  position: absolute;
  background: rgba(40,40,60,0.7);
  border: none;
  color: #fff;
  font-size: 2.2rem;
  padding: 10px 18px;
  border-radius: 50%;
  cursor: pointer;
  z-index: 2;
  transition: background 0.2s, transform 0.2s;
  outline: none;
}

.lightbox button:focus {
  background: #3a3a55;
  outline: 2px solid #fff;
}

.lightbox .close {
  top: 24px; right: 36px;
  font-size: 2.5rem;
}

.lightbox .prev {
  left: 24px; top: 50%;
  transform: translateY(-50%);
}

.lightbox .next {
  right: 24px; top: 50%;
  transform: translateY(-50%);
}

/* Responsividad */
@media (max-width: 900px) {
  .gallery { grid-template-columns: repeat(3, 1fr); }
  .lightbox img { max-width: 98vw; }
}
@media (max-width: 600px) {
  .gallery { grid-template-columns: 1fr; }
  .gallery-item img { height: 120px; }
  .lightbox .close { top: 12px; right: 12px; }
  .lightbox .prev, .lightbox .next { font-size: 2rem; }
}

grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
@media (min-width: 900px) {
  .gallery {
    grid-template-columns: repeat(5, 1fr);
  }
}
