/* =============================================================================
 * gallery.css — legacy picture galleries (/pictures/<brand>/).
 * Loaded only on the 'gallery' template. Responsive thumbnail grid + a
 * dependency-free lightbox. Uses the global Violet Drive tokens.
 * ===========================================================================*/

/* ---- thumbnail grid ------------------------------------------------------ */
.sc-photogrid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(240px, 100%), 1fr));
  gap: 0.85rem;
  margin: 1.4rem 0 1.8rem;
}

.sc-photo {
  margin: 0;
  display: flex;
  flex-direction: column;
}

.sc-photo-link {
  display: block;
  position: relative;
  background: var(--panel-down);
  border-radius: calc(var(--radius) - 4px);
  overflow: hidden;
  box-shadow: var(--shadow-ao);
  cursor: zoom-in;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  outline: none;
}
.sc-photo-link:hover,
.sc-photo-link:focus-visible {
  transform: translateY(-3px);
  box-shadow: var(--glow-amber), var(--shadow-ao);
}
.sc-photo-link:focus-visible {
  box-shadow: 0 0 0 3px var(--amber), var(--shadow-ao);
}

.sc-photo-link img {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  background: var(--panel-down);
}

.sc-photo-cap {
  margin: 0.5rem 0 0;
  font-size: 0.85rem;
  line-height: 1.45;
  color: var(--ink-dim);
}

/* Captioned galleries (speed-cam, sunny) read like a photo essay — wider cells. */
.sc-photogrid-captioned {
  grid-template-columns: repeat(auto-fill, minmax(min(320px, 100%), 1fr));
}
.sc-photogrid-captioned .sc-photo-link img {
  aspect-ratio: auto;
  object-fit: contain;
}
/* Uniform variant: previews are all cropped to the same 4:3 tile (object-fit
   cover); the full, uncropped original is shown only in the lightbox. */
.sc-photogrid-uniform .sc-photo-link img {
  aspect-ratio: 4 / 3;
  object-fit: cover;
}

/* ---- lightbox ------------------------------------------------------------ */
.sc-lightbox {
  position: fixed;
  inset: 0;
  z-index: 11000; /* above ad slots and sticky header */
  display: flex;
  align-items: center;
  justify-content: center;
}
.sc-lightbox[hidden] { display: none; }

.sc-lightbox-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(8, 5, 26, 0.92);
  backdrop-filter: blur(3px);
  cursor: zoom-out;
}

.sc-lightbox-stage {
  position: relative;
  z-index: 1;
  margin: 0;
  max-width: min(96vw, 1100px);
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.6rem;
  pointer-events: none;
}
.sc-lightbox-img {
  max-width: 96vw;
  max-height: 80vh;
  width: auto;
  height: auto;
  border-radius: calc(var(--radius) - 4px);
  box-shadow: var(--shadow-ao);
  background: var(--panel-down);
}
.sc-lightbox-cap {
  max-width: 70ch;
  text-align: center;
  color: var(--ink);
  font-size: 0.95rem;
  line-height: 1.5;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.6);
  pointer-events: auto;
}
.sc-lightbox-cap:empty { display: none; }

.sc-lightbox-count {
  position: absolute;
  bottom: 1rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 2;
  margin: 0;
  font-size: 0.85rem;
  color: var(--ink-dim);
  letter-spacing: 0.04em;
}

/* control buttons */
.sc-lb-btn {
  position: absolute;
  z-index: 3;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: var(--panel);
  color: var(--ink);
  box-shadow: var(--shadow-ao);
  cursor: pointer;
  transition: background 0.15s ease, transform 0.1s ease, color 0.15s ease;
}
.sc-lb-btn:hover { background: var(--amber); color: var(--amber-ink); }
.sc-lb-btn:active { transform: scale(0.94); }
.sc-lb-btn:focus-visible { outline: 3px solid var(--amber); outline-offset: 2px; }
.sc-lb-btn svg { width: 20px; height: 20px; fill: currentColor; }

.sc-lb-close { top: 1rem; right: 1rem; }
.sc-lb-prev  { left: 1rem;  top: 50%; transform: translateY(-50%); }
.sc-lb-next  { right: 1rem; top: 50%; transform: translateY(-50%); }
.sc-lb-prev:active { transform: translateY(-50%) scale(0.94); }
.sc-lb-next:active { transform: translateY(-50%) scale(0.94); }

/* Single-image galleries: hide the prev/next chrome. */
.sc-lightbox.is-single .sc-lb-prev,
.sc-lightbox.is-single .sc-lb-next,
.sc-lightbox.is-single .sc-lightbox-count { display: none; }

/* lock scroll while the lightbox is open */
body.sc-lb-open { overflow: hidden; }

@media (max-width: 560px) {
  .sc-lb-prev { left: 0.4rem; }
  .sc-lb-next { right: 0.4rem; }
  .sc-lb-btn { width: 42px; height: 42px; }
}

@media (prefers-reduced-motion: reduce) {
  .sc-photo-link,
  .sc-lb-btn { transition: none; }
}
