@media screen and (max-width: 1400px) {
  #profile {
    height: 83vh;
    margin-bottom: 6rem;
  }
  .about-containers {
    flex-wrap: wrap;
  }
  #contact,
  #projects {
    height: fit-content;
  }
}

@media screen and (max-width: 1200px) {
  #desktop-nav {
    display: none;
  }
  #hamburger-nav {
    display: flex;
  }
  #experience,
  .experience-details-container {
    margin-top: 2rem;
  }
  #profile,
  .section-container {
    display: block;
  }
  .arrow {
    display: none;
  }
  section,
  .section-container {
    height: fit-content;
  }
  section {
    margin: 0 5%;
  }
  .section__pic-container {
    width: 275px;
    height: 275px;
    margin: 0 auto 2rem;
  }
  .about-containers {
    margin-top: 0;
  }
  #profile {
    padding: 0 4rem;
    gap: 3rem;
  }
  .profile-image {
    max-width: 400px;
    min-width: 400px;
    height: 400px;
  }
  .hero-title {
    font-size: 3rem;
  }
}

@media screen and (max-width: 992px) {
  section {
    padding: 6vh 4rem;
  }
  #profile {
    flex-direction: column;
    gap: 2rem;
    text-align: center;
    padding-top: 6vh;
  }
  .profile-content {
    align-items: center;
  }
  .hero-title {
    font-size: 2.5rem;
  }
  .hero-subtitle {
    max-width: 100%;
  }
  .profile-image {
    max-width: 350px;
    min-width: 350px;
    height: 350px;
    order: -1;
  }
  .profile-buttons {
    justify-content: center;
  }
  #desktop-nav {
    min-width: auto;
    width: 90%;
    max-width: 450px;
  }
  #top-nav .top-nav-container {
    padding: 0 2rem;
  }
}

@media screen and (max-width: 768px) {
  section {
    padding: 6vh 2rem;
  }
  #profile {
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    padding: 100px 2rem 2rem 2rem;
    min-height: calc(100vh - 60px);
  }
  .hero-title {
    font-size: 2.2rem;
  }
  .profile-image {
    max-width: 300px;
    min-width: 300px;
    height: 300px;
  }
  #desktop-nav, #top-nav {
    display: none;
  }
  #hamburger-nav {
    display: flex;
  }
  .about-details-container {
    padding: 0;
  }
  .bento-container {
    grid-template-columns: 1fr;
  }
}

@media screen and (max-width: 576px) {
  section {
    padding: 6vh 1rem;
  }
  #profile {
    padding: 0 1rem;
  }
  .hero-title {
    font-size: 2rem;
  }
  .hero-subtitle {
    font-size: 1rem;
  }
  .profile-buttons {
    flex-direction: column;
    gap: 1rem;
  }
  .cta {
    width: 100%;
  }
  .profile-image {
    max-width: 280px;
    min-width: 280px;
    height: 280px;
  }
  .section__text__p1 {
    font-size: 0.9rem;
  }
  .title {
    font-size: 2rem;
  }
  .text-container p {
    font-size: 1rem;
  }
  .hero-title {
  font-size: 1.8rem;
}

.hero-subtitle {
  font-size: 1rem;
}

.cta {
  width: 100%;
  font-size: 1rem;
  padding: 0.8rem 1.2rem;
}

.resume-btn {
  width: 100%;
  font-size: 1rem;
}

.profile-buttons {
  flex-direction: column;
  gap: 1rem;
  width: 100%;
}

.nav-links li a {
  font-size: 1rem;
}

.hero-title {
  font-size: 1.8rem;
}

.hero-subtitle {
  font-size: 1rem;
}

.cta {
  width: 100%;
  font-size: 1rem;
  padding: 0.8rem 1.2rem;
}

.resume-btn {
  width: 100%;
  font-size: 1rem;
}

.profile-buttons {
  flex-direction: column;
  gap: 1rem;
  width: 100%;
}

.nav-links li a {
  font-size: 1rem;
}
}

@media screen and (max-width: 380px) {
  .hero-title {
    font-size: 1.8rem;
  }
  .profile-image {
    max-width: 250px;
    min-width: 250px;
    height: 250px;
  }
}

@media screen and (max-height: 700px) {
  section {
    padding: 4vh 2rem;
  }
  #profile {
    min-height: 90vh;
  }
}

@media screen and (min-height: 1000px) {
  #profile {
    min-height: 80vh;
  }
}

@media screen and (max-width: 600px) {
  #contact,
  footer {
    height: 40vh;
  }
  #profile {
    height: 83vh;
    margin-bottom: 0;
  }
  article {
    font-size: 1rem;
  }
  footer nav {
    height: fit-content;
    margin-bottom: 2rem;
  }
  .about-containers,
  .contact-info-upper-container,
  .btn-container {
    flex-wrap: wrap;
  }
  .contact-info-container {
    margin: 0;
  }
  .contact-info-container p,
  .nav-links li a {
    font-size: 1rem;
  }
  .experience-sub-title {
    font-size: 1.25rem;
  }
  .logo {
    font-size: 1.5rem;
  }
  .nav-links {
    flex-direction: column;
    gap: 0.5rem;
    text-align: center;
  }
  .section__pic-container {
    width: auto;
    height: 46vw;
    justify-content: center;
  }
  .section__text__p2 {
    font-size: 1.25rem;
  }
  .title {
    font-size: 2rem;
  }
  .text-container {
    text-align: justify;
  }
}

/* Fix z-index stacking */
:root {
  --z-modal: 2000;
  --z-nav: 1000;
  --z-header: 900;
}

.modal { z-index: var(--z-modal); }
#desktop-nav { z-index: var(--z-nav); }
#hamburger-nav { z-index: var(--z-nav); }

/* Improve touch device interaction */
@media (hover: hover) {
  .button:hover {
    transform: translateY(-2px);
  }
}

/* Fix media query overlaps */
@media screen and (max-width: 1200px) { /* ... */ }
@media screen and (max-width: 992px) { /* ... */ }
@media screen and (max-width: 768px) { /* ... */ }
@media screen and (max-width: 576px) { /* ... */ }

/* Prevent layout shifts during transitions */
.project-item {
  contain: layout;
  content-visibility: auto;
}
