/**
 * Galeria — klikalne zdjęcia, lupa, lightbox (desktop + mobile)
 */

/* —— Komórka galerii —— */
.realizacje-gallery__item {
  cursor: default;
}

.realizacje-gallery__item .el-gallery-trigger {
  display: block;
  position: relative;
  width: 100%;
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: zoom-in;
  font: inherit;
  color: inherit;
  text-align: inherit;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.realizacje-gallery__item .el-gallery-trigger img {
  width: 100%;
  height: clamp(300px, 34vw, 620px);
  object-fit: cover;
  object-position: center center;
  display: block;
  transition: transform 0.55s ease;
}

.realizacje-gallery__item .el-gallery-trigger:hover img,
.realizacje-gallery__item .el-gallery-trigger:focus-visible img {
  transform: scale(1.03);
}

.page-key-home .realizacje-gallery__item .el-gallery-trigger img {
  height: 100%;
  min-height: clamp(280px, 32vw, 580px);
}

/* CTA na kafelku — nie blokuje powiększenia (klik w link nadal działa) */
.realizacje-gallery__cta-wrap {
  z-index: 3;
  pointer-events: none;
}

.realizacje-gallery__cta-link {
  pointer-events: auto;
}

/* —— Realizacje showcase —— */
.project-block__media .el-gallery-trigger {
  flex: 1 1 0;
  position: relative;
  min-height: 0;
  width: 100%;
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: zoom-in;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.project-block__media .el-gallery-trigger img {
  width: 100%;
  height: 100%;
  min-height: inherit;
  object-fit: cover;
  display: block;
  transition: transform 0.45s ease, filter 0.35s ease;
}

.project-block__media .el-gallery-trigger:hover img,
.project-block__media .el-gallery-trigger:focus-visible img {
  transform: scale(1.02);
  filter: brightness(1.04);
}

.layout-realizacje-showcase .project-block__media--solo .el-gallery-trigger {
  flex: 0 0 auto;
}

/* —— Ikona lupy —— */
.el-gallery-loupe {
  position: absolute;
  right: clamp(10px, 2vw, 16px);
  bottom: clamp(10px, 2vw, 16px);
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  width: clamp(36px, 8vw, 44px);
  height: clamp(36px, 8vw, 44px);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.94);
  color: var(--brand-graphite, #22282c);
  box-shadow: 0 2px 14px rgba(0, 0, 0, 0.22);
  opacity: 0;
  transform: scale(0.9);
  transition: opacity 0.25s ease, transform 0.25s ease;
  pointer-events: none;
}

.el-gallery-loupe svg {
  width: 20px;
  height: 20px;
}

.el-gallery-trigger:hover .el-gallery-loupe,
.el-gallery-trigger:focus-visible .el-gallery-loupe {
  opacity: 1;
  transform: scale(1);
}

@media (hover: none) {
  .el-gallery-loupe {
    opacity: 1;
    transform: scale(1);
  }
}

.project-block--dark .el-gallery-loupe {
  background: rgba(255, 255, 255, 0.9);
  color: var(--brand-graphite, #22282c);
}

/* —— Lightbox —— */
.el-lightbox {
  position: fixed;
  inset: 0;
  z-index: 10050;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

.el-lightbox[hidden] {
  display: none !important;
}

.el-lightbox__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(12, 14, 16, 0.94);
  cursor: zoom-out;
}

.el-lightbox__dialog {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  width: min(96vw, 1280px);
  max-height: min(96vh, calc(var(--vh, 1vh) * 96));
  margin: 0 auto;
  pointer-events: none;
}

.el-lightbox__dialog > * {
  pointer-events: auto;
}

.el-lightbox__stage {
  --el-lightbox-radius: clamp(10px, 1.4vw, 14px);
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: fit-content;
  max-width: min(96vw, 1280px);
  max-height: min(78vh, calc(var(--vh, 1vh) * 78));
  overflow: hidden;
  border-radius: var(--el-lightbox-radius);
  line-height: 0;
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.1),
    0 18px 60px rgba(0, 0, 0, 0.55);
  touch-action: pan-y pinch-zoom;
}

.el-lightbox__tap {
  position: absolute;
  top: 0;
  z-index: 2;
  width: 50%;
  height: 100%;
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.el-lightbox__tap[hidden] {
  display: none !important;
}

.el-lightbox__tap--prev {
  left: 0;
  cursor: w-resize;
}

.el-lightbox__tap--next {
  right: 0;
  cursor: e-resize;
}

.el-lightbox__stage--multi .el-lightbox__tap--prev:hover {
  background: linear-gradient(to right, rgba(0, 0, 0, 0.18), transparent);
}

.el-lightbox__stage--multi .el-lightbox__tap--next:hover {
  background: linear-gradient(to left, rgba(0, 0, 0, 0.18), transparent);
}

.el-lightbox__img {
  position: relative;
  z-index: 1;
  display: block;
  max-width: min(96vw, 1280px);
  max-height: min(78vh, calc(var(--vh, 1vh) * 78));
  width: auto;
  height: auto;
  vertical-align: middle;
  object-fit: contain;
  border-radius: inherit;
  opacity: 1;
  transition: opacity 0.2s ease;
  pointer-events: none;
  user-select: none;
  -webkit-user-drag: none;
}

.el-lightbox__img.is-loading {
  opacity: 0.35;
}

.el-lightbox__caption {
  margin: 14px 0 0;
  max-width: 42em;
  padding: 0 12px;
  font-family: var(--font-body, 'Roboto', sans-serif);
  font-size: clamp(13px, 2.8vw, 15px);
  line-height: 1.45;
  letter-spacing: 0.03em;
  color: rgba(255, 255, 255, 0.88);
  text-align: center;
}

.el-lightbox__caption[hidden] {
  display: none;
}

.el-lightbox__counter {
  margin: 8px 0 0;
  font-family: var(--font-detail, 'Roboto Mono', monospace);
  font-size: 11px;
  letter-spacing: 0.12em;
  color: rgba(255, 255, 255, 0.55);
  text-align: center;
}

.el-lightbox__close {
  position: fixed;
  top: max(12px, env(safe-area-inset-top));
  right: max(12px, env(safe-area-inset-right));
  z-index: 3;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  font-size: 28px;
  line-height: 1;
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease;
  -webkit-tap-highlight-color: transparent;
}

.el-lightbox__close:hover,
.el-lightbox__close:focus-visible {
  background: var(--brand-red, #b84b55);
  color: #fff;
  outline: none;
}

.el-lightbox__nav {
  position: fixed;
  top: 50%;
  z-index: 3;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  font-size: 32px;
  line-height: 1;
  transform: translateY(-50%);
  cursor: pointer;
  transition: background 0.2s ease;
  -webkit-tap-highlight-color: transparent;
}

.el-lightbox__nav[hidden] {
  display: none !important;
}

.el-lightbox__nav:hover,
.el-lightbox__nav:focus-visible {
  background: rgba(255, 255, 255, 0.22);
  outline: none;
}

.el-lightbox__nav--prev {
  left: max(8px, env(safe-area-inset-left));
}

.el-lightbox__nav--next {
  right: max(8px, env(safe-area-inset-right));
}

body.el-lightbox-open {
  overflow: hidden;
  touch-action: none;
}

@media (max-width: 767px) {
  .realizacje-gallery__item .el-gallery-trigger img {
    height: clamp(260px, 58vw, 520px);
  }

  .el-lightbox__nav {
    width: 44px;
    height: 44px;
    font-size: 28px;
  }

  .el-lightbox__close {
    width: 44px;
    height: 44px;
    font-size: 26px;
  }

  .el-lightbox__stage {
    --el-lightbox-radius: 10px;
    max-height: min(72vh, calc(var(--vh, 1vh) * 72));
  }

  .el-lightbox__img {
    max-height: min(72vh, calc(var(--vh, 1vh) * 72));
  }
}

@media (prefers-reduced-motion: reduce) {
  .realizacje-gallery__item .el-gallery-trigger img,
  .project-block__media .el-gallery-trigger img,
  .el-gallery-loupe,
  .el-lightbox__img {
    transition: none;
  }
}
