.containerCards {
  display: flex;
  justify-content: center;
  align-items: center;
  margin: 2vmin 5vmin;
  overflow: hidden;
  transform: skew(0deg);
  border-radius: 12px;
}

.containerCards .card {
  flex: 1;
  transition: all 1s ease-in-out;
  height: 75vmin;
  position: relative;
  border-radius: 12px;
}

.containerCards .card img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: all 1s ease-in-out;
  filter: grayscale(100%);
  border-radius: 12px;
}

.containerCards .card {
  margin-right: 1em;
}

.containerCards .card .card__head {
  color: #FFF;
  background: #000066;
  padding: 0.5em;
  transform: rotate(-90deg);
  transform-origin: 0% 0%;
  transition: all 0.5s ease-in-out;
  min-width: 100%;
  text-align: center;
  position: absolute;
  bottom: 0;
  left: 0;
  font-size: 1em;
  white-space: nowrap;
  border-radius: 0px 0px 12px 12px;
  opacity: 1;
  visibility: visible;
}

.containerCards .card:hover .card__head {
  opacity: 0;
  visibility: hidden;
}

.containerCards .card .card-caption {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: rgba(0, 0, 0, 0.7);
  color: #fff;
  padding: 1em;
  font-size: 0.9em;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.5s ease, visibility 0.5s ease;
  border-radius: 0 0 12px 12px;
  max-height: 200px;
  overflow-y: auto;
}

.containerCards .card:hover .card-caption {
  opacity: 1;
  visibility: visible;
  transition-delay: 0.5s;
}

.containerCards .card:hover {
  flex-grow: 10;
  opacity: 1;
}

.containerCards .card:hover img {
  filter: grayscale(0);
}

.containerCards .card:hover .card__head {
  text-align: center;
  color: white;
  background: rgba(0, 0, 0, 0.5);
  font-size: 2em;
  transform: rotate(0deg) skew(0deg);
}

a {
  color: white;
  text-decoration: none;
}

a:hover {
  color: white;
}

/* NEW FLEX LAYOUT FOR HEADER + BUTTON */
.caption-header-flex {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.5em;
  flex-wrap: wrap;
}

.caption-header-flex h2 {
  margin: 0;
  font-size: 1.4em;
  color: #00d475;
}

.caption-header-flex .more-button {
  background-color: #00d475;
  color: white;
  padding: 0.8em 1.8em;
  font-size: 1em;
  border-radius: 5px;
  text-decoration: none;
  transition: background-color 0.3s ease;
  white-space: nowrap;
}

.caption-header-flex .more-button:hover {
  background-color: #00a463;
}


@media (max-width: 768px) {
  .containerCards {
    flex-direction: column;
    margin: 1em;
  }

  .containerCards .card {
    flex: unset;
    width: 100%;
    height: auto;
    margin-bottom: 0.5em;
    border: 1px solid #ddd;
    border-radius: 6px;
    overflow: hidden;
  }

  .containerCards .card .card__head {
    position: relative;
    transform: rotate(0deg);
    background: #000066;
    color: #fff;
    font-size: 1.1em;
    border-radius: 0;
    cursor: pointer;
    padding: 1em;
  }

  /* مخفی کردن کامل محتوا */
.containerCards .card .card-caption {
    opacity: 0;
    max-height: 0;
    overflow: hidden;
    transform: translateY(-10px);
    transition: all 0.3s ease;
}

.containerCards .card.active .card-caption {
    opacity: 1;
    max-height: 1000px; /* یه مقدار زیاد تا مطمئن بشیم کامل باز میشه */
    transform: translateY(0);
}

  .containerCards .card .card-caption img {
    width: 100%;
    height: auto;
    border-radius: 6px;
    margin-bottom: 1em;
    filter: grayscale(0);
  }

}
@media (max-width: 768px) {
  .containerCards .card .card-caption {
    font-size: 0.9em; 
    line-height: 1.6;
    padding: 0.8em 1em;
    background: rgba(0,0,0,0.75);
    color: #fff;
    overflow: hidden;
    max-height: 0;
    opacity: 0;
    transition: all 0.3s ease;
  }

  .containerCards .card.active .card-caption {
    max-height: 500px; /* کافی برای متن‌های معمولی */
    opacity: 1;
    overflow-y: auto; /* اسکرول برای متن‌های بلند */
  }

  /* ظاهر بهتر متن */
  .containerCards .card .card-caption p {
    margin: 0;
    font-size: 0.85em;
  }
}
