/* Gallery page — uses the site tokens, buttons, and type from style.css */

.gallery-page {
  padding: 128px 0 96px;
}

.gallery-head {
  max-width: 760px;
  margin-bottom: 40px;
}

.gallery-head h1 {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: clamp(40px, 5vw, 72px);
  line-height: 1.05;
  letter-spacing: -0.01em;
  margin-bottom: 16px;
}

.gallery-lede {
  color: var(--muted);
  font-size: 18px;
  line-height: 1.5;
  max-width: 42em;
}

.photo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 18px;
}

.photo-card {
  display: flex;
  flex-direction: column;
  min-width: 0;
  content-visibility: auto;
  contain-intrinsic-size: auto 280px;
  background: #262121;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 16px;
  overflow: hidden;
}

.photo-open {
  position: relative;
  display: block;
  width: 100%;
  margin: 0;
  padding: 0;
  border: 0;
  background: #111;
  cursor: zoom-in;
  aspect-ratio: 1 / 1;
  overflow: hidden;
}

.photo-open img {
  position: absolute;
  inset: 0;
  z-index: 1;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  transition: opacity 0.28s ease;
}

.photo-open img.is-ready {
  opacity: 1;
}

.photo-open.is-loading::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(100deg, rgba(255, 255, 255, 0.04) 30%, rgba(255, 255, 255, 0.14) 50%, rgba(255, 255, 255, 0.04) 70%);
  background-size: 200% 100%;
  animation: photo-shimmer 1.3s ease-in-out infinite;
}

.photo-open:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: -2px;
}

.photo-meta {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  min-width: 0;
  padding: 8px;
}

.photo-name {
  display: none;
}

.photo-download {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 999px;
  color: var(--ink);
  background: transparent;
  box-shadow: inset 0 0 0 1.5px rgba(229, 229, 229, 0.4);
  text-decoration: none;
}

.photo-download:hover,
.photo-download:focus-visible {
  background: var(--light);
  color: var(--ink-dark);
  box-shadow: none;
}

.photo-download svg {
  width: 18px;
  height: 18px;
}

/* Native dialog viewer. Full viewport so the photo and controls stay in frame. */
dialog.lightbox {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  max-width: none;
  max-height: none;
  margin: 0;
  padding: 24px;
  border: 0;
  background: rgba(12, 10, 10, 0.94);
  color: var(--ink);
}

.lightbox::backdrop {
  background: rgba(12, 10, 10, 0.94);
}

.lightbox-frame {
  position: relative;
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  gap: 16px;
  height: 100%;
  min-height: 0;
}

.lightbox-frame.is-loading::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 42%;
  width: 36px;
  height: 36px;
  margin: -18px 0 0 -18px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.2);
  border-top-color: #fff;
  animation: photo-spin 0.7s linear infinite;
}

.lightbox-img {
  display: block;
  width: 100%;
  height: 100%;
  min-height: 0;
  object-fit: contain;
  border-radius: 12px;
  background: transparent;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.lightbox-img.is-ready {
  opacity: 1;
}

.lightbox-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.lightbox-name {
  display: none;
}

.lightbox-count {
  margin: 0;
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 14px;
  font-variant-numeric: tabular-nums;
}

.lightbox-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.lightbox-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--ink);
  box-shadow: inset 0 0 0 1.5px rgba(229, 229, 229, 0.45);
  cursor: pointer;
}

.lightbox-icon svg {
  width: 20px;
  height: 20px;
}

.lightbox-icon:hover,
.lightbox-icon:focus-visible {
  background: var(--light);
  color: var(--ink-dark);
  box-shadow: none;
}

.lightbox-download .btn-pill {
  padding: 10px 18px;
  font-size: 14px;
}

body.lightbox-open {
  overflow: hidden;
}

@media (max-width: 720px) {
  .gallery-page { padding: 104px 0 72px; }
  .photo-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
  .lightbox-bar { flex-wrap: wrap; }
  .lightbox-actions { width: 100%; margin-left: 0; }
  .lightbox-name { flex-basis: 100%; }
}

@keyframes photo-shimmer {
  from { background-position: 100% 0; }
  to { background-position: -100% 0; }
}

@keyframes photo-spin {
  to { transform: rotate(360deg); }
}

@media (prefers-reduced-motion: reduce) {
  .lightbox { transition: none; }
  .photo-open img,
  .lightbox-img { transition: none; }
  .photo-open.is-loading::before,
  .lightbox-frame.is-loading::before { animation: none; }
}
