/* Gallery, album grids and the photo viewer. Tokens live in base.css. */

.breadcrumb { color: var(--color-muted); margin-bottom: var(--space-2); }
.empty { color: var(--color-muted); }
.gallery-section { margin-top: var(--space-7); }

.album-tiles, .decade-tiles, .photo-grid { list-style: none; padding: 0; margin: 0 0 var(--space-6); display: grid; }

.album-tiles { gap: var(--space-5); }
@media (min-width: 768px) { .album-tiles { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 1100px) { .album-tiles { grid-template-columns: repeat(3, 1fr); } }

.album-tile, .decade-tile {
  display: block;
  position: relative;
  overflow: hidden;
  border-radius: var(--radius-lg);
  background: var(--color-pond);
  color: var(--color-pond-text);
  text-decoration: none;
  box-shadow: var(--shadow-card);
}
.album-tile img { width: 100%; aspect-ratio: 3 / 2; object-fit: cover; }
.album-tile__title, .album-tile__count, .decade-tile__label, .decade-tile__count {
  position: absolute;
  left: var(--space-4);
  right: var(--space-4);
  text-shadow: 0 1px 3px rgb(0 0 0 / 0.8);
}
.album-tile::after, .decade-tile::after {
  /* Scrim so the white title reads on any photo. */
  content: "";
  position: absolute;
  inset: 40% 0 0 0;
  background: linear-gradient(to bottom, rgb(0 0 0 / 0), rgb(0 0 0 / 0.72));
}
.album-tile__title, .album-tile__count, .decade-tile__label, .decade-tile__count { z-index: 1; }
.album-tile__title {
  bottom: calc(var(--space-4) + 1.6em);
  font-family: var(--font-heading);
  font-weight: 600;
  font-size: var(--text-xl);
  line-height: var(--leading-heading);
}
.album-tile__count, .decade-tile__count { bottom: var(--space-3); font-size: var(--text-sm); }
.album-tile:hover .album-tile__title, .decade-tile:hover .decade-tile__label { text-decoration: underline; text-decoration-thickness: 2px; text-underline-offset: 0.12em; }

.decade-tiles { grid-template-columns: repeat(2, 1fr); gap: var(--space-4); }
@media (min-width: 768px) { .decade-tiles { grid-template-columns: repeat(4, 1fr); } }
/* Archive prints are never tinted or filtered: the scuffs are the point. */
.decade-tile img { width: 100%; aspect-ratio: 1; object-fit: cover; }
.decade-tile__label {
  bottom: calc(var(--space-3) + 1.5em);
  font-family: var(--font-heading);
  font-weight: 600;
  font-size: var(--text-2xl);
  line-height: 1;
}

/* Photo grid: two columns on phones, more on wider screens. */
.photo-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-3); }
@media (min-width: 768px) { .photo-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--space-4); } }
@media (min-width: 1100px) { .photo-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.photo-link { display: block; border-radius: var(--radius-md); overflow: hidden; background: var(--color-border); }
.photo-link img { width: 100%; aspect-ratio: 1; object-fit: cover; }
/* Archive albums: each print whole, unretouched, on a paper mount. The
   square keeps the grid even; the print sits inside it uncropped. */
.photo-grid--archive .photo-link {
  padding: var(--space-2);
  background: var(--color-paper);
  border: var(--border-width) solid var(--color-paper-edge);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-card);
}
.photo-grid--archive .photo-link img { object-fit: contain; }
.photo-grid--archive .photo-link:hover { border-color: var(--color-wood); }
.photo-note { font-size: var(--text-sm); line-height: 1.45; margin: var(--space-2) 0 0; }
.photo-ask { font-size: var(--text-sm); margin: var(--space-1) 0 0; }
.photo-ask a { display: inline-block; padding: var(--space-1) 0; }

/* Viewer */
.viewer {
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  max-width: none;
  max-height: none;
  margin: 0;
  padding: var(--space-3);
  border: 0;
  background: rgb(8 12 11 / 0.96);
  color: var(--color-pond-text);
  flex-direction: column;
  gap: var(--space-2);
}
.viewer[open] { display: flex; }
.viewer::backdrop { background: rgb(0 0 0 / 0.8); }
.viewer__bar, .viewer__nav { display: flex; justify-content: space-between; align-items: center; gap: var(--space-3); }
.viewer__figure {
  flex: 1;
  min-height: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  touch-action: pan-y pinch-zoom;
  user-select: none;
}
.viewer__img { max-width: 100%; max-height: calc(100% - 4.5em); object-fit: contain; }
.viewer__caption { text-align: center; max-width: var(--measure); }
.viewer__ask { color: var(--color-pond-text); }
.viewer__close, .viewer__prev, .viewer__next {
  min-height: var(--tap-target);
  min-width: 6.5em;
  padding: var(--space-2) var(--space-4);
  border: 2px solid currentColor;
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--color-pond-text);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

@media print {
  .viewer, .edit-link, .photo-ask { display: none; }
  .photo-grid { grid-template-columns: repeat(3, 1fr); }
}

/* The hidden attribute wins over component display rules. */
[hidden] { display: none !important; }
.viewer__nav[hidden] { display: none; }

/* A named archive album ("The 1915 charter and the club history"): smaller
   words on a full scrim, so the title fits the square tile at 390px. */
.decade-tile--long::after { inset: 0; background: linear-gradient(to bottom, rgb(0 0 0 / 0.35), rgb(0 0 0 / 0.75)); }
.decade-tile--long .decade-tile__label { font-size: var(--text-lg); line-height: 1.2; }
