*{
  box-sizing: border-box;
}

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

.portrait-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%;
}

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

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

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

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

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

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

  .portrait-grid img {
    border-radius: 4px;
  }
}

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


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

/* Add semi-transparent overlay for better text readability */
.portrait-contact-section::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.35); /* 35% dark overlay */
  z-index: 1;
}

.portrait-contact-content {
  padding-top: 20em;
  max-width: 40em;
  text-align: center;
  position: relative;
  z-index: 2; /* Ensure content appears above overlay */
}

.portrait-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;
}

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

/* Mobile optimizations for contact section */
@media (max-width: 1024px) {
  .portrait-contact-section {
    height: clamp(60vh, 80vh, 90vh);
    background-position: center 30%; /* Better focal point for mobile/tablet */
    padding: clamp(1em, 5vw, 3em);
    justify-content: center;
    align-items: center;
    text-align: center;
  }

  .portrait-contact-content {
    padding-top: 0;
    max-width: 90%;
    width: 100%;
  }

  .portrait-contact-content h2 {
    font-size: clamp(2em, 8vw, 3em);
    margin-bottom: clamp(1em, 4vw, 1.5em);
  }

  .portrait-contact-content p {
    font-size: clamp(1em, 4vw, 1.2em);
    line-height: 1.5;
    margin-bottom: clamp(1.5em, 6vw, 2em);
  }
}

/* Mobile-only background position adjustment */
@media (max-width: 768px) {
  .portrait-contact-section {
    background-position: 60% 30%; /* Shifted to show more left side for mobile only */
  }
}

@media (max-width: 768px) {
  .portrait-contact-section {
    height: clamp(50vh, 70vh, 80vh);
    background-position: 60% 25%; /* Show more left side for small screens */
  }

  .portrait-contact-content {
    max-width: 95%;
  }
}

@media (max-width: 480px) {
  .portrait-contact-section {
    height: clamp(45vh, 60vh, 70vh);
    background-position: 60% 20%; /* Show more left side for very small screens */
    padding: clamp(0.5em, 3vw, 1.5em);
  }

  .portrait-contact-content h2 {
    font-size: clamp(1.8em, 7vw, 2.5em);
    line-height: 1.2;
  }

  .portrait-contact-content p {
    font-size: clamp(0.9em, 3.5vw, 1.1em);
  }
}

/* Image Modal Styles */
.image-modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.95);
  z-index: 9999;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.image-modal.active {
  display: flex;
  opacity: 1;
  align-items: center;
  justify-content: center;
}

.modal-content {
  position: relative;
  max-width: 90%;
  max-height: 90%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-content img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  border-radius: 8px;
}

.modal-close {
  position: absolute;
  top: 20px;
  right: 20px;
  background: rgba(255, 255, 255, 0.2);
  border: none;
  color: white;
  font-size: 1.5em;
  padding: 12px;
  border-radius: 50%;
  cursor: pointer;
  z-index: 10001;
  transition: background-color 0.3s ease;
  backdrop-filter: blur(10px);
}

.modal-close:hover {
  background: rgba(255, 255, 255, 0.3);
}

.modal-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(255, 255, 255, 0.2);
  border: none;
  color: white;
  font-size: 1.2em;
  padding: 15px 12px;
  border-radius: 50%;
  cursor: pointer;
  z-index: 10001;
  transition: all 0.3s ease;
  backdrop-filter: blur(10px);
}

.modal-prev {
  left: 20px;
}

.modal-next {
  right: 20px;
}

.modal-nav:hover {
  background: rgba(255, 255, 255, 0.3);
  transform: translateY(-50%) scale(1.1);
}

.modal-nav:active {
  transform: translateY(-50%) scale(0.95);
}

/* Mobile optimizations for modal */
@media (max-width: 768px) {
  .modal-close {
    top: 15px;
    right: 15px;
    font-size: 1.3em;
    padding: 10px;
  }

  .modal-nav {
    font-size: 1.1em;
    padding: 12px 10px;
  }

  .modal-prev {
    left: 15px;
  }

  .modal-next {
    right: 15px;
  }

  .modal-content {
    max-width: 95%;
    max-height: 85%;
  }
}