/* ============================
   GLOBAL RESPONSIVE OVERRIDES
   ============================ */

@media (max-width: 1200px) {
  /* Swap desktop to hamburger */
  #desktop-nav {
    display: none;
  }
  #hamburger-nav {
    display: flex;
  }

  /* Sections: no fixed vh, consistent smaller vertical gaps on smaller screens */
  section {
    height: auto;
    margin: var(--section-gap-sm) 0;
    padding: 56px 20px;
  }

  /* Profile stacks */
  #profile {
    flex-direction: column;
    height: auto;
    gap: 2rem;
    padding-top: 24px;
  }

  .section__pic-container {
    width: 260px;
    height: 260px;
    margin: 0 auto;
  }

  .section__text {
    width: 100%;
  }

  .section__text p {
    text-align: left;
  }
}

@media (max-width: 992px) {
  section {
    padding: 52px 18px;
  }

  /* About stacks */
  .about-containers {
    flex-direction: column;
    gap: 1.25rem;
  }

  .about-details-container {
    width: 100%;
    gap: 1rem;
  }

  /* Experience: single column */
  .experience-details-container {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1rem;
  }

  /* Projects and Certifications cards full width */
  .details-container,
  .color-container {
    width: 100%;
    max-width: 100%;
  }

  /* Prevent image cards from overflowing */
  .project-img {
    width: 100%;
    max-width: 100%;
  }
}

@media (max-width: 768px) {
  :root {
    --pad: 16px;
  }

  /* Titles scale nicely */
  .title {
    font-size: 2.2rem;
  }
  .logo {
    font-size: 1.5rem;
  }

  /* Buttons wrap nicely */
  .btn-container {
    flex-wrap: wrap;
    gap: 10px;
  }
  .btn {
    width: min(260px, 100%);
  }
  /* Demo buttons: match main button responsive behavior */
  .demo-btn {
    width: min(260px, 100%);
  }

  /* Modal responsive tweaks */
  .video-modal__content {
    max-width: 720px;
    padding: 0;
  }
  .video-modal {
    padding: 0.75rem;
  }
  .video-modal__close {
    right: 0.5rem;
    top: 0.5rem;
    width: 2rem;
    height: 2rem;
    font-size: 1rem;
  }

  /* Ensure video fits inside the viewport and stays centered */
  .video-wrapper {
    padding-top: 0; /* disable 16:9 padding trick on smaller screens */
    height: auto;
    display: flex;
    align-items: center;
    justify-content: center;
  }
  .video-wrapper video {
    position: relative;
    width: 100%;
    height: auto;
    max-height: calc(100vh - 8rem);
    object-fit: contain;
  }

  /* About paragraph readability */
  #about .text-container p,
  .about-details-container .text-container p {
    text-align: left;
  }

  /* Contact stacks */
  .contact-info-upper-container {
    flex-direction: column;
    gap: 0.75rem;
    width: calc(100% - 48px);
    max-width: 400px;
    padding: 1.25rem;
    margin: 0.75rem auto;
    border-radius: 1rem;
    background-color: #f1f1f1;
  }

  .contact-info-container {
    justify-content: center;
  }

  .contact-info-container p {
    font-size: 1rem;
  }
}

@media screen and (max-width: 600px) {
  html,
  body {
    width: 100%;
    overflow-x: hidden;
    position: relative;
  }

  #experience,
  .experience-details-container,
  .about-containers {
    width: 100%;
    margin-left: 0;
    margin-right: 0;
  }

  .about-containers,
  .experience-details-container {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    width: 100%;
    height: auto;
  }

  .details-container {
    width: 100% !important;
    margin: 0 auto;
    padding: 1.5rem;
  }

  .article-container {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 1rem;
  }

  #experience {
    height: auto;
    margin-top: 2rem;
    padding: 0 1rem;
  }

  section {
    padding: 44px 14px;
  }

  .section__pic-container {
    width: 220px;
    height: 220px;
  }

  footer {
    height: auto;
    margin: 0;
    padding: 24px 14px;
  }

  /* Tap targets + avoid overflow */
  .nav-links li a,
  .menu-links a {
    font-size: 1.05rem;
  }

  /* Make contact info container narrower and centered on small screens */
  .contact-info-upper-container {
    width: calc(100% - 40px);
    max-width: 320px;
    margin: 0.75rem auto;
    padding: 1rem;
  }

  /* Footer nav: keep all links on one line and tighten spacing */
  footer .nav-links {
    display: flex;
    gap: 0.5rem;
    justify-content: center;
    flex-wrap: nowrap; /* prevent wrapping */
    padding: 0;
    align-items: center;
  }

  footer .nav-links li {
    white-space: nowrap; /* keep each link on one line */
    margin: 0 0.4rem;
    flex: 0 1 auto;
  }

  footer .nav-links a {
    font-size: 0.95rem;
    padding: 0 0.25rem;
  }

  /* Keep footer paragraph in one line on small screens */
  footer p {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: 0.95rem;
    margin: 0.5rem 0 0;
  }
}

@media (max-width: 420px) {
  section {
    padding: 40px 12px;
  }
  .title {
    font-size: 1.9rem;
  }

  /* 320px safety: prevent horizontal overflow */
  .btn,
  .demo-btn {
    width: min(260px, 100%);
  }

  /* Project buttons on small screens: stack vertically and each occupy half the width */
  .details-container .btn-container {
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
  }
  .details-container .btn-container .btn {
    width: 50%;
    max-width: 260px;
    /* Ensure text stays horizontal and centered */
    white-space: nowrap;
    display: inline-flex;
    justify-content: center;
    align-items: center;
    text-align: center;
    min-width: 120px;
  }

  /* Modal responsive tweaks for very small screens */
  .video-modal__content {
    max-width: calc(100% - 1rem);
    border-radius: 6px;
  }
  .video-modal {
    padding: 0.5rem;
  }
  .video-modal__close {
    right: 0.5rem;
    top: 0.5rem;
    width: 1.8rem;
    height: 1.8rem;
    font-size: 0.9rem;
  }

  /* Small-screen video fit and centering */
  .video-wrapper {
    padding-top: 0;
    height: auto;
    display: flex;
    align-items: center;
    justify-content: center;
  }
  .video-wrapper video {
    position: relative;
    width: calc(100% - 1rem);
    height: auto;
    max-height: calc(100vh - 6rem);
    object-fit: contain;
  }

  .contact-info-upper-container {
    padding: 0.9rem;
    width: calc(100% - 28px);
    max-width: 280px;
    margin: 0.5rem auto;
    border-radius: 0.75rem;
    background-color: #f1f1f1;
  }

  /* Further reduce footer nav font-size/gap on very small screens to prevent wrapping */
  footer .nav-links {
    gap: 0.4rem;
  }
  footer .nav-links a {
    font-size: 0.9rem;
  }

  footer p {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: 0.85rem;
    margin: 0.4rem 0 0;
  }

  /* Make sure nothing forces a wide layout */
  .project-resume {
    max-width: 100%;
  }
}
