/* ==========================================================================
   Praxis-Galerie — Grid
   ========================================================================== */

.hpg-gallery {
  --hpg-columns: 3;
  --hpg-gap: 12px;
  --hpg-row-height: 180px;
  --hpg-radius: 10px;
  --hpg-overlay: rgba(0, 0, 0, 0.45);

  display: grid;
  grid-template-columns: repeat(var(--hpg-columns), 1fr);
  grid-auto-rows: var(--hpg-row-height);
  gap: var(--hpg-gap);
  margin: 30px 0;
}

/* ---------- Layout: Masonry ---------- */
.hpg-gallery[data-layout="masonry"] .hpg-item:nth-child(5n + 1) { grid-row: span 2; }
.hpg-gallery[data-layout="masonry"] .hpg-item:nth-child(5n + 3) { grid-column: span 2; }
.hpg-gallery[data-layout="masonry"] .hpg-item:nth-child(5n + 5) { grid-column: span 2; grid-row: span 2; }

/* ---------- Layout: Uniform ---------- */
/* No spanning — all tiles same size */

/* ---------- Layout: Wide ---------- */
.hpg-gallery[data-layout="wide"] {
  grid-template-columns: repeat(2, 1fr);
  grid-auto-rows: calc(var(--hpg-row-height) * 1.5);
}

/* ---------- Tile ---------- */

.hpg-item {
  position: relative;
  border-radius: var(--hpg-radius);
  overflow: hidden;
  cursor: pointer;
  margin: 0;
}

.hpg-item .hpg-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.4s ease;
}

/* ---------- Video Items ---------- */

.hpg-item-video {
  position: relative;
}

.hpg-play-icon {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 50px;
  height: 50px;
  background: rgba(0, 0, 0, 0.6);
  color: #fff;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  padding-left: 3px;
  transition: background 0.3s ease, transform 0.3s ease;
  z-index: 2;
  pointer-events: none;
}

.hpg-item-video:hover .hpg-play-icon {
  background: rgba(61, 122, 45, 0.85);
  transform: translate(-50%, -50%) scale(1.1);
}

.hpg-video-poster-placeholder {
  width: 100%;
  height: 100%;
  background: #2c3338;
}

/* ---------- Overlay ---------- */

.hpg-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0);
  transition: background 0.3s ease;
}

.hpg-title {
  color: #fff;
  font-size: 1.1rem;
  font-weight: 700;
  text-align: center;
  padding: 8px 16px;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.3s ease, transform 0.3s ease;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.5);
}

/* ---------- Hover: zoom-overlay (default) ---------- */
.hpg-gallery[data-hover="zoom-overlay"] .hpg-item:hover .hpg-img {
  transform: scale(1.03);
}
.hpg-gallery[data-hover="zoom-overlay"] .hpg-item:hover .hpg-overlay {
  background: var(--hpg-overlay);
}
.hpg-gallery[data-hover="zoom-overlay"] .hpg-item:hover .hpg-title {
  opacity: 1;
  transform: translateY(0);
}

/* ---------- Hover: overlay-only ---------- */
.hpg-gallery[data-hover="overlay-only"] .hpg-item:hover .hpg-overlay {
  background: var(--hpg-overlay);
}
.hpg-gallery[data-hover="overlay-only"] .hpg-item:hover .hpg-title {
  opacity: 1;
  transform: translateY(0);
}

/* ---------- Hover: zoom-only ---------- */
.hpg-gallery[data-hover="zoom-only"] .hpg-item:hover .hpg-img {
  transform: scale(1.03);
}

/* ---------- Hover: none ---------- */
/* No hover effects */

/* ---------- Focus (keyboard) ---------- */
.hpg-item:focus-visible {
  outline: 3px solid #3d7a2d;
  outline-offset: 2px;
}

/* ==========================================================================
   Lightbox
   ========================================================================== */

