/* ---------- selected work: one card per project ----------
   text on the left (title, tags, a line about it, View project), a screenshot on the right sitting in a
   pale frame that crops it at the bottom edge. On phones the screenshot goes on top and the cards stack
   sideways; on large screens they stack downwards. */
.work { display: grid; gap: var(--s-6); padding-block: var(--s-7) var(--s-10); }
.work-card { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); gap: var(--s-8); align-items: center; padding: var(--s-8); border: var(--rule); }
.work-card__title { margin: 0; font-size: calc(clamp(2.25rem, 1.4rem + 2.6vw, 3.75rem) * var(--display-scale)); line-height: .9; }
.work-card__tags { margin: var(--s-3) 0 0; color: var(--accent-ink); }
.work-card__desc { margin: var(--s-5) 0 var(--s-6); max-width: 42ch; color: var(--muted); text-wrap: pretty; }

.work-card__shot { overflow: hidden; padding: var(--s-6) var(--s-6) 0; border: var(--rule); background: var(--surface); }
.work-card__shot img { display: block; width: 100%; height: auto; border: 1px solid var(--line); border-bottom: 0; transform-origin: top center; transition: transform 600ms var(--ease-out); }
.work-card:hover .work-card__shot img { transform: scale(1.03); }

@media (max-width: 900px) {
  .work-card { grid-template-columns: 1fr; gap: var(--s-6); padding: var(--s-5); }
  .work-card__shot { order: -1; padding: var(--s-4) var(--s-4) 0; }

  /* phones: the same stack, sideways. The list scrolls left/right edge to edge and snaps card by card; each card
     sticks 12px further right than the one before, so the next card slides in over it from the right and the
     earlier cards keep a strip of their left edge showing. The next card peeks in at the right edge as a hint.
     work.js scrubs --s to shrink a covered card a little. */
  .work {
    --card-w: calc(100vw - 2 * var(--gutter) - 56px);
    position: relative; display: flex; gap: var(--s-3); overflow-x: auto; overscroll-behavior-x: contain;
    scroll-snap-type: x mandatory; scrollbar-width: none;
    margin-inline: calc(-1 * var(--gutter));
    padding: var(--s-6) calc(var(--gutter) + 32px) var(--s-9) var(--gutter); /* the end padding lets the last card reach its stop */
  }
  .work::-webkit-scrollbar { display: none; }
  /* sticky `left` counts from inside the list's padding, so card n stops n × 12px past the gutter */
  .work-card { flex: 0 0 var(--card-w); position: sticky; left: calc(var(--n, 0) * 12px); background: var(--bg); transform-origin: 0 50%; scale: var(--s, 1); }
  /* snap points: invisible markers where each card sits before it sticks (work.js adds them). Snapping on the
     sticky cards themselves doesn't work, because a stuck card's position moves with the scroll. */
  .work__snap { position: absolute; top: 0; width: 1px; height: 1px; left: calc(var(--gutter) + var(--n) * (var(--card-w) + var(--s-3))); scroll-snap-align: start; scroll-margin-left: calc(var(--gutter) + var(--n) * 12px); pointer-events: none; }
}
@media (min-width: 901px) { .work__snap { display: none; } }

/* stacking: on screens tall enough to hold a whole card, the SELECTED WORK label stays pinned under the nav
   and each card sticks just below it, 28px lower than the card before. The next card slides up over the last,
   and every earlier card keeps a strip of its top edge showing, layer above layer. work.js sets --nav-h and
   --stack-top, and GSAP scrubs --s to shrink a covered card a little (the `scale` property, so it composes
   with the reveal's transform). */
@media (min-width: 901px) and (min-height: 700px) {
  /* white padding above the label gives it room under the nav once pinned (and hides cards passing behind) */
  #work > .eyebrow { position: sticky; top: var(--nav-h, 91px); z-index: 2; padding-top: var(--s-5); background: var(--bg); }
  .work-card { position: sticky; top: calc(var(--stack-top, 160px) + var(--n, 0) * 28px); background: var(--bg); transform-origin: 50% 0; scale: var(--s, 1); }
  /* when the stack reaches the end of the list, the list's bottom edge stops every card at once; extra bottom
     margin on the earlier cards (28px per card after them) makes them stop higher, so the edges stay visible */
  .work { gap: 0; }
  .work-card { margin-bottom: calc(var(--s-6) + (2 - var(--n, 0)) * 28px); }
}
