/* gallery.css, boumliha.studio multipage (Wilson 2026-11-17). Needs site.css first (tokens).
   Project tiles in three layouts (data-layout on .pgrid: mosaic | bands | squares), hover name, infinite batches,
   overlay A (one item at a time viewer) and overlay B (?overlay=sheet, contact sheet). API notes: top of gallery.js. */

/* ---------- grid shell ---------- */
.pgrid { list-style: none; margin: 0 auto; padding: 0; max-width: var(--measure); padding-inline: var(--gutter); display: grid; gap: var(--pg-gap); --pg-gap: clamp(.75rem, 1.6vw, 1.5rem); }
.sr-only, .pgrid-status { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }   /* fix pass S8: screen readers only */
.pgrid-sentinel { height: 1px; }

/* ---------- tile ---------- */
.tile { position: relative; display: block; overflow: hidden; background: var(--ground-2); color: var(--ink); text-decoration: none; isolation: isolate; }
.tile > img, .tile > video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; transition: transform 1.4s var(--ease), opacity .5s ease-out; }
.tile > video { opacity: 0; }
.tile > video.is-on { opacity: 1; }
.tile::after { content: ""; position: absolute; inset: 42% 0 0 0; z-index: 1; pointer-events: none; opacity: 0;
  background: linear-gradient(180deg, oklch(11% .003 75 / 0), oklch(11% .003 75 / .8) 52%, oklch(11% .003 75 / .88)); transition: opacity .35s ease-out; }   /* fix pass S2: .8 by 72 % of the tile height */
.tile-cap { position: absolute; z-index: 2; left: clamp(.7rem, 1.4vw, 1.1rem); right: clamp(.7rem, 1.4vw, 1.1rem); bottom: clamp(.75rem, 1.5vw, 1.15rem);
  display: grid; gap: .4rem; opacity: 0; transform: translateY(6px); transition: opacity .3s ease-out, transform .4s var(--ease); }
.tile-cap b { font-weight: 500; font-size: var(--t-lg); line-height: 1.15; text-box: trim-both cap alphabetic; }
.tile-cap small { font-size: var(--t-xs); line-height: 1.3; color: oklch(88% .008 85); }
.tile-cap .n { color: oklch(80% .01 80); }
.tile .kind { position: absolute; z-index: 2; top: .65rem; right: .65rem; width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center;
  background: oklch(13% .003 75 / .6); color: var(--ink); }
.tile .kind svg { width: 14px; height: 14px; }
.tile:hover > img, .tile:focus-visible > img, .tile:hover > video, .tile:focus-visible > video { transform: scale(1.03); }
.tile:hover::after, .tile:focus-visible::after, .tile:hover .tile-cap, .tile:focus-visible .tile-cap { opacity: 1; }
.tile:hover .tile-cap, .tile:focus-visible .tile-cap { transform: none; }
.tile:focus-visible { outline: 2px solid var(--accent-ink); outline-offset: 3px; }
@media (hover: none) {
  .tile::after, .tile-cap { opacity: 1; transform: none; }
  .tile-cap .n { display: none; }
}

/* ---------- layout: mosaic (photography, home). 4 columns, 1x1 / 2x1 wide / 1x2 tall. Fix pass S4: NO dense flow (DOM
   order = visual order); the span pattern in gallery.js closes every batch of 8 and the tail, per breakpoint ---------- */
.pgrid[data-layout="mosaic"] { grid-template-columns: repeat(4, minmax(0, 1fr)); grid-auto-rows: clamp(150px, 13vw, 200px); }
@media (min-width: 700px) {
  .pgrid[data-layout="mosaic"] .tile.w { grid-column: span 2; }
  .pgrid[data-layout="mosaic"] .tile.t { grid-row: span 2; }
  .pgrid[data-layout="mosaic"] .tile.f { grid-column: 1 / -1; grid-row: span 2; }
}
@media (max-width: 699px) {
  .pgrid[data-layout="mosaic"] { grid-template-columns: repeat(2, minmax(0, 1fr)); grid-auto-rows: 34vw; }
  .pgrid[data-layout="mosaic"] .tile.pw { grid-column: span 2; }
  .pgrid[data-layout="mosaic"] .tile.pt { grid-row: span 2; }
}

