/**
 * Rejilla y cards de /obras: estilos globales.
 * El listado vive en el island React (GalleryGrid) y no recibe el data-astro del scope
 * de la página, así que el CSS scoped de Astro no les aplica.
 */

html:has(.gallery-page-wrapper),
body:has(.gallery-page-wrapper) {
  /* min-height (no height) para que la página crezca y contenga el footer
     completo cuando hay pocas obras; height:100% lo recortaba. */
  min-height: 100%;
  overflow-x: hidden;
}

#gallery-main {
  --gallery-card-type-scale: 1;
}

@media (max-width: 1119px) {
  #gallery-main {
    --gallery-card-type-scale: 0.78;
  }
}

@media (min-width: 1120px) {
  /* 4 por renglon es el default (base, sin clase) */
  #gallery-main {
    --gallery-card-type-scale: 0.75;
  }
  #gallery-main.gallery--cols-3 {
    --gallery-card-type-scale: 1;
  }
  #gallery-main.gallery--cols-6 {
    --gallery-card-type-scale: 0.68;
  }
}

#gallery-main .gallery__grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.75rem;
  align-items: stretch;
  align-content: start;
  flex: 1 0 auto;
  padding-bottom: 0;
  margin-bottom: 0;
  min-height: unset;
}

/* Sentinel al final del grid (IO + rootMargin amplio); sin altura extra bajo las cards */
#gallery-main .gallery__load-sentinel--tail {
  grid-column: 1 / -1;
  width: 0;
  height: 0;
  min-height: 0;
  padding: 0;
  margin: 0;
  overflow: hidden;
  align-self: stretch;
  pointer-events: none;
  line-height: 0;
}

@media (max-width: 1119px) {
  #gallery-main.gallery--mobile-cols-1 .gallery__grid {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (min-width: 640px) {
  #gallery-main .gallery__grid {
    gap: 1.25rem;
  }
}

@media (min-width: 1120px) {
  /* Default: 4 por renglon (base, sin clase).
     Mas aire entre obras, sobre todo vertical (row-gap). */
  #gallery-main .gallery__grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    column-gap: 1.75rem;
    row-gap: 3rem;
  }

  #gallery-main.gallery--cols-3 .gallery__grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    column-gap: 2rem;
    row-gap: 3.25rem;
  }

  /* 6 por renglon: pensado para pantallas grandes */
  #gallery-main.gallery--cols-6 .gallery__grid {
    grid-template-columns: repeat(6, minmax(0, 1fr));
    column-gap: 1.25rem;
    row-gap: 2.25rem;
  }
}

#gallery-main .gallery__card-link {
  display: flex;
  flex-direction: column;
  min-height: 0;
  color: inherit;
  text-decoration: none;
}

#gallery-main .gallery__card {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  opacity: 0;
  transform: translateY(24px);
  animation: galleryCardAppear 0.5s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

#gallery-main .gallery__card--visible {
  animation-delay: calc(var(--stagger, 0) * 40ms);
}

@keyframes galleryCardAppear {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

#gallery-main .gallery__card-frame {
  position: relative;
  overflow: hidden;
  aspect-ratio: 1 / 1;
  width: 100%;
  background: var(--cantera-deep);
  flex-shrink: 0;
}

#gallery-main .gallery__card-image {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  transition: transform 0.6s cubic-bezier(0.22, 1, 0.36, 1);
}

#gallery-main .gallery__card-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  min-height: calc(120px * var(--gallery-card-type-scale, 1));
  font-size: calc(0.7rem * var(--gallery-card-type-scale, 1));
  color: rgba(17, 17, 17, 0.35);
}

@media (hover: hover) {
  #gallery-main .gallery__card:hover .gallery__card-image {
    transform: scale(1.03);
  }
}

#gallery-main .gallery__card-caption {
  flex: 1;
  padding: calc(1rem * var(--gallery-card-type-scale, 1)) 0 0;
  display: flex;
  flex-direction: column;
  gap: 0;
  min-height: 0;
}

#gallery-main .gallery__card-artist {
  font-family: 'Inter', var(--font-sans);
  font-size: calc(0.9rem * var(--gallery-card-type-scale, 1));
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: rgba(17, 17, 17, 0.55);
  margin-bottom: calc(0.25rem * var(--gallery-card-type-scale, 1));
}

#gallery-main .gallery__card-title {
  font-family: 'Google Sans', sans-serif;
  font-size: calc(1.35rem * var(--gallery-card-type-scale, 1));
  font-weight: 600;
  color: #111;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin: calc(0.25rem * var(--gallery-card-type-scale, 1)) 0;
  line-height: 1.2;
}

#gallery-main .gallery__card-details {
  font-family: 'Inter', var(--font-sans);
  font-size: calc(1.04rem * var(--gallery-card-type-scale, 1));
  line-height: 1.45;
  color: rgba(17, 17, 17, 0.62);
  display: flex;
  flex-direction: column;
  gap: calc(0.16rem * var(--gallery-card-type-scale, 1));
  margin-top: calc(0.25rem * var(--gallery-card-type-scale, 1));
}

#gallery-main .gallery__card-detail-line {
  display: block;
  font-family: var(--font-sans);
}

#gallery-main .gallery__card-price {
  font-family: 'Inter', var(--font-sans);
  font-size: calc(1.08rem * var(--gallery-card-type-scale, 1));
  font-weight: 500;
  color: #e07b39;
}

/* ─── /obras: sin min-height en el wrapper (evita hueco entre última card y footer al hacer scroll) ─── */
.gallery-page-wrapper {
  display: flex;
  flex-direction: column;
}

.gallery-page-wrapper #gallery-main.gallery {
  flex: 0 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.gallery-page-wrapper #gallery-main .gallery__layout {
  flex: 0 1 auto;
  min-height: 0;
}

.gallery-page-wrapper #gallery-main .gallery__main {
  flex: 0 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.gallery-page-wrapper .gallery-grid-host {
  display: flex;
  flex-direction: column;
  flex: 0 1 auto;
  min-height: 0;
  width: 100%;
}

.gallery-page-wrapper footer.footer {
  flex-shrink: 0;
  margin-top: 0;
  /* Conserva el padding superior propio del footer para que no se vea recortado. */
}

.footer .gallery-footer-load-root:empty {
  display: none;
}

.footer .gallery-footer-load-root:not(:empty) {
  width: 100%;
  border-top: 1px solid rgba(45, 11, 61, 0.1);
  background: var(--cantera, #ffffff);
}

.gallery-footer-loading {
  width: 100%;
  color: rgba(45, 11, 61, 0.65);
  font-family: var(--font-sans, 'Inter', system-ui, sans-serif);
}

.gallery-footer-loading .loading-indicator {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 16px 0;
  width: 100%;
  flex-wrap: wrap;
}

.gallery-footer-loading .loading-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  animation: gallery-footer-load-pulse 1.2s ease-in-out infinite;
}

.gallery-footer-loading .loading-dot:nth-of-type(2) {
  animation-delay: 0.2s;
}

.gallery-footer-loading .loading-dot:nth-of-type(3) {
  animation-delay: 0.4s;
}

.gallery-footer-loading__text {
  margin: 0;
  text-align: center;
  font-size: 0.85rem;
  letter-spacing: 0.06em;
}

@keyframes gallery-footer-load-pulse {
  0%,
  100% {
    opacity: 0.3;
    transform: scale(0.8);
  }

  50% {
    opacity: 1;
    transform: scale(1);
  }
}
