/* =========================================================
   FEDEGÁN 5.0 · Galería de fotografías
   ========================================================= */

.page-galeria { background: var(--grad-bg), var(--purple-ink); background-attachment: fixed; min-height: 100vh; }
.gal { padding-top: clamp(130px, 14vw, 180px); min-height: 100vh; }

/* ---------- Estado / mensajes ---------- */
.gal__status { color: var(--text-soft); font-size: 0.95rem; margin-bottom: 1.4rem; }
.gal__status:empty { display: none; }
.gal__status--error {
  padding: 1rem 1.2rem;
  border: 1px solid rgba(255, 92, 198, 0.4);
  border-radius: var(--radius-sm);
  background: rgba(169, 0, 114, 0.14);
  color: #fff;
}

/* ---------- Cuadrícula ---------- */
.gal__grid {
  list-style: none;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: clamp(10px, 1.4vw, 18px);
}
.gal__item { position: relative; opacity: 0; transform: translateY(18px); animation: galIn 0.6s var(--ease) forwards; }
@keyframes galIn { to { opacity: 1; transform: none; } }

.gal__thumb {
  position: relative;
  display: block;
  width: 100%;
  aspect-ratio: 4 / 3;
  overflow: hidden;
  border-radius: var(--radius-sm);
  background: linear-gradient(110deg, rgba(42, 0, 72, 0.6) 30%, rgba(0, 211, 241, 0.12) 50%, rgba(42, 0, 72, 0.6) 70%) 0 0 / 300% 100%;
  animation: galShimmer 1.6s linear infinite;
  border: 1px solid var(--line-soft);
  cursor: zoom-in;
}
.gal__thumb.is-loaded { animation: none; background: var(--purple-deep); }
@keyframes galShimmer { to { background-position: -300% 0; } }

.gal__thumb img {
  width: 100%; height: 100%;
  object-fit: cover;
  opacity: 0;
  transform: scale(1.04);
  transition: opacity 0.5s, transform 0.7s var(--ease);
}
.gal__thumb.is-loaded img { opacity: 1; transform: none; }
.gal__thumb::after {
  content: "";
  position: absolute; inset: 0;
  background: linear-gradient(180deg, transparent 50%, rgba(23, 0, 43, 0.85) 100%);
  opacity: 0;
  transition: opacity 0.35s;
}
.gal__zoom {
  position: absolute; right: 12px; bottom: 12px; z-index: 1;
  width: 38px; height: 38px;
  display: grid; place-items: center;
  border-radius: 50%;
  background: var(--grad-cool);
  color: var(--purple-ink);
  font-size: 1.1rem; font-weight: 700;
  opacity: 0; transform: translateY(8px);
  transition: opacity 0.35s, transform 0.35s var(--ease);
}
.gal__thumb:hover img, .gal__thumb:focus-visible img { transform: scale(1.06); }
.gal__thumb:hover::after, .gal__thumb:focus-visible::after,
.gal__thumb:hover .gal__zoom, .gal__thumb:focus-visible .gal__zoom { opacity: 1; transform: none; }
.gal__thumb:focus-visible { outline: 2px solid var(--aqua); outline-offset: 3px; }

.gal__more { display: flex; justify-content: center; margin-top: clamp(32px, 5vw, 56px); }
.gal__more .btn[hidden] { display: none; }
.gal__more .btn[disabled] { opacity: 0.6; pointer-events: none; }

/* ---------- Visor (lightbox) ---------- */
.lb {
  position: fixed; inset: 0; z-index: 600;
  display: grid;
  grid-template-columns: 72px 1fr 72px;
  grid-template-rows: auto 1fr;
  visibility: hidden;
  opacity: 0;
  transition: opacity 0.35s, visibility 0.35s;
}
.lb.is-open { visibility: visible; opacity: 1; }
.lb__backdrop { position: absolute; inset: 0; background: rgba(8, 0, 16, 0.94); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); }

.lb__top {
  position: relative; z-index: 2;
  grid-column: 1 / -1;
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: 14px 16px;
}
.lb__count { font-family: var(--f-title); font-size: 0.78rem; letter-spacing: 0.08em; color: var(--aqua); }
.lb__actions { display: flex; align-items: center; gap: 0.7rem; }
.lb__close {
  width: 42px; height: 42px; border-radius: 50%;
  font-size: 1.5rem; line-height: 1;
  background: rgba(12, 0, 23, 0.75); border: 1px solid var(--line);
  transition: transform 0.3s var(--ease), background 0.3s;
}
.lb__close:hover { transform: rotate(90deg); background: var(--magenta); }

.lb__stage {
  position: relative; z-index: 1;
  grid-column: 2; grid-row: 2;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  min-width: 0; min-height: 0;
  padding: 0 0 18px;
  touch-action: pan-y;
}
.lb__img {
  max-width: 100%;
  max-height: calc(100vh - 130px);
  max-height: calc(100svh - 130px);
  object-fit: contain;
  border-radius: 10px;
  box-shadow: 0 30px 80px -20px rgba(0, 0, 0, 0.8);
  opacity: 0;
  transform: scale(0.98);
  transition: opacity 0.35s, transform 0.45s var(--ease);
  user-select: none;
}
.lb__img.is-loaded { opacity: 1; transform: none; }
.lb__caption { margin-top: 0.8rem; font-size: 0.85rem; color: var(--text-mute); text-align: center; overflow-wrap: anywhere; }

.lb__spinner {
  position: absolute; top: 50%; left: 50%;
  width: 44px; height: 44px; margin: -22px 0 0 -22px;
  border-radius: 50%;
  border: 3px solid rgba(0, 211, 241, 0.2);
  border-top-color: var(--aqua);
  animation: lbSpin 0.8s linear infinite;
  opacity: 0; transition: opacity 0.2s;
}
.lb.is-busy .lb__spinner { opacity: 1; }
@keyframes lbSpin { to { transform: rotate(360deg); } }

.lb__nav {
  position: relative; z-index: 2;
  grid-row: 2; align-self: center; justify-self: center;
  width: 54px; height: 54px; border-radius: 50%;
  font-size: 2rem; line-height: 1;
  background: rgba(12, 0, 23, 0.6);
  border: 1px solid var(--line);
  transition: background 0.3s, transform 0.3s var(--ease), opacity 0.3s;
}
.lb__nav--prev { grid-column: 1; }
.lb__nav--next { grid-column: 3; }
.lb__nav:hover { background: var(--magenta); transform: scale(1.06); }
.lb__nav[disabled] { opacity: 0.25; pointer-events: none; }

@media (max-width: 640px) {
  .gal__grid { grid-template-columns: repeat(2, 1fr); }
  .gal__zoom { display: none; }
  .lb { grid-template-columns: 0 1fr 0; }
  .lb__stage { padding: 0 8px 80px; }
  .lb__img { max-height: calc(100svh - 190px); }
  .lb__nav { position: fixed; bottom: 18px; width: 50px; height: 50px; }
  .lb__nav--prev { left: calc(50% - 64px); }
  .lb__nav--next { right: calc(50% - 64px); }
  .lb__count { font-size: 0.68rem; }
}

@media (prefers-reduced-motion: reduce) {
  .gal__item { animation: none; opacity: 1; transform: none; }
  .gal__thumb { animation: none; }
}
