*{
    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*/
  .graduation-contact-section {
    width: 100%;
    height: 90vh;
    background: url("../images/graduation/graduation-contact.webp") center/cover no-repeat;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    padding-left: 5em;
    color: white;
    position: relative;
  }
  
  .graduation-contact-content {
    position: absolute;
    padding-top: 5em;
    right: 10em;
    max-width: 25em;
    text-align: center;
  }
  
  .graduation-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;
  }
  
  .graduation-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) {
    .graduation-contact-section {
      height: clamp(60vh, 80vh, 90vh);
      background-position: center 30%; /* Better focal point for mobile */
      padding: clamp(1em, 5vw, 3em);
      justify-content: center;
      align-items: center;
      padding-left: 0;
      position: relative;
    }

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

    .graduation-contact-content {
      position: static; /* Remove absolute positioning on mobile */
      max-width: 90%;
      width: 100%;
      text-align: center;
      padding-top: 0;
      right: auto;
      position: relative;
      z-index: 2; /* Ensure content is above overlay */
    }

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

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

  @media (max-width: 768px) {
    .graduation-contact-section {
      height: clamp(50vh, 70vh, 80vh);
      background-position: center 25%; /* Even better focal point for small screens */
    }

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

  @media (max-width: 480px) {
    .graduation-contact-section {
      height: clamp(45vh, 60vh, 70vh);
      background-position: center 20%; /* Optimal focal point for very small screens */
      padding: clamp(0.5em, 3vw, 1.5em);
    }

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

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

  .portrait-grid .grad-clipped{
    object-fit: cover;
    height: 29em;
    width: 100%;
    object-position: top;
  }

  /* 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%;
    }
  }