.album {
  padding-block: clamp(3rem, 6vw, 6rem);
}
.album-head, .album-index, .album-index nav, .album-pages, .viewer-tools, .viewer-position {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.album-head {
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 1.25rem;
  padding-bottom: clamp(2rem, 4vw, 3.5rem);
}
.album-head h1 {
  font: 400 clamp(3.25rem, 7.25vw, 7rem)/1.06 var(--serif);
  letter-spacing: -.045em;
  margin: .85rem 0 0;
}
.album-head h1 em { color: var(--accent); }
.album-random, .album-index a, .album-pages a, .gallery-viewer button, .viewer-tools a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 99px;
  border: 1px solid var(--line);
  color: var(--ink);
  background: transparent;
  text-decoration: none;
  cursor: pointer;
  font: 500 .9rem var(--sans);
}
.album-random[hidden] { display: none; }
.album-random {
  padding: .875rem 1.3rem;
  gap: .65rem;
  border-color: var(--ink);
}
.album svg, .gallery-viewer svg {
  width: 1.25rem;
  height: 1.25rem;
  flex-shrink: 0;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.7;
  fill: none;
}
.album-index {
  flex-wrap: wrap;
  gap: .5rem;
  border-top: 1px solid var(--line);
  color: var(--muted);
  padding: 1rem 0;
  font: 500 .875rem var(--sans);
}
.album-index nav { gap: .4rem; }
.album-index nav span { margin-right: .6rem; }
.album-index a, .album-pages a { width: 44px; height: 44px; }
.album-index a[aria-disabled] { opacity: .4; cursor: default; }
.album-random:hover, .album-pages a:hover, .album-index a[href]:hover { background: var(--soft); }
.album-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: clamp(.5rem, 1.4vw, 1.3rem);
}
.album-link {
  display: block;
  position: relative;
  overflow: hidden;
  background: var(--soft);
  aspect-ratio: 4 / 3;
  border-radius: 8px;
}
.album-link img { display: block; width: 100%; height: 100%; object-fit: cover; }
.album-link span {
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: absolute;
  inset: auto 0 0;
  padding: 2.5rem 1rem 1rem;
  color: white;
  font: 500 .9rem var(--sans);
  background: linear-gradient(transparent, rgba(0,0,0,.78));
  opacity: 0;
}
.album-link:is(:hover, :focus-visible) span { opacity: 1; }
.album-pages {
  justify-content: center;
  gap: clamp(.2rem, 1vw, .7rem);
  padding-top: clamp(2rem, 4vw, 3.5rem);
}
.album-pages a { border-color: transparent; }
.album-pages a[aria-current] { background: var(--ink); color: var(--paper); }
@media (max-width: 740px) {
  .album-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
}
@media (max-width: 480px) {
  .album-index nav span { display: none; }
  .album-head h1 { font-size: clamp(2.65rem, 12vw, 3.5rem); }
  .album-link { border-radius: 4px; }
}
@media (prefers-reduced-motion: no-preference) {
  .album-link img { transition: transform .4s ease; }
  .album-link span { transition: opacity .25s ease; }
  .album-link:hover img { transform: scale(1.035); }
}

html:has(.gallery-viewer[open]) { overflow: hidden; }
.gallery-viewer:not([open]) { display: none; }
.gallery-viewer[open] {
  position: fixed;
  inset: 0;
  display: grid;
  grid-template-rows: auto minmax(4rem, 1fr) auto;
  grid-template-columns: minmax(0, 1fr);
  gap: clamp(.5rem, 2vh, 1.5rem);
  width: 100%;
  height: 100%;
  height: 100dvh;
  max-width: none;
  max-height: none;
  margin: 0;
  padding: clamp(.65rem, 2.5vh, 2rem) clamp(.75rem, 4vw, 4rem);
  color: #fff;
  border: 0;
  background: #101b20;
  background: color-mix(in srgb, var(--ink) 20%, #080a0b);
  font: 500 .95rem var(--sans);
  overscroll-behavior: contain;
}
.gallery-viewer::backdrop { background: #101b20; }
.gallery-viewer button, .viewer-tools a {
  color: white;
  border-color: #ffffff55;
  height: 44px;
  flex: none;
}
.gallery-viewer button { width: 44px; padding: 0; }
.viewer-tools a { padding-inline: 1rem; gap: .4rem; }
.gallery-viewer button:hover, .viewer-tools a:hover { background: #ffffff25; }
.gallery-viewer :focus-visible { outline: 2px solid #fff; outline-offset: 3px; }
.viewer-stage {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  touch-action: pan-y pinch-zoom;
}
.viewer-stage img {
  max-width: 100%;
  max-height: 100%;
  display: block;
  object-fit: contain;
}
.viewer-stage span { position: absolute; text-align: center; }
.viewer-position {
  justify-content: center;
  gap: 1rem;
  text-align: center;
  font-variant-numeric: tabular-nums;
}
.viewer-position span {
  min-width: 6rem;
  max-height: 15vh;
  overflow: auto;
  overflow-wrap: anywhere;
}
@media (min-width: 850px) and (min-height: 450px) {
  .viewer-stage { margin-inline: 4.5rem; }
  .viewer-position button { position: absolute; top: calc(50% - 22px); }
  .viewer-position [data-previous] { left: clamp(.75rem, 4vw, 4rem); }
  .viewer-position [data-next] { right: clamp(.75rem, 4vw, 4rem); }
}
