/* =============================================================
   Bento gallery — the homepage "Selected work" strip.
   A two-row bento that runs edge to edge and scrolls sideways;
   the first tile lines up with the section heading.
   ============================================================= */
.bgal__hint { margin: -1.1rem 0 0; font-size: .875rem; color: var(--fg-muted); }

.bgal { position: relative; width: 100vw; margin-left: calc(50% - 50vw); margin-top: 1.75rem; }
.bgal__rail {
  --tile: clamp(13rem, 19vw, 16.5rem);
  display: grid; grid-auto-flow: column dense; grid-template-rows: repeat(2, var(--tile)); grid-auto-columns: var(--tile);
  gap: 14px; overflow-x: auto; overscroll-behavior-x: contain; scrollbar-width: none;
  padding: 6px max(var(--pad), calc((100vw - var(--narrow)) / 2 + var(--pad))) 18px;
  scroll-padding-inline: max(var(--pad), calc((100vw - var(--narrow)) / 2 + var(--pad)));
  cursor: grab; -webkit-user-select: none; user-select: none; }
.bgal__rail::-webkit-scrollbar { display: none; }
.bgal__rail.is-dragging { cursor: grabbing; }
.bgal__rail.is-dragging .bg-t { pointer-events: none; }

/* a tile: the image fills it; title and project rise in on hover */
.bg-t { position: relative; display: block; padding: 0; margin: 0; border: 1px solid var(--border-2, rgba(17,17,17,.1)); border-radius: 18px;
  overflow: hidden; background: var(--bg-elev); cursor: pointer; color: #fff; font: inherit; text-align: left;
  box-shadow: 0 1px 2px rgba(40,30,20,.06);
  transition: transform .45s cubic-bezier(.2,.9,.3,1.15), box-shadow .35s ease, opacity .6s ease;
  transform: translateY(20px) scale(.95); opacity: 0; transition-delay: calc(var(--i, 0) * 70ms); }
.bgal.is-in .bg-t { transform: none; opacity: 1; }
.bgal.is-in .bg-t:hover { transform: scale(1.02); box-shadow: 0 22px 44px -24px rgba(40,32,20,.5); transition-delay: 0s; }
.bg-t--big { grid-column: span 2; grid-row: span 2; }
.bg-t--tall { grid-row: span 2; }
.bg-t--wide { grid-column: span 2; }
.bg-t img, .bg-t video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; display: block;
  -webkit-user-drag: none; transition: transform .5s ease; }
.bg-t:hover img, .bg-t:hover video { transform: scale(1.05); }
.bg-t::after { content: ""; position: absolute; inset: 0; pointer-events: none; opacity: 0; transition: opacity .5s ease;
  background: linear-gradient(to top, rgba(0,0,0,.8), rgba(0,0,0,.4) 45%, transparent); }
.bg-t__cap { position: absolute; left: 16px; right: 16px; bottom: 14px; z-index: 1; opacity: 0; transform: translateY(14px);
  transition: opacity .5s ease, transform .5s ease; pointer-events: none; }
.bg-t__cap b { display: block; font-size: 1rem; font-weight: 600; line-height: 1.3; }
.bg-t__cap span { display: block; margin-top: .2rem; font-size: .8125rem; color: rgba(255,255,255,.8); }
.bg-t__cap span:empty { display: none; }
.bg-t:hover::after, .bg-t:focus-visible::after { opacity: 1; }
.bg-t:hover .bg-t__cap, .bg-t:focus-visible .bg-t__cap { opacity: 1; transform: none; }
.bg-t:focus-visible { outline: 2px solid var(--fg); outline-offset: 3px; }

/* the viewer */
.bgal-locked, .bgal-locked body { overflow: hidden; }
.bgal-lb { position: fixed; inset: 0; z-index: 1000; display: grid; place-items: center; padding: 64px 72px;
  background: rgba(0,0,0,.8); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
  opacity: 0; visibility: hidden; transition: opacity .25s ease, visibility 0s linear .25s; }
.bgal-lb.is-open { opacity: 1; visibility: visible; transition: opacity .25s ease; }
.bgal-lb__fig { margin: 0; max-width: min(1100px, 100%); display: flex; flex-direction: column; align-items: center; gap: 14px;
  transform: translateY(20px) scale(.92); transition: transform .4s cubic-bezier(.2,.9,.3,1.15); }
.bgal-lb.is-open .bgal-lb__fig { transform: none; }
.bgal-lb__media img, .bgal-lb__media video { display: block; max-width: 100%; max-height: calc(100vh - 170px); width: auto; height: auto;
  border-radius: 12px; object-fit: contain; box-shadow: 0 30px 80px -20px rgba(0,0,0,.6); }
.bgal-lb__cap { text-align: center; color: rgba(255,255,255,.92); }
.bgal-lb__cap b { display: block; font-size: 1rem; font-weight: 600; }
.bgal-lb__cap span { display: block; margin-top: .15rem; font-size: .875rem; color: rgba(255,255,255,.65); }
.bgal-lb__btn { position: absolute; display: grid; place-items: center; width: 44px; height: 44px; border-radius: 50%; border: 0; padding: 0;
  background: rgba(255,255,255,.12); color: #fff; cursor: pointer; transition: background .2s; }
.bgal-lb__btn:hover { background: rgba(255,255,255,.24); }
.bgal-lb__btn:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }
.bgal-lb__btn svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.bgal-lb__close { top: 16px; right: 16px; }
.bgal-lb__prev { left: 16px; top: 50%; margin-top: -22px; }
.bgal-lb__next { right: 16px; top: 50%; margin-top: -22px; }
.bgal-lb__btn[hidden] { display: none; }

@media (max-width: 640px) {
  .bgal__rail { --tile: 9.5rem; gap: 10px; }
  .bg-t { border-radius: 14px; }
  .bg-t__cap { left: 12px; right: 12px; bottom: 10px; }
  .bgal-lb { padding: 64px 12px; }
  .bgal-lb__prev, .bgal-lb__next { top: auto; bottom: 18px; margin-top: 0; }
  .bgal-lb__prev { left: calc(50% - 54px); }
  .bgal-lb__next { right: calc(50% - 54px); }
  .bgal-lb__media img, .bgal-lb__media video { max-height: calc(100vh - 210px); }
}
@media (hover: none) {
  /* no hover on touch: keep the title visible on the big tiles only */
  .bg-t--big::after, .bg-t--big .bg-t__cap { opacity: 1; transform: none; }
}
@media (prefers-reduced-motion: reduce) {
  .bg-t, .bg-t img, .bg-t video, .bgal-lb, .bgal-lb__fig { transition: none; }
  .bg-t { transform: none; opacity: 1; }
}
