.industries-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 20px;
  margin: 90px 0 0 0;
  padding: 0;
  list-style: none;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
}

/* Large screens: 4 columns */
@media (min-width: 1200px) {
  .industries-grid {
    gap: 24px;
  }
}

/* Medium screens: 3 columns */
@media (max-width: 1199px) and (min-width: 900px) {
  .industries-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
  }
}

/* Small desktop/Tablet: 2 columns */
@media (max-width: 899px) and (min-width: 600px) {
  .industries-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 18px;
  }
}

/* Mobile: 1 column */
@media (max-width: 599px) {
  .industries-grid {
    grid-template-columns: 1fr;
    gap: 16px;
  }
  
  .industry-card {
    min-height: 180px;
  }
}

.industry-card {
  position: relative;
  aspect-ratio: 1 / 1;
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  border-radius: 0;
  overflow: hidden;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
  cursor: pointer;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  contain: layout style;
  isolation: isolate;
}

.industry-card:hover {
  transform: translateY(-4px) scale(1.25);
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.15);
  z-index: 999;
  border: 4px solid #000;
}

.industry-card:hover a {
  align-items: center;   
  justify-content: center; 
}

.industry-card:hover::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(transparent, rgba(255, 0, 0, 0.85));
  z-index: 1;
}

.industry-card:active {
  transform: translateY(-2px) scale(1.01);
  transition-duration: 0.1s;
}

.industry-card a {
  flex: 1;
  display: flex;
  align-items: flex-end;
  text-decoration: none;
  color: inherit;
}

.industry-card .overlay {
  width: 100%;
  background: linear-gradient(to bottom, transparent 0%, rgba(0, 0, 0, 0) 10%, rgba(0, 0, 0, 0.7) 50%, rgba(0, 0, 0, 0.95) 100%);
  color: #ffffff;
  text-align: center;
  padding: 20px 16px 16px;
  box-sizing: border-box;
  transition: background 0.3s ease;
}

.industry-card .overlay {
  position: relative;
  z-index: 2;
}

.industry-card:hover h4 {
  color: #fff;
}

.industry-card:hover .overlay {
  background: none;
}

.industry-card h4 {
  margin: 0 auto 32px !important;
  color: #fff;
  position: relative;
  padding-bottom: 16px;
  display: inline-block;
}

.industry-card h4:after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 2px;
  background-color: #ffffff;
  border-radius: 1px;
}

/* Mobile typography is handled in the main responsive section above */

/* Focus states for accessibility */
.industry-card a:focus {
  outline: 3px solid #007cba;
  outline-offset: 2px;
}

.industry-card a:focus-visible {
  outline: 3px solid #007cba;
  outline-offset: 2px;
}

/* Loading state for images */
.industry-card[style*="placeholder"] {
  background-color: #f5f5f5;
  background-image: linear-gradient(135deg, #f5f5f5 25%, #e8e8e8 25%, #e8e8e8 50%, #f5f5f5 50%, #f5f5f5 75%, #e8e8e8 75%);
  background-size: 20px 20px;
  position: relative;
}

.industry-card[style*="placeholder"]:before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 60px;
  height: 60px;
  background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="%23999"><path d="M19 3H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zm-5 14H7l1.5-2L10 16.5l2.5-3.5L15 17h-1z"/></svg>');
  background-size: contain;
  background-repeat: no-repeat;
  opacity: 0.5;
}

/* Ensure proper contrast on fallback images */
.industry-card[style*="placeholder"] .overlay {
  background: linear-gradient(transparent, rgba(0, 0, 0, 0.9));
}

/* Grid items are now properly contained */

/* Container wrapper for better containment */
.wp-block-tempco-industries-grid,
.wp-block-acf-industries-grid {
  width: 100%;
  max-width: 100%;
  overflow: hidden;
  box-sizing: border-box;
}

/* Ensure grid doesn't break out of containers */
.industries-grid * {
  box-sizing: border-box;
}

/* Print styles */
@media print {
  .industries-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
  }
  
  .industry-card:hover {
    transform: none;
    box-shadow: none;
  }
}
