/* Photo albums: a gapless mosaic like the home page; tap a photo to view it
   large, with its date, place, licence, and the original to download. */

.album-page { background: var(--ink); color: var(--paper); }
.album-page .mast { border-bottom-color: #2c2a27; }
.album-page a:hover { color: #9fd0ff; }

.album-head { max-width: 46rem; padding: clamp(2.5rem, 7vh, 5rem) clamp(1.25rem, 5vw, 3.5rem) 2.5rem; }
.album-head .kicker { color: #9fd0ff; }
.album-head h1 { margin-bottom: 1rem; }
.album-head .lede { margin: 0; font-size: clamp(1.15rem, 1.8vw, 1.4rem); line-height: 1.35; }
.album-head .aside { margin: 1rem 0 0; font-size: 1rem; line-height: 1.5; color: #cfcac0; }
.album-head .aside a { color: inherit; }
.album-head .license { margin: 1.2rem 0 0; font: 500 0.75rem/1.6 var(--mono); text-transform: uppercase; letter-spacing: 0.04em; color: #a8a49b; }

/* Square cells; features take 2x2, wide photos 2x1, tall photos 1x2. */
.album-grid {
  --cols: 6;
  --cell: calc(100vw / var(--cols));
  display: grid;
  grid-template-columns: repeat(var(--cols), 1fr);
  grid-auto-rows: var(--cell);
}
.tile-photo { position: relative; overflow: hidden; margin: 0; padding: 0; border: 0; background: #222; cursor: zoom-in; }
.tile-photo img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform 0.9s cubic-bezier(.25,.8,.25,1), filter 0.4s; }
.tile-photo:hover img, .tile-photo:focus-visible img { transform: scale(1.04); }
.tile-photo:focus-visible { outline: 3px solid #fff; outline-offset: -3px; z-index: 1; }

@media (max-width: 90rem) { .album-grid { --cols: 5; } }
@media (max-width: 60rem) { .album-grid { --cols: 4; } }
@media (max-width: 40rem) { .album-grid { --cols: 2; } }

/* The viewer */
body.locked { overflow: hidden; }
.viewer {
  position: fixed; inset: 0; z-index: 100;
  display: grid; grid-template-columns: 4rem 1fr 4rem; grid-template-rows: 1fr auto;
  background: #0a0a09; color: #efece5;
  animation: v-in 0.3s ease both;
}
.viewer[hidden] { display: none; }
@keyframes v-in { from { opacity: 0; } to { opacity: 1; } }
.v-frame { grid-column: 2; grid-row: 1; margin: 0; min-height: 0; position: relative; }
/* The photo fits the space above the caption bar, whatever its shape. */
.v-frame img { position: absolute; top: 1.5rem; left: 0; width: 100%; height: calc(100% - 2rem); object-fit: contain; display: block; transition: opacity 0.25s ease; }
.v-frame img.loading { opacity: 0.35; }
.v-prev, .v-next, .v-close {
  border: 0; background: none; color: #efece5; cursor: pointer;
  font: 300 2rem/1 var(--sans); opacity: 0.7; transition: opacity 0.2s;
}
.v-prev:hover, .v-next:hover, .v-close:hover { opacity: 1; }
.v-prev { grid-column: 1; grid-row: 1; }
.v-next { grid-column: 3; grid-row: 1; }
.v-close { position: absolute; top: 0.75rem; right: 1rem; z-index: 2; width: 3rem; height: 3rem; font-size: 2.2rem; }
.v-bar {
  grid-column: 1 / -1; grid-row: 2;
  display: flex; align-items: flex-end; justify-content: space-between; gap: 1.5rem;
  padding: 0.75rem clamp(1rem, 4vw, 4rem) 1.25rem;
}
.v-meta p { margin: 0; }
.v-caption { font-size: 1.05rem; font-weight: 600; }
.v-detail, .v-credit { margin-top: 0.3rem !important; font: 500 0.72rem/1.5 var(--mono); text-transform: uppercase; letter-spacing: 0.04em; color: #a8a49b; }
.v-detail span + span::before { content: " · "; }
.v-detail span[hidden] + span::before { content: none; }
.v-credit a { color: inherit; }
.v-download {
  flex: none; padding: 0.7rem 1rem; border: 1px solid rgb(239 236 229 / 0.4);
  color: #efece5; text-decoration: none;
  font: 500 0.75rem/1 var(--mono); text-transform: uppercase; letter-spacing: 0.05em;
  transition: background 0.2s, color 0.2s;
}
.v-download::after { content: " \2193"; }
.v-download:hover { background: #efece5; color: #161513 !important; }

@media (max-width: 40rem) {
  .viewer { grid-template-columns: 1fr; }
  .v-prev, .v-next { display: none; }
  .v-frame { grid-column: 1; }
  .v-frame img { top: 3.75rem; height: calc(100% - 4.25rem); }
  .v-bar { flex-direction: column; align-items: stretch; gap: 0.9rem; }
  .v-download { text-align: center; }
}
@media (prefers-reduced-motion: reduce) {
  .viewer { animation: none; }
  .tile-photo img, .v-frame img { transition: none; }
}