.hpg-lightbox {
  position: fixed;
  inset: 0;
  z-index: 100000;
  background: rgba(0, 0, 0, 0.92);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

.hpg-lightbox.hpg-lb-open {
  opacity: 1;
  visibility: visible;
}

/* ---------- Image ---------- */

.hpg-lb-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  max-width: 90vw;
  max-height: 90vh;
}

.hpg-lb-img {
  max-width: 90vw;
  max-height: 75vh;
  object-fit: contain;
  border-radius: 6px;
  opacity: 0;
  transform: scale(0.95);
  transition: opacity 0.3s ease, transform 0.3s ease;
}

.hpg-lb-open .hpg-lb-img {
  opacity: 1;
  transform: scale(1);
}

/* ---------- Video in Lightbox ---------- */

.hpg-lb-video {
  max-width: 90vw;
  max-height: 75vh;
  width: 900px;
  height: 506px;
  border-radius: 6px;
  border: none;
}

video.hpg-lb-video {
  width: auto;
  max-width: 90vw;
  max-height: 75vh;
}

/* ---------- Caption ---------- */

.hpg-lb-caption {
  text-align: center;
  margin-top: 16px;
  max-width: 600px;
}

.hpg-lb-title {
  color: #fff;
  font-size: 1.1rem;
  font-weight: 600;
  margin: 0 0 6px;
}

.hpg-lb-desc {
  color: rgba(255, 255, 255, 0.75);
  font-size: 0.9rem;
  line-height: 1.5;
  margin: 0;
}

/* ---------- Navigation ---------- */

.hpg-lb-close,
.hpg-lb-prev,
.hpg-lb-next {
  position: absolute;
  background: none;
  border: none;
  color: rgba(255, 255, 255, 0.7);
  cursor: pointer;
  font-size: 28px;
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: background 0.2s ease, color 0.2s ease;
  z-index: 10;
}

.hpg-lb-close:hover,
.hpg-lb-prev:hover,
.hpg-lb-next:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.15);
}

.hpg-lb-close:focus-visible,
.hpg-lb-prev:focus-visible,
.hpg-lb-next:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 2px;
}

.hpg-lb-close {
  top: 16px;
  right: 16px;
  font-size: 24px;
}

.hpg-lb-prev {
  left: 16px;
  top: 50%;
  transform: translateY(-50%);
}

.hpg-lb-next {
  right: 16px;
  top: 50%;
  transform: translateY(-50%);
}

/* ==========================================================================
   Reduced Motion
   ========================================================================== */

@media (prefers-reduced-motion: reduce) {
  .hpg-item .hpg-img,
  .hpg-overlay,
  .hpg-title,
  .hpg-lightbox,
  .hpg-lb-img {
    transition: none;
  }
  .hpg-item:hover .hpg-img {
    transform: none;
  }
}

/* ==========================================================================
   Responsive
   ========================================================================== */

@media (max-width: 900px) {
  .hpg-gallery {
    grid-template-columns: repeat(2, 1fr);
    grid-auto-rows: 150px;
  }
  .hpg-gallery[data-layout="masonry"] .hpg-item:nth-child(5n + 5) {
    grid-column: span 2;
    grid-row: span 1;
  }
  .hpg-gallery[data-layout="wide"] {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 600px) {
  .hpg-gallery {
    grid-template-columns: 1fr;
    grid-auto-rows: 200px;
    gap: 10px;
  }
  .hpg-gallery[data-layout="masonry"] .hpg-item:nth-child(5n + 1) { grid-row: span 1; }
  .hpg-gallery[data-layout="masonry"] .hpg-item:nth-child(5n + 3) { grid-column: span 1; }
  .hpg-gallery[data-layout="masonry"] .hpg-item:nth-child(5n + 5) { grid-column: span 1; grid-row: span 1; }

  .hpg-lb-prev { left: 8px; }
  .hpg-lb-next { right: 8px; }
  .hpg-lb-close { top: 8px; right: 8px; }
  .hpg-lb-caption { padding: 0 16px; }
}
