/* ============================================================
   MEDIA QUERIES — Roland Hidvégi Portfolio
   Breakpoints: 1400px | 1200px | 900px | 600px
   ============================================================ */

/* Global mobile-safe reset */
html, body {
  overflow-x: hidden;
  width: 100%;
  margin: 0;
  padding: 0;
}

* {
  box-sizing: border-box;
}

/* ----------------------------------------------------------
   1400px — Wide laptops / slightly cramped desktops
   ---------------------------------------------------------- */
@media screen and (max-width: 1400px) {
  section {
    margin: 0 4rem;
  }

  #profile {
    height: auto;
    min-height: 80vh;
    margin-bottom: 4rem;
  }

  .about-containers {
    flex-wrap: wrap;
  }

  .toolkit-details-container {
    gap: 1rem;
    padding: 0 0.5rem;
  }
}

/* ----------------------------------------------------------
   1200px — Switch to hamburger nav; tablet-like layout
   ---------------------------------------------------------- */
@media screen and (max-width: 1200px) {
  /* Nav */
  #desktop-nav {
    display: none;
  }

  #hamburger-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    padding: 0.75rem 1rem;
    background-color: white;
    z-index: 1000;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
    margin-top: 0 !important;
    box-sizing: border-box;
  }

  /* Defensive: ensure hamburger nav is visible on small screens */
  #hamburger-nav {
    display: flex !important;
  }

  #hamburger-nav .name-logo {
    display: block;
    font-size: 1.25rem;
    line-height: normal;
    margin-left: 1rem;
    flex: 1;
  }

  .hamburger-menu {
    position: static; /* avoid creating a positioned parent so dropdown anchors to #hamburger-nav */
    height: auto;
    display: flex;
    align-items: center;
    margin: 0;
    padding: 0;
  }

  .hamburger-icon {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    height: 24px;
    width: 30px;
    cursor: pointer;
    z-index: 1002; /* keep icon above dropdown while closed/open */
  }

  /* Anchor dropdown to the bottom edge of the fixed nav bar */
  #hamburger-nav .menu-links {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    width: 100%;
    background-color: white;
    min-width: 0;
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease-in-out;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
    border-radius: 0 0 0.5rem 0.5rem;
    box-sizing: border-box;
  }

  /* Ensure open state expands reliably */
  #hamburger-nav .menu-links.open {
    max-height: 320px; /* slightly larger to accommodate items */
  }

  .menu-links.open {
    max-height: 280px;
  }

  .menu-links ul {
    margin: 0.5rem 0;
    padding: 0;
    list-style: none;
  }

  .menu-links a {
    display: block;
    padding: 0.75rem 1.5rem;
    font-size: 1rem;
    color: black;
    text-decoration: none;
    white-space: nowrap;  /* prevent text wrapping */
  }

  /* All sections must clear the fixed hamburger bar (~60px) */
  section {
    margin: 0 3rem;
  }

  /* First section pushed below the hamburger bar */
  #profile {
    margin-top: 5rem;
  }

  /* Sections that follow profile keep a modest top gap */
  #about,
  #toolkit,
  #projects,
  #contact {
    margin-top: 2rem;
  }

  /* Turn side-by-side layouts into stacked */
  #profile,
  .section-container {
    display: flex;
    flex-direction: column;
    align-items: center;
  }

  #profile {
    gap: 2rem;
    height: auto;
    padding-bottom: 3rem;
  }

  /* Profile image */
  .section__medallion-pic-container {
    width: 260px;
    height: 260px;
    flex-shrink: 0;
  }

  .shape {
    width: 260px;
    height: 260px;
  }

  /* About image */
  #about .section__pic-container {
    width: 260px;
    height: auto;
    margin: 0 auto;
    flex-shrink: 0;
  }

  .about-pic {
    width: 100%;
    height: auto;
    margin: 0 auto;
    display: block;
  }

  /* About details become full-width column */
  #about .about-details-container {
    width: 100%;
  }

  .about-containers {
    flex-direction: column;
  }

  /* General section sizing */
  section,
  .section-container {
    height: fit-content;
  }

  /* Toolkit — allow columns to wrap on tablet */
  .toolkit-details-container {
    flex-wrap: wrap;
    justify-content: center;
  }

  /* Projects — stack image below text */
  .project-details-left,
  .project-details-right {
    flex-direction: column !important;
    align-items: center;
    gap: 1rem;
  }

  .content {
    width: 100%;
    flex: unset;
  }

  .image-container {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    height: 280px;
    flex: unset;
  }

  /* Hide nav arrows on tablet — sections scroll naturally */
  .arrow {
    display: none;
  }

  /* Contact */
  #contact {
    height: auto;
  }

  .section__text__p3 {
    font-size: 1.75rem;
  }

  .menu-links a {
    font-size: 1rem;
    padding: 5px;
  }

}

