/* ============================================================
   GALLERY — a continuous, full-bleed photo collage behind the
   entire scene. Not a card wall, not interactive: pointer-events
   are off everywhere in this layer and it never intercepts a
   click meant for a balloon.

   Namespace: .gal-*    z-index band: 1-99 (background, behind
   ambient balloons 100-199, decorate 300-399, etc).
   Loads after css/stylesheet.css so it may override it.
   ============================================================ */

#gallery-layer {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 30;
  overflow: hidden;
  pointer-events: none;
  display: none;
  opacity: 0;
  transform: scale(1.045);
  transition: opacity 0.8s ease, transform 0.8s ease;
}

#gallery-layer.gal-visible {
  opacity: 1;
  transform: scale(1);
  transition: opacity 1.5s ease, transform 1.5s ease;
}

/* ---------------------------------------------------------
   The photo grid. Full viewport, no gaps, no letterboxing.
   A slight blur + desaturation on the whole grid keeps every
   tile reading as one continuous backdrop rather than a set of
   distinct photos, and softens the seams between tiles.
   --------------------------------------------------------- */
.gal-backdrop {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background-color: var(--bd-bg-deep);
}

.gal-backdrop--empty {
  background-color: var(--bd-bg-deep);
}

.gal-grid {
  width: 100%;
  height: 100%;
  display: grid;
  grid-template-columns: repeat(var(--gal-cols, 2), 1fr);
  grid-template-rows: repeat(var(--gal-rows, 2), 1fr);
  gap: 0;
  filter: saturate(0.85) blur(1px);
}

.gal-visible .gal-grid {
  animation: gal-kenburns 46s ease-in-out infinite alternate;
}

@keyframes gal-kenburns {
  0%   { transform: scale(1) translate(0, 0); }
  100% { transform: scale(1.045) translate(-0.8%, -0.6%); }
}

.gal-tile {
  position: relative;
  overflow: hidden;
  width: 100%;
  height: 100%;
  background-color: var(--bd-bg-deep);
}

.gal-tile-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* ---------------------------------------------------------
   Fallback — a broken or missing src becomes a plain
   palette-coloured panel, never a broken-image icon and never
   a hole in the collage. A little colour variety across tiles
   keeps a run of fallbacks from reading as a dead grey wall.
   --------------------------------------------------------- */
.gal-tile--fallback { background-color: var(--bd-bg-deep); }
.gal-tile--fallback:nth-child(2n) { background-color: var(--bd-coral); }
.gal-tile--fallback:nth-child(3n) { background-color: var(--bd-sage); }
.gal-tile--fallback:nth-child(5n) { background-color: var(--bd-teal); }
.gal-tile--fallback:nth-child(7n) { background-color: var(--bd-plum); }

/* ---------------------------------------------------------
   The veil — the legibility layer. Content in front of the
   background (cake, balloons, letters, message card) must read
   clearly, so this wash sits above every tile.
   --------------------------------------------------------- */
.gal-veil {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: var(--bd-veil);
  pointer-events: none;
}

/* ---------------------------------------------------------
   Heading — kept small and low-contrast near the bottom edge
   so it cannot collide with the decorate bunting (roughly
   -6vh..22vh) or the centre stage where the cake and the
   H-B-D-B-A-B-Y letters live.
   --------------------------------------------------------- */
.gal-heading {
  position: absolute;
  left: 50%;
  bottom: 2.5vh;
  transform: translateX(-50%);
  margin: 0;
  padding: 0 1em;
  font-family: 'Happy', 'Comic Sans MS', cursive, sans-serif;
  font-weight: normal;
  font-size: clamp(11px, 2.2vw, 15px);
  letter-spacing: 0.04em;
  color: var(--bd-cream);
  opacity: 0.55;
  text-shadow: 0 1px 4px var(--bd-shadow);
  text-align: center;
  white-space: nowrap;
  max-width: 90vw;
  overflow: hidden;
  text-overflow: ellipsis;
  pointer-events: none;
}

@media (max-width: 480px) {
  .gal-heading {
    bottom: 1.5vh;
    font-size: clamp(10px, 3vw, 13px);
    max-width: 84vw;
  }
}

@media (prefers-reduced-motion: reduce) {
  #gallery-layer {
    transform: none;
    transition: opacity 0.6s ease;
  }
  #gallery-layer.gal-visible {
    transform: none;
    transition: opacity 0.8s ease;
  }
  .gal-visible .gal-grid {
    animation: none;
  }
}
