/* Fade-in animation for homepage gallery items */
.gallery-home-item {
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 1s cubic-bezier(.4,1,.6,1), transform 0.5s cubic-bezier(.4,1,.6,1);
}
.gallery-home-item.visible {
  opacity: 1;
  transform: none;
}
#gallery-home {
  transition: opacity 0.25s;
}
/* Reset MkDocs content layout for gallery page */
.md-content {
  display: flex !important;
  flex-direction: column !important;
  align-items: center !important;
  width: 100% !important;
}

.md-content__inner {
  display: block !important;
  width: 100% !important;
  max-width: 61rem !important;
  margin-top: 1rem !important;
  padding: 0 1rem !important;
  text-align: left !important;
}

/* Gallery Section Layout */
.gallery-home-wrapper {
  width: 100%;
  max-width: 61rem;
  margin: 0 auto;
  padding: 1rem 1rem;
  padding-bottom: 2rem;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  clear: both;
}

/* Layout: Responsive grid, fixed-size squares */
/* Responsive grid: auto-fit with minmax ensures square items shrink but never collapse */
#gallery-home {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(clamp(180px, 20vw, 260px), 1fr));
  gap: 1.5rem;
  width: 100%;
  padding: 0;
  margin: 0 auto;
  /* Limit to max 5 columns on wide screens */
  max-width: calc(5 * 260px + 4 * 1.5rem); /* 5 columns + 4 gaps */
}

/* Gallery item: fixed square, centered */

/* Gallery item: stack image and title, image always square */
.gallery-home-item {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  text-align: center;
  background: none;
  margin: 0;
  padding: 0;
}

/* Image wrapper always square, independent of title */
.gallery-home-image-wrapper {
  width: 100%;
  aspect-ratio: 1 / 1;
  border-radius: 16px;
  overflow: hidden;
  background: #f8f8f8;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  min-height: 0;
  min-width: 0;
}

.gallery-home-image-wrapper img {
  width: 100%;
  height: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  object-position: center;
  border-radius: 16px;
  transition: transform 0.35s cubic-bezier(.4,1,.6,1);
  display: block;
  background: none;
  min-width: 0;
  min-height: 0;
  max-width: 100%;
  max-height: 100%;
}
/* Image container: perfect square, rounded corners */
.gallery-home-image-wrapper img {
  width: 100%;
  height: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  object-position: center;
  border-radius: 16px;
  transition: transform 0.35s cubic-bezier(.4,1,.6,1);
  display: block;
  background: none;
  min-width: 0;
  min-height: 0;
  max-width: 100%;
  max-height: 100%;
}

/* Hover effect: only image zooms */
.gallery-home-image-wrapper:hover img,
.gallery-home-image-wrapper:focus-within img {
  transform: scale(1.07);
}

/* Title: minimal, clear, proportional */
.gallery-home-title {
  margin-top: 0.85rem;
  font-size: 1.08rem;
  font-weight: 500;
  text-align: center;
  font-family: 'Lato', 'Segoe UI', Arial, sans-serif;
  line-height: 1.3;
  letter-spacing: 0.01em;
  min-height: 1.3em;
  transition: color 0.18s cubic-bezier(.4,1,.6,1);
}

/* Cambia el color del título al hacer hover sobre la imagen */
.gallery-home-item:hover .gallery-home-title,
.gallery-home-image-wrapper:hover + .gallery-home-title {
  color: var(--md-accent-fg-color, #00bcd4);
}

/* Responsive: grid auto-fits, but squares stay fixed size */
@media (max-width: 768px) {
  .gallery-home-wrapper {
    padding: 1rem;
  }
  #gallery-home {
    gap: 1rem;
  }
  .gallery-home-title {
    font-size: 1rem;
  }
}