/* Galería de ejemplos: tableros de BI (landing-bi) y pantallas de las aplicaciones (gestion-humana, itos).
   Cada imagen es un enlace a su WebP; con JS se abre en un <dialog>. */
.gal {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 3rem 2rem;
}

/* Pantallas de celular: angostas, tres por fila y centradas bajo las de computador */
.gal--celular { grid-template-columns: repeat(3, minmax(0, 1fr)); max-width: 880px; margin: 0 auto; }
.gal + .gal--celular { margin-top: 3.5rem; }

/* Si quedan impares, la última va centrada en su fila en vez de colgar a la izquierda */
@media (min-width: 769px) {
  .gal:not(.gal--celular) > .gal__item:last-child:nth-child(odd) { grid-column: 1 / -1; justify-self: center; width: calc(50% - 1rem); }
}

.gal__item { margin: 0; display: flex; flex-direction: column; }

.gal__abrir {
  position: relative;
  display: block;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--bg-2);
  box-shadow: var(--shadow);
  cursor: zoom-in;
  transition: transform .2s var(--ease), border-color .2s var(--ease);
}
.gal__abrir img { display: block; width: 100%; height: auto; }
.gal__abrir:hover { transform: translateY(-2px); border-color: var(--blue-line); }
.gal__abrir:active { transform: scale(.99); }
.gal__abrir:focus-visible { outline: 3px solid var(--navy-fill); outline-offset: 3px; }

/* Franja fija bajo la imagen (no encima: taparía rótulos y créditos que la captura trae dentro). No depende del hover,
   así que en el celular también se ve que se puede ampliar */
.gal__ver {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: .4rem;
  padding: .6rem .9rem;
  border-top: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-2);
  font-size: .85rem;
  line-height: 1.2;
}
.gal__ver svg { width: 14px; height: 14px; flex: none; }
.gal__abrir:hover .gal__ver { color: var(--text); }

.gal__texto { margin-top: 1.1rem; }
.gal__texto h3 { font-size: 1.2rem; margin: 0; }
.gal__desc { margin: .4rem 0 0; color: var(--text-2); font-size: .98rem; line-height: 1.5; }
.gal__rotulo { margin: .6rem 0 0; color: var(--text-3); font-size: .85rem; }
.gal__fuente { margin: .4rem 0 0; color: var(--text-3); font-size: .8rem; line-height: 1.55; overflow-wrap: anywhere; }
.gal__fuente a, .gal-dlg a { color: var(--text-2); text-decoration: underline; text-underline-offset: 2px; }
.gal__fuente a:hover, .gal-dlg a:hover { color: var(--text); }
.gal__fuente a:focus-visible, .gal-dlg a:focus-visible { outline: 2px solid var(--navy-fill); outline-offset: 2px; border-radius: 2px; }

/* Diálogo con la imagen en grande */
.gal-dlg {
  margin: auto;
  width: min(1400px, calc(100vw - 2rem));
  max-width: none;
  max-height: calc(100dvh - 2rem);
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 8px 28px rgba(0, 32, 96, .18);
  overflow: auto;
}
.gal-dlg[open] { display: flex; flex-direction: column; animation: gal-entra .28s var(--ease); }
.gal-dlg::backdrop { background: rgba(0, 15, 46, .72); }
.gal-dlg[open]::backdrop { animation: gal-fondo .28s ease-out; }
html:has(.gal-dlg[open]) { overflow: hidden; }

.gal-dlg__barra {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: .75rem .75rem .75rem 1.25rem;
  border-bottom: 1px solid var(--border);
}
.gal-dlg__barra h2 { margin: 0; font-size: 1.15rem; line-height: 1.3; }
.gal-dlg__barra form { margin: 0; }
.gal-dlg__cerrar {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  min-height: 44px;
  padding: 0 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: .95rem;
  transition: background-color .15s ease-out;
}
.gal-dlg__cerrar svg { width: 16px; height: 16px; }
.gal-dlg__cerrar:hover { background: var(--bg-2); }
.gal-dlg__cerrar:focus-visible { outline: 3px solid var(--navy-fill); outline-offset: 2px; }

.gal-dlg__lienzo { flex: 0 1 auto; min-height: 0; background: var(--bg-2); display: flex; }
.gal-dlg__img { display: block; margin: auto; width: auto; height: auto; max-width: 100%; max-height: var(--gal-alto, calc(100dvh - 12rem)); }

.gal-dlg__pie { padding: .75rem 1.25rem 1rem; border-top: 1px solid var(--border); font-size: .85rem; color: var(--text-3); }
.gal-dlg__pie p { margin: 0; }
.gal-dlg__pie p + p { margin-top: .35rem; }
.gal-dlg__pie .gal__fuente, .gal-dlg__pie .gal__rotulo { margin: 0; }
.gal-dlg__real { display: inline-block; margin-top: .5rem; }

@keyframes gal-entra { from { opacity: 0; transform: translateY(8px) scale(.985); } to { opacity: 1; transform: none; } }
@keyframes gal-fondo { from { opacity: 0; } to { opacity: 1; } }

@media (max-width: 768px) {
  .gal { grid-template-columns: minmax(0, 1fr); gap: 2.5rem; }
  .gal-dlg { width: calc(100vw - 1rem); max-height: calc(100dvh - 1rem); }
  .gal-dlg__barra { padding-left: 1rem; }
  .gal-dlg__pie { padding: .75rem 1rem 1rem; }
  /* En el celular las pantallas de celular van en una fila que se desliza de lado; la siguiente se asoma */
  .gal--celular {
    display: flex;
    gap: 1rem;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    overscroll-behavior-x: contain;
    margin: 0 -1.5rem;
    padding: .25rem 1.5rem 1rem;
    scroll-padding: 0 1.5rem;
  }
  .gal + .gal--celular { margin-top: 2.5rem; }
  .gal--celular > .gal__item { flex: 0 0 72%; scroll-snap-align: start; }
}

@media (prefers-reduced-motion: reduce) {
  .gal__abrir { transition: none; }
  .gal__abrir:hover, .gal__abrir:active { transform: none; }
  .gal-dlg[open], .gal-dlg[open]::backdrop { animation: none; }
}
