/* Rimini Woodworks Specific Styles */
/* Updated to use main site color scheme instead of custom brown theme */

body {
  background-color: var(--bg-color);
  color: var(--text-color);
  margin: 0;
  padding: 0;
  font-family: 'Cairo', sans-serif;
}

h1,
h2,
h3,
h4,
h5,
h6 {
  color: var(--text-color-h2);
}

/* Grid Styling */
.projects-grid {
  display: flex !important;
  flex-wrap: wrap !important;
  gap: 30px !important;
  margin: 40px auto !important;
  width: fit-content !important;
  box-sizing: border-box !important;
  justify-content: center !important;
  max-width: 1590px !important; /* Limits to 4 cards: (4 × 350px) + (3 × 30px) = 1490px */
  padding: 0 20px !important;
}

.project-card {
  background-color: var(--header-bg-color) !important;
  border-radius: 8px !important;
  overflow: hidden !important;
  box-shadow: 0 4px 6px var(--shadow-color) !important;
  border: 1px solid var(--border-color2) !important;
  transition: transform 0.3s, box-shadow 0.3s !important;
  cursor: pointer !important;
  width: 350px !important;
  flex: 0 0 450px !important;
  margin: 0 !important;
}

.project-card:hover {
  transform: translateY(-5px) !important;
  box-shadow: 0 10px 15px #fcd00b !important;
}

.project-image-container {
  aspect-ratio: 1 / 1;
  overflow: hidden;
}

.project-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.5s;
  border-radius: 8px 8px 0 0; /* Rounded corners only at the top for grid images */
}

.project-card:hover .project-image {
  transform: scale(1.05);
}

.project-info {
  padding: 20px;
}

.project-title {
  color: var(--text-color-h2);
  font-size: 1.5rem;
  margin-bottom: 12px;
  font-weight: 600;
}

.project-description {
  color: var(--text-color);
  font-size: 1.1rem;
  opacity: 0.9;
  line-height: 1.5;
}

.section-title {
  text-align: center;
  margin: 40px 0;
  color: var(--text-color-h2);
  font-size: 2.5rem;
  font-weight: 700;
}

/* Image Slider Overlay */
.image-slider-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(0, 0, 0, 0.9);
  z-index: 1000; /* Increased z-index to be above header */
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s;
}

.image-slider-overlay.active {
  opacity: 1;
  pointer-events: auto; /* Changed from 'all' to 'auto' for better compatibility */
}

/* Make sure the slider image container doesn't block clicks to the overlay */
.slider-image-container {
  position: relative;
  z-index: 1; /* Lower than controls but higher than the overlay background */
  display: inline-flex; /* Changed from flex to inline-flex to fit content */
  align-items: center;
  justify-content: center;
  touch-action: pan-y; /* Allow vertical scrolling but capture horizontal swipes */
  /* Remove fixed dimensions to fit content exactly */
  width: auto;
  height: auto;
  max-height: 80vh;
  max-width: 90vw;
}

.slider-image {
  max-height: 100%;
  max-width: 100%;
  object-fit: contain;
  border-radius: 12px; /* Add rounded corners to main image */
}

/* Ensure controls have proper z-index */
.close-btn,
.nav-btn {
  position: absolute;
  background-color: #333333;
  color: white;
  border: none;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background-color 0.3s, transform 0.2s;
  z-index: 10; /* Higher than the image container */
}

/* Add a subtle hover effect to make it clear they're interactive */
.close-btn:hover,
.nav-btn:hover {
  background-color: #555555;
  transform: scale(1.05);
}

/* Make the clickable area slightly larger than the visible button */
.close-btn::before,
.nav-btn::before {
  content: "";
  position: absolute;
  top: -5px;
  left: -5px;
  right: -5px;
  bottom: -5px;
  z-index: -1;
}

.close-btn {
  top: 20px;
  right: 20px;
  width: 40px;
  height: 40px;
}

.nav-btn {
  top: 50%;
  transform: translateY(-50%);
  width: 50px;
  height: 50px;
}

.nav-btn:hover {
  transform: translateY(-50%) scale(1.05);
}

.prev-btn {
  left: 20px;
}

.next-btn {
  right: 20px;
}

