/* Row Gallery Frontend Styles - Justified Gallery */
.nwf-row-gallery {
  margin: 2rem 0;
  width: 100%;
  display: flex;
  flex-wrap: wrap;
  --gap: 4px;
  --row-height: 200px;
}

/* Responsive row heights */
@media (min-width: 768px) {
  .nwf-row-gallery {
    --row-height: 220px;
    --gap: 6px;
  }
}

@media (min-width: 1024px) {
  .nwf-row-gallery {
    --row-height: 240px;
    --gap: 8px;
  }
}

@media (min-width: 1200px) {
  .nwf-row-gallery {
    --row-height: 20vmin;
    --gap: 8px;
  }
}

/* Phantom element to push last row items to left */
.nwf-row-gallery::after {
  --width: 2;
  --height: 1;
  --ratio: calc(var(--width) / var(--height));
  content: "";
  flex-basis: calc(var(--ratio) * var(--row-height));
  flex-grow: 1000000;
}

.nwf-gallery-item {
  --ratio: calc(var(--width) / var(--height));
  flex-grow: calc(var(--ratio) * 100);
  flex-basis: calc(var(--ratio) * var(--row-height));
  margin-bottom: var(--gap);
  margin-right: var(--gap);
  position: relative;
  border-radius: 4px;
  overflow: hidden;
  background-color: rgba(155, 155, 155, 0.1);
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.nwf-gallery-item:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
  z-index: 10;
}

.nwf-gallery-link {
  display: block;
  width: 100%;
  height: 100%;
  text-decoration: none;
  position: relative;
}

.nwf-gallery-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.3s ease;
}

.nwf-gallery-caption {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: linear-gradient(transparent, rgba(0, 0, 0, 0.7));
  color: white;
  padding: 20px 12px 12px;
  font-size: 14px;
  line-height: 1.4;
  pointer-events: none;
  opacity: 1;
  transform: translateY(0);
}

/* Optional: Add a subtle transition for polish */
.nwf-gallery-caption {
  transition: opacity 0.3s ease;
}

.nwf-gallery-link:hover .nwf-gallery-image {
  transform: scale(1.05);
}

/* Remove rows - not needed with flex-wrap */
.nwf-gallery-row {
  display: none;
}

/* Mobile adjustments */
@media (max-width: 767px) {
  .nwf-row-gallery {
    --gap: 2px;
    --row-height: 120px;
  }

  .nwf-gallery-item:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
  }

  .nwf-gallery-link:hover .nwf-gallery-image {
    transform: scale(1.02);
  }

  /* Captions on mobile */
  .nwf-gallery-caption {
    font-size: 12px;
    padding: 15px 8px 8px;
  }
}

@media (max-width: 480px) {
  .nwf-row-gallery {
    --gap: 1px;
    --row-height: 100px;
  }

  .nwf-gallery-item:hover {
    transform: none;
    box-shadow: none;
  }

  .nwf-gallery-link:hover .nwf-gallery-image {
    transform: none;
  }
}

/* Loading state */
.nwf-gallery-image[loading="lazy"] {
  background: #f0f0f0;
}

/* Accessibility */
.nwf-gallery-link:focus {
  outline: 2px solid #0073aa;
  outline-offset: 2px;
}

/* Print styles */
@media print {
  .nwf-gallery-item:hover {
    transform: none !important;
    box-shadow: none !important;
  }
}
