/* ==========================================================================
   Help The Poor Initiative — Photo Gallery
   Page-specific only. Tokens, header, footer, page banner, buttons and the
   CTA band all come from css/style.css.

   CSS grid rather than columns: multi-column would reorder the photographs
   visually without reordering them in the DOM, which breaks tab order and
   what a screen reader announces. Grid keeps source order == reading order
   == visual order, and still gives the layout editorial rhythm through a few
   deliberately larger tiles.
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. Filters
   -------------------------------------------------------------------------- */
.shots { padding: 46px 0 90px; }

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
  margin-bottom: 12px;
}

.filter {
  padding: 9px 17px;
  border-radius: 999px;
  border: 1.5px solid var(--line);
  background: var(--surface);
  font-family: var(--font-display);
  font-size: .8125rem;
  font-weight: 700;
  color: var(--muted);
  cursor: pointer;
  transition: color var(--speed) var(--ease),
              border-color var(--speed) var(--ease),
              background-color var(--speed) var(--ease);
}

.filter:hover {
  border-color: color-mix(in srgb, var(--accent, var(--green)) 45%, var(--line));
  color: var(--accent, var(--green));
}

.filter[aria-pressed="true"] {
  background: var(--accent, var(--green));
  border-color: var(--accent, var(--green));
  color: #fff;
}

.shot-count {
  min-height: 22px;
  margin-bottom: 26px;
  font-size: .875rem;
  color: var(--muted);
}

.shot-count strong { color: var(--ink); font-weight: 700; }

/* --------------------------------------------------------------------------
   2. The grid
   -------------------------------------------------------------------------- */
.shot-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  /* Fixed row height + row spans is what lets a tile be "tall" without
     knowing the photograph's real proportions. */
  grid-auto-rows: 190px;
  gap: 14px;
}

.shot {
  position: relative;
  grid-row: span 1;
  overflow: hidden;
  border-radius: var(--radius);
  background: var(--surface-alt);
  border: 0;
  padding: 0;
  cursor: zoom-in;
  transition: transform var(--speed) var(--ease), box-shadow var(--speed) var(--ease);
}

/* A handful of tiles run double height, so the wall does not read as a uniform
   contact sheet. Set per-item in the markup.

   Height only, never width: a double-width tile cannot start in the last column,
   so it wraps and leaves a hole behind it. Measured at 1440/1100/768/390, tall
   tiles alone tessellate with zero gaps, while adding wide ones left holes at
   every breakpoint — and grid-auto-flow:dense fixed neither the gaps nor the
   reordering it caused. */
.shot--tall { grid-row: span 2; }

.shot[hidden] { display: none; }

/* Branded placeholder painted behind every tile. While the photograph loads —
   or if the file is missing entirely — this is what shows, instead of a blank
   box or a broken-image icon. Same intent as .media in style.css. */
.shot::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 240 150'%3E%3Ccircle cx='120' cy='52' r='42' fill='%23EE7C20'/%3E%3Cpath d='M6 146c22-38 62-60 114-60s92 22 114 60c-30-26-68-40-114-40S36 120 6 146Z' fill='%231E5C26'/%3E%3C/svg%3E")
      center / 44% no-repeat,
    linear-gradient(150deg, var(--green-soft) 0%, var(--surface-alt) 100%);
  opacity: .55;
}

.shot img {
  position: relative;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform .7s var(--ease-glide), opacity var(--speed) var(--ease);
}

/* Set by the inline onerror handler — inline because an image can fail before
   gallery.js has executed. */
.shot img.is-missing { opacity: 0; }

.shot:hover { box-shadow: var(--shadow-md); }
.shot:hover img { transform: scale(1.06); }

.shot:focus-visible {
  outline: 3px solid var(--orange);
  outline-offset: 3px;
}

/* Caption rides in from the bottom edge on hover/focus. */
.shot-cap {
  position: absolute;
  inset: auto 0 0 0;
  padding: 30px 14px 12px;
  text-align: left;
  background: linear-gradient(to top, rgba(8, 26, 12, .88) 0%, transparent 100%);
  color: #fff;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity var(--speed) var(--ease), transform var(--speed) var(--ease);
}

.shot:hover .shot-cap,
.shot:focus-visible .shot-cap { opacity: 1; transform: translateY(0); }

.shot-cap span {
  display: block;
  font-family: var(--font-display);
  font-size: .625rem;
  font-weight: 800;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--orange-warm);
  margin-bottom: 3px;
}

.shot-cap p {
  font-size: .8125rem;
  line-height: 1.45;
  color: #fff;
}

