/* Masonry Grid Layout */
.matric-portrait-grid {
  column-count: 3;
  column-gap: 1rem;
  column-fill: balance; /* Try to equalize column heights */
  padding: 0 2% 2rem;
  background-color: #262a2d;
}

.matric-grid-item {
  position: relative;
  overflow: hidden;
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  transition: transform 0.3s ease, box-shadow 0.3s ease;
  cursor: pointer;
  break-inside: avoid;
  margin-bottom: 1rem;
  display: inline-block;
  width: 100%;
}

.matric-grid-item:hover {
  transform: translateY(-5px);
  box-shadow: 0 8px 16px rgba(0, 0, 0, 0.2);
}

.matric-grid-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.3s ease;
}

.matric-grid-item:hover img {
  transform: scale(1.05);
}

  /*PORTRAIT CONTACT SECTION*/
.matric-contact-section {
    width: 100%;
    height: 100vh;
    background: url("../images/matric/matric_last_section.webp") center/cover no-repeat;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    padding-left: 5em;
    color: white;
    position: relative;
}

.matric-contact-content {
    position: absolute;
    bottom: 5rem;
    right: 7rem;
    max-width: 30em;
    text-align: center;
}

.matric-contact-content h2 {
    font-size: 3em;
    font-weight: 400;
    text-shadow: 2px 2px 6px rgba(0, 0, 0, 0.3);
    margin-bottom: 20px;
    line-height: 1.1;
}

.matric-contact-content p{
    font-size: 1.2em;
    text-shadow: 2px 2px 6px rgba(0, 0, 0, 0.9);
}

.matric-contact-button {
    position: absolute;
    top: -28rem;
    right: 8rem;
    background-color: transparent;
    color: white;
    padding: 1em 4em;
    border: 2px solid white;
    font-weight: 600;
    font-size: 1.1em;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.3s ease;
    border: 1.5px solid white;
    border-radius: 0.5em;
    cursor: pointer;
    transition: background 0.3s ease;
}

.matric-contact-button:hover {
  background-color: #ffffff;
  color: black;
}

/* Mobile Contact Section Responsive Styles */
@media (max-width: 768px) {
  .matric-contact-section {
    height: 100vh;
    background-position: 40% center;
    background-size: cover;
    padding: 2rem 1rem;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    position: relative;
  }

  /* Add dark overlay for better text readability on mobile */
  .matric-contact-section::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.45);
    z-index: 1;
  }
  
  .matric-contact-content {
    position: relative;
    bottom: auto;
    right: auto;
    max-width: 100%;
    width: 100%;
    padding: 0 1rem 2rem;
    text-align: center;
    z-index: 2;
    color: white;
  }
  
  .matric-contact-content h2 {
    font-size: 2em;
    margin-bottom: 1rem;
    color: white;
  }
  
  .matric-contact-content p {
    font-size: 1em;
    line-height: 1.5;
    color: white;
  }
  
  .matric-contact-button {
    position: static;
    top: auto;
    right: auto;
    display: block;
    margin: 0 auto 2rem;
    padding: 0.8em 2.5em;
    font-size: 1em;
    background-color: white;
    color: black;
    font-weight: 600;
  }
}

/* Tablet Contact Section */
@media (min-width: 769px) and (max-width: 1024px) {
  .matric-contact-section {
    padding: 3rem;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    position: relative;
    background-position: 35% center;
  }
  
  /* Add dark overlay for better text readability on tablet */
  .matric-contact-section::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.45);
    z-index: 1;
  }
  
  .matric-contact-content {
    position: relative;
    right: auto;
    bottom: auto;
    max-width: 30em;
    text-align: center;
    z-index: 2;
    color: white;
    padding-bottom: 3rem;
  }
  
  .matric-contact-content h2 {
    font-size: 2.5em;
    color: white;
  }
  
  .matric-contact-content p {
    font-size: 1.1em;
    color: white;
  }
  
  .matric-contact-button {
    position: static;
    top: auto;
    right: auto;
    display: inline-block;
    padding: 0.9em 3em;
    background-color: white;
    color: black;
    font-weight: 600;
  }
}

/* Mobile - Single Column */
@media (max-width: 768px) {
  .matric-portrait-grid {
    column-count: 1;
    padding: 0 3% 2rem;
  }
}

/* Tablet - 2 columns */
@media (min-width: 769px) and (max-width: 1024px) {
  .matric-portrait-grid {
    column-count: 2;
  }
}

/* Desktop - 3 columns */
@media (min-width: 1025px) {
  .matric-portrait-grid {
    column-count: 3;
  }
}

/* Laptop button positioning */
@media (max-width: 1600px) {
  .matric-contact-button {
    top: -25rem;
    right: 8rem;
  }
}

/* Image Modal - ensure it appears above header */
.image-modal {
  z-index: 9999;
}
