/* ========================================
   gallery.css – Frederick’s Apartelle
   ======================================== */

/* ==============================
   Page / Heading / Intro Styles
   ============================== */
.gallery-page {
  text-align: center;
  padding-top: 2rem;
}

.gallery-page h1 {
  font-size: 2.4rem;
  color: var(--primary);
  margin-bottom: 0.5rem;
}

.gallery-page .intro {
  font-size: 1.1rem;
  color: var(--muted);
  margin-bottom: 2.5rem;
  line-height: 1.6;
}

/* ==============================
   Responsive Grid Container
   ============================== */
.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 2rem;
  padding: 0 1.5rem 3rem;
  max-width: 1280px;
  margin: 0 auto;
}

/* ==============================
   Gallery Item (Card) Styles
   ============================== */
.gallery-item {
  opacity: 1;
  transform: translateY(0);
  background: #fff;
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-main);
  transition: opacity 0.4s ease, transform 0.4s ease;
}

.gallery-item:hover {
  transform: translateY(-5px);
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.08);
}

.gallery-item picture,
.gallery-item img {
  width: 100%;
  height: auto;
  display: block;
}

.gallery-item .caption {
  font-size: 0.95rem;
  padding: 0.75rem 1rem 1rem;
  color: var(--text);
  background: #fff;
  text-align: left;
}

/* ==============================
   Gallery “Tile” (4:3 Aspect) —
   not currently used, but kept
   ============================== */
.gallery-tile {
  aspect-ratio: 4 / 3;
  overflow: hidden;
  border-radius: var(--radius);
  background: #fff;
  box-shadow: var(--shadow-main);
}

.gallery-tile img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}



/* ==============================
   Fade‐In‐Stagger Animation
   ============================== */
.fade-in-stagger {
  opacity: 0;
  transform: translateY(10px);
  animation: fadeInUp 0.4s ease forwards;
}

@keyframes fadeInUp {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}


/* Consistent tiles with no CLS */
:root { --gallery-ar: 4 / 3; }             /* change to 16/9 if you prefer */
.gallery-item .media { display:block; aspect-ratio: var(--gallery-ar); overflow:hidden; }
.gallery-item .media img { width:100%; height:100%; object-fit: cover; }

/* Keyboard parity with hover */
.gallery-item:focus-within,
.gallery-item:focus-visible {
  outline: 3px solid var(--primary);
  outline-offset: 3px;
  transform: translateY(-5px);
}
.gallery-item:focus { outline: none; } /* avoid mouse-focus outline */

/* Prevent sticky header covering anchor jumps (if you ever link to #gallery or items) */
.gallery-page [id] { scroll-margin-top: 96px; }

/* Injection performance: only render when near viewport */
@supports (content-visibility: auto) {
  .gallery-item { content-visibility: auto; contain-intrinsic-size: 300px; }
}

/* Minor UX niceties */
.gallery-item img { -webkit-user-drag: none; user-select: none; }

/* Fallback in case a tile ever misses .media */
.gallery-item picture:not(.media) { display:block; aspect-ratio: var(--gallery-ar); overflow:hidden; }
.gallery-item picture:not(.media) img { width:100%; height:100%; object-fit: cover; }

/* Respect reduced motion */
@media (prefers-reduced-motion: reduce) {
  .fade-in-stagger { animation: none; opacity: 1; transform: none; }
  .gallery-item:hover { transform: none; box-shadow: var(--shadow-main); }
}