/* ----------------------------------------------------------
   900px — Smaller tablets / large phones landscape
   ---------------------------------------------------------- */
@media screen and (max-width: 900px) {
  section {
    margin: 0 1.5rem;
  }

  .toolkit-details-container {
    flex-direction: column;
    align-items: center;
  }

  .details-container {
    width: 100%;
    max-width: 480px;
  }

  .image-container {
    height: 240px;
  }

  .about-containers {
    gap: 1rem;
  }

    /* Toolkit – prevent logo clipping on tablets */
    .toolkit-details-container .details-container {
      overflow: visible;
    }
  
    .article-container {
      grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
      gap: 1rem;
    }
  
    article {
      flex-wrap: wrap;
      justify-content: flex-start;
    }
  
    article img {
      max-width: 100%;
      height: auto;
      max-height: 3rem;object-fit: contain;
}
}

/* ----------------------------------------------------------
   600px — Mobile phones
   ---------------------------------------------------------- */
@media screen and (max-width: 600px) {
  /* Base layout */
  html, body {
    overflow-x: hidden;
    width: 100%;
  }

  section {
    margin: 0 1rem;
    padding-left: 0.5rem;
    padding-right: 0.5rem;
    height: auto;
    box-sizing: border-box;
  }

  /* First section clears the fixed hamburger bar */
  #profile {
    margin-top: 5rem;
    padding-bottom: 2rem;
    gap: 1.5rem;
  }

  /* Profile image */
  .section__medallion-pic-container {
    width: 200px;
    height: 200px;
  }

  .shape {
    width: 200px;
    height: 200px;
  }

  /* Typography scale-down */
  .title {
    font-size: 2rem;
  }

  .section__text__p1 {
    font-size: 1.1rem;
  }

  .section__text__p2 {
    font-size: 1.2rem;
    padding-top: 0.5rem;
  }

  .section__text__p3 {
    font-size: 1.5rem;
  }

  .name-logo {
    font-size: 1.4rem;
  }

  /* Buttons */
  .btn-container,
  .button-container {
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.75rem;
  }

  .button {
    width: auto;
    padding: 0.75rem 1.25rem;
    font-size: 0.9rem;
  }

  /* About section */
  #about {
    margin-top: 1.5rem;
  }

  #about .section__pic-container {
    width: 200px;
    height: auto;
    margin: 0 auto 1rem;
  }

  .about-containers {
    flex-direction: column;
    gap: 1rem;
    padding: 0.5rem;
  }

  .details-container {
    width: 100%;
    max-width: 100%;
    padding: 1rem;
    box-sizing: border-box;
    margin: 0 auto;
    overflow: hidden;
  }

  .text-container {
    text-align: justify;
  }

  /* Toolkit – fix logo clipping and reflow on mobile */
  #toolkit {
    overflow-x: hidden;
  }

  .toolkit-details-container {
    flex-direction: column;
    align-items: center;
    width: 100%;
    overflow-x: visible;
    margin: 0 auto;
  }

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

  /* Each details container becomes full width and handles content */
  .details-container {
    width: 100%;
    max-width: 100%;
    padding: 1rem;
    box-sizing: border-box;
    overflow: visible;  /* allow content to be seen, not clipped */
  }

  /* Toolkit – stack logo above text on mobile */
  .article-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
    justify-items: center;
    width: 100%;
  }

  article {
    display: flex;
    flex-direction: column;
    /* stack icon (checkmark) above the logo+text block */
    align-items: center;
    gap: 0.5rem;
    width: 100%;
    padding: 0.5rem;
    text-align: center;
  }

  /* The checkmark icon */
  article>.icon {
    width: 1.5rem;
    height: 1.5rem;
    flex-shrink: 0;
  }

  /* Container for logo + text – now stacked vertically */
  article div {
    display: flex;
    flex-direction: column;
    /* logo above text */
    align-items: center;
    gap: 0.25rem;
    width: 100%;
  }

  /* Logos scale to fit, never overflow */
  article div img {
    max-width: 100%;
    height: auto;
    max-height: 2.8rem;
    /* consistent cap for all logos */
    object-fit: contain;
  }

  /* Slightly taller for MathCad logo (keeps readability) */
  article div img[alt="MathCad logo"] {
    max-height: 3.2rem;
  }

  /* Text label */
  article div p {
    margin: 0;
    font-size: 0.8rem;
    white-space: normal;
  }
}

