@import url("colors.css");

.modal {
display: none;
position: fixed; 
z-index: 9999; 
padding-top: 60px; 
left: 0; top: 0;
width: 100%; height: 100%; 
overflow: auto; 
background-color: rgba(0,0,0,0.8);
}

.modal-content {
margin: auto;
display: block;
max-width: 90%;
max-height: 80%;
}

#caption {
text-align: center;
color: var(--text1);
padding: 10px 0;
}

.close {
position: absolute;
top: 30px; right: 45px;
color: var(--text1) !important;
font-size: 40px;
font-weight: bold;
cursor: pointer;
}

.close:hover, .arrow:hover { color: var(--priAcc); }

.arrow {
cursor: pointer;
position: absolute;
top: 50%;
width: auto;
margin-top: -22px;
padding: 16px;
color: var(--text1);
font-weight: bold;
font-size: 30px;
user-select: none;
-webkit-user-select: none;
}

.arrow.left {
left: 20px;
}

.arrow.right {
right: 20px;
}

figure {
display: inline-block;
margin: 10px;
max-width: 200px;  
}

img.thumb {
max-width: 100%;
cursor: pointer;
display: block;
}

media.thumb {
max-width: 100%;
cursor: pointer;
display: block;
}

.gallery {
  display: flex;
  flex-wrap: wrap;
  gap: 20px; /* space between images */
  justify-content: center; 
  padding: 20px 10px;
  
}

.gallery figure.landscape {
  flex: 2 1 400px;  /* Bigger size for landscape */
  max-width: 450px;
}

.gallery figure.portrait {
  flex: 1 1 200px;  /* Smaller size for portrait */
  max-width: 350px;
}

.gallery figure {
  margin: 0px;
  background: var(--bkg2);
  overflow: hidden;
  box-shadow: 0 4px 8px rgba(0,0,0,0.1);
  transition: transform 0.3s ease, box-shadow 0.3s ease;
  flex: 1 1 300px; /* Responsive: grows/shrinks, min 300px */
  max-width: 350px;
  border: 2px solid var(--pri) !important;

}

.gallery figure:hover {
  transform: translateY(-5px);
  box-shadow: 0 8px 25px rgba(0,0,0,0.15);
}

/* Universal thumbnail styling - applies to BOTH <img> and <video> */
.gallery .thumb {
  width: 100%;
  height: 300px; /* Fixed height for uniform grid */
  object-fit: cover; /* Crops images/videos to fill space perfectly */
  cursor: pointer;
  display: block;
  border: none;
}

/* Video thumbnail specific tweaks */
.gallery video.thumb {
  background: #000; /* Black background if video fails to load frame */
}

/* Figcaption styling */
.gallery figcaption {
  padding: 12px;
  font-size: 14px;
  font-weight: 1500;
  color: var(--text1);
  text-align: center;
  background: var(--bkg2);
  border-top: 2px solid var(--pri) !important;
}

#caption {
  color: var(--text1);
  text-align: center;
  padding: 20px 10px;
  font-size: 18px;
}


/* Responsive breakpoints */
@media (max-width: 768px) {
  .gallery figure {
    flex: 1 1 250px;
    max-width: 300px;
  }
  
  .modal-content {
    max-width: 80% !important;    /* Less coverage */
    max-height: 75%;
  }
  
  .gallery .thumb {
    height: 180px;
  }
}

@media (max-width: 480px) {
  .gallery {
    gap: 15px;
    padding: 15px 5px;
  }
  
  /* ← FIX: Even smaller modal on tiny screens */
  .modal-content {
    max-width: 80% !important;
    max-height: 70%;
  }

  .gallery figure {
    flex: 1 1 100%;
    max-width: none;
  }
  
  .gallery .thumb {
    height: 250px;
  }
}

/* kill any rounded corners or borders on the modal media */
#myModal,
#myModal .modal-content,
#modalImage,
#modalVideo {
  border-radius: 0 !important;
  border: none !important;
  outline: none !important;
}

@media screen and (max-width: 768px) and (-webkit-min-device-pixel-ratio: 1) {
  .modal-content {
    max-width: 82% !important;
    max-height: 70%;
  }
  
  .arrow.left {
    left: 8px !important;
  }
  
  .arrow.right {
    right: 8px !important;
  }
}

@media screen and (max-width: 480px) and (-webkit-min-device-pixel-ratio: 1) {
  .modal-content {
    max-width: 88% !important;
    max-height: 65%;
  }
  
  .arrow.left {
    left: 3px !important;
  }
  
  .arrow.right {
    right: 3px !important;
  }
}

/* Also target high-DPI phones */
@media screen and (max-width: 768px) and (-webkit-min-device-pixel-ratio: 2), 
       screen and (max-width: 768px) and (-webkit-min-device-pixel-ratio: 3) {
  .arrow {
    font-size: 26px !important;
    padding: 12px !important;
  }
}