/* Native scrolling owns momentum and alignment. Pausing motion disables both. */
html.scroll-motion-paused {
  scroll-snap-type: none;
  scroll-behavior: auto;
}

/* Keep portfolio expansion and its controls in a stable document flow. */
#work.work-section {
  justify-content: flex-start;
  scroll-snap-align: none;
  overflow-anchor: auto;
}

#work .project-grid {
  align-items: start;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 32px;
}

#work .project-grid > .project-card {
  margin: 0;
  min-width: 0;
  scroll-snap-align: none;
}

#work .work-bottom {
  flex-wrap: wrap;
  gap: 14px 24px;
  margin-block: 26px 0;
}

#work #more-projects {
  margin-block: 32px 0;
}

#more-work {
  flex-shrink: 0;
  white-space: nowrap;
  min-inline-size: 187px;
  justify-content: space-between;
}

/* The category has its own row, clear of the website image at every width. */
#work .project-image {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: flex-start;
  gap: 18px;
  height: auto;
  min-height: 0;
  aspect-ratio: auto;
  padding: 23px 26px 30px;
}

#work .project-tag {
  position: relative;
  inset: auto;
  z-index: 2;
  flex-shrink: 0;
  font-size: 10px;
  line-height: 1.5;
}

#work .browser-mock {
  flex: 0 0 auto;
  min-width: 0;
  width: 100%;
}

#work .project-open {
  right: 15px;
  bottom: 12px;
  z-index: 2;
  background: var(--paper);
}

/* The dialog scrolls beneath a persistent, opaque close bar. */
#project-dialog {
  overflow-y: auto;
  overscroll-behavior: contain;
  scroll-padding-top: 90px;
  scrollbar-gutter: stable;
}

#project-dialog > .dialog-top {
  position: sticky;
  top: 0;
  z-index: 5;
  flex-shrink: 0;
  background: var(--paper);
}

#project-dialog .dialog-close {
  flex-shrink: 0;
}

@media (max-width: 760px) {
  #work .project-grid {
    grid-template-columns: minmax(0, 1fr);
    gap: 30px;
  }

  #work #more-projects {
    margin-top: 30px;
  }

  #work .project-image {
    gap: 17px;
    padding: 19px 20px 27px;
  }

  #work .project-tag {
    font-size: 9px;
    letter-spacing: .08em;
  }

  #project-dialog {
    scroll-padding-top: 80px;
  }
}