/* Empty state — should be unreachable, since every filter has photographs. */
.no-shots {
  display: none;
  grid-column: 1 / -1;
  padding: 54px 24px;
  text-align: center;
  border: 1px dashed var(--line);
  border-radius: var(--radius-lg);
  color: var(--muted);
}

.no-shots.is-shown { display: block; }

/* --------------------------------------------------------------------------
   3. Lightbox
   -------------------------------------------------------------------------- */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 120;
  display: grid;
  grid-template-rows: auto 1fr auto;
  padding: 18px;
  background: rgba(6, 18, 9, .94);
  opacity: 0;
  visibility: hidden;
  /* visibility is stepped, not eased. Transitioning it means that at the instant
     .is-open is added the computed value is still `hidden`, so focus() into the
     dialog is refused and the reader is left on the page behind. Instead: on
     close, hold visibility until the fade finishes (0s delay .28s); on open,
     flip it immediately (0s, no delay) so the dialog is focusable at once. */
  transition: opacity .28s var(--ease), visibility 0s linear .28s;
}

.lightbox.is-open {
  opacity: 1;
  visibility: visible;
  transition: opacity .28s var(--ease), visibility 0s linear 0s;
}

.lb-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  color: rgba(255, 255, 255, .72);
  font-size: .8125rem;
}

.lb-counter { font-variant-numeric: tabular-nums; letter-spacing: .04em; }

.lb-close,
.lb-nav {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: rgba(255, 255, 255, .1);
  color: #fff;
  cursor: pointer;
  transition: background-color var(--speed) var(--ease), transform var(--speed) var(--ease);
}

.lb-close:hover,
.lb-nav:hover { background: rgba(255, 255, 255, .22); }
.lb-nav:hover { transform: scale(1.06); }

.lb-close:focus-visible,
.lb-nav:focus-visible { outline: 3px solid var(--orange); outline-offset: 2px; }

.lb-stage {
  position: relative;
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) 44px;
  align-items: center;
  gap: 14px;
  min-height: 0;
}

.lb-figure {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  min-height: 0;
  height: 100%;
}

.lb-figure img {
  max-width: 100%;
  /* Leaves room for the caption under it without the image ever overflowing. */
  max-height: calc(100% - 58px);
  object-fit: contain;
  border-radius: var(--radius);
  background: #0b1f0f;
}

.lb-cap {
  max-width: 62ch;
  text-align: center;
  color: rgba(255, 255, 255, .82);
  font-size: .9375rem;
  line-height: 1.55;
}

.lb-cap b {
  display: block;
  margin-bottom: 4px;
  font-family: var(--font-display);
  font-size: .625rem;
  font-weight: 800;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--orange-warm);
}

.lb-foot {
  padding-top: 10px;
  text-align: center;
  font-size: .75rem;
  color: rgba(255, 255, 255, .45);
}

.lb-foot kbd {
  padding: 2px 6px;
  border-radius: 4px;
  background: rgba(255, 255, 255, .12);
  font-family: inherit;
  font-size: .6875rem;
}

/* --------------------------------------------------------------------------
   4. Responsive
   -------------------------------------------------------------------------- */
@media (max-width: 1100px) {
  .shot-grid { grid-template-columns: repeat(3, 1fr); grid-auto-rows: 175px; }
}

@media (max-width: 768px) {
  .shots { padding: 34px 0 64px; }
  .shot-grid { grid-template-columns: repeat(2, 1fr); grid-auto-rows: 150px; gap: 10px; }
  .filter { padding: 8px 13px; font-size: .75rem; }

  /* On a small screen the caption is the only way to know what a photo shows,
     so it stops depending on hover. */
  .shot-cap { opacity: 1; transform: none; padding-top: 24px; }

  .lightbox { padding: 12px; }
  .lb-stage { grid-template-columns: 1fr; }
  /* Arrows move below the picture rather than squeezing it. */
  .lb-nav { position: absolute; bottom: 0; }
  .lb-nav--prev { left: 12%; }
  .lb-nav--next { right: 12%; }
  .lb-figure { padding-bottom: 56px; }
  .lb-foot { display: none; }
}

@media (max-width: 480px) {
  .shot-grid { grid-template-columns: 1fr 1fr; grid-auto-rows: 132px; }
  .shot-cap p { font-size: .75rem; }
}

/* --------------------------------------------------------------------------
   5. Reduced motion
   -------------------------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  .shot img,
  .shot,
  .shot-cap,
  .lightbox { transition: none !important; }
  .shot:hover img { transform: none; }
}
