/* Responsive overrides. Page layout is written as inline styles, so these
   rules use !important to win over them at small widths. */

/* ---------- Header: logo on its own row, nav spread across below ---------- */
@media (max-width: 640px) {
  .site-header {
    flex-wrap: wrap !important;
    justify-content: center !important;
    row-gap: 2px !important;
    padding-top: 8px !important;
    padding-bottom: 6px !important;
  }
  .site-nav {
    width: 100% !important;
    justify-content: space-between !important;
    gap: 8px !important;
    font-size: 12.5px !important;
    letter-spacing: 0.16em !important;
  }
  .site-nav a {
    padding: 10px 0 !important; /* bigger tap targets */
  }
}

/* ---------- Footer: stack and center ---------- */
@media (max-width: 640px) {
  .site-footer {
    grid-template-columns: 1fr !important;
    justify-items: center !important;
    text-align: center !important;
    gap: 14px !important;
    padding-top: 24px !important;
    padding-bottom: calc(24px + env(safe-area-inset-bottom, 0px)) !important;
  }
  footer.site-footer:not([style*="grid"]) {
    flex-direction: column !important;
  }
  .site-footer > div:last-child {
    justify-content: center !important;
  }
}

/* ---------- Home: let the page scroll instead of clipping at 100vh ---------- */
@media (max-width: 760px) {
  .home-shell {
    height: auto !important;
    min-height: 100svh !important;
    overflow: visible !important;
  }
  .home-hero {
    flex: 0 0 auto !important;
  }
  .home-hero-grid {
    grid-template-columns: 1fr !important;
    height: auto !important;
    padding-top: 28px !important;
    padding-bottom: 36px !important;
    row-gap: 8px !important;
  }
  /* "Software developer" script: move below the intro instead of overlapping it */
  .home-hero-art {
    justify-self: center !important;
    align-items: center !important;
    padding-right: 0 !important;
    order: -1;
  }
  .home-hero-art img {
    width: min(76vw, 340px) !important;
    max-height: none !important;
    margin-right: 0 !important;
  }
  .home-hero-art {
    margin-bottom: 14px;
  }
  /* Center the photo, intro, and buttons under the script */
  .home-hero-intro {
    align-items: center !important;
    text-align: center !important;
    max-width: none !important;
  }
  .home-hero-photo {
    width: min(72vw, 280px) !important;
    height: auto !important;
    aspect-ratio: 14 / 15;
  }
  .home-hero-actions {
    flex-direction: column !important;
    align-items: stretch !important;
    width: min(100%, 300px) !important;
  }
  .home-hero-actions a {
    justify-content: center !important;
  }
}

/* ---------- Home, tablet / half-width window: wider landscape photo, buttons in a row ---------- */
@media (min-width: 561px) and (max-width: 760px) {
  .home-hero-photo {
    width: min(80vw, 460px) !important;
    aspect-ratio: 4 / 3;
  }
  .home-hero-intro p {
    max-width: 52ch !important;
  }
  .home-hero-actions {
    flex-direction: row !important;
    justify-content: center !important;
    width: 100% !important;
  }
}

/* ---------- About: one timeline entry per row ---------- */
@media (max-width: 640px) {
  .story-grid {
    grid-template-columns: 1fr !important;
  }
  .story-grid > div {
    padding-right: 0 !important;
  }
}

/* ---------- About: free-time photos swipe in one row instead of wrapping unevenly ---------- */
@media (max-width: 820px) {
  .photo-strip {
    display: flex !important;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    margin-left: calc(-1 * clamp(20px, 4.5vw, 56px)) !important;
    margin-right: calc(-1 * clamp(20px, 4.5vw, 56px)) !important;
    padding: 0 clamp(20px, 4.5vw, 56px);
    scroll-padding: 0 clamp(20px, 4.5vw, 56px);
  }
  .photo-strip::-webkit-scrollbar { display: none; }
  .photo-strip > div {
    flex: 0 0 min(42%, 220px);
    scroll-snap-align: start;
  }
}

/* ---------- Project: sidebar above the write-up ---------- */
@media (max-width: 720px) {
  .project-grid {
    grid-template-columns: 1fr !important;
  }
}

/* ---------- Service pages: heading above its section ---------- */
@media (max-width: 720px) {
  .svc-row {
    grid-template-columns: 1fr !important;
  }
}
