/*
 * BSidesBSB 2026 — Galeria de fotos (seção #galeria)
 * ------------------------------------------------------------------
 * Grade de miniaturas em carrossel horizontal (2 linhas no desktop,
 * 3 no celular) + lightbox para ampliar cada foto individualmente.
 * Usa os tokens de design de styles.css (--pink, --cyan, --line...).
 */

.gallery-panel {
  --track-accent: #2dd7ff;
  --gal-gap: 10px;
  --gal-cols: 6;
  --gal-rows: 2;
  position: relative;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: linear-gradient(180deg, rgba(8, 15, 32, 0.78), rgba(2, 6, 14, 0.78));
  overflow: hidden;
}
.gallery-panel:before {
  content: "";
  position: absolute;
  inset: 0;
  background: url("../assets/crops/purple-smoke.png") center / cover;
  opacity: 0.1;
  mix-blend-mode: screen;
  pointer-events: none;
}
.gallery-panel > * {
  position: relative;
}

.gallery-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}
.gallery-count {
  font-size: 0.64rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: #8ca2c7;
}
.gallery-count b {
  color: var(--ink);
  font-weight: 600;
}
.gallery-controls button {
  display: grid;
  place-items: center;
}
.gallery-controls button svg {
  width: 16px;
  height: 16px;
}
.gallery-controls button:disabled {
  opacity: 0.35;
  cursor: default;
  transform: none;
  box-shadow: none;
}

/* --- carrossel em grade --- */
.gallery-viewport {
  overflow-x: auto;
  overflow-y: hidden;
  scroll-snap-type: x mandatory;
  scroll-behavior: smooth;
  scrollbar-width: none;
  overscroll-behavior-x: contain;
  border-radius: 14px;
  outline: none;
}
.gallery-viewport::-webkit-scrollbar {
  display: none;
}
.gallery-viewport:focus-visible {
  box-shadow: 0 0 0 2px var(--cyan);
}
.gallery-grid {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-auto-flow: column;
  grid-template-rows: repeat(var(--gal-rows), auto);
  grid-auto-columns: calc((100% - (var(--gal-cols) - 1) * var(--gal-gap)) / var(--gal-cols));
  gap: var(--gal-gap);
}
.gallery-grid li {
  scroll-snap-align: start;
}
.gal-thumb {
  position: relative;
  display: block;
  width: 100%;
  aspect-ratio: 3 / 2;
  padding: 0;
  border: 1px solid rgba(90, 127, 205, 0.28);
  border-radius: 12px;
  overflow: hidden;
  cursor: zoom-in;
  background:
    linear-gradient(110deg, rgba(163, 92, 255, 0.08) 30%, rgba(17, 209, 255, 0.16) 50%, rgba(163, 92, 255, 0.08) 70%)
      0 0 / 300% 100%,
    #0a1124;
  animation: gal-shimmer 1.6s linear infinite;
  transition:
    border-color 0.25s ease,
    box-shadow 0.25s ease,
    transform 0.25s ease;
}
.gal-thumb.loaded {
  animation: none;
  background: #0a1124;
}
.gal-thumb img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  transform: scale(1.02);
  transition:
    opacity 0.45s ease,
    transform 0.45s ease,
    filter 0.3s ease;
  filter: saturate(0.92);
}
.gal-thumb.loaded img {
  opacity: 1;
}
.gal-thumb:after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, transparent 55%, rgba(255, 25, 220, 0.28));
  opacity: 0;
  transition: opacity 0.25s ease;
}
.gal-thumb:hover,
.gal-thumb:focus-visible {
  outline: none;
  border-color: color-mix(in srgb, var(--cyan) 75%, transparent);
  box-shadow:
    0 0 18px rgba(17, 209, 255, 0.3),
    0 0 0 1px rgba(255, 25, 220, 0.35);
}
.gal-thumb:hover img,
.gal-thumb:focus-visible img {
  transform: scale(1.08);
  filter: saturate(1.1);
}
.gal-thumb:hover:after,
.gal-thumb:focus-visible:after {
  opacity: 1;
}
.gal-thumb.failed {
  animation: none;
  cursor: default;
}

.gallery-progress {
  height: 2px;
  margin-top: 16px;
  border-radius: 2px;
  background: rgba(90, 127, 205, 0.2);
  overflow: hidden;
}
.gallery-progress i {
  display: block;
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, var(--pink), #bd67ff, var(--cyan));
  transition: width 0.3s ease;
}