/* ---------- layout: bands (videography). full-width stacked bands, title centred (sub4 2026-11-17: Outfit title in
   sentence case, category + film count always shown under it, darker scrim for 4.5:1 over moving frames) ---------- */
.pgrid[data-layout="bands"] { grid-template-columns: 1fr; }
.pgrid[data-layout="bands"] .tile { height: clamp(200px, 15.6vw, 260px); }
/* fix pass S1: scrim .66 (.75 on hover), count in ink not copper. S3: title on its own line, category + count in one
   flex row with a fixed 1rem gap. Wilson: a vertical film (fv) sits as a centred 9:16 strip at band height on the dark
   ground (poster and preview both contain, no blur); a 5:1 film (fp) does the same on phone only. */
.pgrid[data-layout="bands"] .tile { background: var(--ground); }
.pgrid[data-layout="bands"] .tile.fv > img, .pgrid[data-layout="bands"] .tile.fv > video { object-fit: contain; }
.pgrid[data-layout="bands"] .tile::after { inset: 0; opacity: 1; background: oklch(11% .003 75 / .66); }
.pgrid[data-layout="bands"] .tile:hover::after, .pgrid[data-layout="bands"] .tile:focus-visible::after { background: oklch(11% .003 75 / .75); }
.pgrid[data-layout="bands"] .tile-cap { inset: 0; display: flex; flex-wrap: wrap; align-content: center; justify-content: center; text-align: center; opacity: 1; transform: none;
  column-gap: 1rem; row-gap: .85rem; padding-inline: var(--gutter); text-shadow: 0 1px 12px oklch(11% .003 75 / .6); }
.pgrid[data-layout="bands"] .tile-cap b { flex: 0 0 100%; font-weight: 500; font-size: var(--t-title); letter-spacing: -.01em; text-wrap: balance; }
.pgrid[data-layout="bands"] .tile-cap small { color: oklch(90% .008 85); }
.pgrid[data-layout="bands"] .tile-cap .n { display: block; color: oklch(90% .008 85); }
.pgrid[data-layout="bands"] .kind { display: none; }   /* every band is a film, the film badge is noise */
@media (max-width: 699px) {
  .pgrid[data-layout="bands"] .tile { height: auto; aspect-ratio: 16 / 10; }
  .pgrid[data-layout="bands"] .tile.fp > img, .pgrid[data-layout="bands"] .tile.fp > video { object-fit: contain; }
}

