/* Home-page gallery ("Recent Deliveries"). Cars are managed in the staff area (/admin/gallery)
   and served by /api/gallery; scripts/gallery.js builds the collage cards and the full-screen viewer. */
#gallery[hidden],
.afg-gallery-more[hidden],
.afg-lightbox[hidden],
.afg-lb-btn[hidden] { display: none !important; }

.afg-gallery-grid { display: grid; grid-template-columns: minmax(0, 1fr); gap: 18px; align-items: start; }
@media (min-width: 640px) { .afg-gallery-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; } }
@media (min-width: 1100px) { .afg-gallery-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 24px; } }

.afg-gpost {
  position: relative;
  overflow: hidden;
  border-radius: 10px;
  background: #121414;
  border: 1px solid rgba(255, 255, 255, 0.07);
  opacity: 0;
  transform: translateY(16px);
  transition: opacity 0.6s ease, transform 0.6s ease, border-color 0.3s ease;
}
.afg-gpost.in { opacity: 1; transform: none; }
.afg-gpost:hover { border-color: rgba(230, 0, 35, 0.5); }
/* red accent line slides in on hover */
.afg-gpost::after {
  content: '';
  position: absolute;
  left: 0;
  bottom: 0;
  width: 100%;
  height: 3px;
  background: #E60023;
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 0.4s ease;
}
.afg-gpost:hover::after, .afg-gpost:focus-within::after { transform: scaleX(1); }

/* collage layouts (chosen per car in the staff area) */
.afg-collage { display: grid; gap: 3px; aspect-ratio: 4 / 3; background: #0b0c0c; }
.afg-collage.l-single { grid-template: 1fr / 1fr; }
.afg-collage.l-duo { grid-template: 1fr / 1fr 1fr; }
.afg-collage.l-trio { grid-template: 1fr 1fr / 2fr 1fr; }
.afg-collage.l-trio .afg-gcell:first-child { grid-row: span 2; }
.afg-collage.l-quad { grid-template: 1fr 1fr / 1fr 1fr; }
.afg-gcell {
  position: relative;
  min-height: 0;
  padding: 0;
  border: 0;
  overflow: hidden;
  cursor: zoom-in;
  background: #1a1c1c;
}
.afg-gcell img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  filter: brightness(0.9) saturate(0.95);
  transition: transform 0.8s cubic-bezier(0.2, 0.7, 0.2, 1), filter 0.4s ease;
}
.afg-gcell:hover img, .afg-gcell:focus-visible img { transform: scale(1.06); filter: none; }
.afg-gcell:focus-visible { outline: 2px solid #fff; outline-offset: -2px; }
.afg-gmore {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  font: italic 800 26px/1 'AFG Sans', 'Inter', sans-serif;
}
.afg-gcap { padding: 14px 16px 18px; }
.afg-gcap h3 {
  margin: 0;
  font: italic 800 16px/1.3 'AFG Sans', 'Inter', sans-serif;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #fff;
}
.afg-gcap p { margin: 4px 0 0; font-size: 14px; line-height: 1.5; color: #cfc4c5; }

/* ---- Full-screen viewer ---- */
.afg-lightbox {
  position: fixed;
  inset: 0;
  z-index: 120;
  background: rgba(6, 7, 7, 0.95);
  -webkit-backdrop-filter: blur(6px);
          backdrop-filter: blur(6px);
  opacity: 0;
  transition: opacity 0.2s ease;
}
.afg-lightbox.open { opacity: 1; }
.afg-lb-stage {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 72px 88px 104px;
}
.afg-lb-stage img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  border-radius: 4px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
  opacity: 0;
  transition: opacity 0.25s ease;
}
.afg-lb-stage img.loaded { opacity: 1; }
.afg-lb-btn {
  position: absolute;
  z-index: 2;
  width: 52px;
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  color: #fff;
  cursor: pointer;
  background: rgba(230, 0, 35, 0.4);
  border: 1px solid rgba(255, 255, 255, 0.25);
  -webkit-backdrop-filter: blur(12px);
          backdrop-filter: blur(12px);
  transition: background 0.2s ease;
}
.afg-lb-btn:hover { background: rgba(230, 0, 35, 0.65); }
.afg-lb-btn:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }
.afg-lb-btn .material-symbols-outlined { font-size: 30px; }
.afg-lb-prev { left: 20px; top: 50%; transform: translateY(-50%); }
.afg-lb-next { right: 20px; top: 50%; transform: translateY(-50%); }
.afg-lb-close {
  top: calc(16px + env(safe-area-inset-top, 0px));
  right: 16px;
  background: rgba(255, 255, 255, 0.08);
}
.afg-lb-meta {
  position: absolute;
  left: 0;
  right: 0;
  bottom: calc(32px + env(safe-area-inset-bottom, 0px));
  text-align: center;
  color: #cfc4c5;
  font: italic 700 13px/1.4 'AFG Sans', 'Inter', sans-serif;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}
.afg-lb-count { color: #E60023; margin-left: 12px; }
@media (max-width: 640px) {
  .afg-lb-stage { padding: 72px 12px 150px; }
  .afg-lb-prev,
  .afg-lb-next { top: auto; bottom: calc(20px + env(safe-area-inset-bottom, 0px)); transform: none; }
  .afg-lb-meta { bottom: calc(92px + env(safe-area-inset-bottom, 0px)); }
}

@media (prefers-reduced-motion: reduce) {
  .afg-gpost { opacity: 1; transform: none; transition: none; }
  .afg-gcell img { transition: none; }
}
