.gallery__viewport {
  position: relative;
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: var(--color-muted);
  touch-action: pan-y;
}

.gallery__list {
  display: flex;
  width: 100%;
  max-width: none;
  margin: 0;
  padding: 0;
  list-style: none;
  overflow: visible;
  transform: translateX(var(--gallery-offset, 0));
  transition: transform var(--dur-base) var(--ease-out);
}

.gallery__list.is-jumping {
  transition: none;
}

.gallery__slide {
  flex: 0 0 100%;
  aspect-ratio: 4 / 3;
}

@media (max-width: 767px) {
  .gallery__slide {
    aspect-ratio: 16 / 9;
  }

  .gallery__thumb {
    width: 60px;
    height: 44px;
  }
}

.gallery__slide img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.gallery__zoom {
  display: block;
  width: 100%;
  height: 100%;
  cursor: zoom-in;
}

.gallery__zoom:focus-visible {
  outline: 2px solid var(--color-ring);
  outline-offset: -2px;
}

.gallery__thumbs-wrap {
  position: relative;
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr) 34px;
  gap: var(--space-2);
  align-items: center;
  margin-top: var(--space-3);
}

.gallery__thumbs {
  display: flex;
  flex-wrap: nowrap;
  max-width: none;
  gap: var(--space-2);
  margin: 0;
  padding: 0;
  list-style: none;
  overflow: hidden;
  scroll-behavior: smooth;
}

.gallery__thumbs li {
  flex: 0 0 auto;
  list-style: none;
}

.gallery__thumb {
  display: block;
  width: 72px;
  height: 54px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 2px solid transparent;
  opacity: .7;
  transition: opacity var(--dur-fast) var(--ease-out), border-color var(--dur-fast) var(--ease-out);
}

.gallery__thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: 80% center;
  display: block;
}

.gallery__thumb-nav {
  width: 34px;
  height: 54px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: var(--radius-sm);
  background: var(--color-muted);
  color: var(--color-foreground);
  cursor: pointer;
  transition: background-color var(--dur-fast) var(--ease-out),
              box-shadow var(--dur-fast) var(--ease-out),
              color var(--dur-fast) var(--ease-out);
}

.gallery__thumb-nav:hover {
  background: var(--color-action);
  color: var(--color-on-accent);
  box-shadow: 0 8px 20px color-mix(in srgb, var(--color-foreground) 18%, transparent);
}

.gallery__thumb-nav:focus-visible {
  outline: 2px solid var(--color-ring);
  outline-offset: 2px;
}

.gallery__nav {
  position: absolute;
  top: 50%;
  z-index: 2;
  width: 44px;
  height: 44px;
  display: none;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-full);
  background: var(--color-card);
  color: var(--color-card-foreground);
  cursor: pointer;
  transform: translateY(-50%);
  box-shadow: var(--shadow-md);
  transition: background var(--dur-fast) var(--ease-out),
              border-color var(--dur-fast) var(--ease-out),
              opacity var(--dur-fast) var(--ease-out);
}

.js-product-enhanced .gallery__nav {
  display: inline-flex;
}

.gallery__nav:hover:not(:disabled) {
  border-color: var(--color-accent);
  background: var(--color-accent);
  color: var(--color-on-accent);
}

.gallery__nav:focus-visible {
  outline: 2px solid var(--color-ring);
  outline-offset: 2px;
}

.gallery__nav--prev {
  left: var(--space-3);
}

.gallery__nav--next {
  right: var(--space-3);
}

@media (prefers-reduced-motion: reduce) {
  .gallery__list,
  .gallery__thumbs {
    transition: none;
    scroll-behavior: auto;
  }
}

.gallery__thumb:hover {
  opacity: 1;
}

.gallery__thumb:focus-visible {
  outline: 2px solid var(--color-ring);
  outline-offset: 2px;
}

.gallery__thumb[aria-current="true"] {
  border-color: var(--color-accent);
  opacity: 1;
}

.lightbox[hidden] {
  display: none;
}

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 60;
}

.lightbox__backdrop {
  position: absolute;
  inset: 0;
  background: var(--color-scrim);
}

.lightbox__dialog {
  position: relative;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-5);
  touch-action: none;
}

.lightbox__image {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  border-radius: var(--radius-md);
}

.lightbox__close,
.lightbox__nav {
  position: absolute;
  width: 44px;
  height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: var(--radius-full);
  background: var(--color-card);
  color: var(--color-foreground);
  cursor: pointer;
}

.lightbox__nav {
  border: 1px solid var(--color-border);
  background: var(--color-card);
  color: var(--color-card-foreground);
  box-shadow: var(--shadow-md);
  transition: background var(--dur-fast) var(--ease-out),
              border-color var(--dur-fast) var(--ease-out),
              opacity var(--dur-fast) var(--ease-out);
}

.lightbox__close:hover {
  background: var(--color-muted);
}

.lightbox__nav:hover:not(:disabled) {
  border-color: var(--color-accent);
  background: var(--color-accent);
  color: var(--color-on-accent);
}

.lightbox__close:focus-visible,
.lightbox__nav:focus-visible {
  outline: 2px solid #FFFFFF;
  outline-offset: 2px;
}

.lightbox__close {
  top: var(--space-4);
  right: var(--space-4);
}

.lightbox__nav--prev {
  left: var(--space-4);
  top: 50%;
  transform: translateY(-50%);
}

.lightbox__nav--next {
  right: var(--space-4);
  top: 50%;
  transform: translateY(-50%);
}
