/* Photo gallery — photos.html pages (assets/js/gallery.js, data/gallery.js) */

.gallery { scroll-margin-top: 96px; }
.gallery [hidden] { display: none !important; }

.gallery-intro { max-width: 680px; margin-bottom: 28px; color: var(--muted); font-size: 1.1rem; }
.gallery-intro p { margin: 0; }

/* ---------- Album grid ---------- */

.gallery-filters { margin: 0 0 18px; }
.gallery-status { margin: 0 0 18px; color: var(--muted); font-size: .95rem; font-weight: 600; }
.gallery-notice {
  margin: 0 0 20px; padding: 12px 16px; border-radius: 10px;
  background: var(--cream); border-left: 4px solid var(--red); font-weight: 600;
}

.gallery-albums {
  list-style: none; margin: 0; padding: 0;
  display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 24px;
}
.gallery-albums > li { display: flex; min-width: 0; }

.gallery-card { width: 100%; --card-accent: var(--navy); }
.gallery-card[data-unit-key="Pack182"] { --card-accent: #f2b705; }
.gallery-card[data-unit-key="Troop182B"] { --card-accent: #c4561b; }
.gallery-card[data-unit-key="Troop182G"] { --card-accent: #6c3483; }
.gallery-card[data-unit-key="Crew182"] { --card-accent: #4e6b1f; }

.gallery-cover { position: relative; display: block; overflow: hidden; background: var(--cream); }
.gallery-cover img { transition: transform .4s ease; }
a.gallery-card:hover .gallery-cover img { transform: scale(1.04); }
.gallery-count {
  position: absolute; right: 12px; bottom: 12px;
  display: inline-flex; align-items: center; gap: 6px; padding: 4px 11px; border-radius: 999px;
  background: rgba(0, 26, 56, .78); color: #fff; font: 700 .8rem/1.4 var(--font-head); letter-spacing: .02em;
}
.gallery-count .icon { width: 15px; height: 15px; }
.gallery-card h3 { overflow-wrap: anywhere; }
.gallery-card .gallery-date { font-size: .95rem; }

.gallery-more { margin: 32px 0 0; font-family: var(--font-head); font-weight: 700; }
.gallery-more a { text-decoration: none; color: var(--red); }

.gallery-empty {
  max-width: 620px; margin: 8px auto 0; padding: 44px 28px; text-align: center;
  border-radius: var(--radius); background: var(--cream); border: 1px solid var(--line);
}
.gallery-empty h2 { margin-bottom: .35em; font-size: 1.6rem; }
.gallery-empty p { margin: 0; color: var(--muted); }
.gallery-empty-icon {
  display: inline-grid; place-items: center; width: 64px; height: 64px; margin-bottom: 16px;
  border-radius: 50%; background: var(--unit); color: var(--unit-ink);
}
.gallery-empty-icon .icon { width: 30px; height: 30px; }

/* ---------- Album view ---------- */

.gallery-back {
  display: inline-flex; align-items: center; gap: 8px; padding: 6px 0;
  font: 700 .95rem var(--font-head); text-decoration: none; color: var(--navy);
}
.gallery-back:hover { color: var(--red); }
.gallery-back .icon { width: 20px; height: 20px; }

.gallery-head { max-width: 760px; margin: 18px 0 26px; }
.gallery-head .eyebrow { color: var(--muted); }
.gallery-head h2 { margin: 0 0 .4em; overflow-wrap: anywhere; }
.gallery-head h2:focus { outline: none; }
.gallery-desc { color: #344052; }
.gallery-meta { margin: 0; color: var(--muted); font-size: .95rem; font-weight: 600; }

.gallery-photos {
  list-style: none; margin: 0 0 28px; padding: 0;
  display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 10px;
}
.gallery-photo {
  position: relative; display: block; aspect-ratio: 1; overflow: hidden;
  border-radius: 10px; background: var(--cream);
}
.gallery-photo img { width: 100%; height: 100%; object-fit: cover; transition: transform .35s ease, opacity .2s; }
.gallery-photo:hover img { transform: scale(1.05); opacity: .92; }
.gallery-photo:focus-visible { outline: 3px solid var(--unit); outline-offset: 3px; }
body:not([data-unit]) .gallery-photo:focus-visible { outline-color: var(--navy); }

/* ---------- Lightbox ---------- */

html.lb-open { overflow: hidden; }

.lightbox {
  position: fixed; inset: 0; z-index: 1000;
  display: flex; flex-direction: column;
  background: #000c1c; color: #fff;
}
.lightbox[hidden], .lightbox [hidden] { display: none !important; }
.lightbox :focus-visible { outline: 3px solid #fff; outline-offset: 2px; }

.lb-bar { display: flex; align-items: center; gap: 10px; padding: 12px 14px 12px 22px; }
.lb-counter { margin: 0 auto 0 0; font: 700 .95rem var(--font-head); letter-spacing: .06em; color: #dbe4f0; }

.lb-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  width: 48px; height: 48px; padding: 0; border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, .35); background: rgba(255, 255, 255, .08);
  color: #fff; cursor: pointer; text-decoration: none;
  transition: background-color .15s, border-color .15s;
}
.lb-btn:hover { background: rgba(255, 255, 255, .2); border-color: rgba(255, 255, 255, .7); color: #fff; }
.lb-btn .icon { width: 26px; height: 26px; }
.lb-download { width: auto; padding: 0 18px 0 14px; font: 700 .9rem var(--font-head); }
.lb-download .icon { width: 22px; height: 22px; }

.lb-stage {
  position: relative; flex: 1; min-height: 0;
  display: flex; align-items: center; justify-content: center; padding: 0 84px;
}
.lb-img {
  display: block; flex: none; max-width: none; border-radius: 4px; user-select: none;
  background: rgba(255, 255, 255, .05) center / 100% 100% no-repeat;
  box-shadow: 0 12px 48px rgba(0, 0, 0, .5);
}
.lb-stage.is-loading::after {
  content: ""; position: absolute; top: 50%; left: 50%; width: 40px; height: 40px; margin: -20px 0 0 -20px;
  border: 3px solid rgba(255, 255, 255, .25); border-top-color: #fff; border-radius: 50%;
  animation: lb-spin .8s linear infinite; pointer-events: none;
}
@keyframes lb-spin { to { transform: rotate(360deg); } }

.lb-caption {
  margin: 0; padding: 14px 84px 20px; min-height: 64px; text-align: center;
  color: #dbe4f0; font-size: 1rem; line-height: 1.45;
}

.lb-prev, .lb-next { position: absolute; top: 50%; margin-top: -24px; width: 56px; height: 56px; }
.lb-prev { left: 16px; }
.lb-next { right: 16px; }

@media (max-width: 600px) {
  .gallery-albums { gap: 18px; }
  .gallery-photos { grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); gap: 4px; }
  .gallery-photo { border-radius: 4px; }
  .gallery-empty { padding: 36px 20px; }

  .lb-bar { padding: 8px 8px 8px 16px; gap: 8px; }
  .lb-download { width: 48px; padding: 0; }
  .lb-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .lb-stage { padding: 0; }
  .lb-caption { padding: 14px 72px 16px; min-height: 80px; font-size: .95rem; }
  .lb-prev, .lb-next { top: auto; bottom: 14px; margin-top: 0; width: 52px; height: 52px; }
  .lb-prev { left: 10px; }
  .lb-next { right: 10px; }
}

@media (prefers-reduced-motion: reduce) {
  .gallery-cover img, .gallery-photo img, .lb-btn { transition: none; }
  a.gallery-card:hover .gallery-cover img, .gallery-photo:hover img { transform: none; }
  .lb-stage.is-loading::after { animation-duration: 2.4s; }
}

@media print {
  .lightbox, .gallery-back, .gallery-filters { display: none !important; }
  .gallery-count { background: none; color: #000; }
}