/* Project title in slider */
.slider-title-container {
  position: absolute;
  top: 20px;
  left: 20px;
  right: 80px; /* Leave space for the close button */
  text-align: left;
  z-index: 10;
  display: flex;
  align-items: center;
  height: 40px; /* Match the height of the close button */
}

.slider-title {
  color: var(--text-color-h2);
  font-size: 1.5rem;
  margin: 0;
  text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.8);
  font-weight: 600;
}

/* Thumbnail navigation */
.thumbnail-navigation {
  position: absolute;
  bottom: 20px;
  left: 0;
  right: 0;
  z-index: 10;
  display: flex;
  justify-content: center;
}

.thumbnails-container {
  display: flex;
  gap: 10px;
  max-width: 80%;
  overflow-x: auto;
  padding: 10px;
  background-color: rgba(0, 0, 0, 0.5);
  border-radius: 8px;
}

.thumbnail-btn {
  flex-shrink: 0;
  width: 60px;
  height: 60px;
  border: 2px solid transparent;
  border-radius: 4px;
  cursor: pointer;
  transition: border-color 0.3s, transform 0.2s;
  background-color: transparent;
  padding: 0;
  overflow: hidden;
}

.thumbnail-btn.active {
  border-color: var(--text-color-h2);
  transform: scale(1.1);
}

.thumbnail-btn:hover {
  border-color: var(--text-color-h2);
  transform: scale(1.05);
}

.thumbnail-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 2px;
}

/* Image counter */
.image-counter {
  display: none;
}

/* Dark mode adjustments */
body.dark-mode {
  background-color: var(--bg-color);
  color: var(--text-color);
}

body.dark-mode .project-card {
  background-color: var(--header-bg-color);
  border-color: var(--border-color2);
}

body.dark-mode .project-title {
  color: var(--text-color-h2);
}

body.dark-mode .project-description {
  color: var(--text-color);
}

/* RTL support */
.rtl .prev-btn {
  right: auto;
  left: 20px;
}

.rtl .next-btn {
  left: auto;
  right: 20px;
}

.rtl .close-btn {
  left: 20px;
  right: auto;
}

/* Error and loading states */
.error-message,
.loading-indicator {
  text-align: center;
  padding: 20px;
  color: var(--text-color);
  font-size: 1.1rem;
}

.loading-indicator {
  color: var(--text-color-h2);
}

/* Focus states for accessibility */
.nav-btn:focus,
.close-btn:focus {
  outline: none;
}

.project-card:focus-visible {
  outline: 2px solid var(--text-color-h2);
  outline-offset: 2px;
}

/* Responsive design */
@media (max-width: 768px) {
  .projects-grid {
    gap: 20px !important;
    padding: 0 15px !important;
  }

  .slider-title {
    font-size: 1.4rem;
  }

  .nav-btn {
    width: 40px;
    height: 40px;
  }

  .thumbnail-btn {
    width: 50px;
    height: 50px;
  }

  .thumbnails-container {
    max-width: 90%;
  }
}

@media (max-width: 576px) {
  .projects-grid {
    gap: 15px !important;
    padding: 0 10px !important;
  }

  .project-card {
    width: 300px !important;
    flex: 0 0 300px !important;
  }

  .project-title {
    font-size: 1.3rem;
  }

  .project-description {
    font-size: 1rem;
  }

  .project-info {
    padding: 16px;
  }

  .slider-title {
    font-size: 1.2rem;
  }

  .nav-btn {
    width: 35px;
    height: 35px;
  }

  .image-counter {
    font-size: 0.9rem;
    padding: 6px 10px;
  }
}

@media (max-width: 400px) {
  .project-card {
    width: 280px !important;
    flex: 0 0 280px !important;
  }

  .project-title {
    font-size: 1.2rem;
  }

  .project-description {
    font-size: 0.95rem;
  }

  .project-info {
    padding: 14px;
  }

  .close-btn {
    top: 10px;
    right: 10px;
    width: 35px;
    height: 35px;
  }

  .slider-image-container {
    max-height: 70vh;
    max-width: 95vw;
  }

  .thumbnail-btn {
    width: 40px;
    height: 40px;
  }

  .nav-btn,
  .close-btn {
    width: 30px;
    height: 30px;
  }
}
