/* ==========================================================================
   GALERIA 2027 (/galeria) - siatka + lightbox.
   Tokeny marki z brand-2027.css (--k-*). Animujemy wyłącznie transform i opacity.
   ========================================================================== */

.galeria-intro {
  max-width: 64ch;
  margin: 2px 0 30px;
  color: var(--k-text-muted, #b3a9c4);
  font-size: 1.02rem;
  line-height: 1.65;
}

.galeria-more {
  margin: 30px 0 0;
  color: var(--k-text-muted, #b3a9c4);
  font-size: 0.95rem;
}

.galeria-more a {
  color: var(--k-gold-light, #f3c77d);
  text-decoration: none;
  border-bottom: 1px solid rgba(243, 199, 125, 0.4);
}

.galeria-more a:hover {
  border-bottom-color: var(--k-gold-light, #f3c77d);
}

/* ---------- siatka: równe wiersze o proporcjonalnych szerokościach (flex + --ar) ---------- */
.g-grid {
  --row-h: 300px;
  --gap: 10px;
  display: flex;
  flex-wrap: wrap;
  gap: var(--gap);
}

/* ostatni wiersz nie jest rozciągany na całą szerokość */
.g-grid::after {
  content: "";
  flex-grow: 100000;
  height: 0;
  margin-top: calc(var(--gap) * -1);
}

.g-item {
  --m: 1;
  position: relative;
  display: block;
  min-width: 0;
  overflow: hidden;
  border-radius: 12px;
  background: #120a1f;
  aspect-ratio: var(--ar);
  flex: calc(var(--ar) * 100 * var(--m)) 1 calc(var(--ar) * var(--row-h) * var(--m));
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.06);
  cursor: zoom-in;
  -webkit-tap-highlight-color: transparent;
}

.g-item--feature {
  --m: 1.35;
}

/* układ liczony w galeria.js: szerokość i wysokość kafelka podane wprost, rzędy domknięte */
.g-grid.is-justified .g-item {
  flex: none;
  aspect-ratio: auto;
}

.g-grid.is-justified .g-item.g-row-end {
  flex: 1 1 auto;
}

.g-grid.is-justified::after {
  display: none;
}

.g-item img {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: scale(1);
  transition: transform 220ms cubic-bezier(0.23, 1, 0.32, 1);
}

/* fioletowa poświata krawędzi - animowana przez opacity */
.g-item::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  opacity: 0;
  box-shadow: inset 0 0 0 1px rgba(177, 77, 255, 0.75), inset 0 0 26px rgba(143, 43, 255, 0.38);
  transition: opacity 220ms cubic-bezier(0.23, 1, 0.32, 1);
}

@media (hover: hover) and (pointer: fine) {
  .g-item:hover img {
    transform: scale(1.03);
  }

  .g-item:hover::after {
    opacity: 1;
  }
}

.g-item:focus-visible {
  outline: 2px solid var(--k-gold-light, #f3c77d);
  outline-offset: 3px;
}

.g-item:focus-visible::after {
  opacity: 1;
}

@media (max-width: 900px) {
  .g-grid {
    --row-h: 250px;
    --gap: 8px;
  }
}

@media (max-width: 600px) {
  .g-grid {
    --row-h: 230px;
  }

  .g-item--feature {
    --m: 1;
  }
}

/* ==========================================================================
   LIGHTBOX
   ========================================================================== */
.glb {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 64px 88px 72px;
  opacity: 0;
  overscroll-behavior: contain;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  transition: opacity 160ms ease-in;
}

.glb[hidden] {
  display: none;
}

.glb.is-open {
  opacity: 1;
  transition: opacity 220ms cubic-bezier(0.23, 1, 0.32, 1);
}

.glb-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(6, 3, 12, 0.92);
  cursor: zoom-out;
}

.glb-stage {
  position: relative;
  margin: 0;
  display: flex;
  max-width: 100%;
  transform: scale(0.96);
  transition: transform 160ms ease-in;
}

.glb.is-open .glb-stage {
  transform: none;
  transition: transform 220ms cubic-bezier(0.23, 1, 0.32, 1);
}

.glb-img {
  display: block;
  width: auto;
  height: auto;
  max-width: calc(100vw - 176px);
  max-height: calc(100vh - 136px);
  max-height: calc(100dvh - 136px);
  border-radius: 8px;
  background: #120a1f;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.65), 0 0 0 1px rgba(255, 255, 255, 0.06);
}

.glb-cap {
  position: absolute;
  left: 88px;
  right: 88px;
  bottom: 22px;
  margin: 0;
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 14px;
  font-family: "Oswald", sans-serif;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-size: 0.85rem;
  color: var(--k-text, #ece6f5);
  pointer-events: none;
}

.glb-count {
  color: var(--k-gold-light, #f3c77d);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.glb-btn {
  position: absolute;
  z-index: 1;
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  padding: 0;
  border-radius: 50%;
  border: 1px solid rgba(243, 199, 125, 0.32);
  background: rgba(20, 10, 34, 0.78);
  color: #fff;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background-color 150ms ease, border-color 150ms ease, transform 150ms ease;
}

.glb-btn:active {
  transform: scale(0.94);
}

.glb-btn:focus-visible {
  outline: 3px solid var(--k-gold-light, #f3c77d);
  outline-offset: 3px;
}

@media (hover: hover) and (pointer: fine) {
  .glb-btn:hover {
    background: rgba(143, 43, 255, 0.5);
    border-color: var(--k-gold-light, #f3c77d);
  }
}

.glb-close {
  top: 14px;
  right: 14px;
}

.glb-prev,
.glb-next {
  top: 50%;
  margin-top: -24px;
}

.glb-prev {
  left: 18px;
}

.glb-next {
  right: 18px;
}

/* przyciski prev/next ruszają się tylko przez :active (scale), więc margin-top zamiast translate */
@media (max-width: 700px) {
  .glb {
    padding: 60px 12px 84px;
  }

  .glb-img {
    max-width: calc(100vw - 24px);
    max-height: calc(100vh - 144px);
    max-height: calc(100dvh - 144px);
  }

  .glb-prev,
  .glb-next {
    top: auto;
    margin-top: 0;
    bottom: 16px;
  }

  .glb-prev {
    left: 14px;
  }

  .glb-next {
    right: 14px;
  }

  .glb-cap {
    left: 72px;
    right: 72px;
    bottom: 22px;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    font-size: 0.78rem;
    text-align: center;
  }
}

@media (prefers-reduced-motion: reduce) {
  .g-item img,
  .g-item:hover img {
    transform: none;
    transition: none;
  }

  .glb,
  .glb.is-open {
    transition: opacity 120ms linear;
  }

  .glb-stage,
  .glb.is-open .glb-stage {
    transform: none;
    transition: none;
  }

  .glb-btn,
  .glb-btn:active {
    transform: none;
    transition: none;
  }
}
