/* Container: Creates the responsive grid */
.kn-master-gallery {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 20px;
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 20px 0;
}

/* Individual Image Wrapper */
.kn-gallery-item {
  position: relative;
  overflow: hidden;
  border-radius: 8px;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
  cursor: pointer;
  background-color: #f4f4f4;
}

/* The Grid Images (Cropped uniformly) */
.kn-gallery-item img {
  display: block;
  width: 100%;
  height: 300px;
  object-fit: cover;
  transition: transform 0.4s ease;
}

/* Subtle Zoom on Hover (No Text) */
.kn-gallery-item:hover img {
  transform: scale(1.05);
}

/* HIDE THE OLD TEXT AND OVERLAY COMPLETELY */
.kn-overlay {
  display: none !important;
}

/* --- LIGHTBOX POPUP STYLES --- */
.kn-lightbox {
  display: none; /* Hidden by default */
  position: fixed;
  z-index: 999999; /* Always on top */
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.9); /* Dark background */
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.3s ease;
}

/* Shows the popup */
.kn-lightbox.show-popup {
  display: flex;
  opacity: 1;
}

/* The Full Uncropped Image */
.kn-lightbox-content {
  max-width: 90%;
  max-height: 90vh; /* Fits within the screen height */
  object-fit: contain; /* Shows full uncropped image */
  border-radius: 4px;
  box-shadow: 0 5px 25px rgba(0,0,0,0.5);
  animation: zoomIn 0.3s ease;
}

/* Close Button (The X) */
.kn-close {
  position: absolute;
  top: 20px;
  right: 40px;
  color: #ffffff;
  font-size: 50px;
  font-weight: bold;
  cursor: pointer;
  transition: 0.2s;
  z-index: 1000000;
}

.kn-close:hover {
  color: #cccccc;
}

/* Popup Animation */
@keyframes zoomIn {
  from {transform: scale(0.9);}
  to {transform: scale(1);}
}

/* Mobile Adjustments */
@media (max-width: 768px) {
  .kn-master-gallery {
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 15px;
  }
  .kn-gallery-item img {
    height: 250px; 
  }
  .kn-close {
    top: 10px;
    right: 20px;
  }
}

/* --- LIGHTBOX NAVIGATION ARROWS --- */
.kn-prev, .kn-next {
  cursor: pointer;
  position: absolute;
  top: 50%;
  width: auto;
  padding: 16px;
  margin-top: -30px;
  color: white;
  font-weight: bold;
  font-size: 40px;
  transition: background-color 0.3s ease;
  user-select: none;
  z-index: 1000000;
  background-color: rgba(0, 0, 0, 0.4); /* Slight background to stand out over images */
  border-radius: 4px;
}

/* Position Left Arrow */
.kn-prev {
  left: 20px;
}

/* Position Right Arrow */
.kn-next {
  right: 20px;
}

/* Arrow Hover Effect */
.kn-prev:hover, .kn-next:hover {
  background-color: rgba(0, 0, 0, 0.9);
}

/* Mobile Adjustments for Arrows */
@media (max-width: 768px) {
  .kn-prev, .kn-next {
    font-size: 25px;
    padding: 12px;
  }
  .kn-prev { left: 10px; }
  .kn-next { right: 10px; }
}