/* =========================================================================
   Product gallery: a stage and a thumbnail rail.

   The photography is unedited camera output on the studio backdrop, so the
   stage is a dark neutral rather than white -- a white stage would put bright
   bars either side of a photo whose own background is grey, and the seam
   would read as a mistake. Dark framing makes the letterboxing deliberate.

   The stage is 3:4 because that is the phone's portrait ratio, so upright
   shots fill it edge to edge; the occasional landscape frame letterboxes
   inside the same box rather than changing the page height.
   ========================================================================= */

.td-gallery {
  display: grid;
  gap: 12px;
  min-width: 0;
}

.td-gallery__stage {
  position: relative;
  margin: 0;
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-lg);
  overflow: hidden;
  aspect-ratio: 3 / 4;
}

.td-gallery__main {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  animation: td-gallery-in .32s cubic-bezier(.2,.7,.3,1);
}

@keyframes td-gallery-in {
  from { opacity: 0; transform: scale(.985); }
  to   { opacity: 1; transform: none; }
}

/* Says which colour is pictured whenever that is not the colour chosen. */
.td-gallery__tag {
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: 12px;
  width: fit-content;
  max-width: calc(100% - 24px);
  background: rgba(13, 13, 13, .88);
  color: #fff;
  font-size: .78rem;
  font-weight: 600;
  line-height: 1.35;
  padding: 8px 12px;
  border-radius: 999px;
}
.td-gallery__tag[hidden] { display: none; }

.td-gallery__thumbs {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(74px, 1fr));
  gap: 10px;
}
.td-gallery__thumbs[hidden] { display: none; }

.td-gallery__thumb {
  padding: 0;
  aspect-ratio: 1 / 1;
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: 10px;
  overflow: hidden;
  cursor: pointer;
  transition: border-color .2s ease, transform .2s ease, box-shadow .2s ease;
}
.td-gallery__thumb img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.td-gallery__thumb:hover { transform: translateY(-2px); }
.td-gallery__thumb:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.td-gallery__thumb.is-active {
  border-color: var(--accent);
  box-shadow: inset 0 0 0 1px var(--accent);
}

@media (prefers-reduced-motion: reduce) {
  .td-gallery__main { animation: none; }
  .td-gallery__thumb:hover { transform: none; }
}

@media (max-width: 640px) {
  .td-gallery__thumbs { grid-template-columns: repeat(auto-fill, minmax(62px, 1fr)); }
}
