/* Photo gallery (assets/gallery.js). The parent gives .tb-gallery its size (height or aspect-ratio).
   Without JS it is a swipeable scroll-snap strip with a label on each photo. */
.tb-gallery { position: relative; overflow: hidden; background: var(--ink); isolation: isolate; }
.tb-gallery__track {
  position: absolute; inset: 0;
  display: flex; overflow-x: auto; overflow-y: hidden;
  scroll-snap-type: x mandatory; scroll-behavior: smooth;
  scrollbar-width: none; overscroll-behavior-x: contain;
}
.tb-gallery__track::-webkit-scrollbar { display: none; }
.tb-gallery__track:focus-visible { outline: 2px solid var(--paper); outline-offset: -4px; }
.tb-gallery__slide { position: relative; flex: 0 0 100%; height: 100%; margin: 0; scroll-snap-align: start; scroll-snap-stop: always; }
.tb-gallery__img { position: absolute; inset: 0; background-color: var(--ink-2); background-size: cover; background-position: center; }
.tb-gallery__img > .tb-ps { position: absolute; inset: 0; border-radius: 0; border: none; }
/* a PhotoSlot in a gallery: caption sits above the controls, pill stays clear of overlays */
.tb-gallery .tb-ps__bottom { padding-bottom: 72px; }
.tb-gallery .tb-ps__credit { display: none; }
.tb-gallery__label {
  position: absolute; left: 14px; bottom: 14px; z-index: 2;
  padding: 5px 10px; border-radius: 999px;
  background: color-mix(in srgb, var(--ink) 70%, transparent); color: var(--paper);
  font-family: var(--mono); font-size: 11px; letter-spacing: 0.1em; text-transform: uppercase;
}
.tb-gallery.is-ready .tb-gallery__label { display: none; }

/* prev / next */
.tb-gallery__nav {
  position: absolute; top: 50%; z-index: 3; transform: translateY(-50%);
  width: 44px; height: 44px; border-radius: 50%; border: none; cursor: pointer;
  display: grid; place-items: center;
  background: color-mix(in srgb, var(--paper) 88%, transparent); color: var(--ink);
  font-size: 26px; line-height: 1; padding: 0 0 3px;
  opacity: 0; transition: opacity var(--t-fast, .2s ease), background var(--t-fast, .2s ease);
}
.tb-gallery__nav--prev { left: 12px; }
.tb-gallery__nav--next { right: 12px; }
.tb-gallery:hover .tb-gallery__nav, .tb-gallery:focus-within .tb-gallery__nav { opacity: 1; }
.tb-gallery__nav:hover { background: var(--paper); }
@media (hover: none) { .tb-gallery__nav { opacity: 0.92; } }

/* the labelled pills (dots) and pause/play */
.tb-gallery__bar {
  position: absolute; left: 12px; right: 12px; bottom: 12px; z-index: 3;
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  pointer-events: none;
}
.tb-gallery__pills {
  display: flex; gap: 4px; padding: 4px; border-radius: 999px; min-width: 0;
  background: color-mix(in srgb, var(--ink) 62%, transparent);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  overflow-x: auto; scrollbar-width: none; pointer-events: auto;
}
.tb-gallery__pills::-webkit-scrollbar { display: none; }
.tb-gallery__pill {
  position: relative; overflow: hidden; flex-shrink: 0;
  min-height: 36px; padding: 0 12px; border: none; border-radius: 999px; cursor: pointer;
  background: transparent; color: color-mix(in srgb, var(--paper) 78%, transparent);
  font-family: var(--mono); font-size: 10.5px; letter-spacing: 0.1em; text-transform: uppercase;
}
.tb-gallery__pill::before { content: ""; position: absolute; inset: -4px 0; } /* 44px tap height */
.tb-gallery__pill:hover { color: var(--paper); }
.tb-gallery__pill[aria-current="true"] { background: color-mix(in srgb, var(--paper) 18%, transparent); color: var(--paper); }
.tb-gallery__pill-text { position: relative; z-index: 1; }
.tb-gallery__pill-fill { position: absolute; left: 0; bottom: 0; height: 2px; width: 0; background: var(--paper); }
.tb-gallery.is-playing .tb-gallery__pill[aria-current="true"] .tb-gallery__pill-fill { animation: tb-gallery-fill 5s linear forwards; }
@keyframes tb-gallery-fill { from { width: 0; } to { width: 100%; } }
.tb-gallery__play {
  flex-shrink: 0; width: 44px; height: 44px; border-radius: 50%; border: none; cursor: pointer;
  background: color-mix(in srgb, var(--ink) 62%, transparent); color: var(--paper);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  display: grid; place-items: center; pointer-events: auto; position: relative;
}
/* pause bars, or a play triangle when stopped */
.tb-gallery__play::before { content: ""; width: 10px; height: 12px; border-left: 3px solid currentColor; border-right: 3px solid currentColor; box-sizing: border-box; }
.tb-gallery.is-stopped .tb-gallery__play::before { width: 0; height: 0; border-style: solid; border-width: 7px 0 7px 11px; border-color: transparent transparent transparent currentColor; margin-left: 3px; }
.tb-gallery__play:hover, .tb-gallery__play:focus-visible { background: var(--ink); }
.tb-gallery__pill:focus-visible, .tb-gallery__play:focus-visible, .tb-gallery__nav:focus-visible { outline: 2px solid var(--paper); outline-offset: 2px; }

@media (prefers-reduced-motion: reduce) {
  .tb-gallery__track { scroll-behavior: auto; }
  .tb-gallery.is-playing .tb-gallery__pill[aria-current="true"] .tb-gallery__pill-fill { animation: none; width: 100%; }
}
@media (max-width: 560px) {
  .tb-gallery__pill { padding: 0 9px; font-size: 10px; letter-spacing: 0.06em; }
}
