/* =============================================
   GALLERY PAGE — gy- prefix
   Light page. Reuses the home .mosaic-card / .mosaic-overlay look (styles.css)
   and the catalogue hero/section shell (catalogue.css, ct-).
   ============================================= */

/* --- Mosaic grid ----------------------------------------------------------
   Copied from the home .sports-mosaic: 1 column on mobile, 3 columns from
   768px. grid-auto-flow: dense lets the layout variants below fill the holes.

   Alignment rule: the rows are implicit (auto), so every card must be an
   EXACT multiple of the row unit (one cell = 0.75 × column width) plus the
   grid gaps. With `aspect-ratio` that is impossible — the aspect ratios a
   card spans over change when the gap is taken into account, so the rows end
   up with slightly different heights and the vertical gutters look uneven
   (8px between two cells, ~19px after a portrait card).

   The heights are therefore expressed with `padding-bottom`, whose percentage
   resolves against the element's OWN width. That is the only way to combine
   the fluid column width with the fixed gap:
     - cell      → 1 column, 1 row    → 75% of its width
     - landscape → 2 columns + 1 gap  → 0.75 × column
                   = 37.5% of its width (2col + gap) minus 0.375 × gap
     - portrait  → 1 column, 2 rows + 1 gap → 150% of its width plus the gap */
.gallery-mosaic {
  --mosaic-gap: 8px;
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--mosaic-gap);
  grid-auto-flow: dense;
}

.gallery-mosaic .mosaic-card {
  aspect-ratio: 4 / 3;
}

@media (min-width: 768px) {
  .gallery-mosaic {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  /* The card height now comes from padding-bottom, so aspect-ratio is dropped
     (and the media is absolutely positioned to cover the padding box). */
  .gallery-mosaic .mosaic-card {
    aspect-ratio: auto;
    height: 0;
    padding-bottom: 75%;
  }

  /* Landscape: two columns wide, same height as a single cell. */
  .gallery-mosaic .mosaic-card--landscape {
    grid-column: span 2;
    padding-bottom: calc(37.5% - var(--mosaic-gap) * 0.375);
  }

  /* Portrait: one column wide, two rows tall. */
  .gallery-mosaic .mosaic-card--portrait {
    grid-row: span 2;
    padding-bottom: calc(150% + var(--mosaic-gap));
  }

  /* The media is taken out of the flow to cover the padding box. Both shapes
     are handled: galleryPicture() outputs <picture><img></picture> when the
     variants exist, and a bare <img> when they do not. */
  .gallery-mosaic .mosaic-card > img,
  .gallery-mosaic .mosaic-card picture {
    position: absolute;
    inset: 0;
  }
}

/* The picture wrapper must fill the card so .mosaic-card img covers it. */
.gallery-mosaic .mosaic-card picture {
  display: block;
  width: 100%;
  height: 100%;
}

/* Clickable cards (lightbox trigger). */
.gallery-mosaic .mosaic-card {
  cursor: zoom-in;
}

.gallery-mosaic .mosaic-card h3 {
  margin: 0;
  color: white;
}

/* --- Lightbox ------------------------------------------------------------- */
.gy-lightbox {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.92);
  padding: 4vh 4vw;
  opacity: 0;
  transition: opacity 220ms var(--ease-out, ease-out);
}

.gy-lightbox[hidden] {
  display: none;
}

.gy-lightbox.is-open {
  opacity: 1;
}

.gy-lightbox-figure {
  position: relative;
  margin: 0;
  max-width: 100%;
  max-height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}

.gy-lightbox-img {
  display: block;
  max-width: 100%;
  max-height: 82vh;
  width: auto;
  height: auto;
  object-fit: contain;
  border-radius: 4px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

.gy-lightbox-caption {
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.85);
}

.gy-lightbox-close {
  position: absolute;
  top: 18px;
  right: 22px;
  width: 44px;
  height: 44px;
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 50%;
  background: transparent;
  color: #fff;
  font-size: 26px;
  line-height: 1;
  cursor: pointer;
  transition: background 200ms, border-color 200ms;
}

.gy-lightbox-close:hover {
  background: rgba(255, 255, 255, 0.12);
  border-color: var(--volt);
}

.gy-lightbox-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 52px;
  height: 52px;
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.35);
  color: #fff;
  font-size: 30px;
  line-height: 1;
  cursor: pointer;
  transition: background 200ms, border-color 200ms;
}

.gy-lightbox-nav:hover {
  background: rgba(255, 255, 255, 0.12);
  border-color: var(--volt);
}

.gy-lightbox-prev { left: 18px; }
.gy-lightbox-next { right: 18px; }

@media (max-width: 640px) {
  .gy-lightbox-prev { left: 8px; }
  .gy-lightbox-next { right: 8px; }
  .gy-lightbox-nav { width: 42px; height: 42px; font-size: 24px; }
  .gy-lightbox-img { max-height: 74vh; }
}

body.gy-lightbox-open {
  overflow: hidden;
}
