/* --- User Provided Card Styles --- */
.image-hover-container {
  position: relative;
  overflow: hidden;
  display: block;
  cursor: pointer;
  width: 100%;
}

.msi-card-link {
  display: block;
  line-height: 0;
}

.image-hover-container img {
  display: block;
  width: 100%;
  height: auto;
  object-fit: cover;
  transition: transform 0.3s ease-in-out;
}

.image-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.7);
  color: #fff;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  opacity: 0;
  transition: opacity 0.3s ease-in-out;
  box-sizing: border-box;
  padding: 15px;
  text-align: center;
}

.image-overlay h3.msi-card-title {
  margin: 0;
  line-height: 1.2;
  display: block;
}

.msi-card-excerpt {
  display: block;
  padding-top: 10px; /* Increased spacing for better separation */
  font-size: 0.9em;
  opacity: 0.9;
}

.image-hover-container:hover .image-overlay {
  opacity: 1;
}

.image-hover-container:hover img {
  transform: scale(1.05);
}

/* --- Modal Styles --- */
.msi-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: none; /* Hidden by default */
  z-index: 99999;
}

.msi-modal.is-active {
  display: flex !important;
  align-items: flex-start !important;
  justify-content: center !important;
  padding-top: 114px !important;
}

.msi-modal-overlay {
  position: absolute;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.85);
}

.msi-modal-content {
  position: relative;
  background: var(--global-palette9);
  color: var(--global-palette3);
  width: 90%;
  max-width: 900px;
  max-height: 85vh;
  overflow-y: auto;
  padding: 40px;
  border-radius: 4px;
  z-index: 10;
}

.msi-modal-close {
  position: absolute;
  top: 15px;
  right: 20px;
  background: none;
  border: none;
  font-size: 32px;
  cursor: pointer;
  color: var(--global-palette3);
}

.msi-modal-header {
  padding-bottom: 15px;
}

.msi-modal-header h3 {
  display: inline;
  margin: 0;
  color: var(--global-palette3);
  vertical-align: baseline;
}

.msi-modal-excerpt {
  display: inline;
  font-weight: bold;
  color: var(--global-palette3);
  opacity: 0.8;
  margin-left: 15px; /* Add spacing after the title */
  vertical-align: baseline;
}

.msi-project-description {
  margin-bottom: 30px;
  line-height: 1.6;
}

.msi-gallery-slider {
  position: relative;
  width: 100%;
  margin-top: 20px;
}

.msi-slider-container {
  overflow: hidden;
  width: 100%;
  border-radius: 4px;
}

.msi-slider-track {
  display: flex;
  transition: transform 0.4s cubic-bezier(0.25, 1, 0.5, 1);
  will-change: transform;
}

.msi-slide {
  min-width: 100%;
  box-sizing: border-box;
}

.msi-slide img {
  width: 100%;
  height: auto;
  display: block;
  border-radius: 4px;
}

.msi-slider-prev,
.msi-slider-next {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(0, 0, 0, 0.5);
  color: #fff;
  border: none;
  font-size: 24px;
  padding: 15px 10px;
  cursor: pointer;
  z-index: 5;
  transition: background 0.3s ease;
  border-radius: 2px;
}

.msi-slider-prev:hover,
.msi-slider-next:hover {
  background: rgba(0, 0, 0, 0.8);
}

.msi-slider-prev {
  left: 10px;
}

.msi-slider-next {
  right: 10px;
}

/* Hide navigation if there is only one slide */
.msi-gallery-slider.single-slide .msi-slider-prev,
.msi-gallery-slider.single-slide .msi-slider-next {
  display: none;
}

/* --- Grid and Filtering Styles --- */
.msi-projects-container {
  margin: 20px 0;
}

.msi-project-filters {
  display: flex;
  justify-content: flex-start;
  margin: -5px -4px 40px;
  flex-wrap: wrap;
}

.msi-project-filters .radio {
  text-transform: uppercase;
  font-weight: 600;
  width: 100%;
  margin: 5px 4px !important;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid var(--global-palette3);
  background: transparent;
  color: var(--global-palette3);
  white-space: normal;
  text-align: center;
  min-height: 60px;
  flex-basis: calc(25% - 8px);
  box-sizing: border-box;
  cursor: pointer;
  padding: 10px 20px;
  transition: all 0.3s ease;
}

.msi-project-filters .radio:hover,
.msi-project-filters .radio.active {
  background-color: var(--global-palette2);
  color: var(--global-palette3) !important;
}

.msi-projects-grid {
  column-count: 3;
  column-gap: 20px;
}

.msi-project-wrapper {
  display: inline-block;
  width: 100%;
  margin-bottom: 20px;
  break-inside: avoid;
}

.msi-project-wrapper.hidden {
  display: none;
}

/* --- Responsive Adjustments --- */
@media (max-width: 1200px) {
  .msi-projects-grid {
    column-count: 2;
  }
}

@media (max-width: 768px) {
  .msi-projects-grid {
    column-count: 1;
  }
  .msi-card-link {
    line-height: normal;
  }
  .image-overlay {
    position: static;
    height: auto;
    opacity: 1;
    background-color: transparent;
    color: #fff;
    padding: 15px;
    text-align: left;
    width: 100%;
  }
  .msi-modal-content {
    padding: 20px;
    width: 95%;
  }
}

@media only screen and (max-width: 767px) {
  .msi-project-filters .radio {
    flex-basis: calc(100% - 8px);
    font-size: 15px;
    min-height: 50px;
  }
}
