/* Smaller screens: keep these rules after the page's original stylesheet. */
@media (max-width: 1100px) {
  nav.nav {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 0 8px;
    padding: 8px 20px;
    align-items: center;
  }

  nav.nav > a {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 0;
    min-height: 44px;
  }

  nav.nav .Portfolio {
    position: static;
    transform: none;
    margin: 0;
    grid-column: 1 / 4;
    grid-row: 1;
    justify-content: flex-start;
  }

  nav.nav .instagram {
    position: static;
    transform: none;
    grid-column: 4;
    grid-row: 1;
    justify-self: end;
    width: 44px;
  }

  nav.nav > a:not(.Portfolio):not(.instagram) {
    grid-row: 2;
  }

  .projects-header,
  .projects-content {
    padding-left: 6%;
    padding-right: 6%;
  }

  .projects-intro {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1.5fr);
    gap: 32px;
  }

  .project {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 28px 20px;
  }

  /* Release the desktop-only fixed height and internal scrolling. */
  body:has(.about-me) {
    height: auto;
    min-height: 100vh;
    overflow: visible;
    background-attachment: scroll;
  }

  .about-me {
    flex: none;
    padding: 32px 6%;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1.5fr);
    gap: 40px;
  }

  .left-about-me {
    left: auto;
    top: auto;
  }

  .right-about-me {
    overflow: visible;
    padding-right: 0;
  }

  #choose-discovered-past:checked ~ .projects-header label[for="choose-discovered-past"],
  #choose-new-city:checked ~ .projects-header label[for="choose-new-city"],
  #choose-polaroids:checked ~ .projects-header label[for="choose-polaroids"],
  #choose-other-works:checked ~ .projects-header label[for="choose-other-works"] {
    color: #222;
    text-decoration: underline;
    text-underline-offset: 6px;
  }

  #choose-discovered-past:focus-visible ~ .projects-header label[for="choose-discovered-past"],
  #choose-new-city:focus-visible ~ .projects-header label[for="choose-new-city"],
  #choose-polaroids:focus-visible ~ .projects-header label[for="choose-polaroids"],
  #choose-other-works:focus-visible ~ .projects-header label[for="choose-other-works"] {
    outline: 2px solid #555;
    outline-offset: 4px;
  }
}

@media (max-width: 700px) {
  body {
    height: auto;
    min-height: 100vh;
    min-height: 100svh;
    display: flex;
    flex-direction: column;
    background-attachment: scroll;
  }

  body.home-page {
    background-image: url("static/welcome-mobile.png");
    background-color: #fff;
    background-size: 100% auto;
    background-position: center;
    background-repeat: no-repeat;
  }

  body > header {
    flex-shrink: 0;
  }

  nav.nav {
    padding: 8px 16px;
    gap: 0 4px;
  }

  nav.nav > a {
    font-size: 15px;
  }

  nav.nav .Portfolio {
    font-size: 20px;
  }

  .projects-header,
  .projects-content,
  .about-me {
    box-sizing: border-box;
    width: 100%;
    padding: 28px 20px;
  }

  .projects-header h1 {
    font-size: 30px;
    margin-bottom: 20px;
  }

  .projects-intro,
  .about-me {
    grid-template-columns: minmax(0, 1fr);
    gap: 28px;
  }

  .projects-categories {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 4px 12px;
  }

  .category-button {
    display: flex;
    align-items: center;
    min-height: 44px;
    box-sizing: border-box;
    padding: 8px 0;
    font-size: 15px;
  }

  .projects-description p,
  .about-me-intro p {
    font-size: 16px;
    line-height: 1.7;
  }

  .projects img {
    height: auto;
    aspect-ratio: auto;
  }

  .project a {
    scroll-margin-top: 120px;
  }

  .about-me {
    padding-bottom: 40px;
  }

  .left-about-me p {
    font-size: 16px;
  }

  .experience-position-time {
    flex-direction: column;
  }

  .contact-main {
    min-width: 0;
    padding: 20px;
  }

  .contact-form {
    min-width: 0;
    max-width: 340px;
    padding: 20px 16px;
    gap: 8px;
    border-radius: 18px;
  }

  .contact-form h1 {
    margin: 0 0 8px;
    font-size: 24px;
    line-height: 1.25;
  }

  .contact-form label {
    margin-bottom: 0;
    font-size: 14px;
  }

  .contact-form input {
    margin-bottom: 4px;
  }

  .contact-form input,
  .contact-form button {
    min-width: 0;
    min-height: 44px;
    font-size: 16px;
  }

  footer {
    box-sizing: border-box;
    position: static;
    padding: 20px 16px;
    font-size: 13px;
    line-height: 1.5;
  }

  footer p {
    margin: 0;
  }

  header.top ~ footer {
    margin-top: auto;
  }

  .lightbox {
    padding: 64px 12px 24px;
  }

  .lightbox-close {
    display: flex;
    align-items: center;
    justify-content: center;
    top: max(12px, env(safe-area-inset-top));
    right: 12px;
    width: 44px;
    height: 44px;
  }
}

@media (max-width: 600px) {
  .project {
    grid-template-columns: minmax(0, 1fr);
    gap: 24px;
  }
}