@keyframes gal-shimmer {
  to {
    background-position: -300% 0;
  }
}

/* --- lightbox --- */
.gal-lightbox {
  position: fixed;
  inset: 0;
  z-index: 150000;
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr) 72px;
  align-items: center;
  padding: 56px 16px 24px;
  background:
    radial-gradient(circle at 50% 40%, rgba(163, 92, 255, 0.18), transparent 60%),
    rgba(3, 6, 16, 0.94);
  backdrop-filter: blur(10px);
  opacity: 0;
  transition: opacity 0.28s ease;
}
.gal-lightbox[hidden] {
  display: none;
}
.gal-lightbox.open {
  opacity: 1;
}
.gal-lb-stage {
  position: relative;
  margin: 0;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  min-height: 0;
}
.gal-lb-stage img {
  display: block;
  max-width: 100%;
  max-height: calc(100% - 34px);
  object-fit: contain;
  border-radius: 14px;
  border: 1px solid rgba(90, 127, 205, 0.35);
  box-shadow:
    0 0 40px rgba(163, 92, 255, 0.25),
    0 20px 60px rgba(0, 0, 0, 0.6);
  opacity: 0;
  transform: scale(0.985);
  transition:
    opacity 0.3s ease,
    transform 0.3s ease;
}
.gal-lb-stage.ready img {
  opacity: 1;
  transform: none;
}
.gal-lb-stage figcaption {
  font-size: 0.72rem;
  letter-spacing: 0.14em;
  color: #8ca2c7;
}
.gal-lb-stage figcaption b {
  color: var(--ink);
  font-weight: 600;
}
.gal-lb-spinner {
  position: absolute;
  top: calc(50% - 17px);
  left: 50%;
  width: 34px;
  height: 34px;
  margin: -17px 0 0 -17px;
  border-radius: 50%;
  border: 2px solid rgba(17, 209, 255, 0.2);
  border-top-color: var(--cyan);
  animation: gal-spin 0.8s linear infinite;
}
.gal-lb-stage.ready .gal-lb-spinner {
  display: none;
}
@keyframes gal-spin {
  to {
    transform: rotate(360deg);
  }
}
.gal-lb-nav,
.gal-lb-close {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: 1px solid rgba(45, 215, 255, 0.6);
  background: rgba(2, 5, 15, 0.75);
  color: #fff;
  cursor: pointer;
  transition:
    background 0.2s ease,
    box-shadow 0.2s ease,
    transform 0.2s ease;
}
.gal-lb-nav svg,
.gal-lb-close svg {
  width: 20px;
  height: 20px;
}
.gal-lb-nav:hover,
.gal-lb-close:hover,
.gal-lb-nav:focus-visible,
.gal-lb-close:focus-visible {
  outline: none;
  background: rgba(45, 215, 255, 0.2);
  box-shadow: 0 0 16px rgba(45, 215, 255, 0.45);
}
.gal-lb-nav {
  justify-self: center;
}
.gal-lb-close {
  position: absolute;
  top: 14px;
  right: 16px;
  border-color: rgba(255, 25, 220, 0.6);
}
.gal-lb-close:hover,
.gal-lb-close:focus-visible {
  background: rgba(255, 25, 220, 0.2);
  box-shadow: 0 0 16px rgba(255, 25, 220, 0.45);
}

/* --- responsivo --- */
@media (max-width: 1100px) {
  .gallery-panel {
    --gal-cols: 5;
  }
}
@media (max-width: 860px) {
  .gallery-panel {
    --gal-cols: 4;
  }
}
@media (max-width: 620px) {
  .gallery-panel {
    --gal-cols: 3;
    --gal-rows: 3;
    --gal-gap: 8px;
    padding: 14px;
    border-radius: 18px;
  }
  .gal-thumb {
    aspect-ratio: 1;
    border-radius: 10px;
  }
  .gal-lightbox {
    grid-template-columns: minmax(0, 1fr);
    padding: 64px 10px 86px;
  }
  .gal-lb-nav {
    position: absolute;
    bottom: 22px;
  }
  .gal-lb-prev {
    left: calc(50% - 64px);
  }
  .gal-lb-next {
    right: calc(50% - 64px);
  }
}
@media (prefers-reduced-motion: reduce) {
  .gallery-viewport {
    scroll-behavior: auto;
  }
  .gal-thumb,
  .gal-thumb img,
  .gal-lightbox,
  .gal-lb-stage img {
    transition: none;
    animation: none;
  }
}
