/* ==========================================================
   gallery.css — load AFTER style.css
   Every photo fills its cell (object-fit: cover), and each row
   keeps a fixed shape as the window is resized.

   Tweak a row's shape:    --ratio  (row width / row height)
   Tweak a photo's crop:   --focus  (object-position), e.g. "50% 20%"
   Tweak a photo on phones:--m-ratio (aspect-ratio), e.g. "3 / 4"
   ========================================================== */

#work {
  --gap: clamp(8px, 1.4vw, 20px);
}

.g-intro,
.g-row {
  max-width: 62.5rem;           /* same cap Foundation's .row had */
  margin-inline: auto;
}

.g-intro { margin-bottom: var(--gap); }
.g-row   { margin-bottom: var(--gap); }
.g-row + .g-intro { margin-top: calc(var(--gap) * 2); }

/* ---------- a single photo cell ---------- */
.g-item {
  position: relative;
  display: block;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  background: rgba(0, 0, 0, .06);              /* placeholder while loading */
  box-shadow: 1px 1px 10px rgba(0, 0, 0, .1);
  aspect-ratio: var(--m-ratio, 4 / 3);          /* phones: own shape */
}

.g-item img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: var(--focus, center);
  display: block;
  transition: opacity .2s ease;
}

.g-item:hover img,
.g-item:focus-visible img { opacity: .85; }

/* ---------- phones: simple single column ---------- */
.g-row,
.g-stack,
.g-pair {
  display: flex;
  flex-direction: column;
  gap: var(--gap);
}

/* ---------- tablets and up: fixed-shape grid rows ---------- */
@media (min-width: 41.063em) {

  .g-row {
    display: grid;
    grid-template-rows: minmax(0, 1fr);
    aspect-ratio: var(--ratio, 2 / 1);
  }

  .g-item { aspect-ratio: auto; }               /* the cell decides now */

  .g-stack {
    display: grid;
    grid-template-rows: repeat(2, minmax(0, 1fr));
    min-height: 0;
  }

  .g-pair {
    display: grid;
    grid-template-rows: none;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  /* column layouts */
  .g-8-4   { grid-template-columns: 2fr 1fr; }
  .g-4-8   { grid-template-columns: 1fr 2fr; }
  .g-6-6   { grid-template-columns: 1fr 1fr;  --ratio: 8 / 3; }
  .g-4-4-4 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .g-12    { grid-template-columns: 1fr;      --ratio: 7 / 3; }

  /* the row with a big photo + a pair stacked beside a tall one */
  .g-tall  { --ratio: 7 / 4; }
}