/* ---------- layout: squares (weddings). 4 columns of squares, 2 on phone ---------- */
.pgrid[data-layout="squares"] { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.pgrid[data-layout="squares"] .tile { aspect-ratio: 1; }
@media (max-width: 699px) { .pgrid[data-layout="squares"] { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

/* ---------- overlay (shared shell) ---------- */
html.gx-lock, html.gx-lock body { overflow: hidden; }
.gx { position: fixed; inset: 0; z-index: 90; background: oklch(11.5% .003 75); color: var(--ink); display: grid; grid-template-rows: auto minmax(0, 1fr) auto;
  opacity: 0; visibility: hidden; transition: opacity .3s ease-out, visibility 0s linear .3s; }
.gx.open { opacity: 1; visibility: visible; transition: opacity .3s ease-out, visibility 0s; }
.gx[hidden] { display: none; }
.gx-head { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: start; gap: .5rem 1.5rem; padding: clamp(.9rem, 2vw, 1.5rem) var(--gutter) clamp(.6rem, 1.4vw, 1rem); }
.gx-title { font-family: 'Cormorant Garamond', Georgia, serif; font-weight: 400; font-synthesis: none; font-size: var(--t-lead); line-height: 1.05; text-box: trim-both cap alphabetic; }
.gx-meta { margin-top: .75rem; display: grid; gap: .3rem; font-size: var(--t-sm); line-height: 1.5; color: var(--ink-dim); max-width: 60rem; }
.gx-meta b { color: var(--ink); font-weight: 500; }
.gx-summary { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; }
.gx-tools { display: flex; align-items: center; gap: .75rem; }
.gx-count { font-size: var(--t-sm); color: var(--ink-dim); font-variant-numeric: tabular-nums; white-space: nowrap; }
.gx-btn { width: 44px; height: 44px; flex: none; border-radius: 50%; display: grid; place-items: center; cursor: pointer; color: var(--ink);
  background: oklch(17% .004 75 / .7); border: 1px solid oklch(93.6% .008 85 / .4); transition: background .2s, border-color .2s; }
.gx-btn:hover { background: var(--ink); color: var(--ground); border-color: var(--ink); }
.gx-btn svg { width: 18px; height: 18px; }
.gx-btn[disabled] { opacity: .35; cursor: default; pointer-events: none; }
.gx-btn[hidden] { display: none; }

/* overlay A: one item at a time */
.gx-stage { position: relative; min-height: 0; display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: clamp(.5rem, 1.5vw, 1.25rem); padding: 0 var(--gutter); touch-action: pan-y; }
.gx-item { grid-column: 2; grid-row: 1; position: relative; min-width: 0; min-height: 0; height: 100%; margin: 0; }   /* fix pass: stays in the middle column when the arrows are hidden (single item) */
.gx-item img, .gx-item video { position: absolute; inset: 0; width: 100%; height: 100%; max-width: none; object-fit: contain; }
.gx-item:has(video) { container-type: size; }   /* sub4 2026-11-17: film box = picture size, so the controls bar sits on the film (16:9 and 9:16), not across the stage */
.gx-item video { margin: auto; width: min(100cqw, 100cqh * var(--ar, 1.7778)); height: auto; max-height: 100%; }
.gx-item.fade-in { animation: gx-in .35s ease-out; }
@keyframes gx-in { from { opacity: 0; } to { opacity: 1; } }
.gx-cap { padding: clamp(.6rem, 1.4vw, 1rem) var(--gutter) calc(clamp(.8rem, 1.8vw, 1.25rem) + env(safe-area-inset-bottom)); text-align: center; font-size: var(--t-sm); color: var(--ink-dim); min-height: 3.2rem; }
.gx-cap b { color: var(--ink); font-weight: 500; }
@media (max-width: 699px) {
  .gx-head { grid-template-columns: minmax(0, 1fr) auto; }
  .gx-summary { display: none; }
  .gx-stage { grid-template-columns: minmax(0, 1fr); padding: 0; }
  .gx-item { grid-column: 1; }
  .gx-stage .gx-prev, .gx-stage .gx-next { position: absolute; z-index: 2; bottom: .75rem; }
  .gx-stage .gx-prev { left: .75rem; } .gx-stage .gx-next { right: .75rem; }
  .gx-stage:has(video) .gx-prev, .gx-stage:has(video) .gx-next { bottom: auto; top: 50%; translate: 0 -50%; }   /* sub4: off the film controls */
}

/* overlay B: contact sheet (masonry by columns) */
.gx-sheet { min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: .25rem var(--gutter) calc(2rem + env(safe-area-inset-bottom)); }
.gx-sheet-in { columns: 4 220px; column-gap: .75rem; max-width: 1440px; margin: 0 auto; }
.gx-sheet[hidden] { display: none; }
.gx-sheet button { display: block; width: 100%; margin: 0 0 .75rem; padding: 0; border: 0; background: var(--ground-2); cursor: zoom-in; break-inside: avoid; position: relative; color: var(--ink); }
.gx-sheet img { width: 100%; height: auto; transition: opacity .2s; }
.gx-sheet button:hover img { opacity: .82; }
.gx-sheet .kind { position: absolute; top: .5rem; right: .5rem; width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; background: oklch(13% .003 75 / .65); }
.gx-sheet .kind svg { width: 14px; height: 14px; }
@media (max-width: 699px) { .gx-sheet-in { columns: 2; column-gap: .5rem; } .gx-sheet button { margin-bottom: .5rem; } }
.gx.is-sheet .gx-stage, .gx.is-sheet .gx-cap { display: none; }

@media (prefers-reduced-motion: reduce) {
  .tile > img, .tile > video, .tile-cap, .gx { transition: none; }
  .tile:hover > img, .tile:focus-visible > img { transform: none; }
  .gx-item.fade-in { animation: none; }
}

/* ---------- justified rows (owner 2026-11-18: "images fully visible, check their ratio") ----------
   Every layout (mosaic, bands, squares) now flows as rows of equal height where each tile keeps its cover's own ratio
   (--ar set by gallery.js and in the static HTML), so no photo or film frame is cropped. Flex-grow is proportional
   to the ratio, so every tile in a row ends at the same height; the ::after filler keeps the last row from stretching. */
.pgrid[data-layout] { display: flex; flex-wrap: wrap; justify-content: center; --rh: clamp(130px, 22vw, 300px); }
.pgrid[data-layout]::after { content: ""; flex: 999 1 0; height: 0; }
.pgrid[data-layout] .tile { flex: var(--ar, 1.5) 1 calc(var(--ar, 1.5) * var(--rh)); aspect-ratio: var(--ar, 1.5); height: auto; min-width: 0;
  grid-column: auto; grid-row: auto;
  max-width: min(100%, calc(var(--ar, 1.5) * var(--rh) * 1.7)); }   /* a lone portrait never turns into a full-width tower */
.pgrid[data-layout] .tile > img, .pgrid[data-layout] .tile > video { object-fit: cover; }
@media (max-width: 699px) {
  .pgrid[data-layout] { --rh: 48vw; --pg-gap: .5rem; }
  .pgrid[data-layout] .tile-cap { left: .5rem; right: .5rem; bottom: .5rem; gap: .2rem; }
  .pgrid[data-layout] .tile-cap b { font-size: var(--t-sm); }
  .pgrid[data-layout] .tile-cap small { display: none; }
  .pgrid[data-layout="bands"] .tile { height: auto; aspect-ratio: var(--ar, 1.5); }
  .pgrid[data-layout] .tile .kind { width: 26px; height: 26px; top: .4rem; right: .4rem; }
}

/* phone masonry (gallery.js masonry()): two columns, true ratios, very wide covers letterboxed at 2.2:1 */
.pgrid.is-masonry { display: flex; flex-wrap: nowrap; align-items: flex-start; justify-content: stretch; }
.pgrid.is-masonry::after { display: none; }
.pgrid.is-masonry .mcol { flex: 1 1 0; min-width: 0; display: flex; flex-direction: column; gap: var(--pg-gap); }
.pgrid.is-masonry .tile { flex: none; width: 100%; max-width: none; aspect-ratio: var(--ar, 1.5); }
.pgrid.is-masonry .tile.wide { aspect-ratio: 2.2; background: var(--ground); }
.pgrid.is-masonry .tile.wide > img, .pgrid.is-masonry .tile.wide > video { object-fit: contain; }
/* films in the phone masonry: bottom fade + name at the foot (the full-tile band scrim is too heavy in half-width columns) */
.pgrid.is-masonry[data-layout="bands"] .tile::after { inset: 40% 0 0 0; background: linear-gradient(180deg, oklch(11% .003 75 / 0), oklch(11% .003 75 / .85)); }
.pgrid.is-masonry[data-layout="bands"] .tile-cap { inset: auto .5rem .5rem .5rem; display: grid; justify-content: start; text-align: left; padding: 0; row-gap: .2rem; }
.pgrid.is-masonry[data-layout="bands"] .tile-cap b { font-size: var(--t-sm); }
/* a grid of 5 tiles or fewer is one row: let it fill the width instead of sitting short on the left (couples, about) */
.pgrid[data-layout]:not(:has(> .tile:nth-child(6)))::after { display: none; }
