.gallery-container {
  max-width: var(--width-body-section);
  margin: 0 auto;
  padding: 20px;
}

.gallery-title {
  text-align: center;
  color: #2c3e50;
  margin-bottom: 40px;
  font-size: 2.5rem;
  border-bottom: 3px solid #0d3d35;
  padding-bottom: 10px;
  display: inline-block;
}

.gallery-title-container {
  text-align: center;
  margin-bottom: 30px;
}

.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 25px;
  padding: 20px;
}

.gallery-item {
  position: relative;
  overflow: hidden;
  border-radius: 8px;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
  aspect-ratio: 4/3;
  cursor: pointer;
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.gallery-item:hover {
  transform: translateY(-5px);
  box-shadow: 0 8px 16px rgba(0, 0, 0, 0.2);
}

.gallery-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.3s ease;
}

.gallery-item:hover img {
  transform: scale(1.1);
}

.gallery-caption {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: rgba(0, 0, 0, 0.7);
  color: white;
  padding: 15px;
  transform: translateY(100%);
  font-size: 1.1rem;
  transition: transform 0.3s ease;
}

.gallery-item:hover .gallery-caption {
  transform: translateY(0);
}

/* Modal styles for full-size image view */
/* Modal navigation buttons */
.modal-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(0, 0, 0, 0.5);
  color: white;
  padding: 16px;
  border: none;
  cursor: pointer;
  font-size: 18px;
  transition: background-color 0.3s;
  z-index: 1002;
}

.modal-nav:hover {
  background: rgba(0, 0, 0, 0.8);
}

.prev-btn {
  left: 20px;
}

.next-btn {
  right: 20px;
}

/* Image counter */
.image-counter {
  position: absolute;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.5);
  color: white;
  padding: 8px 16px;
  border-radius: 20px;
  font-size: 14px;
}

.modal-content-wrapper {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  gap: 30px;
}

.modal-image-section {
  position: relative;
  flex: 2;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.gallery-modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.9);
  z-index: 1000;
  padding: 40px;
}

.modal-container {
  display: flex;
  width: 100%;
  height: 100%;
  gap: 30px;
}

