/* ============================================================
   VEIA · Galería interactiva (módulo reutilizable)
   Estética inspirada en el visor de Picasa de principios de los 2000.
   Escritorio: rejilla + visor con filmstrip, flechas, teclado y zoom.
   Móvil: rejilla + visor a pantalla completa con swipe, pinch y arrastre.
   Requiere: galeria.js  ·  Uso: VEIAgaleria.init({...})
   ============================================================ */

/* ---------- Rejilla de miniaturas ---------- */
.vg-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 14px;
}

.vg-item {
  position: relative;
  display: block;
  padding: 6px;
  border: 0;
  border-radius: 6px;
  background: #fff;
  aspect-ratio: 4 / 3;
  overflow: hidden;
  cursor: zoom-in;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .18), 0 6px 14px rgba(0, 0, 0, .08);
  transition: transform .18s ease, box-shadow .18s ease;
}

.vg-item img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
  border-radius: 3px;
}

.vg-item:hover {
  transform: translateY(-3px);
  box-shadow: 0 6px 16px rgba(0, 0, 0, .25), 0 12px 28px rgba(0, 0, 0, .12);
}

.vg-item:focus-visible {
  outline: 2px solid var(--clay, #a65f46);
  outline-offset: 2px;
}

.vg-item-cap {
  position: absolute;
  left: 6px;
  right: 6px;
  bottom: 6px;
  padding: .4rem .55rem;
  font-size: .68rem;
  color: #fff;
  border-radius: 0 0 3px 3px;
  background: linear-gradient(transparent, rgba(0, 0, 0, .72));
  opacity: 0;
  transition: opacity .2s;
}

.vg-item:hover .vg-item-cap,
.vg-item:focus-visible .vg-item-cap {
  opacity: 1;
}

/* Miniaturas en sepia con más contraste (todas las plataformas) */
.vg-item img {
  filter: sepia(.8) contrast(1.2) saturate(1.15) brightness(1.02);
  transition: filter .35s ease;
}

/* Escritorio: al pasar el cursor recuperan su color normal.
   El visor siempre se ve a color. */
@media (hover: hover) and (pointer: fine) {
  .vg-item:hover img,
  .vg-item:focus-visible img {
    filter: none;
  }
}

/* ---------- Filtros ---------- */
.vg-filtros {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
  margin: 1.4rem 0 1.1rem;
}

.vg-filtros button {
  padding: .5rem .95rem;
  border: 1px solid var(--line, rgba(57, 47, 42, .14));
  border-radius: 99px;
  background: transparent;
  color: var(--ink, #392f2a);
  font-size: .82rem;
  cursor: pointer;
  transition: .2s;
}

.vg-filtros button.active {
  border-color: var(--clay, #a65f46);
  background: var(--clay, #a65f46);
  color: #fff;
}

/* ============================================================
   VISOR
   ============================================================ */
.vg-viewer {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: flex;
  flex-direction: column;
  background: #14181d;
  color: #fff;
  opacity: 0;
  visibility: hidden;
  transition: opacity .25s ease;
  touch-action: none;
}

.vg-viewer.abierto {
  opacity: 1;
  visibility: visible;
}

body.vg-bloqueado {
  overflow: hidden;
}

/* Barra superior */
.vg-topbar {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 1rem;
  height: 52px;
  padding: 0 12px;
  background: linear-gradient(#2c3641, #1d242c);
  border-bottom: 1px solid rgba(255, 255, 255, .08);
}

.vg-back {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  padding: .4rem .5rem;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: #dbe7f2;
  font: inherit;
  font-size: .82rem;
  cursor: pointer;
}

.vg-back:hover {
  background: rgba(255, 255, 255, .1);
}

.vg-title {
  flex: 1;
  text-align: center;
  font-family: "Cormorant Garamond", serif;
  font-size: 1.05rem;
  color: #eef4fa;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.vg-tools {
  display: flex;
  gap: .2rem;
}

.vg-zoom,
.vg-close {
  width: 38px;
  height: 38px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: #dbe7f2;
  font-size: 1.2rem;
  line-height: 1;
  cursor: pointer;
}

.vg-zoom:hover,
.vg-close:hover {
  background: rgba(255, 255, 255, .1);
}

/* Escenario de la foto */
.vg-stage {
  position: relative;
  flex: 1;
  min-height: 0;
  display: grid;
  place-items: center;
  overflow: hidden;
  background: radial-gradient(ellipse at center, #232c36 0%, #12161b 75%);
}

.vg-img {
  width: auto;
  height: auto;
  max-width: 94%;
  max-height: 94%;
  object-fit: contain;
  border-radius: 3px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, .6);
  transition: transform .18s ease;
  will-change: transform;
  user-select: none;
  -webkit-user-drag: none;
}

.vg-viewer.sin-transicion .vg-img {
  transition: none;
}

/* Flechas */
.vg-arrow {
  position: absolute;
  top: 50%;
  z-index: 2;
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border: 0;
  border-radius: 50%;
  background: rgba(0, 0, 0, .35);
  color: #fff;
  font-size: 2rem;
  line-height: 1;
  cursor: pointer;
  transform: translateY(-50%);
  transition: background .2s;
}

.vg-arrow:hover {
  background: rgba(0, 0, 0, .6);
}

.vg-prev { left: 12px; }
.vg-next { right: 12px; }

/* Pie: caption + contador */
.vg-bar {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: .55rem 1rem;
  background: linear-gradient(#1d242c, #171c22);
  border-top: 1px solid rgba(255, 255, 255, .08);
}

.vg-caption {
  font-size: .85rem;
  color: #e7eef5;
}

.vg-counter {
  font-size: .72rem;
  color: #9fb0c0;
  letter-spacing: .08em;
  white-space: nowrap;
}

/* Filmstrip */
.vg-filmstrip {
  flex: 0 0 auto;
  display: flex;
  gap: 8px;
  padding: 10px 12px;
  overflow-x: auto;
  background: #0e1216;
  border-top: 1px solid rgba(255, 255, 255, .06);
  scrollbar-width: thin;
  touch-action: pan-x;
}

.vg-thumb {
  flex: 0 0 auto;
  width: 76px;
  height: 56px;
  padding: 2px;
  border: 2px solid transparent;
  border-radius: 4px;
  background: transparent;
  opacity: .65;
  cursor: pointer;
  transition: opacity .15s, border-color .15s, transform .15s;
}

.vg-thumb img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
  border-radius: 2px;
}

.vg-thumb:hover { opacity: 1; }

.vg-thumb.activo {
  opacity: 1;
  border-color: #8fb8dd;
  transform: translateY(-2px);
}

/* Rejilla en pantallas amplias */
@media (min-width: 700px) {
  .vg-grid { grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); }
}

/* ============================================================
   MÓVIL / TÁCTIL — visor a pantalla completa
   ============================================================ */
@media (hover: none) and (pointer: coarse) {
  .vg-topbar {
    height: auto;
    min-height: 52px;
    padding-top: env(safe-area-inset-top);
    padding-left: max(12px, env(safe-area-inset-left));
    padding-right: max(12px, env(safe-area-inset-right));
  }

  .vg-title,
  .vg-zoom,
  .vg-arrow,
  .vg-filmstrip {
    display: none;
  }

  .vg-bar {
    padding-bottom: calc(.55rem + env(safe-area-inset-bottom));
    padding-left: max(1rem, env(safe-area-inset-left));
    padding-right: max(1rem, env(safe-area-inset-right));
  }

  .vg-img {
    max-width: 100%;
    max-height: 100%;
    border-radius: 0;
    box-shadow: none;
  }

  .vg-topbar,
  .vg-bar {
    transition: opacity .2s;
  }

  .vg-viewer.vg-oculto .vg-topbar,
  .vg-viewer.vg-oculto .vg-bar {
    opacity: 0;
    pointer-events: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .vg-item,
  .vg-img,
  .vg-viewer,
  .vg-thumb,
  .vg-topbar,
  .vg-bar {
    transition: none;
  }
}

/* Esquinas cuadradas (estética Picasa) */
.vg-item,
.vg-item img,
.vg-item-cap,
.vg-filtros button,
.vg-back,
.vg-zoom,
.vg-close,
.vg-img,
.vg-arrow,
.vg-thumb,
.vg-thumb img {
  border-radius: 0;
}
