:root{
  --card-height: 380px;  /* adjustable card height */
  --card-width: 900px;
  --card-gap: 16px;      /* space between cards */
}

/* Reset and basic body */
*{box-sizing:border-box;margin:0;padding:0}

body{
  background:#f5f5f5;
  font-family:Arial, sans-serif;
  padding:40px 5%;
}

/* Cards wrapper */
.cards-wrapper{
  display:grid;
  grid-template-columns:repeat(3, 1fr); /* always 3 columns on desktop */
  gap: var(--card-gap);
  max-width:1400px;
  margin:0 auto;
  justify-items:center;    /* center cards in columns */
}

/* Card styles */
.card{
  position:relative;
  border: 3px solid darkred;
  width:98%;
  height: var(--card-height);
  border-radius:10px;
  overflow:hidden;
  cursor:pointer;
  box-shadow:0 3px 8px rgba(0,0,0,0.18);
  transition:transform 0.2s;
  background-size:100% 100%;     /* stretch image fully without cropping */
  background-repeat:no-repeat;
  background-position:center;
}

.card:hover{transform:translateY(-4px);}

/* Info bar at bottom of card */
.info-bar{
  position:absolute;
  bottom:0;
  width:100%;
  background:rgba(220,0,0,0.75);
  color:#fff;
  padding:10px;
  text-align:center;
  box-sizing:border-box;
}

.info-bar h3{
  font-size:18px;
  margin-bottom:4px;
  word-break:break-word;
}

.info-bar p{
  font-size:14px;
  color:#ffdd99;
  margin:0;
  white-space:nowrap;
  overflow:hidden;
  text-overflow:ellipsis;
}

/* Overlay text on hover */
.overlay{
  position:absolute;
  inset:0;
  background:rgba(200,0,0,0.6);
  color:#fff;
  display:flex;
  align-items:center;
  justify-content:center;
  font-size:18px;
  opacity:0;
  transition:opacity 0.25s;
  text-align:center;
  padding:10px;
}

.card:hover .overlay{opacity:1;}

/* Modal styles */
.modal{
  position:fixed;
  inset:0;
  background:rgba(0,0,0,0.55);
  display:flex;
  justify-content:center;
  align-items:center;
  visibility:hidden;
  opacity:0;
  transition:opacity 0.3s;
  z-index:1000;
  padding:10px;
}

.modal.active{
  visibility:visible;
  opacity:1;
}

.modal-content{
  background:#fff;
  width:100%;
  max-width:480px;
  max-height:80vh;
  padding:20px;
  border-radius:8px;
  position:relative;
  overflow-y:auto;
  box-shadow:0 5px 15px rgba(0,0,0,0.3);
}

.modal-content h2{
  margin-bottom:8px;
  font-size:22px;
  word-break:break-word;
}

.modal-content p{
  margin-bottom:12px;
  line-height:1.6;
}

#modalText{
  white-space:pre-line;
  line-height: 1.1;
}

/* Close button */
.close-btn{
  position:absolute;
  top:10px;
  right:14px;
  font-size:24px;
  cursor:pointer;
  color:#333;
  z-index:1010;
}

/* Scrollbar inside modal */
.modal-content::-webkit-scrollbar{
  width:8px;
}

.modal-content::-webkit-scrollbar-thumb{
  background:rgba(0,0,0,0.3);
  border-radius:4px;
}

/* Responsive adjustments */
@media(max-width:1024px){
  .cards-wrapper{
    grid-template-columns:repeat(2, 1fr); /* 2 per row on tablets */
  }
  :root{
    --card-height:350px;
  }
}

@media(max-width:510px){
  .cards-wrapper{
    grid-template-columns:repeat(1, 1fr); /* 1 per row on mobile */
  }
  :root{
    --card-height:380px;
  }
  .info-bar h3{font-size:16px;}
  .info-bar p{font-size:13px;}
  .overlay{font-size:16px;}
  .modal-content{max-width:95%; padding:15px;}
}

@media(max-width:480px){
  :root{
    --card-height:460px;
  }
  .info-bar h3{font-size:15px;}
  .info-bar p{font-size:12px;}
  .overlay{font-size:14px;}
}