/* If screen is extremely small, let text wrap */
@media (max-width: 450px) {
  article div {
    flex-wrap: wrap;
    justify-content: flex-start;
  }
  article div p {
    white-space: normal;
  }

  /* Projects */
  #projects {
    margin-top: 1.5rem;
  }

  .project-details-left,
  .project-details-right {
    flex-direction: column !important;
    align-items: center;
    gap: 1rem;
  }

  .content {
    width: 100%;
    flex: unset;
    text-align: justify;
  }

  .content p {
    margin-top: 0.75rem;
  }

  /* Project images — let them be full width but capped height */
  .image-container {
    flex: unset;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    height: 220px;
    position: relative;
    overflow: hidden;
    padding: 0;
  }

  .image-container img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: contain;
    object-position: center;
    display: block;
  }

  /* Override the left/right image alignment rules on mobile — always center */
  .project-details-right .image-container img,
  .project-details-left .image-container img {
    object-position: center;
    margin: 0 auto;
  }

  .project-details-right .image-container img.hover-image,
  .project-details-left .image-container img.hover-image {
    object-position: center;
  }

  .all-projects-container {
    gap: 2rem;
    margin-top: 1.5rem;
    margin-bottom: 2rem;
  }

  /* Contact */
  #contact {
    height: auto;
    padding-bottom: 2rem;
  }

  .contact-info-upper-container {
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    margin: 1rem auto;
    padding: 1rem;
  }

  .contact-info-container {
    margin: 0.25rem;
    justify-content: center;
    width: 100%;
  }

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

  /* Footer */
  footer {
    height: auto;
    padding: 1.5rem 1rem;
    margin: 0;
    box-sizing: border-box;
  }

  footer nav {
    height: fit-content;
    margin-bottom: 1rem;
  }

  footer p {
    margin-top: 1rem;
    font-size: 0.85rem;
  }

  .nav-links {
    flex-direction: column;
    gap: 0.5rem;
    text-align: center;
  }

  .logo,
  .experience-sub-title {
    font-size: 1.1rem;
  }

}

/* ----------------------------------------------------------
   380px — Very small phones (Galaxy Fold, older iPhones)
   ---------------------------------------------------------- */
@media screen and (max-width: 380px) {
  .menu-links a {
    white-space: normal;
    font-size: 1rem;
    padding: 0.6rem 1.2rem;
  }

  .menu-links {
    min-width: 160px;
  }

  section {
    margin: 0 0.5rem;
    padding-left: 0.75rem;
    padding-right: 0.75rem;
  }

  #profile {
    margin-top: 4.5rem;
  }

  .section__medallion-pic-container {
    width: 160px;
    height: 160px;
  }

  .shape {
    width: 160px;
    height: 160px;
  }

  .title {
    font-size: 1.7rem;
  }

  .section__text__p3 {
    font-size: 1.3rem;
  }

  .name-logo {
    font-size: 1.2rem;
  }

  .article-container {
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
  }

  .image-container {
    height: 180px;
  }

  .button {
    padding: 0.6rem 1rem;
    font-size: 0.85rem;
  }
}

/* ----------------------------------------------------------
   Landscape phones — ensure hamburger icon lines have room
   ---------------------------------------------------------- */
@media (orientation: landscape) and (max-width: 900px) {
  /* Increase top/bottom padding of the fixed nav so hamburger lines are not clipped */
  #hamburger-nav {
    padding-top: 1rem !important;
    padding-bottom: 1rem !important;
  }

  /* Make the icon taller and distribute the three bars with more space */
  #hamburger-nav .hamburger-icon {
    height: 34px !important;
    width: 36px !important;
    justify-content: space-around !important;
  }

  /* Slightly thicker bars improve visibility */
  #hamburger-nav .hamburger-icon span {
    height: 3px !important;
    border-radius: 2px;
  }
}

/* Extra safety for very short viewport heights in landscape */
@media (orientation: landscape) and (max-height: 420px) {
  #hamburger-nav {
    padding-top: 1.15rem !important;
    padding-bottom: 1.15rem !important;
  }

  #hamburger-nav .hamburger-icon {
    height: 36px !important;
    width: 38px !important;
    justify-content: space-around !important;
  }

  #hamburger-nav .hamburger-icon span {
    height: 3.2px !important;
  }
}