/* The free layout: photos in boxes within boxes (album-boxes.liquid). The
   site links this next to album.css, and Arrange loads it from
   /album-layout/album-boxes.css to draw its preview, so it holds only the
   free layout and nothing else of the page. */

/* The album is a container, so 100cqw below is its width. Each block's
   height and each box's place are calc(share * 100cqw + px), as
   album-boxes.liquid sets them, so the gaps stay the same at any width,
   unless the layout file has a width: (below). */
.album-boxes {
  container-type: inline-size;
  display: flex;
  flex-direction: column;
  gap: var(--gap, 8px);
  margin: 1.5rem 0 2rem;
}

/* width: in the layout file. The album is --album-w inches wide, real inches
   on a MacBook Pro screen, which shows 127px to the inch, as frame: uses in
   album.css. That can be wider than the site's usual 42rem page (style.css
   lets main go wider). Where there isn't room, the album is as wide as the
   space and shrinks like a picture, gaps and all, so edges that line up at
   full size line up at every size. album-boxes.js gives every place as a
   plain share of the width (px 0). The space between blocks is --gap px out
   of the full width, scaled to the album's width: --gap-number is --gap
   without its px, for the arithmetic. 100cqw has to be on the blocks, since
   the album, being the container, can't measure itself, so the space is a
   margin above each block after the first instead of the flex gap. */
.album-boxes-wide {
  max-width: calc(var(--album-w) * 127px);
  gap: 0;
}

.album-boxes-wide > .album-boxes-block + .album-boxes-block {
  margin-top: calc(var(--gap-number) / (var(--album-w) * 127) * 100cqw);
}

.album-boxes-block {
  position: relative;
  height: calc(var(--h) * 100cqw + var(--h-px));
}

.album-box {
  position: absolute;
  left: calc(var(--x) * 100cqw + var(--x-px));
  top: calc(var(--y) * 100cqw + var(--y-px));
  width: calc(var(--w) * 100cqw + var(--w-px));
  height: calc(var(--h) * 100cqw + var(--h-px));
  margin: 0;
  overflow: hidden;
}

/* The image plugin wraps each img in a picture, which has to fill the box
   too for the img's 100% height to mean the box's. */
.album-box picture {
  display: block;
  width: 100%;
  height: 100%;
}

/* A photo covers its box, with its crop's centre at --cx --cy, and zooms
   about that same point, so it shows just what Arrange's editor shows. */
.album-box img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: var(--cx) var(--cy);
  transform: scale(var(--zoom));
  transform-origin: var(--cx) var(--cy);
}

/* fit: whole: all of the photo, centred in its box. */
.album-box-whole img {
  object-fit: contain;
  object-position: 50% 50%;
  transform: none;
}