.modal-image-container {
  flex: 2;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-content {
  max-width: 100%;
  max-height: 90vh;
  object-fit: contain;
}

.modal-text-container {
  flex: 1;
  background: rgba(178, 231, 229, 0.95);
  padding: 30px;
  border-radius: 10px;
  overflow-y: auto;
  color: #333;
  max-width: 400px;
}

.modal-title {
  font-size: 24px;
  font-weight: bold;
  color: #0d3d35;
  margin-bottom: 20px;
  border-bottom: 2px solid #0d3d35;
  padding-bottom: 10px;
}

.modal-description {
  font-size: 16px;
  line-height: 1.6;
  margin-bottom: 20px;
}

.modal-details {
  font-size: 14px;
  color: #666;
}

/* Update the .modal-close styles in gallery.css */
.modal-close {
  position: fixed; /* Change from absolute to fixed */
  top: 10px;
  right: 10px;
  background: rgba(0, 0, 0, 0.8); /* Made slightly more opaque */
  border: 2px solid white;
  color: white;
  width: 44px; /* Increased touch target size */
  height: 44px; /* Increased touch target size */
  border-radius: 50%;
  cursor: pointer;
  font-size: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background-color 0.3s;
  z-index: 9999; /* Highest z-index */
  padding: 0; /* Reset padding */
  line-height: 1; /* Ensure proper centering of the × symbol */
  touch-action: manipulation; /* Optimize for touch */
  -webkit-tap-highlight-color: transparent; /* Remove tap highlight on iOS */
}

.modal-close:hover {
  background: rgba(224, 105, 84, 0.63);
}

/* Add touch-specific styles */
@media (hover: none) and (pointer: coarse) {
  .modal-close {
    opacity: 1 !important;
    background: rgba(0, 0, 0, 0.9);
  }
}

/*media queries for better modal mobile display */
@media (max-width: 1024px) {
  .modal-content-wrapper {
    flex-direction: column;
    padding: 20px;
    overflow-y: auto;
  }

  .modal-image-section {
    width: 100%;
    height: auto;
    max-height: 60vh;
  }

  .modal-text-container {
    width: 100%;
    max-height: 30vh;
    overflow-y: auto;
    margin-top: 20px;
    padding: 15px;
  }

  .modal-content {
    max-height: 60vh;
    width: auto;
    max-width: 100%;
  }
  .modal-nav {
    padding: 12px;
    font-size: 16px;
  }

  .prev-btn {
    left: 10px;
  }

  .next-btn {
    right: 10px;
  }
}

@media (max-width: 768px) {
  .gallery-grid {
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 20px;
    padding: 15px;
  }

  .gallery-modal {
    padding: 20px;
  }

  .modal-content-wrapper {
    padding: 10px;
  }

  .modal-image-section {
    max-height: 50vh;
  }

  .modal-content {
    max-height: 50vh;
  }

  .modal-text-container {
    max-height: 40vh;
    padding: 12px;
  }

  .modal-title {
    font-size: 20px;
    margin-bottom: 10px;
  }

  .modal-description {
    font-size: 14px;
  }

  .modal-details {
    font-size: 13px;
  }

  .modal-nav {
    padding: 8px;
    font-size: 14px;
  }

  .image-counter {
    font-size: 12px;
    padding: 6px 12px;
    bottom: 10px;
  }

  .modal-close {
    top: 10px;
    right: 10px;
    width: 35px;
    height: 35px;
    font-size: 20px;
    background: rgba(
      138,
      102,
      96,
      0.9
    ); /* Even more opaque for better visibility */
  }
}

@media (max-width: 480px) {
  .modal-content-wrapper {
    padding: 5px;
  }

  .modal-image-section {
    max-height: 45vh;
  }

  .modal-content {
    max-height: 45vh;
  }

  .modal-text-container {
    max-height: 45vh;
    padding: 10px;
  }

  .modal-title {
    font-size: 18px;
  }

  .modal-description {
    font-size: 13px;
  }

  .modal-details {
    font-size: 12px;
  }

  .modal-nav {
    padding: 6px;
    font-size: 12px;
  }

  .prev-btn {
    left: 5px;
  }

  .next-btn {
    right: 5px;
  }

  .image-counter {
    font-size: 11px;
    padding: 4px 10px;
    bottom: 5px;
  }

  .modal-close {
    width: 30px;
    height: 30px;
    font-size: 18px;
  }
}
/* Handle very tall screens */
@media (min-height: 1000px) {
  .modal-image-section {
    max-height: 70vh;
  }

  .modal-content {
    max-height: 70vh;
  }

  .modal-text-container {
    max-height: 20vh;
  }
}

/* Handle landscape orientation on mobile */
@media (max-width: 896px) and (orientation: landscape) {
  .modal-content-wrapper {
    flex-direction: row;
    gap: 15px;
  }

  .modal-image-section {
    max-height: 80vh;
    flex: 2;
  }

  .modal-content {
    max-height: 80vh;
  }

  .modal-text-container {
    flex: 1;
    max-height: 80vh;
    margin-top: 0;
    max-width: 300px;
  }

  .modal-nav {
    padding: 8px;
  }
}

/* Handle touch devices */
@media (hover: none) {
  .modal-nav {
    background: rgba(0, 0, 0, 0.5);
    opacity: 1;
  }

  .modal-close {
    opacity: 1;
  }
}

/* Prevent content shift when modal opens on mobile */
body.modal-open {
  position: fixed;
  width: 100%;
  height: 100%;
  overflow: hidden;
}

/* Ensure smooth scrolling in modal text container */
.modal-text-container {
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  scrollbar-color: rgba(0, 0, 0, 0.3) transparent;
}

/* Custom scrollbar for modal text */
.modal-text-container::-webkit-scrollbar {
  width: 6px;
}

.modal-text-container::-webkit-scrollbar-track {
  background: transparent;
}

.modal-text-container::-webkit-scrollbar-thumb {
  background-color: rgba(0, 0, 0, 0.3);
  border-radius: 3px;
}
